Enum viceroy_lib::body::Chunk
source · pub enum Chunk {
HttpBody(Body),
Channel(Receiver<StreamingBodyItem>),
CompressedHttpBody(Box<GzDecoder<Writer<BytesMut>>>, Body),
}
Expand description
A chunk of bytes in a Body
.
A chunk represents a block of data in a body. Representing bodies as chunks allows us to append one body to another without copying, and makes it possible from parts of the body to come from different sources, including ongoing asynchronous streaming.
Variants§
HttpBody(Body)
Wraps Hyper’s http body representation.
We use this variant for both data that’s incoming from a Hyper request, and for owned byte
buffers that we’ve allocated while writing to a Body
.
Channel(Receiver<StreamingBodyItem>)
A channel for bodies that may be written to after headers have been sent, such as after
send_downstream_streaming
or send_async_streaming
.
Since the channel yields chunks, this variant represents a stream of chunks rather than
one individual chunk. That stream is effectively “flattened” on-demand, as the Body
containing it is read.
CompressedHttpBody(Box<GzDecoder<Writer<BytesMut>>>, Body)
A version of HttpBody
that assumes that the interior data is gzip-compressed.
Implementations§
Trait Implementations§
source§impl Extend<Chunk> for Body
impl Extend<Chunk> for Body
source§fn extend<I: IntoIterator<Item = Chunk>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Chunk>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Auto Trait Implementations§
impl !Freeze for Chunk
impl !RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl !UnwindSafe for Chunk
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self
file descriptor.source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self
file descriptor. Read moresource§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more