From 06a39b4962d171e4f85e3dde14dfcc115bd1df93 Mon Sep 17 00:00:00 2001 From: Alexey Galakhov Date: Wed, 15 Mar 2017 02:21:25 +0100 Subject: [PATCH] protocol: add get_ref() and get_mut() Signed-off-by: Alexey Galakhov --- src/protocol/frame/mod.rs | 8 ++++++++ src/protocol/mod.rs | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/protocol/frame/mod.rs b/src/protocol/frame/mod.rs index c5d92e8..4d2ffd1 100644 --- a/src/protocol/frame/mod.rs +++ b/src/protocol/frame/mod.rs @@ -37,6 +37,14 @@ impl FrameSocket { pub fn into_inner(self) -> (Stream, Vec) { (self.stream, self.in_buffer.into_vec()) } + /// Returns a shared reference to the inner stream. + pub fn get_ref(&self) -> &Stream { + &self.stream + } + /// Returns a mutable reference to the inner stream. + pub fn get_mut(&mut self) -> &mut Stream { + &mut self.stream + } } impl FrameSocket diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 9d6315c..cf0f96d 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -51,6 +51,15 @@ impl WebSocket { WebSocket::from_frame_socket(FrameSocket::from_partially_read(stream, part), role) } + /// Returns a shared reference to the inner stream. + pub fn get_ref(&self) -> &Stream { + self.socket.get_ref() + } + /// Returns a mutable reference to the inner stream. + pub fn get_mut(&mut self) -> &mut Stream { + self.socket.get_mut() + } + /// Convert a frame socket into a WebSocket. fn from_frame_socket(socket: FrameSocket, role: Role) -> Self { WebSocket {