[−][src]Struct cjdns_hdr::RouteHeader
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: u32
switch_header: SwitchHeader
is_incoming: bool
is_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]
fn clone(&self) -> RouteHeader
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for RouteHeader
[src]
impl Eq for RouteHeader
[src]
impl PartialEq<RouteHeader> for RouteHeader
[src]
fn eq(&self, other: &RouteHeader) -> bool
[src]
fn ne(&self, other: &RouteHeader) -> bool
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,