[−][src]Enum aws_lambda_events::encodings::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
Examples
Body types are inferred with From
implementations.
Text
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 })
Binary
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.
Empty
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.
Variants
An empty body
Text(String)
A body containing string data
A body containing binary data
Implementations
impl Body
[src]
pub fn from_maybe_encoded(is_base64_encoded: bool, body: &str) -> Body
[src]
Decodes body, if needed.
Panics
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]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Body
[src]
impl Default for Body
[src]
impl Deref for Body
[src]
impl<'de> Deserialize<'de> for Body
[src]
pub fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
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
impl RefUnwindSafe for Body
[src]
impl Send for Body
[src]
impl Sync for Body
[src]
impl Unpin for Body
[src]
impl UnwindSafe for Body
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,