Skip to main content

UploadBody

Struct UploadBody 

Source
pub struct UploadBody { /* private fields */ }
Expand description

The request body of an upload.

A body has one of two forms:

  • bytes gives the whole body. The request declares its Content-Length, and hyper takes the bytes in frames of 64 KiB. A followed redirect sends the bytes again.
  • channel streams the body. The caller writes the body into the UploadWriter while the upload runs. Over HTTP/1.1, the body travels chunked.

If a channel body is dropped before an upload sends it, or after its upload ends, each write of its writer fails with io::ErrorKind::BrokenPipe. If a POST body is at its end when the fetcher hands over the request, the request declares a Content-Length of zero.

Implementations§

Source§

impl UploadBody

Source

pub fn bytes(bytes: Vec<u8>) -> UploadBody

Creates a body of bytes.

The request sends the vector in frames cut from it with no copy.

Source

pub fn channel() -> (UploadBody, UploadWriter)

Creates a streamed body and the writer that fills it.

Trait Implementations§

Source§

impl Debug for UploadBody

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<Vec<u8>> for UploadBody

Source§

fn from(bytes: Vec<u8>) -> UploadBody

Converts to this type from the input type.

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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