logo

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

pub struct ChildrenRef { /* fields omitted */ }
Expand description

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

Implementations

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();

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();

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

Example
let distributors = children_ref.distributors();

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

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

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...
    _: _ => ();
}

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.");

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.");

Returns the BastionPath of this ChildrenRef

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Downcast implemented type to Any. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more