use super::{BodyFrame, ReadableBody};
use base_scheduler::{Cancellation, Cancelled};
#[derive(Clone, Copy, Debug, Default)]
pub struct EmptyBody;
impl ReadableBody for EmptyBody {
type Data = Vec<u8>;
type Error = Cancelled;
fn may_have_trailers(&self) -> bool {
false
}
fn is_ready(&self) -> bool {
true
}
fn is_empty(&self) -> bool {
true
}
fn length(&self) -> Option<u64> {
Some(0)
}
fn close(&mut self, _error: Option<Self::Error>) {}
async fn read(
&mut self,
cancellation: &Cancellation,
) -> Result<BodyFrame<Self::Data>, Self::Error> {
cancellation.check()?;
Ok(BodyFrame::End)
}
}