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
impl MethodSink
sourcepub fn new(tx: Sender<String>) -> MethodSink
pub fn new(tx: Sender<String>) -> MethodSink
Create a new MethodSink
with unlimited response size.
sourcepub 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.
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.
sourcepub async fn has_capacity(&self) -> Result<(), DisconnectError>
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
impl Clone for MethodSink
source§fn clone(&self) -> MethodSink
fn clone(&self) -> MethodSink
1.0.0 · 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 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)