Struct workflow_rpc::server::Messenger
source · pub struct Messenger { /* private fields */ }
Expand description
The Messenger
struct is supplied to the RpcHandler::handshake()
call at
the connection negotiation time. This structure comes in as Arc<Messenger>
and can be retained for later processing. It provides two methods: Messenger::notify
that can be used asynchronously to dispatch RPC notifications to the client
and Messenger::close
that can be used to terminate the RPC connection with
the client.
Implementations§
source§impl Messenger
impl Messenger
pub fn new(encoding: Encoding, sink: &WebSocketSink) -> Self
sourcepub fn close(&self) -> Result<()>
pub fn close(&self) -> Result<()>
Close the WebSocket connection. The server checks for the connection channel for the dispatch of this message and relays it to the client as well as proactively terminates the connection.
sourcepub async fn notify<Ops, Msg>(&self, op: Ops, msg: Msg) -> Result<()>where
Ops: OpsT,
Msg: BorshSerialize + BorshDeserialize + Serialize + Send + Sync + 'static,
pub async fn notify<Ops, Msg>(&self, op: Ops, msg: Msg) -> Result<()>where
Ops: OpsT,
Msg: BorshSerialize + BorshDeserialize + Serialize + Send + Sync + 'static,
Post notification message to the WebSocket connection
sourcepub fn serialize_notification_message<Ops, Msg>(
&self,
op: Ops,
msg: Msg
) -> Result<Message>where
Ops: OpsT,
Msg: MsgT,
pub fn serialize_notification_message<Ops, Msg>(
&self,
op: Ops,
msg: Msg
) -> Result<Message>where
Ops: OpsT,
Msg: MsgT,
Serialize message into a tungstenite::Message
for direct websocket delivery.
Once serialized it can be relayed using [send_raw_message()
].
sourcepub fn send_raw_message(&self, msg: Message) -> Result<()>
pub fn send_raw_message(&self, msg: Message) -> Result<()>
Send a raw tungstenite::Message
via the websocket tokio channel.
sourcepub fn sink(&self) -> &WebSocketSink
pub fn sink(&self) -> &WebSocketSink
Provides direct access to the underlying tokio channel.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Messenger
impl Send for Messenger
impl Sync for Messenger
impl Unpin for Messenger
impl !UnwindSafe for Messenger
Blanket Implementations§
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.