Skip to content

Commit

Permalink
chore: Remove unnecessary pin-project
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto committed Jan 9, 2025
1 parent 48b970b commit 2864ec9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
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

0 comments on commit 2864ec9

Please sign in to comment.