[][src]Struct rust_ipv8::serialization::header::Header

pub struct Header {
    pub size: usize,
    pub version: HeaderVersion,
    pub mid_hash: Option<Vec<u8>>,
    pub message_type: Option<u64>,
}

The struct for headers.

The mid_hash and message_type are Options and larger then they need to be for easier expansion later on.

Fields

size: usize

This is a size that is hardcoded when a header is deserialized.

version: HeaderVersion

The version of the packet, 1 is dispersy and 2 is py-ipv8, could be increased to 3 for rust specific enhancements in the future

mid_hash: Option<Vec<u8>>

The hash of the master peer of a community, used to identify to which community the packets belongs

message_type: Option<u64>

Specifies the type of messsage, can be used by communities to distinguish between packets

Methods

impl Header[src]

pub fn py_ipv8_header(mid_hash: [u8; 20], message_type: u8) -> Self[src]

Helper function for creating a PyIPv8 compliant Header

Trait Implementations

impl PartialEq<Header> for Header[src]

impl Debug for Header[src]

impl Serialize for Header[src]

makes the Header serializable.

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
    S: Serializer
[src]

All types of headers need to be serialized differently

impl<'de> Deserialize<'de> for Header[src]

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
    D: Deserializer<'de>, 
[src]

deserializes a Header

Auto Trait Implementations

impl Unpin for Header

impl Sync for Header

impl Send for Header

impl RefUnwindSafe for Header

impl UnwindSafe for Header

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]