[][src]Struct fastly::body::BodyHandle

#[repr(transparent)]
pub struct BodyHandle { /* fields omitted */ }

A low-level interface to HTTP bodies.

This type implements Read to read bytes from the beginning of a body, and Write to write to the end of a body. Note that these operations are unbuffered, unlike the same operations on the higher-level Body type.

These handles can also be used to append bodies to each other in amortized constant time.

Methods

impl BodyHandle[src]

pub const INVALID: Self[src]

pub fn is_invalid(&self) -> bool[src]

pub fn downstream_request() -> Result<Self, Error>[src]

Get a handle to the downstream request body.

This handle may only be retrieved once per execution, either through this function or through fastly::request::downstream_request_and_body_handles().

pub fn new() -> Result<BodyHandle, Error>[src]

Get a handle to a new, empty body.

pub fn append(&mut self, other: BodyHandle) -> Result<(), Error>[src]

Append another body onto the end of this body.

The other body will no longer be valid after this call.

pub fn into_bytes(self) -> Result<Vec<u8>, Error>[src]

Read the entirety of the body.

Note that this will involve copying and buffering the body, and so should only be used for convenience on small request bodies.

pub fn into_string(self) -> Result<String, Error>[src]

Read the entirety of the body into a String, interpreting the bytes as UTF-8.

Note that this will involve copying and buffering the body, and so should only be used for convenience on small request bodies.

Trait Implementations

impl Debug for BodyHandle[src]

impl Eq for BodyHandle[src]

impl From<BodyHandle> for Body[src]

impl Hash for BodyHandle[src]

impl PartialEq<BodyHandle> for BodyHandle[src]

impl Read for BodyHandle[src]

impl StructuralEq for BodyHandle[src]

impl StructuralPartialEq for BodyHandle[src]

impl<'_> TryFrom<&'_ [u8]> for BodyHandle[src]

type Error = Error

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ str> for BodyHandle[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<String> for BodyHandle[src]

type Error = Error

The type returned in the event of a conversion error.

impl TryFrom<Vec<u8>> for BodyHandle[src]

type Error = Error

The type returned in the event of a conversion error.

impl Write for BodyHandle[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.