Added comments

This commit is contained in:
arkpar 2016-02-21 16:52:25 +01:00
parent 93d259e8cb
commit 91276ad82e
3 changed files with 5 additions and 2 deletions

View File

@ -175,6 +175,7 @@ impl Connection {
self.socket.peer_addr() self.socket.peer_addr()
} }
/// Clone this connection. Clears the receiving buffer of the returned connection.
pub fn try_clone(&self) -> io::Result<Self> { pub fn try_clone(&self) -> io::Result<Self> {
Ok(Connection { Ok(Connection {
token: self.token, token: self.token,

View File

@ -176,6 +176,7 @@ impl Handshake {
Ok(()) Ok(())
} }
/// Update socket registration with the event loop.
pub fn update_socket<Host:Handler<Timeout=Token>>(&self, reg: Token, event_loop: &mut EventLoop<Host>) -> Result<(), UtilError> { pub fn update_socket<Host:Handler<Timeout=Token>>(&self, reg: Token, event_loop: &mut EventLoop<Host>) -> Result<(), UtilError> {
if !self.expired() { if !self.expired() {
try!(self.connection.update_socket(reg, event_loop)); try!(self.connection.update_socket(reg, event_loop));

View File

@ -111,7 +111,8 @@ const PACKET_USER: u8 = 0x10;
const PACKET_LAST: u8 = 0x7f; const PACKET_LAST: u8 = 0x7f;
impl Session { impl Session {
/// Create a new session out of comepleted handshake. /// Create a new session out of comepleted handshake. This clones the handshake connection object
/// and leaves the handhsake in limbo to be deregistered from the event loop.
pub fn new(h: &mut Handshake, host: &HostInfo) -> Result<Session, UtilError> { pub fn new(h: &mut Handshake, host: &HostInfo) -> Result<Session, UtilError> {
let id = h.id.clone(); let id = h.id.clone();
let connection = try!(EncryptedConnection::new(h)); let connection = try!(EncryptedConnection::new(h));
@ -189,7 +190,7 @@ impl Session {
} }
/// Register the session socket with the event loop /// Register the session socket with the event loop
pub fn register_socket<Host:Handler<Timeout=Token>>(&self, reg: Token, event_loop: &mut EventLoop<Host>) -> Result<(), UtilError> { pub fn register_socket<Host:Handler<Timeout = Token>>(&self, reg: Token, event_loop: &mut EventLoop<Host>) -> Result<(), UtilError> {
if self.expired() { if self.expired() {
return Ok(()); return Ok(());
} }