Struct routing::messaging::MpidHeader [−][src]
pub struct MpidHeader { /* fields omitted */ }
Minimal information about a given message which can be used as a notification to the receiver.
Methods
impl MpidHeader
[src]
impl MpidHeader
pub fn new(
sender: XorName,
metadata: Vec<u8>,
secret_key: &SecretKey
) -> Result<MpidHeader, Error>
[src]
pub fn new(
sender: XorName,
metadata: Vec<u8>,
secret_key: &SecretKey
) -> Result<MpidHeader, Error>
Constructor.
Each new MpidHeader
will have a random unique identifier assigned to it, accessed via the
guid()
getter.
sender
represents the name of the original creator of the message.
metadata
is arbitrary, user-supplied information which must not exceed
MAX_HEADER_METADATA_SIZE
. It can be empty if
desired.
secret_key
will be used to generate a signature of sender
, guid
and metadata
.
An error will be returned if metadata
exceeds MAX_HEADER_METADATA_SIZE
or if
serialisation during the signing process fails.
pub fn sender(&self) -> &XorName
[src]
pub fn sender(&self) -> &XorName
The name of the original creator of the message.
pub fn guid(&self) -> &[u8; 16]
[src]
pub fn guid(&self) -> &[u8; 16]
A unique identifier generated randomly when calling new()
.
pub fn metadata(&self) -> &Vec<u8>
[src]
pub fn metadata(&self) -> &Vec<u8>
Arbitrary, user-supplied information.
pub fn signature(&self) -> &Signature
[src]
pub fn signature(&self) -> &Signature
The signature of sender
, guid
and metadata
, created when calling new()
.
pub fn name(&self) -> Result<XorName, Error>
[src]
pub fn name(&self) -> Result<XorName, Error>
The name of the header. This is a relatively expensive getter - the name is the SHA512 hash of the serialised header, so its use should be minimised.
pub fn verify(&self, public_key: &PublicKey) -> bool
[src]
pub fn verify(&self, public_key: &PublicKey) -> bool
Validates the header's signature against the provided PublicKey
.
Trait Implementations
impl PartialEq for MpidHeader
[src]
impl PartialEq for MpidHeader
fn eq(&self, other: &MpidHeader) -> bool
[src]
fn eq(&self, other: &MpidHeader) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &MpidHeader) -> bool
[src]
fn ne(&self, other: &MpidHeader) -> bool
This method tests for !=
.
impl Eq for MpidHeader
[src]
impl Eq for MpidHeader
impl Hash for MpidHeader
[src]
impl Hash for MpidHeader
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Clone for MpidHeader
[src]
impl Clone for MpidHeader
fn clone(&self) -> MpidHeader
[src]
fn clone(&self) -> MpidHeader
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for MpidHeader
[src]
impl Debug for MpidHeader
Auto Trait Implementations
impl Send for MpidHeader
impl Send for MpidHeader
impl Sync for MpidHeader
impl Sync for MpidHeader