pub enum Body {
Text(String),
Bytes(Vec<u8>),
}Expand description
What a response carries. Text for everything this projection computes; bytes for a file it serves from disk, which is not always UTF-8 and must not be repaired into it.
Variants§
Text(String)
A string this process produced.
Bytes(Vec<u8>)
Bytes read from somewhere else, passed through unchanged.
Implementations§
Source§impl Body
impl Body
Sourcepub fn text(&self) -> Cow<'_, str>
pub fn text(&self) -> Cow<'_, str>
The body as text: borrowed when it is text, and lossy when it is not, which only a diagnostic or a test ever asks for.
use majordomus_cli::http::router::Body;
assert_eq!(Body::Text("a".into()).text(), "a");
assert_eq!(Body::Bytes(vec![0xff]).text(), "\u{fffd}");Trait Implementations§
impl Eq for Body
impl StructuralPartialEq for Body
Auto Trait Implementations§
impl Freeze for Body
impl RefUnwindSafe for Body
impl Send for Body
impl Sync for Body
impl Unpin for Body
impl UnsafeUnpin for Body
impl UnwindSafe for Body
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.