pub struct GrpcRouter { /* private fields */ }Expand description
Thread-safe registry mapping /package.Service/Method paths to unary async handlers.
Implementations§
Source§impl GrpcRouter
Inherent implementation of GrpcRouter.
impl GrpcRouter
Inherent implementation of GrpcRouter.
Sourcepub fn add_interceptor(
&mut self,
interceptor: Arc<dyn GrpcInterceptor>,
) -> &mut Self
pub fn add_interceptor( &mut self, interceptor: Arc<dyn GrpcInterceptor>, ) -> &mut Self
Registers an extensible GrpcInterceptor invoked before every service dispatch.
§Arguments
Arc<dyn GrpcInterceptor>- Interceptor implementation.
§Returns
&mut Self- This router for fluent chaining.
Sourcepub fn has_method(&self, path: &str) -> bool
pub fn has_method(&self, path: &str) -> bool
Sourcepub async fn dispatch(
&self,
path: &str,
raw_body: &[u8],
req_encoding: Compress,
deadline: Option<Duration>,
config: &GrpcConfig,
) -> (GrpcStatus, String, Vec<u8>)
pub async fn dispatch( &self, path: &str, raw_body: &[u8], req_encoding: Compress, deadline: Option<Duration>, config: &GrpcConfig, ) -> (GrpcStatus, String, Vec<u8>)
Dispatches one gRPC unary call with interceptor check, frame decoding, optional timeout, and response framing.
§Arguments
&str- Full gRPC method path.&[u8]- Raw HTTP/2 request body bytes.Compress- Incominggrpc-encodingcoding.Option<Duration>- Optional clientgrpc-timeoutbudget.&GrpcConfig- Max message size and outgoing compression config.
§Returns
(GrpcStatus, String, Vec<u8>)-(status, percent_encoded_message, framed_response_body).
Trait Implementations§
Source§impl Clone for GrpcRouter
impl Clone for GrpcRouter
Source§impl Default for GrpcRouter
Default construction for GrpcRouter.
impl Default for GrpcRouter
Default construction for GrpcRouter.
Source§fn default() -> Self
fn default() -> Self
Constructs an empty GrpcRouter.
Auto Trait Implementations§
impl !RefUnwindSafe for GrpcRouter
impl !UnwindSafe for GrpcRouter
impl Forget for GrpcRouter
impl Freeze for GrpcRouter
impl Move for GrpcRouter
impl Send for GrpcRouter
impl Sync for GrpcRouter
impl Unpin for GrpcRouter
impl UnsafeUnpin for GrpcRouterwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(String, Arc<dyn Fn(Vec<u8>) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, GrpcError>> + Send>> + Sync + Send>)>: UnsafeUnpin,
PhantomData<fn() -> XxHash3_64>: UnsafeUnpin,
PhantomData<Arc<dyn GrpcInterceptor>>: UnsafeUnpin,
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more