Struct Sender
pub struct Sender<D, E = Infallible> { /* private fields */ }
A sender half created through Channel::new.
Implementations
impl<D, E> Sender<D, E>
async fn send(&mut self, frame: Frame<D>) -> Result<(), SendError>Send a frame on the channel.
async fn send_data(&mut self, buf: D) -> Result<(), SendError>Send data on data channel.
async fn send_trailers(&mut self, trailers: HeaderMap) -> Result<(), SendError>Send trailers on trailers channel.
fn try_send(&mut self, frame: Frame<D>) -> Result<(), Frame<D>>Attempts to send a frame on this channel.
This function returns the unsent frame back as an
Err(_)if the channel could not (currently) accept another frame.Note
This is mostly useful for when trying to send a frame from outside of an asynchronous context. If in an async context, prefer [
Sender::send_data()] instead.fn capacity(&mut self) -> usizeReturns the current capacity of the channel.
The capacity goes down when [
Frame<T>]s are sent. The capacity goes up when these frames are received by the corresponding [Channel<D, E>]. This is distinct from [max_capacity()][Self::max_capacity], which always returns the buffer capacity initially specified when [Channel::new()][Channel::new] was called.Examples
use Bytes; use ; use Infallible; asyncfn max_capacity(&mut self) -> usizeReturns the maximum capacity of the channel.
This function always returns the buffer capacity initially specified when [
Channel::new()][Channel::new] was called. This is distinct from [capacity()][Self::capacity], which returns the currently available capacity.Examples
use Bytes; use ; use Infallible; asyncfn abort(self, error: E)Aborts the body in an abnormal fashion.
Trait Implementations
impl<D, E: Debug> Debug for Sender<D, E>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<D, E = never> !RefUnwindSafe for Sender<D, E>
impl<D, E = never> !UnwindSafe for Sender<D, E>
impl<D, E> Freeze for Sender<D, E>
where
Sender<Frame<D>>: Freeze,
Sender<E>: Freeze,
impl<D, E> Send for Sender<D, E>
where
Sender<Frame<D>>: Send,
Sender<E>: Send,
impl<D, E> Sync for Sender<D, E>
where
Sender<Frame<D>>: Sync,
Sender<E>: Sync,
impl<D, E> Unpin for Sender<D, E>
where
Sender<Frame<D>>: Unpin,
Sender<E>: Unpin,
impl<D, E> UnsafeUnpin for Sender<D, E>
where
Sender<Frame<D>>: UnsafeUnpin,
Sender<E>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for Sender<D, E>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Sender<D, E>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Sender<D, E>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Sender<D, E>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for Sender<D, E>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Sender<D, E>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Sender<D, E>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>