wip: refactor, compiles

This commit is contained in:
Oliver Gould
2017-07-20 14:51:27 +00:00
parent 0d84c98c89
commit a62d3dda54
17 changed files with 1395 additions and 1052 deletions

View File

@@ -80,6 +80,21 @@ impl<T> Frame<T> {
&Settings(_) => StreamId::zero(),
}
}
pub fn is_end_stream(&self) -> bool {
use self::Frame::*;
match self {
&Headers(ref v) => v.is_end_stream(),
&Data(ref v) => v.is_end_stream(),
&Reset(ref v) => true,
&PushPromise(_) |
&WindowUpdate(_) |
&Ping(_) |
&Settings(_) => false,
}
}
}
/// Errors that can occur during parsing an HTTP/2 frame.

View File

@@ -16,6 +16,15 @@ impl Reset {
error_code: error.into(),
}
}
pub fn stream_id(&self) -> StreamId {
self.stream_id
}
pub fn reason(&self) -> Reason {
self.error_code.into()
}
pub fn load(head: Head, payload: &[u8]) -> Result<Reset, Error> {
if payload.len() != 4 {
return Err(Error::InvalidPayloadLength);
@@ -35,14 +44,6 @@ impl Reset {
head.encode(4, dst);
dst.put_u32::<BigEndian>(self.error_code);
}
pub fn stream_id(&self) -> StreamId {
self.stream_id
}
pub fn reason(&self) -> Reason {
self.error_code.into()
}
}
impl<B> From<Reset> for frame::Frame<B> {