Struct hyper::body::Sender

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

A sender half created through Body::channel().

Useful when wanting to stream chunks from another thread.

§Body Closing

Note that the request body will always be closed normally when the sender is dropped (meaning that the empty terminating chunk will be sent to the remote). If you desire to close the connection with an incomplete response (e.g. in the case of an error during asynchronous processing), call the Sender::abort() method to abort the body in an abnormal fashion.

Implementations§

source§

impl Sender

source

pub fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>

Check to see if this Sender can send more data.

source

pub async fn send_data(&mut self, chunk: Bytes) -> Result<()>

Send data on data channel when it is ready.

source

pub async fn send_trailers(&mut self, trailers: HeaderMap) -> Result<()>

Send trailers on trailers channel.

source

pub fn try_send_data(&mut self, chunk: Bytes) -> Result<(), Bytes>

Try to send data on this channel.

§Errors

Returns Err(Bytes) if the channel could not (currently) accept another Bytes.

§Note

This is mostly useful for when trying to send from some other thread that doesn’t have an async context. If in an async context, prefer send_data() instead.

source

pub fn abort(self)

Aborts the body in an abnormal fashion.

Trait Implementations§

source§

impl Debug for Sender

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Sender

§

impl !RefUnwindSafe for Sender

§

impl Send for Sender

§

impl Sync for Sender

§

impl Unpin for Sender

§

impl !UnwindSafe for Sender

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