Msg

Struct Msg 

Source
pub struct Msg { /* private fields */ }
Expand description

The actual payload received by actors inside a Mail enum construct

Implementations§

Source§

impl Msg

Source

pub fn new(content: Option<Vec<u8>>, from: &str, to: &str) -> Self

Construct a new message with binary content with from and to addresses

Source

pub fn with_binary_content(content: Option<Vec<u8>>) -> Self

Update the message with binary content

Source

pub fn from_text(content: &str) -> Self

Create a msg with content as text

Source

pub fn with_text(content: &str, from: &str, to: &str) -> Self

Construct a text message with from and to addresses

Source

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.

Source

pub fn is_command(&self) -> bool

Is the message actually a command?

Source

pub fn command_equals(&self, action: Action) -> bool

Command action equality check

Source

pub fn action(&self) -> Option<Action>

Get the embedded Action out if this Msg content is really is Command

Source

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

Source

pub fn text_reply(&mut self, reply: &str)

Construct a text reply with content as string and message direction reversed

Source

pub fn update_text_content(&mut self, text: &str)

Update the content of the message - text

Source

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

Source

pub fn with_content(&mut self, new_content: Vec<u8>)

Set the binary content of the message

Source

pub fn set_recipient_addr(&mut self, addr: &Addr)

Set the recipient address of the message

Source

pub fn set_recipient(&mut self, new_to: &str)

Set the recipient identifier as string literal

Source

pub fn set_recipient_ip(&mut self, new_to_ip: &str)

Set the recipient actor’s IP - used in remoting

Source

pub fn set_recipient_port(&mut self, new_port: u16)

Set the recipient port

Source

pub fn get_recipient_port(&self) -> u16

Get the port of the recipient actor - used for remote messaging

Source

pub fn binary_reply(&mut self, reply: Option<Vec<u8>>)

Reverse the message direction - ‘to’ to ‘from’ or other way

Source

pub fn binary_content(&self) -> Option<Vec<u8>>

Get the binary content - the message remains intact

Source

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

Source

pub fn get_to(&self) -> &Option<Addr>

Get the address of the actor the message is directed at

Source

pub fn get_id(&self) -> &u64

Get the id

Source

pub fn id_as_string(&self) -> String

Get the id as string. Required because unique ids overflow i64 range supported by the backing store

Source

pub fn get_to_id(&self) -> u64

Get the unique id of the actor message is directed at

Source

pub fn get_from(&self) -> &Option<Addr>

Get the from address

Source

pub fn inbound(&self) -> bool

Check if message is directed at any actor in the system

Source

pub fn set_from(&mut self, from: &Addr)

Set the from address of a message - specific usage while sending out actor message processing outcome

Source

pub fn shutdown() -> Self

Construct a Shutdown command to shutdown the system listener

Source

pub fn echo(s: &str) -> Self

Construct a Echo command to send to the system listener to check its liveness

Trait Implementations§

Source§

impl Clone for Msg

Source§

fn clone(&self) -> Msg

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Msg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Msg

Source§

fn default() -> Msg

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Msg

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Msg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Msg> for Mail

Source§

fn from(msg: Msg) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Msg

Source§

fn eq(&self, other: &Msg) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Msg

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Msg

Auto Trait Implementations§

§

impl Freeze for Msg

§

impl RefUnwindSafe for Msg

§

impl Send for Msg

§

impl Sync for Msg

§

impl Unpin for Msg

§

impl UnwindSafe for Msg

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,