Struct mles_utils::Msg
[−]
[src]
pub struct Msg { /* fields omitted */ }
Msg structure
This structure defines the Mles interface value triplet (uid, channel, message). It is eventually serialized and deserialized by CBOR.
Methods
impl Msg
[src]
fn new(uid: String, channel: String, message: Vec<u8>) -> Msg
Create a new Msg object with value triplet.
Example
use mles_utils::Msg; let msg = Msg::new("My uid".to_string(), "My channel".to_string(), Vec::new());
fn set_uid(self, uid: String) -> Msg
Set uid for Msg object.
Example
use mles_utils::Msg; let mut msg = Msg::new("My uid".to_string(), "My channel".to_string(), Vec::new()); let msg = msg.set_uid("New uid".to_string()); assert_eq!("New uid".to_string(), *msg.get_uid());
fn set_channel(self, channel: String) -> Msg
Set channel for Msg object.
Example
use mles_utils::Msg; let mut msg = Msg::new("My uid".to_string(), "My channel".to_string(), Vec::new()); let msg = msg.set_channel("New channel".to_string()); assert_eq!("New channel".to_string(), *msg.get_channel());
fn set_message(self, message: Vec<u8>) -> Msg
Set message for Msg object.
Example
use mles_utils::Msg; let mut msg = Msg::new("My uid".to_string(), "My channel".to_string(), Vec::new()); let new_message: Vec<u8> = "New message".to_string().into_bytes(); let msg = msg.set_message(new_message);
fn get_uid(&self) -> &String
Get uid for Msg object. See example for set uid.
fn get_channel(&self) -> &String
Get channel for Msg object. See example for set channel.
fn get_message(&self) -> &Vec<u8>
Get message for Msg object.
Example
use mles_utils::Msg; let mut msg = Msg::new("My uid".to_string(), "My channel".to_string(), Vec::new()); let msg: &Vec<u8> = msg.get_message();
Trait Implementations
impl Debug for Msg
[src]
impl Clone for Msg
[src]
fn clone(&self) -> Msg
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more