Struct Volume
pub struct Volume<'a> {
device: &'a Device,
id: u32,
info: VolumeInfo,
path: PathBuf,
}linux and (Android or Linux) only.Expand description
Volume of a UBI device.
Fields§
§device: &'a Device§id: u32§info: VolumeInfo§path: PathBufImplementations§
§impl<'a> Volume<'a>
impl<'a> Volume<'a>
pub fn open(device: &'a Device, id: u32) -> Result<Self, DeviceError>
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 info(&self) -> &VolumeInfo
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
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>
pub fn open_read(&self) -> Result<File, DeviceError>
pub fn truncate(&self) -> Result<(), DeviceError>
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>
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.