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();
pub fn dispatchers(&self) -> &Vec<DispatcherType>ⓘ
pub fn dispatchers(&self) -> &Vec<DispatcherType>ⓘ
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 distributors(&self) -> &Vec<Distributor>ⓘ
pub fn distributors(&self) -> &Vec<Distributor>ⓘ
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();
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
Auto Trait Implementations
impl !RefUnwindSafe for ChildrenRef
impl Send for ChildrenRef
impl Sync for ChildrenRef
impl Unpin for ChildrenRef
impl !UnwindSafe for ChildrenRef
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
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