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

@@ -1,9 +1,16 @@
use ConnectionError;
use {ConnectionError, StreamId};
use frame::{Frame, Ping, SettingSet};
use proto::{ApplySettings, ControlPing, PingPayload, ReadySink};
use proto::{ApplySettings, ReadySink, ControlStreams, FlowControlState};
use futures::*;
pub type PingPayload = [u8; 8];
pub trait ControlPing {
fn start_ping(&mut self, body: PingPayload) -> StartSend<PingPayload, ConnectionError>;
fn take_pong(&mut self) -> Option<PingPayload>;
}
/// Acknowledges ping requests from the remote.
#[derive(Debug)]
pub struct PingPong<T, U> {
@@ -29,16 +36,6 @@ impl<T, U> PingPong<T, U>
}
}
impl<T: ApplySettings, U> ApplySettings for PingPong<T, U> {
fn apply_local_settings(&mut self, set: &SettingSet) -> Result<(), ConnectionError> {
self.inner.apply_local_settings(set)
}
fn apply_remote_settings(&mut self, set: &SettingSet) -> Result<(), ConnectionError> {
self.inner.apply_remote_settings(set)
}
}
impl<T, U> ControlPing for PingPong<T, U>
where T: Sink<SinkItem = Frame<U>, SinkError = ConnectionError>,
T: ReadySink,
@@ -172,6 +169,16 @@ impl<T, U> ReadySink for PingPong<T, U>
}
}
impl<T: ApplySettings, U> ApplySettings for PingPong<T, U> {
fn apply_local_settings(&mut self, set: &SettingSet) -> Result<(), ConnectionError> {
self.inner.apply_local_settings(set)
}
fn apply_remote_settings(&mut self, set: &SettingSet) -> Result<(), ConnectionError> {
self.inner.apply_remote_settings(set)
}
}
#[cfg(test)]
mod test {
use super::*;