Struct smbioslib::Header[][src]

pub struct Header(_);

SMBIOS Header

The header part/section of a structure

Implementations

impl Header[src]

pub const SIZE: usize[src]

Total size of a Header (4)

A header has a byte for the struct_type at offset 0, a byte for the length at offset 1, and a word for the handle at offset 2 for a total of 4 bytes.

pub const STRUCT_TYPE_OFFSET: usize[src]

StructType offset (offset 0 and 1 bytes)

pub const LENGTH_OFFSET: usize[src]

Length offset (offset 1 and 1 bytes)

pub const HANDLE_OFFSET: usize[src]

Handle offset (offset 2 and 2 bytes)

pub fn new(data: [u8; 4]) -> Self[src]

Creates a new Header struct

pub fn struct_type(&self) -> u8[src]

The type of SMBIOS structure

pub fn length(&self) -> u8[src]

The length of the structure not including the strings part/section

pub fn handle(&self) -> Handle[src]

The handle of this structure instance

pub fn iter(&self) -> Iter<'_, u8>[src]

Byte iterator of the header

Methods from Deref<Target = [u8; 4]>

pub fn as_slice(&self) -> &[T]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

🔬 This is a nightly-only experimental API. (array_methods)

Returns a slice containing the entire array. Equivalent to &s[..].

pub fn each_ref(&self) -> [&T; N][src]

🔬 This is a nightly-only experimental API. (array_methods)

Borrows each element and returns an array of references with the same size as self.

Example

#![feature(array_methods)]

let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);

This method is particularly useful if combined with other methods, like map. This way, you can avoid moving the original array if its elements are not Copy.

#![feature(array_methods, array_map)]

let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);

// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);

Trait Implementations

impl Debug for Header[src]

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Deref for Header[src]

type Target = [u8; 4]

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl From<[u8; 4]> for Header[src]

fn from(data: [u8; 4]) -> Self[src]

Performs the conversion.

impl Serialize for Header[src]

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

impl RefUnwindSafe for Header

impl Send for Header

impl Sync for Header

impl Unpin for Header

impl UnwindSafe for Header

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T

Notable traits for &'_ mut R

impl<'_, R> Read for &'_ mut R where
    R: Read + ?Sized
impl<'_, W> Write for &'_ mut W where
    W: Write + ?Sized
[src]

Immutably borrows from an owned value. Read more

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

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

Notable traits for &'_ mut R

impl<'_, R> Read for &'_ mut R where
    R: Read + ?Sized
impl<'_, W> Write for &'_ mut W where
    W: Write + ?Sized
[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

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

Performs the conversion.

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.

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

Performs the conversion.