pub struct Route { /* private fields */ }
Expand description
A full route to a peer.
Implementations
sourceimpl Route
impl Route
sourcepub fn new() -> RouteBuilder<'static>
pub fn new() -> RouteBuilder<'static>
Create an empty RouteBuilder
.
Examples
// ["1#alice", "0#bob"]
let route: Route = Route::new()
.append_t(TCP, "alice")
.append("bob")
.into();
sourcepub fn parse<S>(s: S) -> Option<Route> where
S: Into<String>,
pub fn parse<S>(s: S) -> Option<Route> where
S: Into<String>,
Parse a route from a string.
Examples
if let Some(route) = Route::parse("1#alice => bob") {
// ["1#alice", "0#bob"]
route
}
sourcepub fn modify(&mut self) -> RouteBuilder<'_>
pub fn modify(&mut self) -> RouteBuilder<'_>
Create a new RouteBuilder
from the current Route
.
Examples
let mut route: Route = route!["1#alice", "bob"];
// ["1#alice", "0#bob", "0#carol"]
let route: Route = route.modify()
.append("carol")
.into();
sourcepub fn step(&mut self) -> Result<Address, Error>
pub fn step(&mut self) -> Result<Address, Error>
Return the next Address
and remove it from this route.
Examples
let mut route: Route = route!["1#alice", "bob"];
// "1#alice"
let next_hop: Address = route.step()?;
// ["0#bob"]
route
sourcepub fn next(&self) -> Result<&Address, Error>
pub fn next(&self) -> Result<&Address, Error>
Return the next Address
from this route without removing it.
Examples
let route: Route = route!["1#alice", "bob"];
// "1#alice"
let next_hop: &Address = route.next()?;
// ["1#alice", "0#bob"]
route
sourcepub fn recipient(&self) -> Address
pub fn recipient(&self) -> Address
Return the final recipient address.
Panics
This function will panic if passed an empty route.
Examples
let route: Route = route!["1#alice", "bob"];
// "0#bob"
let final_hop: Address = route.recipient();
// ["1#alice", "0#bob"]
route
TODO
For consistency we should not panic and return a
Result<&Address> instead of an Address.clone().
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Route
impl<'de> Deserialize<'de> for Route
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Route, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Route, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<RouteBuilder<'_>> for Route
impl From<RouteBuilder<'_>> for Route
sourcefn from(RouteBuilder<'_>) -> Route
fn from(RouteBuilder<'_>) -> Route
Converts to this type from the input type.
sourceimpl From<SenderAddress> for Route
impl From<SenderAddress> for Route
sourcefn from(addr: SenderAddress) -> Self
fn from(addr: SenderAddress) -> Self
Converts to this type from the input type.
sourceimpl<T> From<Vec<T, Global>> for Route where
T: Into<Address>,
impl<T> From<Vec<T, Global>> for Route where
T: Into<Address>,
Convert a A Vec
of Address
es into a Route
.
A vector of addresses can represent a valid route.
Note that this only holds if the vector index order is in the same order as the expected route.
sourceimpl Ord for Route
impl Ord for Route
sourceimpl PartialOrd<Route> for Route
impl PartialOrd<Route> for Route
sourcefn partial_cmp(&self, other: &Route) -> Option<Ordering>
fn partial_cmp(&self, other: &Route) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for Route
impl Serialize for Route
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for Route
impl StructuralEq for Route
impl StructuralPartialEq for Route
Auto Trait Implementations
impl RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnwindSafe for Route
Blanket Implementations
sourceimpl<D> AsyncTryClone for D where
D: Clone + Sync,
impl<D> AsyncTryClone for D where
D: Clone + Sync,
sourcefn async_try_clone<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
D: 'async_trait,
fn async_try_clone<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
D: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Try cloning a object and return an Err
in case of failure.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Decodable for T where
T: DeserializeOwned,
impl<T> Decodable for T where
T: DeserializeOwned,
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more