From bf724bd53ee6e7b1c07465671f2179989782f995 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Sat, 22 Jul 2017 21:23:24 +0000 Subject: [PATCH] expose ControlPing to Connection --- src/proto/connection.rs | 33 ++++++++++++++------------------- src/proto/stream_send_open.rs | 2 +- src/proto/stream_store.rs | 10 ++++++++++ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/proto/connection.rs b/src/proto/connection.rs index 9b88e03..587e27a 100644 --- a/src/proto/connection.rs +++ b/src/proto/connection.rs @@ -3,7 +3,8 @@ use client::Client; use error; use frame::{self, StreamId}; use proto::*; -//use proto::ping_pong::PingPayload; +use proto::ping_pong::{ControlPing, PingPayload}; +use proto::settings::ControlSettings; use server::Server; use bytes::{Bytes, IntoBuf}; @@ -33,24 +34,6 @@ pub fn new(transport: Transport) } } -// impl ControlSettings for Connection -// where T: AsyncRead + AsyncWrite, -// B: IntoBuf, -// { -// fn update_local_settings(&mut self, local: frame::SettingSet) -> Result<(), ConnectionError> { -// self.inner.update_local_settings(local) -// } - -// fn local_settings(&self) -> &SettingSet { -// self.inner.local_settings() -// } - -// fn remote_settings(&self) -> &SettingSet { -// self.inner.remote_settings() -// } -// } - - impl Connection where T: AsyncRead + AsyncWrite, P: Peer, @@ -66,6 +49,18 @@ impl Connection self.inner.expand_window(id, incr) } + pub fn update_local_settings(&mut self, local: frame::SettingSet) -> Result<(), ConnectionError> { + self.inner.update_local_settings(local) + } + + pub fn start_ping(&mut self, body: PingPayload) -> StartSend { + self.inner.start_ping(body) + } + + pub fn take_pong(&mut self) -> Option { + self.inner.take_pong() + } + pub fn send_data(self, id: StreamId, data: B, diff --git a/src/proto/stream_send_open.rs b/src/proto/stream_send_open.rs index 2dfa6f5..6c814e2 100644 --- a/src/proto/stream_send_open.rs +++ b/src/proto/stream_send_open.rs @@ -1,5 +1,5 @@ use ConnectionError; -use error::User::{InactiveStreamId, InvalidStreamId, StreamReset, Rejected, UnexpectedFrameType}; +use error::User::{InactiveStreamId, InvalidStreamId, StreamReset, Rejected}; use frame::{Frame, SettingSet}; use proto::*; diff --git a/src/proto/stream_store.rs b/src/proto/stream_store.rs index 597d0ea..23deb62 100644 --- a/src/proto/stream_store.rs +++ b/src/proto/stream_store.rs @@ -390,3 +390,13 @@ impl ApplySettings for StreamStore { self.inner.apply_remote_settings(set) } } + +impl ControlPing for StreamStore { + fn start_ping(&mut self, body: PingPayload) -> StartSend { + self.inner.start_ping(body) + } + + fn take_pong(&mut self) -> Option { + self.inner.take_pong() + } +}