Skip to main content

Device

Struct Device 

pub struct Device {
    file: File,
    geometry: Geometry,
}
Expand description

Open MTD character device.

Access its blocks through Flash.

Fields§

§file: File§geometry: Geometry

Implementations§

§

impl Device

pub fn open(path: &Path) -> Result<Self, DeviceError>

Opens the MTD character device at path for reading and writing.

§Errors

Returns an error if the device can’t be opened or reports a geometry this crate can’t handle.

pub fn open_read_only(path: &Path) -> Result<Self, DeviceError>

Opens the MTD character device at path for reading only.

§Errors

Returns an error if the device can’t be opened or reports a geometry this crate can’t handle.

fn open_with(path: &Path, write: bool) -> Result<Self, DeviceError>

Trait Implementations§

§

impl Debug for Device

§

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

Formats the value using the given formatter. Read more
§

impl Flash for Device

§

fn erase(&self, block: u32) -> Result<(), DeviceError>

Erases block. Read more
§

fn geometry(&self) -> Geometry

Returns the geometry of the flash.
§

fn is_bad(&self, block: u32) -> Result<bool, DeviceError>

Returns whether block has a bad block marker. Read more
§

fn mark_bad(&self, block: u32) -> Result<(), DeviceError>

Writes a bad block marker to block. Read more
§

fn read( &self, block: u32, offset: u32, buf: &mut [u8], ) -> Result<(), DeviceError>

Reads buf.len() bytes from block, starting offset bytes into it. Read more
§

fn read_unchecked( &self, block: u32, offset: u32, buf: &mut [u8], ) -> Result<(), DeviceError>

Reads like Flash::read, but doesn’t check for ECC errors. Read more
§

fn write(&self, block: u32, data: &[u8]) -> Result<(), DeviceError>

Writes data from the start of block. Read more
§

impl Sealed for Device

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
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 = !

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.