[][src]Struct cjdns_hdr::RouteHeader

pub struct RouteHeader {
    pub public_key: Option<CJDNSPublicKey>,
    pub ip6: Option<CJDNS_IP6>,
    pub version: u32,
    pub switch_header: SwitchHeader,
    pub is_incoming: bool,
    pub is_ctrl: bool,
}

Deserialized route header struct.

public_key and ip6 are optional. That is because route header has same structure for both control and incoming frames. So if it is a control frame, then public_key and ip6 fields should both have None value. Sometimes public_key can be None for incoming frames, but in that case ip6 will always have some value. Otherwise, header is considered invalid and won't be serialized.

Fields

public_key: Option<CJDNSPublicKey>ip6: Option<CJDNS_IP6>version: u32switch_header: SwitchHeaderis_incoming: boolis_ctrl: bool

Implementations

impl RouteHeader[src]

pub const SIZE: usize[src]

Size of serialized RouteHeader

pub fn parse(data: &[u8]) -> Result<Self, ParseError>[src]

Parses raw bytes into RouteHeader struct.

Result in error in several situations:

  • if input byte length isn't equal to RouteHeader::SIZE;
  • if parsing provided switch header bytes ended up with an error;
  • if ip6 bytes or public key bytes are invalid for ip6 initialization;
  • if ip6 derived from public key isn't equal to ip6 created from input bytes;
  • if "is_ctrl - public_key - ip6" invariant is not met;
  • if flag for message type states not control, nor incoming frame.

pub fn serialize(&self) -> Result<Vec<u8>, SerializeError>[src]

Serialized RouteHeader instance.

RouteHeader type can be instantiated directly, without using parse method. That's why serialization can result in errors. For example, if invariants stated in parse method are not met or switch header serialization failed, then route header serialization ends up with an error.

Trait Implementations

impl Clone for RouteHeader[src]

impl Debug for RouteHeader[src]

impl Eq for RouteHeader[src]

impl PartialEq<RouteHeader> for RouteHeader[src]

impl StructuralEq for RouteHeader[src]

impl StructuralPartialEq for RouteHeader[src]

Auto Trait Implementations

impl RefUnwindSafe for RouteHeader

impl Send for RouteHeader

impl Sync for RouteHeader

impl Unpin for RouteHeader

impl UnwindSafe for RouteHeader

Blanket Implementations

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.