Struct mles_utils::MsgConn
[−]
[src]
pub struct MsgConn { /* fields omitted */ }
Msg connection structure
This structure defines the Mles connection for simple synchronous connections.
Methods
impl MsgConn
[src]
fn new(uid: String, channel: String) -> MsgConn
[src]
Create a new MsgConn object for a connection.
Example
use mles_utils::MsgConn; let conn = MsgConn::new("My uid".to_string(), "My channel".to_string());
fn get_uid(&self) -> String
[src]
Gets the defined uid.
Example
use mles_utils::MsgConn; let conn = MsgConn::new("My uid".to_string(), "My channel".to_string()); assert_eq!("My uid".to_string(), conn.get_uid());
fn get_channel(&self) -> String
[src]
Gets the defined channel.
Example
use mles_utils::MsgConn; let conn = MsgConn::new("My uid".to_string(), "My channel".to_string()); assert_eq!("My channel".to_string(), conn.get_channel());
fn get_key(&self) -> Option<u64>
[src]
Gets the defined key.
Example
use mles_utils::MsgConn; //key is set only when connection is initiated.. let conn = MsgConn::new("My uid".to_string(), "My channel".to_string()); assert_eq!(true, conn.get_key().is_none());
fn connect_with_message(self, raddr: SocketAddr, msg: Vec<u8>) -> MsgConn
[src]
Connects to the defined address with a message.
fn connect(self, raddr: SocketAddr) -> MsgConn
[src]
Connects to the defined address (without a message).
fn send_message(self, msg: Vec<u8>) -> MsgConn
[src]
Send a message. Blocks until a message is sent.
Errors
If a message cannot be sent, stream is set to None.
fn read_message(self) -> (MsgConn, Vec<u8>)
[src]
Reads a message with non-zero message content. Blocks until a message is received.
Errors
If message cannot be read, an empty message is returned.
fn close(self) -> MsgConn
[src]
Closes the connection.