Enum aws_lambda_events::encodings::Body [−][src]
Expand description
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
Tuple Fields of Text
0: String
A body containing binary data
Implementations
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Body
impl UnwindSafe for Body
Blanket Implementations
Mutably borrows from an owned value. Read more