[][src]Enum now_lambda::Body

pub enum Body {
    Empty,
    Text(String),
    Binary(Vec<u8>),
}

Representation of http request and response bodies as supported by Zeit Now v2.

These come in three flavors

  • Empty ( no body )
  • Text ( text data )
  • Binary ( binary data )

Body types can be Deref and AsRef'd into [u8] types much like the hyper crate

Examples

Body types are inferred with From implementations.

Text

Types like String, str whose type reflects text produce Body::Text variants

assert!(match now_lambda::Body::from("text") {
  now_lambda::Body::Text(_) => true,
  _ => false
})

Binary

Types like Vec<u8> and &[u8] whose types reflect raw bytes produce Body::Binary variants

assert!(match now_lambda::Body::from("text".as_bytes()) {
  now_lambda::Body::Binary(_) => true,
  _ => false
})

Binary responses bodies will automatically get base64 encoded.

Empty

The unit type ( () ) whose type represents an empty value produces Body::Empty variants

assert!(match now_lambda::Body::from(()) {
  now_lambda::Body::Empty => true,
  _ => false
})

Variants

Empty

An empty body

Text(String)

A body containing string data

Binary(Vec<u8>)

A body containing binary data

Trait Implementations

impl AsRef<[u8]> for Body[src]

impl PartialEq<Body> for Body[src]

impl Default for Body[src]

impl From<()> for Body[src]

impl From<Body> for ()[src]

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

impl From<String> for Body[src]

impl From<Body> for String[src]

impl From<Cow<'static, str>> for Body[src]

impl From<Body> for Cow<'static, str>[src]

impl From<Cow<'static, [u8]>> for Body[src]

impl From<Body> for Cow<'static, [u8]>[src]

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

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

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

impl Debug for Body[src]

impl Deref for Body[src]

type Target = [u8]

The resulting type after dereferencing.

impl<'a> Serialize for Body[src]

Auto Trait Implementations

impl Send for Body

impl Sync for Body

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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

impl<T> Erased for T