Struct rings_core::message::MessageRelay
source · 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 forward(&self, current: Did, next_hop: Did) -> Result<Self>
pub fn forward(&self, current: Did, next_hop: Did) -> Result<Self>
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 report(&self, current: Did) -> Result<Self>
pub fn report(&self, current: Did) -> Result<Self>
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 reset_destination(&self, destination: Did) -> Self
pub fn reset_destination(&self, destination: Did) -> Self
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 sender(&self) -> Did
👎Deprecated: please use origin_sender instead
pub fn sender(&self) -> Did
origin_sender insteadGet the origin sender of current message. Should be the first element of path.
sourcepub fn origin_sender(&self) -> Did
pub fn origin_sender(&self) -> Did
Get the origin sender of current message. Should be the first element of path.
Trait Implementations§
source§impl Clone for MessageRelay
impl Clone for MessageRelay
source§fn clone(&self) -> MessageRelay
fn clone(&self) -> MessageRelay
1.0.0 · 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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for MessageRelay
impl PartialEq for MessageRelay
source§fn eq(&self, other: &MessageRelay) -> bool
fn eq(&self, other: &MessageRelay) -> bool
self and other values to be equal, and is used
by ==.source§impl Serialize for MessageRelay
impl Serialize for MessageRelay
impl Eq for MessageRelay
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 UnwindSafe for MessageRelay
Blanket Implementations§
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 more