pub type Payload = MessagePayload<Message>;
Expand description
Type alias for message payload.
Aliased Type§
struct Payload {
pub data: Message,
pub tx_id: Uuid,
pub addr: Did,
pub relay: MessageRelay,
pub verification: MessageVerification,
pub origin_verification: MessageVerification,
}
Fields§
§data: Message
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 ==
.