Struct jsonrpsee_server::helpers::MethodSink

source ·
pub struct MethodSink { /* private fields */ }
Expand description

Sink that is used to send back the result to the server for a specific method.

Implementations§

source§

impl MethodSink

source

pub fn new(tx: Sender<String>) -> MethodSink

Create a new MethodSink with unlimited response size.

source

pub fn new_with_limit(tx: Sender<String>, max_response_size: u32) -> MethodSink

Create a new MethodSink with a limited response size.

source

pub fn is_closed(&self) -> bool

Returns whether this channel is closed without needing a context.

source

pub async fn closed(&self)

Same as tokio::sync::mpsc::Sender::closed.

§Cancel safety

This method is cancel safe. Once the channel is closed, it stays closed forever and all future calls to closed will return immediately.

source

pub const fn max_response_size(&self) -> u32

Get the max response size.

source

pub fn try_send(&mut self, msg: String) -> Result<(), TrySendError>

Attempts to send out the message immediately and fails if the underlying connection has been closed or if the message buffer is full.

Returns the message if the send fails such that either can be thrown away or re-sent later.

source

pub async fn send(&self, msg: String) -> Result<(), DisconnectError>

Async send which will wait until there is space in channel buffer or that the subscription is disconnected.

source

pub async fn send_error<'a>( &self, id: Id<'a>, err: ErrorObject<'a>, ) -> Result<(), DisconnectError>

Send a JSON-RPC error to the client

source

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

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

source

pub fn capacity(&self) -> usize

Get the capacity of the channel.

source

pub fn max_capacity(&self) -> usize

Get the max capacity of the channel.

source

pub async fn has_capacity(&self) -> Result<(), DisconnectError>

Waits for there to be space on the return channel.

Trait Implementations§

source§

impl Clone for MethodSink

source§

fn clone(&self) -> MethodSink

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 MethodSink

source§

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

Formats the value using the given formatter. 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§

default 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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>,

§

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,