pub struct Message {
pub id: String,
pub from: Option<String>,
pub to: Option<String>,
pub timestamp_ms: u64,
pub payload: MessageType,
}Expand description
A message envelope routed between actors.
Fields§
§id: StringUnique WID for this message.
from: Option<String>Sender’s actor WID (None for system-generated messages).
to: Option<String>Recipient actor WID (None means broadcast).
timestamp_ms: u64Unix timestamp (milliseconds) when the message was created.
payload: MessageTypeThe actual payload.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
from: Option<String>,
to: Option<String>,
payload: MessageType,
) -> Self
pub fn new( from: Option<String>, to: Option<String>, payload: MessageType, ) -> Self
Construct a new message with a fresh WID and current timestamp.
Sourcepub fn text(
from: Option<String>,
to: Option<String>,
content: impl Into<String>,
) -> Self
pub fn text( from: Option<String>, to: Option<String>, content: impl Into<String>, ) -> Self
Shorthand: send a plain text message.
Sourcepub fn command(to: String, cmd: ActorCommand) -> Self
pub fn command(to: String, cmd: ActorCommand) -> Self
Shorthand: send a command to a specific actor.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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