[][src]Struct bastion::children_ref::ChildrenRef

pub struct ChildrenRef { /* fields omitted */ }

A "reference" to a children group, allowing to communicate with it.

Implementations

impl ChildrenRef[src]

pub fn id(&self) -> &BastionId[src]

Returns the identifier of the children group this ChildrenRef is referencing.

Note that the children group's identifier is reset when it is restarted.

Example

let children_ref = Bastion::children(|children| {
    // ...
}).expect("Couldn't create the children group.");

let children_id: &BastionId = children_ref.id();

pub fn dispatchers(&self) -> &Vec<DispatcherType>[src]

Returns a list of dispatcher names that can be used for communication with other actors in the same group(s).

Example

let dispatchers = children_ref.dispatchers();

pub fn elems(&self) -> &[ChildRef][src]

Returns a list of ChildRef referencing the elements of the children group this ChildrenRef is referencing.

Example

let elems: &[ChildRef] = children_ref.elems();

pub fn broadcast<M: Message>(&self, msg: M) -> Result<(), M>[src]

Sends a message to the children group this ChildrenRef is referencing which will then send it to all of its elements.

An alternative would be to use elems to get all the elements of the group and then send the message to all of them.

This method returns () if it succeeded, or Err(msg) otherwise.

Arguments

  • msg - The message to send.

Example

let msg = "A message containing data.";
children_ref.broadcast(msg).expect("Couldn't send the message.");

// And then in every of the children group's elements' futures...
msg! { ctx.recv().await?,
    ref msg: &'static str => {
        assert_eq!(msg, &"A message containing data.");
    };
    // We are only sending a `&'static str` in this
    // example, so we know that this won't happen...
    _: _ => ();
}

pub fn stop(&self) -> Result<(), ()>[src]

Sends a message to the children group this ChildrenRef is referencing to tell it to stop all of its running elements.

This method returns () if it succeeded, or Err(()) otherwise.

Example

children_ref.stop().expect("Couldn't send the message.");

pub fn kill(&self) -> Result<(), ()>[src]

Sends a message to the children group this ChildrenRef is referencing to tell it to kill all of its running elements.

This method returns () if it succeeded, or Err(()) otherwise.

Example

children_ref.kill().expect("Couldn't send the message.");

pub fn path(&self) -> &Arc<BastionPath>[src]

Returns the BastionPath of this ChildrenRef

Trait Implementations

impl Clone for ChildrenRef[src]

impl Debug for ChildrenRef[src]

impl Eq for ChildrenRef[src]

impl PartialEq<ChildrenRef> for ChildrenRef[src]

Auto Trait Implementations

Blanket Implementations

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

impl<T> AsAny for T where
    T: Any
[src]

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

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

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

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

impl<T> Message for T where
    T: Any + Send + Sync + Debug
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> State for T where
    T: Send + Sync + 'static, 
[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>,