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,

source

pub fn new( data: T, session_sk: &SessionSk, origin_verification_gen: OriginVerificationGen, relay: MessageRelay ) -> Result<MessagePayload<T>, Error>

Create new instance

source

pub fn new_send( data: T, session_sk: &SessionSk, next_hop: Did, destination: Did ) -> Result<MessagePayload<T>, Error>

Create new Payload for send

source

pub fn is_expired(&self) -> bool

Checks whether the payload is expired.

source

pub fn verify(&self) -> bool

Verifies that the payload is not expired and that the signature is valid.

source

pub fn origin_account_did(&self) -> Result<Did, Error>

Get Did from the origin verification.

source

pub fn account_did(&self) -> Result<Did, Error>

Get did from sender verification.

source

pub fn from_bincode(data: &[u8]) -> Result<MessagePayload<T>, Error>

Deserializes a MessagePayload instance from the given binary data.

source

pub fn to_bincode(&self) -> Result<Bytes, Error>

Serializes the MessagePayload instance into binary data.

source

pub fn sender(&self) -> Result<Did, Error>

Did of Sender

source

pub fn origin(&self) -> Result<Did, Error>

Did of Origin

Trait Implementations§

source§

impl<T> Clone for MessagePayload<T>where T: Clone,

source§

fn clone(&self) -> MessagePayload<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for MessagePayload<T>where T: Debug,

source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> Decoder for MessagePayload<T>where T: Serialize + DeserializeOwned,

source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> Encoder for MessagePayload<T>where T: Serialize + DeserializeOwned,

source§

impl<T> PartialEq<MessagePayload<T>> for MessagePayload<T>where T: PartialEq<T>,

source§

fn eq(&self, other: &MessagePayload<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> Eq for MessagePayload<T>where T: Eq,

source§

impl<T> StructuralEq for MessagePayload<T>

source§

impl<T> StructuralPartialEq for MessagePayload<T>