jetstream_rpc

Trait Service

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

    // Provided method
    fn handle_message<R, W>(
        &mut self,
        reader: &mut R,
        writer: &mut W,
    ) -> impl Future<Output = Result<(), Error>> + Send + Sync
       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( &mut self, req: Self::Request, ) -> impl Future<Output = Result<Self::Response, Error>> + Send + Sync

Handles an RPC call asynchronously.

Provided Methods§

Source

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

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§