Struct MethodSink
pub struct MethodSink { /* private fields */ }server-core only.Expand description
Sink that is used to send back the result to the server for a specific method.
Implementations§
§impl MethodSink
impl MethodSink
pub fn new(tx: Sender<String>) -> MethodSink
pub fn new(tx: Sender<String>) -> MethodSink
Create a new MethodSink with unlimited response size.
pub fn new_with_limit(tx: Sender<String>, max_response_size: u32) -> MethodSink
pub fn new_with_limit(tx: Sender<String>, max_response_size: u32) -> MethodSink
Create a new MethodSink with a limited response size.
pub 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.
pub const fn max_response_size(&self) -> u32
pub const fn max_response_size(&self) -> u32
Get the max response size.
pub 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.
pub 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.
pub 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
pub 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.
pub fn max_capacity(&self) -> usize
pub fn max_capacity(&self) -> usize
Get the max capacity of the channel.
Trait Implementations§
§impl Clone for MethodSink
impl Clone for MethodSink
§fn clone(&self) -> MethodSink
fn clone(&self) -> MethodSink
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto 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