pub type OptionalBody<T> = Either<FullBody<T>, EmptyBody>;Available on crate feature
http only.Expand description
A body type representing an optional payload.
This is a convenience alias for http_body_util::Either<FullBody<T>, EmptyBody>,
used when an HTTP request or response may or may not carry a body.
The Left variant holds a FullBody<T> for when a payload is present,
while the Right variant holds an EmptyBody for when it is absent.
§Examples
ⓘ
use spin_sdk::http::{OptionalBody, FullBody, EmptyBody};
use bytes::Bytes;
// With a body
let with_body: OptionalBody<Bytes> =
http_body_util::Either::Left(FullBody::new(Bytes::from("hello")));
// Without a body
let without_body: OptionalBody<Bytes> =
http_body_util::Either::Right(EmptyBody::new());Aliased Type§
pub enum OptionalBody<T> {
Left(Full<T>),
Right(Empty<Bytes>),
}