Skip to main content

Volume

Struct Volume 

pub struct Volume<'a> {
    device: &'a Device,
    id: u32,
    info: VolumeInfo,
    path: PathBuf,
}
Available on crate feature linux and (Android or Linux) only.
Expand description

Volume of a UBI device.

Fields§

§device: &'a Device§id: u32§info: VolumeInfo§path: PathBuf

Implementations§

§

impl<'a> Volume<'a>

pub fn open(device: &'a Device, id: u32) -> Result<Self, DeviceError>

Opens volume id of device.

Waits up to five seconds for the device file of the volume to appear, because the device manager creates it after the device was attached.

§Errors

Returns an error if the volume doesn’t exist, its attributes can’t be read or its device file doesn’t appear.

pub const fn id(&self) -> u32

Returns the volume ID.

pub const fn device(&self) -> &Device

Returns the UBI device of the volume.

pub const fn info(&self) -> &VolumeInfo

Returns the attributes of the volume as they were when it was opened.

pub fn device_path(&self) -> &Path

Returns the path of the character device, /dev/ubi<device>_<id>.

pub fn open_read(&self) -> Result<File, DeviceError>

Opens the volume for reading.

§Errors

Returns an error if the character device can’t be opened.

pub fn truncate(&self) -> Result<(), DeviceError>

Removes all data from the volume.

§Errors

Returns an error if the character device can’t be opened or the kernel refuses the update.

pub fn update<R: BufRead>(&self, image: R, size: u64) -> Result<(), DeviceError>

Replaces the content of the volume with the first size bytes of image.

Each chunk that image returns from BufRead::fill_buf is written as is. Wrap a File in an io::BufReader. The kernel collects the data into logical eraseblocks, so the chunks can have any size.

If the update fails, the kernel marks the volume corrupted until the next successful update.

§Errors

Returns DeviceError::VolumeTooSmall if size exceeds the reserved bytes and DeviceError::ImageTooShort if image ends early. Returns another error if reading image or writing the volume fails.

fn open_write(&self) -> Result<File, DeviceError>

Trait Implementations§

§

impl<'a> Debug for Volume<'a>

§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Volume<'a>

§

impl<'a> RefUnwindSafe for Volume<'a>

§

impl<'a> Send for Volume<'a>

§

impl<'a> Sync for Volume<'a>

§

impl<'a> Unpin for Volume<'a>

§

impl<'a> UnsafeUnpin for Volume<'a>

§

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