[−][src]Struct cjdns_hdr::DataHeader
Deserialized data header struct.
Fields
version: u8
content_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]
fn clone(&self) -> DataHeader
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for DataHeader
[src]
impl Default for DataHeader
[src]
impl Eq for DataHeader
[src]
impl PartialEq<DataHeader> for DataHeader
[src]
fn eq(&self, other: &DataHeader) -> bool
[src]
fn ne(&self, other: &DataHeader) -> bool
[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]
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>,