1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use bytes::Buf;
use futures::Poll;
use Body;

#[derive(Debug, Default)]
pub struct NoBody;

#[derive(Debug, Default)]
pub struct NoData;

impl Body for NoBody {
    type Data = NoData;
    type Error = h2::Error;

    fn is_end_stream(&self) -> bool {
        true
    }

    fn poll_data(&mut self) -> Poll<Option<Self::Data>, h2::Error> {
        Ok(None.into())
    }

    fn poll_trailers(&mut self) -> Poll<Option<http::HeaderMap>, h2::Error> {
        Ok(None.into())
    }
}

impl Buf for NoData {
    fn remaining(&self) -> usize {
        0
    }

    fn bytes(&self) -> &[u8] {
        &[]
    }

    fn advance(&mut self, _cnt: usize) {}
}