nyquest_interface/blocking/
body.rs1use std::io::{Read, Seek};
6
7pub trait SizedBodyStream: Read + Seek + Send + 'static {}
9
10pub trait UnsizedBodyStream: Read + Send + 'static {}
12
13pub enum BoxedStream {
15 Sized {
17 stream: Box<dyn SizedBodyStream>,
19 content_length: u64,
21 },
22 Unsized {
24 stream: Box<dyn UnsizedBodyStream>,
26 },
27}
28
29pub type Body = crate::body::Body<BoxedStream>;
31
32impl<S: Read + Seek + Send + 'static + ?Sized> SizedBodyStream for S {}
33impl<S: Read + Send + 'static + ?Sized> UnsizedBodyStream for S {}
34
35impl Read for BoxedStream {
36 fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
37 match self {
38 BoxedStream::Sized { stream, .. } => stream.read(buf),
39 BoxedStream::Unsized { stream } => stream.read(buf),
40 }
41 }
42}