Trait FileEntryExt

Source
pub trait FileEntryExt<R: Read + Seek> {
    type FS: VirtualFSExt<R>;

    // Required methods
    fn file_reader(&self, fs: &mut Self::FS) -> Result<SubFile<R>, Error>;
    fn file_size(&self) -> u64;
    fn read_bytes(
        &self,
        fs: &mut Self::FS,
        size: usize,
    ) -> Result<Vec<u8>, Error>;
    fn file_name(&self) -> String;

    // Provided method
    fn file_extension(&self) -> Option<String> { ... }
}

Required Associated Types§

Required Methods§

Source

fn file_reader(&self, fs: &mut Self::FS) -> Result<SubFile<R>, Error>

Returns a virtual file reader that buffers and reads the file

This is useful for reading files from archives, which may be compressed or encrypted. And for reading large files, which may cause performance issues if the entire file is read into memory.

Source

fn file_size(&self) -> u64

Returns the size of the file in bytes.

Source

fn read_bytes(&self, fs: &mut Self::FS, size: usize) -> Result<Vec<u8>, Error>

Read the whole file into memory, and returns a Vec.

This is not recommended for large files, as it may cause performance issues.

Source

fn file_name(&self) -> String

Get the file name of the entry.

Provided Methods§

Source

fn file_extension(&self) -> Option<String>

Get the file extension, if any.

Implementors§