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>
impl<'a> Clone for PropertyValue<'a>
Source§fn clone(&self) -> PropertyValue<'a>
fn clone(&self) -> PropertyValue<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for PropertyValue<'a>
impl<'a> Debug for PropertyValue<'a>
Source§impl Default for PropertyValue<'_>
Default trait for PropertyValue
impl Default for PropertyValue<'_>
Default trait for PropertyValue
Source§impl Display for PropertyValue<'_>
Display trait for PropertyValue
impl Display for PropertyValue<'_>
Display trait for PropertyValue
Source§impl<'a> PartialEq for PropertyValue<'a>
impl<'a> PartialEq for PropertyValue<'a>
Source§impl<'a> TryFrom<&PropertyValue<'a>> for &'a [u8]
TryFrom
trait for converting PropertyValue
to &u8
impl<'a> TryFrom<&PropertyValue<'a>> for &'a [u8]
TryFrom
trait for converting PropertyValue
to &u8
Source§impl<'a> TryFrom<&PropertyValue<'a>> for &'a str
TryFrom
trait for converting PropertyValue
to &str
impl<'a> TryFrom<&PropertyValue<'a>> for &'a str
TryFrom
trait for converting PropertyValue
to &str
Source§impl<'a> TryFrom<&PropertyValue<'a>> for Vec<u32>
TryFrom
trait for converting PropertyValue
to Vec<u32>
impl<'a> TryFrom<&PropertyValue<'a>> for Vec<u32>
TryFrom
trait for converting PropertyValue
to Vec<u32>
Source§impl<'a> TryFrom<&PropertyValue<'a>> for u32
TryFrom
trait for converting PropertyValue
to u32
impl<'a> TryFrom<&PropertyValue<'a>> for u32
TryFrom
trait for converting PropertyValue
to u32
Source§impl<'a> TryFrom<&PropertyValue<'a>> for u64
TryFrom
trait for converting PropertyValue
to u64
impl<'a> TryFrom<&PropertyValue<'a>> for u64
TryFrom
trait for converting PropertyValue
to u64