Trait UefiVariable

Source
pub trait UefiVariable: Sized {
    const SIZE: usize;

    // Required methods
    fn to_bytes(&self, out: &mut [u8]) -> usize;
    fn from_bytes(bytes: &[u8]) -> Self;
    fn default() -> Self;
}
Expand description

A value that can be stored in a UEFI variable.

This is essentially a type that can be converted into and from a vector of bytes. What byte ordering these bytes are in does not particularly matter, or how these bytes are encoded or decoded, as long as the method from UefiVariable is used instead of whatever type you have. It also has to be a set size.

Required Associated Constants§

Source

const SIZE: usize

The size of the type in bytes.

Required Methods§

Source

fn to_bytes(&self, out: &mut [u8]) -> usize

Convert Self to a buffer of bytes, then return the bytes written.

Source

fn from_bytes(bytes: &[u8]) -> Self

Convert a vector of bytes to Self.

Source

fn default() -> Self

Return 0, or an equivalent value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UefiVariable for bool

Source§

const SIZE: usize = 1usize

Source§

fn to_bytes(&self, out: &mut [u8]) -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn default() -> Self

Source§

impl UefiVariable for u8

Source§

const SIZE: usize = 1usize

Source§

fn to_bytes(&self, out: &mut [u8]) -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn default() -> Self

Source§

impl UefiVariable for u16

Source§

const SIZE: usize = 2usize

Source§

fn to_bytes(&self, out: &mut [u8]) -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn default() -> Self

Source§

impl UefiVariable for u32

Source§

const SIZE: usize = 4usize

Source§

fn to_bytes(&self, out: &mut [u8]) -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn default() -> Self

Source§

impl UefiVariable for u64

Source§

const SIZE: usize = 8usize

Source§

fn to_bytes(&self, out: &mut [u8]) -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn default() -> Self

Source§

impl UefiVariable for usize

Source§

const SIZE: Self = 8usize

Source§

fn to_bytes(&self, out: &mut [u8]) -> usize

Source§

fn from_bytes(bytes: &[u8]) -> Self

Source§

fn default() -> Self

Implementors§