Struct ockam_core::RouteBuilder

source ·
pub struct RouteBuilder<'r> { /* private fields */ }
Expand description

A utility type for building and manipulating routes.

Implementations§

source§

impl RouteBuilder<'_>

source

pub fn append<A: Into<Address>>(self, addr: A) -> Self

Push a new item to the back of the route.

§Examples
let builder: RouteBuilder = Route::new()
    .append("1#alice")
    .append("bob");

// ["1#alice, "0#bob"]
let route: Route = builder.into();
source

pub fn append_t<A: Into<String>>(self, ty: TransportType, addr: A) -> Self

Push an item with an explicit type to the back of the route.

§Examples
let builder: RouteBuilder = Route::new()
    .append_t(TCP, "alice")
    .append_t(LOCAL, "bob");

// ["1#alice", "0#bob"]
let route: Route = builder.into();
source

pub fn prepend<A: Into<Address>>(self, addr: A) -> Self

Push a new item to the front of the route.

§Examples
let builder: RouteBuilder = Route::new()
    .prepend("1#alice")
    .prepend("0#bob");

// ["0#bob", "1#alice"]
let route: Route = builder.into();
source

pub fn prepend_route(self, route: Route) -> Self

Prepend a full route to an existing route.

§Examples
let mut route_a: Route = route!["1#alice", "bob"];
let route_b: Route = route!["1#carol", "dave"];

// ["1#carol", "0#dave", "1#alice", "0#bob"]
let route: Route = route_a.modify()
    .prepend_route(route_b)
    .into();
source

pub fn append_route(self, route: Route) -> Self

Append a full route to an existing route.

§Examples
let mut route_a: Route = route!["1#alice", "bob"];
let route_b: Route = route!["1#carol", "dave"];

// ["1#alice", "0#bob", "1#carol", "0#dave"]
let route: Route = route_a.modify()
    .append_route(route_b)
    .into();
source

pub fn replace<A: Into<Address>>(self, addr: A) -> Self

Replace the next item in the route with a new address.

Similar to Self::prepend(...), but drops the previous HEAD value.

§Examples
let mut route: Route = route!["1#alice", "bob"];

// ["1#carol", "0#bob"]
let route: Route = route.modify()
    .replace("1#carol")
    .into();
source

pub fn pop_front(self) -> Self

Pop the front item from the route.

§Examples
let mut route: Route = route!["1#alice", "bob", "carol"];

// ["0#bob", "carol"]
let route: Route = route.modify()
    .pop_front()
    .into();
source

pub fn pop_back(self) -> Self

Pop the back item from the route.

§Examples
let mut route: Route = route!["1#alice", "bob", "carol"];

// ["1#alice", "0#bob"]
let route: Route = route.modify()
    .pop_back()
    .into();

Trait Implementations§

source§

impl Default for RouteBuilder<'_>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Drop for RouteBuilder<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl From<RouteBuilder<'_>> for Route

Convert a RouteBuilder into a Route.

source§

fn from(_: RouteBuilder<'_>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'r> Freeze for RouteBuilder<'r>

§

impl<'r> RefUnwindSafe for RouteBuilder<'r>

§

impl<'r> Send for RouteBuilder<'r>

§

impl<'r> Sync for RouteBuilder<'r>

§

impl<'r> Unpin for RouteBuilder<'r>

§

impl<'r> !UnwindSafe for RouteBuilder<'r>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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