[][src]Enum aws_lambda_events::encodings::Body

pub enum Body {

Representation of http request and response bodies as supported by API Gateway and ALBs.

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


Body types are inferred with From implementations.


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

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


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

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

Binary responses bodies will automatically get based64 encoded to meet API Gateway's response expectations.


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

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

For more information about API Gateway's body types, refer to this documentation.



An empty body


A body containing string data


A body containing binary data


impl Body[src]

pub fn from_maybe_encoded(is_base64_encoded: bool, body: &str) -> Body[src]

Decodes body, if needed.


Panics when aws communicates to handler that request is base64 encoded but it can not be base64 decoded

Trait Implementations

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

impl Clone for Body[src]

impl Debug for Body[src]

impl Default for Body[src]

impl Deref for Body[src]

type Target = [u8]

The resulting type after dereferencing.

impl<'de> Deserialize<'de> for Body[src]

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

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

impl From<()> for Body[src]

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

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

impl From<String> for Body[src]

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

impl PartialEq<Body> for Body[src]

impl<'a> Serialize for Body[src]

impl StructuralPartialEq for Body[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 

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

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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

The type returned in the event of a conversion error.