Skip to main content

FatVolumeWriteExt

Trait FatVolumeWriteExt 

Source
pub trait FatVolumeWriteExt<DATA: Read + Write + Seek> {
    // Required methods
    fn write_file<'a>(
        &'a self,
        entry: &FileEntry,
    ) -> Result<FileWriter<'a, DATA>>;
    fn truncate(&self, entry: &FileEntry, new_size: usize) -> Result<()>;
    fn set_times(
        &self,
        entry: &FileEntry,
        modified: Option<FatDateTime>,
        accessed_date: Option<u16>,
        created: Option<FatDateTime>,
    ) -> Result<()>;
}
Expand description

Extension trait for FatVolume to write files.

Required Methods§

Source

fn write_file<'a>(&'a self, entry: &FileEntry) -> Result<FileWriter<'a, DATA>>

Create a writer for a file entry.

Source

fn truncate(&self, entry: &FileEntry, new_size: usize) -> Result<()>

Truncate a file to the specified size.

If new_size is greater than or equal to the current file size, this method does nothing. Otherwise, it frees any clusters that are no longer needed and updates the directory entry with the new size.

§Errors

Returns Error::NotAFile if the entry is a directory.

Source

fn set_times( &self, entry: &FileEntry, modified: Option<FatDateTime>, accessed_date: Option<u16>, created: Option<FatDateTime>, ) -> Result<()>

Patch the timestamps on an existing entry without rewriting its data.

Each parameter is Option: None keeps the on-disk value untouched. accessed_date is the raw FAT-encoded date (FAT does not store an access time).

Useful when copying files between volumes or rebuilding a reproducible image — every other write path stamps “now” via the configured TimeProvider, which is the wrong behaviour for those workflows.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<DATA: Read + Write + Seek> FatVolumeWriteExt<DATA> for FatVolume<DATA>

Available on crate feature write only.