Struct jsonrpsee_core::server::SubscriptionSink
source · pub struct SubscriptionSink { /* private fields */ }
Available on crate feature
server
only.Expand description
Represents a single subscription that hasn’t been processed yet.
Implementations§
source§impl SubscriptionSink
impl SubscriptionSink
sourcepub fn subscription_id(&self) -> SubscriptionId<'static>
pub fn subscription_id(&self) -> SubscriptionId<'static>
Get the subscription ID.
sourcepub fn method_name(&self) -> &str
pub fn method_name(&self) -> &str
Get the method name.
sourcepub async fn send(
&self,
msg: SubscriptionMessage
) -> Result<(), DisconnectError>
pub async fn send( &self, msg: SubscriptionMessage ) -> Result<(), DisconnectError>
Send out a response on the subscription and wait until there is capacity.
Returns
Ok(())
if the message could be sent.Err(unsent_msg)
if the connection or subscription was closed.
Cancel safety
This method is cancel-safe and dropping a future loses its spot in the waiting queue.
sourcepub async fn send_timeout(
&self,
msg: SubscriptionMessage,
timeout: Duration
) -> Result<(), SendTimeoutError>
pub async fn send_timeout( &self, msg: SubscriptionMessage, timeout: Duration ) -> Result<(), SendTimeoutError>
Similar to to SubscriptionSink::send
but only waits for a limited time.
sourcepub fn try_send(&mut self, msg: SubscriptionMessage) -> Result<(), TrySendError>
pub fn try_send(&mut self, msg: SubscriptionMessage) -> Result<(), TrySendError>
Attempts to immediately send out the message as JSON string to the subscribers but fails if the channel is full or the connection/subscription is closed
This differs from SubscriptionSink::send
where it will until there is capacity
in the channel.
Trait Implementations§
source§impl Clone for SubscriptionSink
impl Clone for SubscriptionSink
source§fn clone(&self) -> SubscriptionSink
fn clone(&self) -> SubscriptionSink
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more