[][src]Struct maxim::message::Message

pub struct Message { /* fields omitted */ }

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]

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]

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]

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]

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]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,