jsonrpsee_core::server

Struct 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

source

pub fn subscription_id(&self) -> SubscriptionId<'static>

Get the subscription ID.

source

pub fn method_name(&self) -> &str

Get the method name.

source

pub fn connection_id(&self) -> ConnectionId

Get the connection ID.

source

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.

source

pub async fn send_timeout( &self, msg: SubscriptionMessage, timeout: Duration, ) -> Result<(), SendTimeoutError>

Similar to SubscriptionSink::send but only waits for a limited time.

source

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.

source

pub fn is_closed(&self) -> bool

Returns whether the subscription is closed.

source

pub async fn closed(&self)

Completes when the subscription has been closed.

source

pub fn capacity(&self) -> usize

Get the capacity of the subscription.

source

pub fn max_capacity(&self) -> usize

Get the max capacity of the subscription.

Trait Implementations§

source§

impl Clone for SubscriptionSink

source§

fn clone(&self) -> SubscriptionSink

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SubscriptionSink

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for SubscriptionSink

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> MaybeSend for T
where T: Send,