Skip to main content

SysfsDir

Struct SysfsDir 

pub(crate) struct SysfsDir {
    path: PathBuf,
    dir: OwnedFd,
}
Expand description

Open directory of a UBI device or volume in sysfs, such as /sys/class/ubi/ubi0.

Attributes are read relative to the open directory into stack buffers, so reading them doesn’t allocate.

Fields§

§path: PathBuf§dir: OwnedFd

Implementations§

§

impl SysfsDir

pub(crate) fn open_device( root: &Path, number: u32, ) -> Result<Option<Self>, DeviceError>

Opens the directory of UBI device number in the class directory root, or returns None if it doesn’t exist.

pub(crate) fn open_volume( root: &Path, device_number: u32, id: u32, ) -> Result<Option<Self>, DeviceError>

Opens the directory of volume id of UBI device device_number in the class directory root, or returns None if it doesn’t exist.

pub(crate) fn device_path(root: &Path, number: u32) -> PathBuf

Returns the path of the directory of UBI device number in root.

pub(crate) fn numbers( root: &Path, parse: impl Fn(&str) -> Option<u32>, ) -> Result<Vec<u32>, DeviceError>

Returns the numbers that parse finds in the entry names of the class directory root, in ascending order. A missing directory, as without the UBI driver, has none.

fn for_each_entry(root: &Path, each: impl FnMut(&str)) -> Result<(), Errno>

Available on Android or Linux only.

Calls each with the name of each entry in the directory root that is valid UTF-8.

pub(crate) fn parse_digits(digits: &str) -> Option<u32>

Parses a decimal number without sign, spaces or other characters.

pub(crate) fn read_text<'b>( &self, name: &str, buf: &'b mut [u8], ) -> Result<Option<&'b str>, DeviceError>

Reads the text attribute name into buf without its line break, or returns None if it doesn’t exist.

pub(crate) fn parse<T: FromStr>( &self, name: &str, ) -> Result<Option<T>, DeviceError>

Reads and parses the attribute name, or returns None if it doesn’t exist.

pub(crate) fn parse_required<T: FromStr>( &self, name: &str, ) -> Result<T, DeviceError>

Reads and parses the attribute name, which every kernel has.

pub(crate) fn parse_flag(&self, name: &str) -> Result<Option<bool>, DeviceError>

Reads the boolean attribute name, 0 or 1, or returns None if it doesn’t exist.

pub(crate) fn parse_flag_required( &self, name: &str, ) -> Result<bool, DeviceError>

Reads the boolean attribute name, which every kernel has.

pub(crate) fn parse_volume_name( &self, name: &str, ) -> Result<VolumeName, DeviceError>

Reads the volume name in the attribute name.

pub(crate) fn parse_char_device(&self) -> Result<(u32, u32), DeviceError>

Parses the dev attribute, such as 249:0.

pub(crate) fn missing(&self, name: &str) -> DeviceError

Returns the error for the attribute name that doesn’t exist.

pub(crate) fn invalid(&self, name: &str, value: &str) -> DeviceError

Returns the error for the attribute name with an invalid value.

fn open(path: PathBuf) -> Result<Option<Self>, DeviceError>

Opens the directory at path, or returns None if it doesn’t exist.

fn entry(root: &Path, entry: Arguments<'_>) -> PathBuf

Returns the path entry in root, with one allocation.

fn read_bytes<'b>( &self, name: &str, buf: &'b mut [u8], ) -> Result<Option<&'b [u8]>, DeviceError>

Reads the attribute name into buf without its line break, or returns None if it doesn’t exist.

Trait Implementations§

§

impl Debug for SysfsDir

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.