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<'_>
impl RouteBuilder<'_>
sourcepub fn append<A: Into<Address>>(self, addr: A) -> Self
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();
sourcepub fn append_t<A: Into<String>>(self, ty: TransportType, addr: A) -> Self
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();
sourcepub fn prepend<A: Into<Address>>(self, addr: A) -> Self
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();
sourcepub fn prepend_route(self, route: Route) -> Self
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();
sourcepub fn append_route(self, route: Route) -> Self
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();
sourcepub fn replace<A: Into<Address>>(self, addr: A) -> Self
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();
Trait Implementations§
source§impl Default for RouteBuilder<'_>
impl Default for RouteBuilder<'_>
source§impl Drop for RouteBuilder<'_>
impl Drop for RouteBuilder<'_>
source§impl From<RouteBuilder<'_>> for Route
impl From<RouteBuilder<'_>> for Route
Convert a RouteBuilder
into a Route
.
source§fn from(_: RouteBuilder<'_>) -> Self
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> 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