pub struct TracingConfigServer<S> { /* private fields */ }Expand description
Server dispatcher for the #trait_name service.
Integrate this with an RpcSession
by calling RpcSession::set_dispatcher
and forwarding method_id/payload into [dispatch] or [dispatch_streaming].
Implementations§
Source§impl<S: TracingConfig + Send + Sync + 'static> TracingConfigServer<S>
impl<S: TracingConfig + Send + Sync + 'static> TracingConfigServer<S>
Sourcepub fn new(service: S) -> Self
pub fn new(service: S) -> Self
Create a new server with the given service implementation.
This automatically registers the service in the global registry on first invocation (subsequent calls are no-ops).
Sourcepub async fn serve_one(&self, transport: &Transport) -> Result<(), RpcError>
pub async fn serve_one(&self, transport: &Transport) -> Result<(), RpcError>
Serve a single request from the transport.
This is useful for testing or when you want to handle each request individually.
Sourcepub async fn dispatch(
&self,
method_id: u32,
request_payload: &[u8],
) -> Result<Frame, RpcError>
pub async fn dispatch( &self, method_id: u32, request_payload: &[u8], ) -> Result<Frame, RpcError>
Dispatch a request frame to the appropriate method.
Returns a response frame on success for unary methods.
For streaming methods, use dispatch_streaming instead.
Sourcepub async fn dispatch_streaming(
&self,
method_id: u32,
channel_id: u32,
request_payload: &[u8],
transport: &Transport,
) -> Result<(), RpcError>
pub async fn dispatch_streaming( &self, method_id: u32, channel_id: u32, request_payload: &[u8], transport: &Transport, ) -> Result<(), RpcError>
Dispatch a streaming request to the appropriate method.
The method sends frames via the provided transport.
Sourcepub fn into_session_dispatcher(
self,
transport: Transport,
) -> impl Fn(Frame) -> Pin<Box<dyn Future<Output = Result<Frame, RpcError>> + Send + 'static>> + Send + Sync + 'static
pub fn into_session_dispatcher( self, transport: Transport, ) -> impl Fn(Frame) -> Pin<Box<dyn Future<Output = Result<Frame, RpcError>> + Send + 'static>> + Send + Sync + 'static
Create a dispatcher closure suitable for RpcSession::set_dispatcher.
This handles both unary and server-streaming methods:
- Unary methods return a single response
Frame. - Streaming methods require the request to be flagged
NO_REPLYand are served by callingdispatch_streamingto emit DATA/EOS frames on the provided transport.
To ensure streaming calls work correctly, use rapace’s generated streaming
clients (they set NO_REPLY automatically).