feat: Decouple NamedService from the transport feature (#969)
Co-authored-by: Eliza Weisman <[email protected]>
This commit is contained in:
co-authored by
Eliza Weisman
parent
1d2083a1a6
commit
feae96c5be
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user