pub trait ProtocolHandler<ServerContext, ConnectionContext, Ops>:
DowncastSync
+ Sized
+ Send
+ Syncwhere
Ops: OpsT,
ServerContext: Clone + Send + Sync + 'static,
ConnectionContext: Clone + Send + Sync + 'static,{
// Required methods
fn new(
methods: Arc<Interface<ServerContext, ConnectionContext, Ops>>,
) -> Self
where Self: Sized;
fn encoding(&self) -> Encoding;
fn handle_message<'life0, 'life1, 'async_trait>(
&'life0 self,
connection_ctx: ConnectionContext,
message: Message,
sink: &'life1 WebSocketSink,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn serialize_notification_message<Msg>(
&self,
op: Ops,
msg: Msg,
) -> Result<Message>
where Msg: BorshSerialize + Serialize + Send + Sync + 'static;
}Expand description
Base trait for BorshProtocol and JsonProtocol protocol handlers
Required Methods§
Sourcefn new(methods: Arc<Interface<ServerContext, ConnectionContext, Ops>>) -> Selfwhere
Self: Sized,
fn new(methods: Arc<Interface<ServerContext, ConnectionContext, Ops>>) -> Selfwhere
Self: Sized,
Construct a protocol handler backed by the given RPC method/notification interface.
Sourcefn encoding(&self) -> Encoding
fn encoding(&self) -> Encoding
Return the wire encoding (Borsh or JSON) implemented by this handler.
Sourcefn handle_message<'life0, 'life1, 'async_trait>(
&'life0 self,
connection_ctx: ConnectionContext,
message: Message,
sink: &'life1 WebSocketSink,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn handle_message<'life0, 'life1, 'async_trait>(
&'life0 self,
connection_ctx: ConnectionContext,
message: Message,
sink: &'life1 WebSocketSink,
) -> Pin<Box<dyn Future<Output = WebSocketResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Decode an incoming WebSocket message, dispatch it to the matching method or notification handler, and send any response back through the sink.
Sourcefn serialize_notification_message<Msg>(
&self,
op: Ops,
msg: Msg,
) -> Result<Message>
fn serialize_notification_message<Msg>( &self, op: Ops, msg: Msg, ) -> Result<Message>
Serialize a server-initiated notification for the given operation and message into an outgoing WebSocket message.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".