pub struct Msg { /* private fields */ }Expand description
The actual payload received by actors inside a Mail enum construct
Implementations§
Source§impl Msg
impl Msg
Sourcepub fn new(content: Option<Vec<u8>>, from: &str, to: &str) -> Self
pub fn new(content: Option<Vec<u8>>, from: &str, to: &str) -> Self
Construct a new message with binary content with from and to addresses
Sourcepub fn with_binary_content(content: Option<Vec<u8>>) -> Self
pub fn with_binary_content(content: Option<Vec<u8>>) -> Self
Update the message with binary content
Sourcepub fn with_text(content: &str, from: &str, to: &str) -> Self
pub fn with_text(content: &str, from: &str, to: &str) -> Self
Construct a text message with from and to addresses
Sourcepub fn as_text(&self) -> Option<&str>
pub fn as_text(&self) -> Option<&str>
Get the content of msg as text. In case - binary content being actually binary this would not be helpful.
Sourcepub fn is_command(&self) -> bool
pub fn is_command(&self) -> bool
Is the message actually a command?
Sourcepub fn command_equals(&self, action: Action) -> bool
pub fn command_equals(&self, action: Action) -> bool
Command action equality check
Sourcepub fn as_bytes(&self) -> Vec<u8> ⓘ
pub fn as_bytes(&self) -> Vec<u8> ⓘ
The message as bytes - irrespective of whether content is text or actual binary blob. Empty byte vec - if can not be serialized
Sourcepub fn text_reply(&mut self, reply: &str)
pub fn text_reply(&mut self, reply: &str)
Construct a text reply with content as string and message direction reversed
Sourcepub fn update_text_content(&mut self, text: &str)
pub fn update_text_content(&mut self, text: &str)
Update the content of the message - text
Sourcepub fn with_content_and_to(&mut self, new_content: Vec<u8>, new_to: &str)
pub fn with_content_and_to(&mut self, new_content: Vec<u8>, new_to: &str)
Set new binary content and new local recipient actor address
Sourcepub fn with_content(&mut self, new_content: Vec<u8>)
pub fn with_content(&mut self, new_content: Vec<u8>)
Set the binary content of the message
Sourcepub fn set_recipient_addr(&mut self, addr: &Addr)
pub fn set_recipient_addr(&mut self, addr: &Addr)
Set the recipient address of the message
Sourcepub fn set_recipient(&mut self, new_to: &str)
pub fn set_recipient(&mut self, new_to: &str)
Set the recipient identifier as string literal
Sourcepub fn set_recipient_ip(&mut self, new_to_ip: &str)
pub fn set_recipient_ip(&mut self, new_to_ip: &str)
Set the recipient actor’s IP - used in remoting
Sourcepub fn set_recipient_port(&mut self, new_port: u16)
pub fn set_recipient_port(&mut self, new_port: u16)
Set the recipient port
Sourcepub fn get_recipient_port(&self) -> u16
pub fn get_recipient_port(&self) -> u16
Get the port of the recipient actor - used for remote messaging
Sourcepub fn binary_reply(&mut self, reply: Option<Vec<u8>>)
pub fn binary_reply(&mut self, reply: Option<Vec<u8>>)
Reverse the message direction - ‘to’ to ‘from’ or other way
Sourcepub fn binary_content(&self) -> Option<Vec<u8>>
pub fn binary_content(&self) -> Option<Vec<u8>>
Get the binary content - the message remains intact
Sourcepub fn binary_content_out(&mut self) -> Option<Vec<u8>>
pub fn binary_content_out(&mut self) -> Option<Vec<u8>>
If the message content is binary blob - get it Would take content out - leaving message content to a None
Sourcepub fn id_as_string(&self) -> String
pub fn id_as_string(&self) -> String
Get the id as string. Required because unique ids overflow i64 range supported by the backing store