[][src]Struct fastly::handle::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.

Implementations

impl BodyHandle[src]

pub const INVALID: Self[src]

An invalid body handle.

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

Return true if the body handle is valid.

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

Return true if the body handle is invalid.

pub fn downstream_request() -> Self[src]

👎 Deprecated since 0.6.0:

renamed to BodyHandle::from_client()

pub fn from_client() -> Self[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() -> Self[src]

Acquire a new BodyHandle.

pub fn append(&mut self, other: BodyHandle)[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) -> Vec<u8>[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) -> String[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.

pub fn write_bytes(&mut self, bytes: &[u8]) -> usize[src]

Write a slice of bytes to the end of this BodyHandle.

This function returns the number of bytes written.

body.write_bytes(&[0, 1, 2, 3]);

pub fn write_str(&mut self, string: &str) -> usize[src]

Write a string slice to the end of this BodyHandle.

This function returns the number of bytes written.

body.write_str("woof woof");

Trait Implementations

impl Debug for BodyHandle[src]

impl Eq for BodyHandle[src]

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

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

impl From<BodyHandle> for Body[src]

impl From<String> for BodyHandle[src]

impl From<Vec<u8>> for BodyHandle[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 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.