Skip to main content

FileSystemExt

Trait FileSystemExt 

Source
pub trait FileSystemExt: Send + Sync {
    // Provided methods
    fn usage(&self) -> FsUsage { ... }
    fn mkfifo<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _path: &'life1 Path,
        _mode: u32,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn limits(&self) -> FsLimits { ... }
}
Expand description

Optional filesystem extensions for resource tracking and special file types.

This trait provides methods that most custom filesystem implementations do not need to override. All methods have sensible defaults:

Built-in implementations (InMemoryFs, OverlayFs, MountableFs) override these to provide real statistics. Custom backends can opt in by implementing just the methods they need.

FileSystemExt is a supertrait of FileSystem, so its methods are available on any dyn FileSystem trait object.

Provided Methods§

Source

fn usage(&self) -> FsUsage

Get current filesystem usage statistics.

Returns total bytes used, file count, and directory count. Used by du and df builtins.

§Default Implementation

Returns zeros. Implementations should override for accurate stats.

Source

fn mkfifo<'life0, 'life1, 'async_trait>( &'life0 self, _path: &'life1 Path, _mode: u32, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a named pipe (FIFO) at the given path.

FIFOs are simulated as buffered files in the virtual filesystem. Reading from a FIFO returns its buffered content, writing appends to it.

§Default Implementation

Returns “not supported” error. Override in implementations that support FIFOs.

Source

fn limits(&self) -> FsLimits

Get filesystem limits.

Returns the configured limits for this filesystem. Used by df builtin to show available space.

§Default Implementation

Returns unlimited limits.

Implementors§