Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove unnecessary pin-project #2128

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tonic-health/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ default = ["transport"]
transport = []

[dependencies]
pin-project = "1"
prost = "0.13"
tokio = {version = "1.0", features = ["sync"]}
tokio-stream = {version = "0.1", features = ["sync"]}
Expand Down
8 changes: 2 additions & 6 deletions tonic-health/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use crate::pb::health_server::{Health, HealthServer};
use crate::pb::{HealthCheckRequest, HealthCheckResponse};
use crate::ServingStatus;
use pin_project::pin_project;
use std::collections::HashMap;
use std::fmt;
use std::sync::Arc;
Expand Down Expand Up @@ -150,9 +149,7 @@ impl Health for HealthService {
}

/// A watch stream for the health service.
#[pin_project]
pub struct WatchStream {
#[pin]
inner: tokio_stream::wrappers::WatchStream<ServingStatus>,
}

Expand All @@ -167,11 +164,10 @@ impl Stream for WatchStream {
type Item = Result<HealthCheckResponse, Status>;

fn poll_next(
self: std::pin::Pin<&mut Self>,
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
self.project()
.inner
std::pin::Pin::new(&mut self.inner)
.poll_next(cx)
.map(|opt| opt.map(|status| Ok(HealthCheckResponse::new(status))))
}
Expand Down
1 change: 0 additions & 1 deletion tonic-reflection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ server = ["prost-types", "dep:tokio", "dep:tokio-stream"]
default = ["server"]

[dependencies]
pin-project = "1"
prost = "0.13"
prost-types = {version = "0.13", optional = true}
tokio = { version = "1.0", features = ["sync", "rt"], optional = true }
Expand Down
10 changes: 3 additions & 7 deletions tonic-reflection/src/server/v1.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{fmt, sync::Arc};

use pin_project::pin_project;
use tokio::sync::mpsc;
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
use tonic::{Request, Response, Status, Streaming};
Expand Down Expand Up @@ -108,19 +107,16 @@ impl From<ReflectionServiceState> for ReflectionService {
}

/// A response stream.
#[pin_project]
pub struct ServerReflectionInfoStream(
#[pin] ReceiverStream<Result<ServerReflectionResponse, Status>>,
);
pub struct ServerReflectionInfoStream(ReceiverStream<Result<ServerReflectionResponse, Status>>);

impl Stream for ServerReflectionInfoStream {
type Item = Result<ServerReflectionResponse, Status>;

fn poll_next(
self: std::pin::Pin<&mut Self>,
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
self.project().0.poll_next(cx)
std::pin::Pin::new(&mut self.0).poll_next(cx)
}

fn size_hint(&self) -> (usize, Option<usize>) {
Expand Down
10 changes: 3 additions & 7 deletions tonic-reflection/src/server/v1alpha.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{fmt, sync::Arc};

use pin_project::pin_project;
use tokio::sync::mpsc;
use tokio_stream::{wrappers::ReceiverStream, Stream, StreamExt};
use tonic::{Request, Response, Status, Streaming};
Expand Down Expand Up @@ -108,19 +107,16 @@ impl From<ReflectionServiceState> for ReflectionService {
}

/// A response stream.
#[pin_project]
pub struct ServerReflectionInfoStream(
#[pin] ReceiverStream<Result<ServerReflectionResponse, Status>>,
);
pub struct ServerReflectionInfoStream(ReceiverStream<Result<ServerReflectionResponse, Status>>);

impl Stream for ServerReflectionInfoStream {
type Item = Result<ServerReflectionResponse, Status>;

fn poll_next(
self: std::pin::Pin<&mut Self>,
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
self.project().0.poll_next(cx)
std::pin::Pin::new(&mut self.0).poll_next(cx)
}

fn size_hint(&self) -> (usize, Option<usize>) {
Expand Down
Loading