[][src]Struct fastly::Body

pub struct Body { /* fields omitted */ }

An HTTP body that can be read from, written to, or appended to another body.

The most efficient way to read and write the body is through the Read, BufRead, and Write implementations.

Implementations

impl Body[src]

pub fn new() -> Self[src]

Get a new, empty HTTP body.

pub fn into_handle(self) -> BodyHandle

Notable traits for BodyHandle

impl Read for BodyHandleimpl Write for BodyHandle
[src]

Convert a Body into a BodyHandle.

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 append(&mut self, other: Body)[src]

Append another body onto the end of this body.

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

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

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 Body.

This function returns the number of bytes written.

body.write_str("woof woof");

Trait Implementations

impl BufRead for Body[src]

impl Debug for Body[src]

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

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

impl From<BodyHandle> for Body[src]

impl From<String> for Body[src]

impl From<Vec<u8>> for Body[src]

impl Read for Body[src]

impl Write for Body[src]

Auto Trait Implementations

impl RefUnwindSafe for Body

impl Send for Body

impl Sync for Body

impl Unpin for Body

impl UnwindSafe for Body

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.