PropertyValue

Enum PropertyValue 

Source
pub enum PropertyValue<'a> {
    Empty,
    String(&'a str),
    StringList(Vec<&'a str>),
    U32(u32),
    U32Array(&'a [u8]),
    U64(u64),
    U64Array(&'a [u8]),
    Bytes(&'a [u8]),
}
Expand description

Strongly-typed property values in device trees.

Device tree properties can contain various data types. Provides type-safe access to property values with zero-copy parsing from the original DTB buffer. Use the ergonomic TryFrom traits for type conversions.

§Examples

match value {
    PropertyValue::String(s) => println!("String: {}", s),
    PropertyValue::U32(n) => println!("Number: {}", n),
    PropertyValue::U32Array(_) => {
        // Use TryFrom for ergonomic access
        let numbers: Vec<u32> = Vec::<u32>::try_from(value)?;
        println!("Array: {:?}", numbers);
    }
    PropertyValue::Bytes(data) => println!("Raw data: {} bytes", data.len()),
    _ => {}
}

Variants§

§

Empty

Empty property (property exists but has no value).

§

String(&'a str)

Null-terminated string value.

Common for device names, compatible strings, and text properties.

§

StringList(Vec<&'a str>)

Multiple null-terminated strings in sequence.

Used for properties like compatible that list multiple values.

§

U32(u32)

32-bit unsigned integer value.

Common for simple numeric properties like counts and flags.

§

U32Array(&'a [u8])

Array of 32-bit unsigned integers (stored as raw bytes for zero-copy).

Use Vec::<u32>::try_from() for ergonomic access. Common for register addresses, interrupt numbers, and GPIO specifications.

§

U64(u64)

64-bit unsigned integer value.

Used for large addresses and sizes in 64-bit systems.

§

U64Array(&'a [u8])

Array of 64-bit unsigned integers (stored as raw bytes for zero-copy).

Use Vec::<u64>::try_from() for ergonomic access.

§

Bytes(&'a [u8])

Raw byte array for binary data.

Used for MAC addresses, binary blobs, and vendor-specific data.

Trait Implementations§

Source§

impl<'a> Clone for PropertyValue<'a>

Source§

fn clone(&self) -> PropertyValue<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for PropertyValue<'a>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PropertyValue<'_>

Default trait for PropertyValue

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for PropertyValue<'_>

Display trait for PropertyValue

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for PropertyValue<'a>

Source§

fn eq(&self, other: &PropertyValue<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> TryFrom<&PropertyValue<'a>> for &'a [u8]

TryFrom trait for converting PropertyValue to &u8

Source§

type Error = DtbError

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

fn try_from(value: &PropertyValue<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&PropertyValue<'a>> for &'a str

TryFrom trait for converting PropertyValue to &str

Source§

type Error = DtbError

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

fn try_from(value: &PropertyValue<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&PropertyValue<'a>> for Vec<u32>

TryFrom trait for converting PropertyValue to Vec<u32>

Source§

type Error = DtbError

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

fn try_from(value: &PropertyValue<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&PropertyValue<'a>> for u32

TryFrom trait for converting PropertyValue to u32

Source§

type Error = DtbError

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

fn try_from(value: &PropertyValue<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&PropertyValue<'a>> for u64

TryFrom trait for converting PropertyValue to u64

Source§

type Error = DtbError

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

fn try_from(value: &PropertyValue<'a>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> StructuralPartialEq for PropertyValue<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for PropertyValue<'a>

§

impl<'a> RefUnwindSafe for PropertyValue<'a>

§

impl<'a> Send for PropertyValue<'a>

§

impl<'a> Sync for PropertyValue<'a>

§

impl<'a> Unpin for PropertyValue<'a>

§

impl<'a> UnwindSafe for PropertyValue<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.