Struct bastion::path::BastionPath[][src]

pub struct BastionPath { /* fields omitted */ }

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

impl BastionPath[src]

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

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

pub fn elem(&self) -> &Option<BastionPathElement>[src]

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

pub fn is_dead_letters(&self) -> bool[src]

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

impl Clone for BastionPath[src]

impl Debug for BastionPath[src]

impl Display for BastionPath[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> Instrument 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> Pointable for T

type Init = T

The type for initializers.

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> ToString for T where
    T: Display + ?Sized
[src]

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>,