Skip to main content

Module fs

Module fs 

Source
Expand description

Virtual File System Abstraction

Provides platform-agnostic async file operations through the Vfs trait. This enables the same code to work on native platforms and in the browser.

§Platform Implementations

  • Native (NativeVfs): Uses tokio::fs with atomic write operations
  • WASM (OpfsVfs): Uses the browser’s Origin Private File System API

§Features

Requires the persistence feature.

§Example

use logicaffeine_system::fs::{Vfs, NativeVfs};
use std::sync::Arc;

let vfs: Arc<dyn Vfs + Send + Sync> = Arc::new(NativeVfs::new("/data"));

// Write and read files
vfs.write("config.json", b"{}").await?;
let data = vfs.read("config.json").await?;

// Atomic append for journaling
vfs.append("log.txt", b"entry\n").await?;

Structs§

DirEntry
A directory entry returned by list_dir.
NativeVfs
Native filesystem VFS using tokio::fs.

Enums§

VfsError
Error type for VFS operations

Traits§

Vfs
Virtual File System trait for platform-agnostic file operations.

Functions§

get_platform_vfs
Get the platform-default VFS instance.

Type Aliases§

PlatformVfs
Type alias for platform-specific VFS.
VfsResult