jetstream_rpc

Trait Service

Source
pub trait Service<P: Protocol>:
    Send
    + Sync
    + Sized {
    // Required method
    fn rpc(
        self,
        req: P::Request,
    ) -> impl Future<Output = Result<P::Response, Error>> + Send + Sync + Sized;

    // Provided method
    fn handle_message<R, W>(
        self,
        reader: &mut R,
        writer: &mut W,
    ) -> impl Future<Output = Result<(), Error>> + Send + Sync + Sized
       where R: AsyncReadExt + Unpin + Send + Sync,
             W: AsyncWriteExt + Unpin + Send + Sync { ... }
}
Expand description

An asynchronous JetStream service that can handle RPC calls and messages.

Required Methods§

Source

fn rpc( self, req: P::Request, ) -> impl Future<Output = Result<P::Response, Error>> + Send + Sync + Sized

Handles an RPC call asynchronously.

Provided Methods§

Source

fn handle_message<R, W>( self, reader: &mut R, writer: &mut W, ) -> impl Future<Output = Result<(), Error>> + Send + Sync + Sized

Handles a message by reading from the reader, processing it, and writing the response.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<P: Protocol + Clone, S> Service<P> for SharedJetStreamService<P, S>
where S: Clone + Service<P>,