[−][src]Struct maxim::message::Message
A type for a message sent to an actor channel.
Note that this type uses an internal Arc
so there is no reason to surround it with
another Arc
to make it thread safe.
Methods
impl Message
[src]
pub fn new<T>(value: T) -> Message where
T: 'static + ActorMessage,
[src]
T: 'static + ActorMessage,
Creates a new message from a value, transferring ownership to the message.
Examples
use maxim::message::Message; let msg = Message::new(11);
pub fn from_arc<T>(value: Arc<T>) -> Message where
T: 'static + ActorMessage,
[src]
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 maxim::message::Message; use std::sync::Arc; let arc = Arc::new(11); let msg = Message::new(arc);
pub fn content_as<T>(&self) -> Option<Arc<T>> where
T: 'static + ActorMessage,
[src]
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 maxim::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
impl Clone for Message
[src]
impl<'de> Deserialize<'de> for Message
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Serialize for Message
[src]
Auto Trait Implementations
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations
impl<T> ActorMessage for T where
T: 'static + Serialize + DeserializeOwned + Sync + Send + Any + ?Sized,
[src]
T: 'static + Serialize + DeserializeOwned + Sync + Send + Any + ?Sized,
fn to_bincode(&Self) -> Result<Vec<u8>, Box<dyn Error + 'static>>
[src]
fn from_bincode(&Vec<u8>) -> Result<T, Box<dyn Error + 'static>>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,