Struct mles_utils::MsgConn
source · pub struct MsgConn { /* private fields */ }
Expand description
Msg connection structure
This structure defines the Mles connection for simple synchronous connections.
Implementations§
source§impl MsgConn
impl MsgConn
sourcepub fn new(uid: String, channel: String) -> MsgConn
pub fn new(uid: String, channel: String) -> MsgConn
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());
sourcepub fn get_uid(&self) -> String
pub fn get_uid(&self) -> String
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());
sourcepub fn get_channel(&self) -> String
pub fn get_channel(&self) -> String
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());
sourcepub fn get_key(&self) -> Option<u64>
pub fn get_key(&self) -> Option<u64>
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());
sourcepub fn connect_with_message(self, raddr: SocketAddr, msg: Vec<u8>) -> MsgConn
pub fn connect_with_message(self, raddr: SocketAddr, msg: Vec<u8>) -> MsgConn
Connects to the defined address with a message.
sourcepub fn connect(self, raddr: SocketAddr) -> MsgConn
pub fn connect(self, raddr: SocketAddr) -> MsgConn
Connects to the defined address (without a message).
sourcepub fn send_message(self, msg: Vec<u8>) -> MsgConn
pub fn send_message(self, msg: Vec<u8>) -> MsgConn
Send a message. Blocks until a message is sent.
Errors
If a message cannot be sent, stream is set to None.
Auto Trait Implementations§
impl RefUnwindSafe for MsgConn
impl Send for MsgConn
impl Sync for MsgConn
impl Unpin for MsgConn
impl UnwindSafe for MsgConn
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more