protocol: add get_ref() and get_mut()

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
pull/7/head
Alexey Galakhov 8 years ago
parent 9e00140e19
commit 06a39b4962
  1. 8
      src/protocol/frame/mod.rs
  2. 9
      src/protocol/mod.rs

@ -37,6 +37,14 @@ impl<Stream> FrameSocket<Stream> {
pub fn into_inner(self) -> (Stream, Vec<u8>) {
(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<Stream> FrameSocket<Stream>

@ -51,6 +51,15 @@ impl<Stream> WebSocket<Stream> {
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<Stream>, role: Role) -> Self {
WebSocket {

Loading…
Cancel
Save