use bytes::Bytes;
use futures_util::stream::Stream;
use std::{
borrow::Cow,
fmt::{self, Debug},
pin::Pin
};
pub use mime::Mime;
pub type ByteStream<Err> = Pin<Box<dyn Stream<Item = Result<Bytes, Err>> + Send>>;
pub enum BytesOrString<'a, Err> {
Bytes(ByteStream<Err>),
String(Cow<'a, str>)
}
impl<'a, Err> Debug for BytesOrString<'a, Err> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Bytes(_) => write!(f, "BytesOrString::Bytes(...)"),
Self::String(_) => write!(f, "BytesOrString::String(...)")
}
}
}
#[derive(Debug)]
pub struct Value<'a, Err> {
pub value: BytesOrString<'a, Err>,
pub content_type: Option<Mime>
}