pub struct Message { /* private fields */ }Expand description
Implementations§
Source§impl Message
impl Message
Sourcepub fn new<T>(value: T) -> Messagewhere
T: 'static + ActorMessage,
pub fn new<T>(value: T) -> Messagewhere
T: 'static + ActorMessage,
Creates a new message from a value, transferring ownership to the message.
§Examples
use axiom::message::Message;
let msg = Message::new(11);Sourcepub fn from_arc<T>(value: Arc<T>) -> Messagewhere
T: 'static + ActorMessage,
pub fn from_arc<T>(value: Arc<T>) -> Messagewhere
T: 'static + ActorMessage,
Creates a new message from an Arc, transferring ownership of the Arc to the message.
Note that this is more efficient if a user wants to send a message that is already an
Arc so they dont create an arc inside an Arc.
§Examples
use axiom::message::Message;
use std::sync::Arc;
let arc = Arc::new(11);
let msg = Message::new(arc);Sourcepub fn content_as<T>(&self) -> Option<Arc<T>>where
T: 'static + ActorMessage,
pub fn content_as<T>(&self) -> Option<Arc<T>>where
T: 'static + ActorMessage,
Get the content as an Arc<T>. If this fails a None will be returned. Note that
the user need not worry whether the message came from a local or remote source as the
heavy lifting for that is done internally. The first successful attempt to downcast a
remote message will result in the value being converted to a local message.
§Examples
use axiom::message::Message;
use std::sync::Arc;
let value = 11 as i32;
let msg = Message::new(value);
assert_eq!(value, *msg.content_as::<i32>().unwrap());
assert_eq!(None, msg.content_as::<u32>());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 UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> ActorMessage for T
impl<T> ActorMessage for T
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