[][src]Struct cjdns_hdr::DataHeader

pub struct DataHeader {
    pub version: u8,
    pub content_type: ContentType,
}

Deserialized data header struct.

Fields

version: u8content_type: ContentType

Implementations

impl DataHeader[src]

pub const SIZE: usize[src]

Size of serialized DataHeader

pub const CURRENT_VERSION: u8[src]

Current version of DataHeader which is automatically set, if version is not specified during serialization.

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

Parses raw bytes into DataHeader struct.

Results in error if input bytes length isn't equal to 4, which is current size of serialized header.

DataHeader bytes have a following structure : one byte each for version and padding, two bytes for content number. Content number is a u16 number which is a numerical representation of ContentType. If content number is not defined in ContentType, default ContentType variant will be used. Note: default ContentType variant is a temporary solution.

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

Serializes DataHeader instance.

DataHeader type can be instantiated directly, without using parse method. That's why serialization can result in errors. If header version is greater than 15, then serialization fails, because version is only a 4-bit field in DataHeader. Also serialization fails if no suitable 16-bit content type code was found.

If DataHeader was instantiated with 0 version, header will be parsed with version equal to current version.

Trait Implementations

impl Clone for DataHeader[src]

impl Debug for DataHeader[src]

impl Default for DataHeader[src]

impl Eq for DataHeader[src]

impl PartialEq<DataHeader> for DataHeader[src]

impl StructuralEq for DataHeader[src]

impl StructuralPartialEq for DataHeader[src]

Auto Trait Implementations

impl RefUnwindSafe for DataHeader

impl Send for DataHeader

impl Sync for DataHeader

impl Unpin for DataHeader

impl UnwindSafe for DataHeader

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.