Struct routing::messaging::MpidMessage [] [src]

pub struct MpidMessage {
    // some fields omitted
}

A full message including header and body which can be sent to or retrieved from the network.

Methods

impl MpidMessage
[src]

fn new(sender: XorName, metadata: Vec<u8>, recipient: XorName, body: Vec<u8>, secret_key: &SecretKey) -> Result<MpidMessageError>

Constructor.

sender and metadata are used to construct an MpidHeader member, accessed via the header() getter. For details on these arguments, see MpidHeader::new().

recipient represents the name of the intended receiver of the message.

body is arbitrary, user-supplied data representing the main portion of the message. It must not exceed MAX_BODY_SIZE. It can be empty if desired.

An error will be returned if body exceeds MAX_BODY_SIZE, if MpidHeader::new() fails or if serialisation during the signing process fails.

fn header(&self) -> &MpidHeader

Getter for MpidHeader member, created when calling new().

fn recipient(&self) -> &XorName

The name of the intended receiver of the message.

fn body(&self) -> &Vec<u8>

Arbitrary, user-supplied data representing the main portion of the message.

fn name(&self) -> Result<XorNameError>

The name of the message, equivalent to the MpidHeader::name(). As per that getter, this is relatively expensive, so its use should be minimised.

fn verify(&self, public_key: &PublicKey) -> bool

Validates the message and header signatures against the provided PublicKey.

Trait Implementations

impl Encodable for MpidMessage
[src]

fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>

impl Decodable for MpidMessage
[src]

fn decode<__D: Decoder>(__arg_0: &mut __D) -> Result<MpidMessage, __D::Error>

impl Clone for MpidMessage
[src]

fn clone(&self) -> MpidMessage

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Hash for MpidMessage
[src]

fn hash<__H: Hasher>(&self, __arg_0: &mut __H)

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

impl Eq for MpidMessage
[src]

impl PartialEq for MpidMessage
[src]

fn eq(&self, __arg_0: &MpidMessage) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &MpidMessage) -> bool

This method tests for !=.

impl Debug for MpidMessage
[src]

fn fmt(&self, formatter: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.