Skip to main content

Property

Struct Property 

Source
pub struct Property<'a> { /* private fields */ }
Expand description

A generic device tree property containing name and raw data.

Represents a property with a name and associated data. Provides methods for accessing and interpreting the data in various formats (u32, u64, strings, etc.).

Implementations§

Source§

impl<'a> Property<'a>

Source

pub fn new(name: &'a str, data: Bytes<'a>) -> Self

Creates a new property from a name and data bytes.

Source

pub fn name(&self) -> &'a str

Returns the property name.

Source

pub fn data(&self) -> Bytes<'a>

Returns the property data.

Source

pub fn is_empty(&self) -> bool

Returns true if the property has no data.

Source

pub fn len(&self) -> usize

Returns the length of the property data in bytes.

Source

pub fn as_u32_iter(&self) -> U32Iter<'a>

Returns an iterator over u32 values in the property data.

Source

pub fn as_str_iter(&self) -> StrIter<'a>

Returns an iterator over null-terminated strings in the property data.

Used for properties like compatible that contain multiple strings.

Source

pub fn as_slice(&self) -> &[u8]

Returns the property data as a byte slice.

Source

pub fn as_u64(&self) -> Option<u64>

Returns the data as a single u64 value.

Returns None if the data is not exactly 8 bytes.

Source

pub fn as_u32(&self) -> Option<u32>

Returns the data as a single u32 value.

Returns None if the data is not exactly 4 bytes.

Source

pub fn as_str(&self) -> Option<&'a str>

Returns the data as a null-terminated string.

Source

pub fn as_address_cells(&self) -> Option<u8>

Returns the property value as #address-cells.

Only returns a value if the property name is “#address-cells”.

Source

pub fn as_size_cells(&self) -> Option<u8>

Returns the property value as #size-cells.

Only returns a value if the property name is “#size-cells”.

Source

pub fn as_interrupt_cells(&self) -> Option<u8>

Returns the property value as #interrupt-cells.

Only returns a value if the property name is “#interrupt-cells”.

Source

pub fn as_status(&self) -> Option<Status>

Returns the property value as a Status enum.

Only returns a value if the property name is “status”.

Source

pub fn as_phandle(&self) -> Option<Phandle>

Returns the property value as a phandle.

Only returns a value if the property name is “phandle”.

Source

pub fn as_device_type(&self) -> Option<&'a str>

Returns the property value as device_type string.

Only returns a value if the property name is “device_type”.

Source

pub fn as_interrupt_parent(&self) -> Option<Phandle>

Returns the property value as interrupt-parent phandle.

Only returns a value if the property name is “interrupt-parent”.

Source

pub fn as_clock_names(&self) -> Option<StrIter<'a>>

Returns the property value as clock-names string list.

Only returns a value if the property name is “clock-names”.

Source

pub fn as_compatible(&self) -> Option<StrIter<'a>>

Returns the property value as compatible string list.

Only returns a value if the property name is “compatible”.

Source

pub fn is_dma_coherent(&self) -> bool

Returns true if this is a dma-coherent property.

A dma-coherent property has no data and indicates DMA coherence.

Trait Implementations§

Source§

impl<'a> Clone for Property<'a>

Source§

fn clone(&self) -> Property<'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 Display for Property<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Property<'a>

§

impl<'a> RefUnwindSafe for Property<'a>

§

impl<'a> Send for Property<'a>

§

impl<'a> Sync for Property<'a>

§

impl<'a> Unpin for Property<'a>

§

impl<'a> UnwindSafe for Property<'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, 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.