Struct cbnf_rs::CBNFHeader

source ·
#[repr(C, packed)]
pub struct CBNFHeader { pub magic: [u8; 4], pub version: u16, pub flags: u16, pub padding: u8, pub arch: u8, pub activation: u8, pub hidden_size: u16, pub input_buckets: u8, pub output_buckets: u8, pub name_len: u8, pub name: [u8; 48], }
Expand description

The header of a CBNF file.

Fields§

§magic: [u8; 4]§version: u16§flags: u16§padding: u8§arch: u8§activation: u8§hidden_size: u16§input_buckets: u8§output_buckets: u8§name_len: u8§name: [u8; 48]

Implementations§

source§

impl CBNFHeader

source

pub fn parse(data: &[u8]) -> Option<&Self>

Parse a CBNF header from a byte slice. Returns None if the data is too short or the magic number is incorrect.

source

pub fn name(&self) -> Result<&str, Utf8Error>

Get the name of the network as a UTF-8 string. Truncates the name if the length field indicates a name longer than the 48 bytes available in the header.

Errors

Returns an error if the name is not valid UTF-8.

source

pub const fn as_bytes(&self) -> &[u8]

Get the header as a byte slice.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.