pub struct MethodSink { /* private fields */ }server only.Expand description
Sink that is used to send back the result to the server for a specific method.
Implementations§
Source§impl MethodSink
impl MethodSink
Sourcepub fn new_with_limit(tx: Sender<String>, max_response_size: u32) -> Self
pub fn new_with_limit(tx: Sender<String>, max_response_size: u32) -> Self
Create a new MethodSink with a limited response size.
Sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Returns whether this channel is closed without needing a context.
Sourcepub async fn closed(&self)
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.
Sourcepub const fn max_response_size(&self) -> u32
pub const fn max_response_size(&self) -> u32
Get the max response size.
Sourcepub fn try_send(&mut self, msg: String) -> Result<(), TrySendError>
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.
Sourcepub async fn send(&self, msg: String) -> Result<(), DisconnectError>
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.
Sourcepub async fn send_error<'a>(
&self,
id: Id<'a>,
err: ErrorObject<'a>,
) -> Result<(), DisconnectError>
pub async fn send_error<'a>( &self, id: Id<'a>, err: ErrorObject<'a>, ) -> Result<(), DisconnectError>
Send a JSON-RPC error to the client
Sourcepub async fn send_timeout(
&self,
msg: String,
timeout: Duration,
) -> Result<(), SendTimeoutError>
pub async fn send_timeout( &self, msg: String, timeout: Duration, ) -> Result<(), SendTimeoutError>
Similar to MethodSink::send but only waits for a limited time.
Sourcepub fn max_capacity(&self) -> usize
pub fn max_capacity(&self) -> usize
Get the max capacity of the channel.
Trait Implementations§
Source§impl Clone for MethodSink
impl Clone for MethodSink
Auto Trait Implementations§
impl Freeze for MethodSink
impl RefUnwindSafe for MethodSink
impl Send for MethodSink
impl Sync for MethodSink
impl Unpin for MethodSink
impl UnsafeUnpin for MethodSink
impl UnwindSafe for MethodSink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes