[][src]Struct fdt_rs::DevTreeProp

pub struct DevTreeProp<'a> { /* fields omitted */ }

A handle to a DevTreeNode's Device Tree Property

Implementations

impl<'a> DevTreeProp<'a>[src]

pub fn name(&self) -> Result<&'a Str, DevTreeError>[src]

Returns the name of the property within the device tree.

#[must_use]pub fn parent(&self) -> DevTreeNode<'a>[src]

Returns the node which this property is attached to

#[must_use]pub fn length(&self) -> usize[src]

Returns the length of the property value within the device tree

pub unsafe fn get_u32(&self, offset: usize) -> Result<u32, DevTreeError>[src]

Read a big-endian u32 from the provided offset in this device tree property's value. Convert the read value into the machines' native u32 format and return it.

If an offset which would cause this read to access memory outside of this property's value an Err containing DevTreeError::InvalidOffset will be returned.

Safety

Device Tree Properties are not strongly typed therefore any dereference could return unexpected data.

This method will access memory using core::ptr::read_unaligned, therefore an unaligned offset may be provided.

This method will not panic.

pub unsafe fn get_u64(&self, offset: usize) -> Result<u64, DevTreeError>[src]

Read a big-endian u64 from the provided offset in this device tree property's value. Convert the read value into the machines' native u64 format and return it.

If an offset which would cause this read to access memory outside of this property's value an Err containing DevTreeError::InvalidOffset will be returned.

Safety

See the safety note of DevTreeProp::get_u32

pub unsafe fn get_phandle(&self, offset: usize) -> Result<Phandle, DevTreeError>[src]

A Phandle is simply defined as a u32 value, as such this method performs the same action as [self.get_u32]

Safety

See the safety note of DevTreeProp::get_u32

pub unsafe fn get_str(&'a self) -> Result<&'a Str, DevTreeError>[src]

Returns the string property as a string if it can be parsed as one.

Safety

See the safety note of DevTreeProp::get_u32

pub unsafe fn get_str_at(
    &'a self,
    offset: usize
) -> Result<&'a Str, DevTreeError>
[src]

Returns the string at the given offset within the property.

Safety

See the safety note of DevTreeProp::get_u32

pub unsafe fn get_str_count(&self) -> Result<usize, DevTreeError>[src]

Safety

See the safety note of DevTreeProp::get_u32

pub unsafe fn get_strlist(
    &'a self,
    list: &mut [Option<&'a Str>]
) -> Result<usize, DevTreeError>
[src]

Fills the supplied slice of references with Str slices parsed from the given property. If parsing is successful, the number of parsed strings will be returned.

If an error occurred parsing one or more of the strings (E.g. they were not valid UTF-8/ASCII strings) an Err of type DevTreeError will be returned.

// Get the number of possible strings
if let Ok(count) = prop.get_str_count() {

    // Allocate a vector to store the strings
    let mut vec: Vec<Option<&Str>> = vec![None; count];

    // Read and parse the strings
    if let Ok(_) = prop.get_strlist(&mut vec) {
        let mut iter = vec.iter();

        // Print out all the strings we found in the property
        while let Some(Some(s)) = iter.next() {
            print!("{} ", s);
        }
    }
}

Safety

See the safety note of DevTreeProp::get_u32

pub unsafe fn get_raw(&self) -> &'a [u8][src]

Safety

See the safety note of DevTreeProp::get_u32

Trait Implementations

impl<'a> Clone for DevTreeProp<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for DevTreeProp<'a>

impl<'a> Send for DevTreeProp<'a>

impl<'a> Sync for DevTreeProp<'a>

impl<'a> Unpin for DevTreeProp<'a>

impl<'a> UnwindSafe for DevTreeProp<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.