pub struct BastionPath { /* private fields */ }Expand description
Represents a Path for a System, Supervisor, Children or Child.
BastionPath can be used to identify message senders. Later it will be used to route messages to a path.
§Example
ctx.tell(&ctx.signature(), "Hello to myself").expect("Couldn't send a message");
msg! { ctx.recv().await?,
ref msg: &'static str => {
let path: &BastionPath = signature!().path();
assert_eq!(path.elem(), ctx.signature().path().elem());
};
// We are only sending a `&'static str` in this
// example, so we know that this won't happen...
_: _ => ();
}Implementations§
Source§impl BastionPath
impl BastionPath
Sourcepub fn id(&self) -> &BastionId
pub fn id(&self) -> &BastionId
Returns the last element’s id. If it’s root or a dead_letters then &NIL_ID is returned.
§Example
let msg = "A message containing data.";
children_ref.broadcast(msg).expect("Couldn't send the message.");
msg! { ctx.recv().await?,
ref msg: &'static str => {
let path = signature!().path();
assert_eq!(path.id(), &NIL_ID);
};
// We are only sending a `&'static str` in this
// example, so we know that this won't happen...
_: _ => ();
}Sourcepub fn elem(&self) -> &Option<BastionPathElement>
pub fn elem(&self) -> &Option<BastionPathElement>
Returns a path element. If the path is root then None is returned.
§Example
let msg = "A message containing data.";
children_ref.broadcast(msg).expect("Couldn't send the message.");
msg! { ctx.recv().await?,
ref msg: &'static str => {
let path = signature!().path();
assert!(path.elem().as_ref().unwrap().is_children());
};
// We are only sending a `&'static str` in this
// example, so we know that this won't happen...
_: _ => ();
}Sourcepub fn is_dead_letters(&self) -> bool
pub fn is_dead_letters(&self) -> bool
Checks whether BastionPath is a dead-letters path.
§Example
let msg = "A message containing data.";
children_ref.broadcast(msg).expect("Couldn't send the message.");
msg! { ctx.recv().await?,
ref msg: &'static str => {
let path = signature!().path();
assert!(path.is_dead_letters());
};
// We are only sending a `&'static str` in this
// example, so we know that this won't happen...
_: _ => ();
}Trait Implementations§
Source§impl Clone for BastionPath
impl Clone for BastionPath
Source§fn clone(&self) -> BastionPath
fn clone(&self) -> BastionPath
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BastionPath
impl Debug for BastionPath
Auto Trait Implementations§
impl Freeze for BastionPath
impl RefUnwindSafe for BastionPath
impl Send for BastionPath
impl Sync for BastionPath
impl Unpin for BastionPath
impl UnwindSafe for BastionPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more