feat: Decouple NamedService from the transport feature (#969)

Co-authored-by: Eliza Weisman <[email protected]>
This commit is contained in:
Oliver Gould
2022-06-21 13:48:57 -04:00
committed by GitHub
co-authored by Eliza Weisman
parent 1d2083a1a6
commit feae96c5be
3 changed files with 14 additions and 23 deletions
+9
View File
@@ -15,3 +15,12 @@ pub use self::grpc::Grpc;
pub use self::service::{
ClientStreamingService, ServerStreamingService, StreamingService, UnaryService,
};
/// A trait to provide a static reference to the service's
/// name. This is used for routing service's within the router.
pub trait NamedService {
/// The `Service-Name` as described [here].
///
/// [here]: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests
const NAME: &'static str;
}
+1 -9
View File
@@ -10,6 +10,7 @@ mod tls;
mod unix;
pub use super::service::Routes;
pub use crate::server::NamedService;
pub use conn::{Connected, TcpConnectInfo};
#[cfg(feature = "tls")]
pub use tls::ServerTlsConfig;
@@ -123,15 +124,6 @@ pub struct Router<L = Identity> {
routes: Routes,
}
/// A trait to provide a static reference to the service's
/// name. This is used for routing service's within the router.
pub trait NamedService {
/// The `Service-Name` as described [here].
///
/// [here]: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests
const NAME: &'static str;
}
impl<S: NamedService, T> NamedService for Either<S, T> {
const NAME: &'static str = S::NAME;
}