Struct Builder

Source
pub struct Builder<'a, T = (), V = BubbleSortValidator>{ /* private fields */ }
Expand description

The FDT builder.

Uses the default BubbleSortValidator validator of the quadratic time complexity to validate memory reservations. That is suitable for the small number of memory reservations (say, up until ~8). Consider implementing your own validator if you expect a larger number of memory reservations.

Implementations§

Source§

impl<'a, V> Builder<'a, (), V>

Source

pub fn new(_: BuilderConfig<'a>) -> Result<Self, Error>

Creates a new builder.

Source

pub fn build(self, boot_cpuid_phys: u32) -> Result<usize, Error>

Finishes building the FDT blob. Returns the number of bytes used.

Source§

impl<'a, T> Builder<'a, T>

Source

pub fn start_node(self, name: &str) -> Result<Builder<'a, Nest<T>>, Error>

Starts a new child node.

Source

pub fn add_string(&mut self, s: &str) -> Result<StringId, Error>

Adds a string to the string table.

Source§

impl<'a, T> Builder<'a, Nest<T>>

Source

pub fn add_null(self, name: StringId) -> Result<Self, Error>

Adds a property that does not have a value.

Source

pub fn add_u32(self, name: StringId, data: u32) -> Result<Self, Error>

Adds a u32 property.

Source

pub fn add_u64(self, name: StringId, data: u64) -> Result<Self, Error>

Adds a u64 property.

Source

pub fn add_u64_array(self, name: StringId, data: &[u64]) -> Result<Self, Error>

Adds an array of u64 properties. Useful for reg or ranges.

Source

pub fn add_u64_list( self, name: StringId, data: impl IntoIterator<Item = u64>, ) -> Result<Self, Error>

Adds a list of u64 properties. Useful for reg or ranges.

Source

pub fn add_u32_array(self, name: StringId, data: &[u32]) -> Result<Self, Error>

Adds an array of u32 properties.

Source

pub fn add_prop_array( self, name: StringId, data_array: &[&[u8]], ) -> Result<Self, Error>

Adds an array of properties. The caller must ensure these are Big Endian slices.

Source

pub fn add_str(self, name: StringId, data: &str) -> Result<Self, Error>

Adds a string property.

Source

pub fn add_str_array( self, name: StringId, strings: &[&str], ) -> Result<Self, Error>

Adds a string list property.

Source

pub fn end_node(self) -> Result<Builder<'a, T>, Error>

Ends this node.

Auto Trait Implementations§

§

impl<'a, T, V> Freeze for Builder<'a, T, V>

§

impl<'a, T, V> RefUnwindSafe for Builder<'a, T, V>
where V: RefUnwindSafe,

§

impl<'a, T, V> Send for Builder<'a, T, V>
where V: Send,

§

impl<'a, T, V> Sync for Builder<'a, T, V>
where V: Sync,

§

impl<'a, T, V> Unpin for Builder<'a, T, V>
where V: Unpin,

§

impl<'a, T = (), V = BubbleSortValidator> !UnwindSafe for Builder<'a, T, V>

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, 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, 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.