Struct rings_node::prelude::message::MessagePayload
source · pub struct MessagePayload<T> {
pub data: T,
pub tx_id: Uuid,
pub addr: Did,
pub relay: MessageRelay,
pub verification: MessageVerification,
pub origin_verification: MessageVerification,
}
Expand description
All messages transmitted in RingsNetwork should be wrapped by MessagePayload. It additionally offer transaction ID, origin did, relay, previous hop verification, and origin verification.
Fields§
§data: T
Payload data
tx_id: Uuid
The transaction ID of payload. Remote peer should use same tx_id when response.
addr: Did
The did of payload account, usually it’s last sender.
relay: MessageRelay
Relay records the transport path of message. And can also help message sender to find the next hop.
verification: MessageVerification
This field hold a signature from a node, which is used to prove that the message was sent from that node.
origin_verification: MessageVerification
Same as verification, but the signature was from the original sender.
Implementations§
source§impl<T> MessagePayload<T>where
T: Serialize + DeserializeOwned,
impl<T> MessagePayload<T>where T: Serialize + DeserializeOwned,
sourcepub fn new(
data: T,
session_sk: &SessionSk,
origin_verification_gen: OriginVerificationGen,
relay: MessageRelay
) -> Result<MessagePayload<T>, Error>
pub fn new( data: T, session_sk: &SessionSk, origin_verification_gen: OriginVerificationGen, relay: MessageRelay ) -> Result<MessagePayload<T>, Error>
Create new instance
sourcepub fn new_send(
data: T,
session_sk: &SessionSk,
next_hop: Did,
destination: Did
) -> Result<MessagePayload<T>, Error>
pub fn new_send( data: T, session_sk: &SessionSk, next_hop: Did, destination: Did ) -> Result<MessagePayload<T>, Error>
Create new Payload for send
sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Checks whether the payload is expired.
sourcepub fn verify(&self) -> bool
pub fn verify(&self) -> bool
Verifies that the payload is not expired and that the signature is valid.
sourcepub fn origin_account_did(&self) -> Result<Did, Error>
pub fn origin_account_did(&self) -> Result<Did, Error>
Get Did from the origin verification.
sourcepub fn account_did(&self) -> Result<Did, Error>
pub fn account_did(&self) -> Result<Did, Error>
Get did from sender verification.
sourcepub fn from_bincode(data: &[u8]) -> Result<MessagePayload<T>, Error>
pub fn from_bincode(data: &[u8]) -> Result<MessagePayload<T>, Error>
Deserializes a MessagePayload
instance from the given binary data.
sourcepub fn to_bincode(&self) -> Result<Bytes, Error>
pub fn to_bincode(&self) -> Result<Bytes, Error>
Serializes the MessagePayload
instance into binary data.
Trait Implementations§
source§impl<T> Clone for MessagePayload<T>where
T: Clone,
impl<T> Clone for MessagePayload<T>where T: Clone,
source§fn clone(&self) -> MessagePayload<T>
fn clone(&self) -> MessagePayload<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Debug for MessagePayload<T>where
T: Debug,
impl<T> Debug for MessagePayload<T>where T: Debug,
source§impl<T> Decoder for MessagePayload<T>where
T: Serialize + DeserializeOwned,
impl<T> Decoder for MessagePayload<T>where T: Serialize + DeserializeOwned,
fn from_encoded(encoded: &Encoded) -> Result<MessagePayload<T>, Error>
source§impl<'de, T> Deserialize<'de> for MessagePayload<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for MessagePayload<T>where T: Deserialize<'de>,
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<MessagePayload<T>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>( __deserializer: __D ) -> Result<MessagePayload<T>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,
source§impl<T> Encoder for MessagePayload<T>where
T: Serialize + DeserializeOwned,
impl<T> Encoder for MessagePayload<T>where T: Serialize + DeserializeOwned,
source§impl<T> PartialEq<MessagePayload<T>> for MessagePayload<T>where
T: PartialEq<T>,
impl<T> PartialEq<MessagePayload<T>> for MessagePayload<T>where T: PartialEq<T>,
source§fn eq(&self, other: &MessagePayload<T>) -> bool
fn eq(&self, other: &MessagePayload<T>) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl<T> Serialize for MessagePayload<T>where
T: Serialize,
impl<T> Serialize for MessagePayload<T>where T: Serialize,
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,
source§impl<T> TryFrom<MessagePayload<T>> for VirtualNodewhere
T: Serialize + DeserializeOwned,
impl<T> TryFrom<MessagePayload<T>> for VirtualNodewhere T: Serialize + DeserializeOwned,
source§fn try_from(msg: MessagePayload<T>) -> Result<VirtualNode, Error>
fn try_from(msg: MessagePayload<T>) -> Result<VirtualNode, Error>
impl<T> Eq for MessagePayload<T>where T: Eq,
impl<T> StructuralEq for MessagePayload<T>
impl<T> StructuralPartialEq for MessagePayload<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for MessagePayload<T>where T: RefUnwindSafe,
impl<T> Send for MessagePayload<T>where T: Send,
impl<T> Sync for MessagePayload<T>where T: Sync,
impl<T> Unpin for MessagePayload<T>where T: Unpin,
impl<T> UnwindSafe for MessagePayload<T>where T: UnwindSafe,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
§impl<'a, T> AsTaggedExplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedExplicit<'a> for Twhere T: 'a,
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,
§impl<'a, T> AsTaggedImplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedImplicit<'a> for Twhere T: 'a,
§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
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.