1use super::{BodyFrame, ReadableBody};
5use base_scheduler::{Cancellation, Cancelled};
6
7#[derive(Clone, Copy, Debug, Default)]
9pub struct EmptyBody;
10
11impl ReadableBody for EmptyBody {
12 type Data = Vec<u8>;
13 type Error = Cancelled;
14
15 fn may_have_trailers(&self) -> bool {
16 false
17 }
18
19 fn is_ready(&self) -> bool {
20 true
21 }
22
23 fn is_empty(&self) -> bool {
24 true
25 }
26
27 fn length(&self) -> Option<u64> {
28 Some(0)
29 }
30
31 fn close(&mut self, _error: Option<Self::Error>) {}
32
33 async fn read(
34 &mut self,
35 cancellation: &Cancellation,
36 ) -> Result<BodyFrame<Self::Data>, Self::Error> {
37 cancellation.check()?;
38 Ok(BodyFrame::End)
39 }
40}