H3: move codecs to a new proto module

This commit is contained in:
stammw
2019-05-08 16:57:59 +02:00
committed by Dirkjan Ochtman
parent 2053e564f4
commit eab98c19f8
4 changed files with 36 additions and 30 deletions
+4 -2
View File
@@ -8,8 +8,10 @@ use tokio::runtime::current_thread::Runtime;
use bytes::{Bytes, BytesMut};
use failure::{format_err, Error};
use quinn_h3::frame::{HeadersFrame, HttpFrame, SettingsFrame};
use quinn_h3::StreamType;
use quinn_h3::proto::{
frame::{HeadersFrame, HttpFrame, SettingsFrame},
StreamType,
};
use slog::{o, warn, Drain, Logger};
type Result<T> = std::result::Result<T, Error>;
+1 -28
View File
@@ -9,32 +9,5 @@ extern crate proptest;
#[macro_use]
extern crate assert_matches;
extern crate quinn_proto;
pub mod frame;
pub mod proto;
pub mod qpack;
use bytes::BufMut;
use quinn_proto::coding::BufMutExt;
pub struct StreamType(u64);
macro_rules! stream_types {
{$($name:ident = $val:expr,)*} => {
impl StreamType {
$(pub const $name: StreamType = StreamType($val);)*
}
}
}
stream_types! {
CONTROL = 0x00,
PUSH = 0x01,
ENCODER = 0x02,
DECODER = 0x03,
}
impl StreamType {
pub fn encode<W: BufMut>(&self, buf: &mut W) {
buf.write_var(self.0);
}
}
@@ -426,6 +426,8 @@ mod tests {
HttpFrame::Settings(SettingsFrame {
num_placeholders: 0xfada,
max_header_list_size: 0xfada,
qpack_max_table_capacity: 0,
qpack_blocked_streams: 0,
})
);
}
@@ -453,6 +455,8 @@ mod tests {
Ok(HttpFrame::Settings(SettingsFrame {
num_placeholders: 16,
max_header_list_size: 0xFADA,
qpack_max_table_capacity: 0,
qpack_blocked_streams: 0,
}))
);
}
+27
View File
@@ -0,0 +1,27 @@
use bytes::BufMut;
use quinn_proto::coding::BufMutExt;
pub mod frame;
pub struct StreamType(u64);
macro_rules! stream_types {
{$($name:ident = $val:expr,)*} => {
impl StreamType {
$(pub const $name: StreamType = StreamType($val);)*
}
}
}
stream_types! {
CONTROL = 0x00,
PUSH = 0x01,
ENCODER = 0x02,
DECODER = 0x03,
}
impl StreamType {
pub fn encode<W: BufMut>(&self, buf: &mut W) {
buf.write_var(self.0);
}
}