Struct ModInfoBuilder

Source
pub struct ModInfoBuilder<const N: usize> { /* private fields */ }
Expand description

Builder for firmware module info.

ModInfoBuilder is a helper component to flexibly compose firmware paths strings for the .modinfo section in const context.

Therefore the ModInfoBuilder provides the methods ModInfoBuilder::new_entry and ModInfoBuilder::push, where the latter is used to push path components and the former to mark the beginning of a new path string.

ModInfoBuilder is meant to be used in combination with kernel::module_firmware!.

The const generic N as well as the module_name parameter of ModInfoBuilder::new is an internal implementation detail and supplied through the above macro.

Implementations§

Source§

impl<const N: usize> ModInfoBuilder<N>

Source

pub const fn new(module_name: &'static CStr) -> Self

Create an empty builder instance.

Source

pub const fn push(self, s: &str) -> Self

Push an additional path component.

Append path components to the ModInfoBuilder instance. Paths need to be separated with ModInfoBuilder::new_entry.

§Example
use kernel::firmware::ModInfoBuilder;

let builder = builder.new_entry()
    .push(DIR)
    .push("foo.bin")
    .new_entry()
    .push(DIR)
    .push("bar.bin");
Source

pub const fn new_entry(self) -> Self

Prepare the ModInfoBuilder for the next entry.

This method acts as a separator between module firmware path entries.

Must be called before constructing a new entry with subsequent calls to ModInfoBuilder::push.

See ModInfoBuilder::push for an example.

Source

pub const fn build(self) -> [u8; N]

Build the byte array.

Source§

impl ModInfoBuilder<0>

Source

pub const fn build_length(self) -> usize

Return the length of the byte array to build.

Auto Trait Implementations§

§

impl<const N: usize> Freeze for ModInfoBuilder<N>

§

impl<const N: usize> RefUnwindSafe for ModInfoBuilder<N>

§

impl<const N: usize> Send for ModInfoBuilder<N>

§

impl<const N: usize> Sync for ModInfoBuilder<N>

§

impl<const N: usize> Unpin for ModInfoBuilder<N>

§

impl<const N: usize> UnwindSafe for ModInfoBuilder<N>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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, E> Init<T, E> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T, U> Into<U> for T
where 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, E> PinInit<T, E> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.