Get server module compiling again

This commit is contained in:
Carl Lerche
2017-08-08 22:25:05 -07:00
parent 26df3a3698
commit 38762a9711
3 changed files with 144 additions and 104 deletions

View File

@@ -32,7 +32,7 @@ pub mod error;
mod hpack;
mod proto;
mod frame;
// pub mod server;
pub mod server;
pub use error::{ConnectionError, Reason};
pub use frame::StreamId;
@@ -43,6 +43,45 @@ pub type FrameSize = u32;
// TODO: remove if carllerche/http#90 lands
pub type HeaderMap = http::HeaderMap<http::header::HeaderValue>;
// TODO: Move into other location
use bytes::IntoBuf;
use futures::Poll;
#[derive(Debug)]
pub struct Body<B: IntoBuf> {
inner: proto::StreamRef<B::Buf>,
}
#[derive(Debug)]
pub struct Chunk<B: IntoBuf> {
inner: proto::Chunk<B::Buf>,
}
// ===== impl Body =====
impl<B: IntoBuf> futures::Stream for Body<B> {
type Item = Chunk<B>;
type Error = ConnectionError;
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
let chunk = try_ready!(self.inner.poll_data())
.map(|inner| Chunk { inner });
Ok(chunk.into())
}
}
// ===== impl Chunk =====
impl<B: IntoBuf> Chunk<B> {
pub fn pop_bytes(&mut self) -> Option<Bytes> {
self.inner.pop_bytes()
}
}
// TODO: Delete below
/// An H2 connection frame
#[derive(Debug)]
pub enum Frame<T, B = Bytes> {