use std::{borrow::Cow, fmt::Debug};
#[cfg(feature = "multipart")]
#[cfg_attr(docsrs, doc(cfg(feature = "multipart")))]
mod multipart;
#[cfg(feature = "multipart")]
#[cfg_attr(docsrs, doc(cfg(feature = "multipart")))]
pub use multipart::{Part, PartBody};
pub enum Body<S> {
Bytes {
content: Cow<'static, [u8]>,
content_type: Cow<'static, str>,
},
Form {
fields: Vec<(Cow<'static, str>, Cow<'static, str>)>,
},
#[cfg(feature = "multipart")]
Multipart {
parts: Vec<Part<S>>,
},
Stream {
stream: S,
content_type: Cow<'static, str>,
},
}
impl<S> Debug for Body<S> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Body::Bytes {
content,
content_type,
} => f
.debug_struct("Body::Bytes")
.field("content", content)
.field("content_type", content_type)
.finish(),
Body::Form { fields } => f
.debug_struct("Body::Form")
.field("fields", fields)
.finish(),
#[cfg(feature = "multipart")]
Body::Multipart { parts: _ } => f.debug_struct("Body::Multipart").finish(),
Body::Stream {
stream: _,
content_type,
} => f
.debug_struct("Body::Stream")
.field("content_type", content_type)
.finish(),
}
}
}