use std::io::{Read, Seek};
pub trait SizedBodyStream: Read + Seek + Send + 'static {}
pub trait UnsizedBodyStream: Read + Send + 'static {}
pub enum BoxedStream {
Sized {
stream: Box<dyn SizedBodyStream>,
content_length: u64,
},
Unsized {
stream: Box<dyn UnsizedBodyStream>,
},
}
pub type Body = crate::body::Body<BoxedStream>;
impl<S: Read + Seek + Send + 'static + ?Sized> SizedBodyStream for S {}
impl<S: Read + Send + 'static + ?Sized> UnsizedBodyStream for S {}
impl Read for BoxedStream {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
match self {
BoxedStream::Sized { stream, .. } => stream.read(buf),
BoxedStream::Unsized { stream } => stream.read(buf),
}
}
}