pub struct MessageRelay {
pub path: Vec<Did>,
pub next_hop: Did,
pub destination: Did,
}Expand description
MessageRelay guide message passing on rings network by relay.
All messages should be sent with MessageRelay.
By calling relay method in correct place, MessageRelay help to do things:
- Record the whole transport path for inspection.
- Get the sender of a message.
Fields§
§path: Vec<Did>A push only stack. Record routes when handling messages.
next_hop: DidThe next node to handle the message. A message handler will pick transport by this field.
destination: DidThe destination of the message.
It may help the handler to find out next_hop in some situations.
Implementations§
Source§impl MessageRelay
impl MessageRelay
Sourcepub fn new(path: Vec<Did>, next_hop: Did, destination: Did) -> MessageRelay
pub fn new(path: Vec<Did>, next_hop: Did, destination: Did) -> MessageRelay
Create a new MessageRelay.
Sourcepub fn forward(
&self,
current: Did,
next_hop: Did,
) -> Result<MessageRelay, Error>
pub fn forward( &self, current: Did, next_hop: Did, ) -> Result<MessageRelay, Error>
Validate relay, then create a new MessageRelay that have current did in the end of path.
The new relay will use next_hop as next_hop and self.destination as destination.
Sourcepub fn path_report(&self, current: Did) -> Result<MessageRelay, Error>
pub fn path_report(&self, current: Did) -> Result<MessageRelay, Error>
Validate relay, then create a new MessageRelay that used to report the message.
The new relay will use self.path[self.path.len() - 1] as next_hop and self.sender() as destination.
In the new relay, the path will be cleared and only have current did.
Sourcepub fn routed_report(
&self,
current: Did,
destination: Did,
next_hop: Did,
) -> Result<MessageRelay, Error>
pub fn routed_report( &self, current: Did, destination: Did, next_hop: Did, ) -> Result<MessageRelay, Error>
Validate relay, then create a fresh Chord-routed report relay.
The caller must infer next_hop from the destination before invoking
this constructor.
Sourcepub fn report(
&self,
current: Did,
policy: ReportReturnPolicy,
routed_next_hop: Option<Did>,
) -> Result<MessageRelay, Error>
pub fn report( &self, current: Did, policy: ReportReturnPolicy, routed_next_hop: Option<Did>, ) -> Result<MessageRelay, Error>
Create a report relay with an explicit return policy.
Sourcepub fn reset_destination(&self, destination: Did) -> MessageRelay
pub fn reset_destination(&self, destination: Did) -> MessageRelay
Sometime the sender may not know the destination of the message. They just use next_hop as destination. The next node can find a new next_hop, and may use this function to set that next_hop as destination again.
Sourcepub fn validate(&self, current: Did) -> Result<(), Error>
pub fn validate(&self, current: Did) -> Result<(), Error>
Check if path and destination is valid.
Sourcepub fn sender(&self) -> Did
👎Deprecated: please use origin_sender instead
pub fn sender(&self) -> Did
please use origin_sender instead
Get the origin sender of current message. Should be the first element of path.
Sourcepub fn try_origin_sender(&self) -> Result<Did, Error>
pub fn try_origin_sender(&self) -> Result<Did, Error>
Get the origin sender of current message as a checked relay-path boundary.
Sourcepub fn origin_sender(&self) -> Did
pub fn origin_sender(&self) -> Did
Get the origin sender of current message.
The origin should be the first element of path. Empty relay paths keep
the legacy fallback to destination; callers that must distinguish an
invalid relay boundary from a real origin should use
try_origin_sender.
Trait Implementations§
Source§impl Clone for MessageRelay
impl Clone for MessageRelay
Source§fn clone(&self) -> MessageRelay
fn clone(&self) -> MessageRelay
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageRelay
impl Debug for MessageRelay
Source§impl<'de> Deserialize<'de> for MessageRelay
impl<'de> Deserialize<'de> for MessageRelay
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MessageRelay, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MessageRelay, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for MessageRelay
Source§impl PartialEq for MessageRelay
impl PartialEq for MessageRelay
Source§impl Serialize for MessageRelay
impl Serialize for MessageRelay
Source§fn 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,
impl StructuralPartialEq for MessageRelay
Auto Trait Implementations§
impl Freeze for MessageRelay
impl RefUnwindSafe for MessageRelay
impl Send for MessageRelay
impl Sync for MessageRelay
impl Unpin for MessageRelay
impl UnsafeUnpin for MessageRelay
impl UnwindSafe for MessageRelay
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T> MaybeSend for T
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.