Expand description
day-part-filesystem: app-local file storage with one API on every target (docs/fs.md). No UI; any
Rust code can depend on this crate and call read/write()/list/remove.
day_part_filesystem::write("notes/today.txt", b"rain later")?;
let bytes = day_part_filesystem::read("notes/today.txt")?;Files live under a private per-app root: a real directory on the native targets (the mobile
hosts pass it as DAY_DATA_DIR; desktops use the platform’s data-dir convention), and the
browser’s Origin Private File System on web-dom. Paths are relative and sandboxed (an
absolute path or a ./.. segment is FsError::BadPath), and write creates missing
parent directories.
Threading. The blocking calls run where you call them, so keep them off the UI thread
for large files; on web they return FsError::Unsupported (one thread, no blocking waits:
the day-part-http rule). The *_async twins and futures work on every target; completions
arrive on an unspecified background thread natively and on the sole browser thread on web,
so deliver into UI state with a Setter or await under day::task (docs/async.md).
Structs§
- FsFuture
- An in-flight storage operation;
.awaitresolves it.
Enums§
- FsError
- A storage failure. The web tier collapses provider detail into
FsError::Io, like day-part-http’s error taxonomy does for the browser.
Functions§
- data_
dir - The app’s data directory on native targets,
day_process::storage::data_dir:DAY_DATA_DIRwhen a host or a test sets it, else the platform’s folder for this app (Application Support on Apple platforms,%LOCALAPPDATA%on Windows,$XDG_DATA_HOMEon Linux, each followed by the app id). This part’s own files live in itsday-fs/subdirectory; other parts that keep files, such as a download manager’s journal, take a sibling. The web has no such directory. - list
- List the entry names directly under
dir(""= the storage root), sorted. Directories are listed with a trailing/. Blocking;FsError::Unsupportedon web. - list_
async listwithout blocking.- list_
future list_asyncas aFuture.- open_
read - Open an app-local file for read-only, seekable access on native targets.
Uses the same relative path rules and storage root as
read. This lets archive readers fetch individual entries without loading the whole file. Opening and reading are blocking; use a worker when called from UI code. Not available on web, whose storage API currently supplies owned buffers throughread_future. - platform_
data_ dir - The platform’s shared application-data directory, the one other applications keep their own
folders in:
~/Library/Application Supporton Apple, the roaming%APPDATA%on Windows (where Electron and Tauri apps keep theirs),$XDG_DATA_HOME(else~/.local/share) elsewhere. For an app that opens a store another application keeps there, the way a CLI companion of a desktop app reads that app’s database.DAY_DATA_DIRdoes not redirect it: a host that names the app’s own directory says nothing about where other applications keep theirs. - read
- Read a file’s bytes. Blocking;
FsError::Unsupportedon web, so useread_asyncorread_futurethere (they work everywhere). - read_
async readwithout blocking;on_doneruns on an unspecified background thread (the sole browser thread on web).- read_
future read_asyncas aFuture.- remove
- Remove a file (or an empty directory). Blocking;
FsError::Unsupportedon web. Removing a missing path isFsError::NotFound. - remove_
async removewithout blocking.- remove_
future remove_asyncas aFuture.- write
- Write
bytestopath(create or truncate), creating missing parent directories. Blocking;FsError::Unsupportedon web. - write_
async write()without blocking.- write_
future write_asyncas aFuture.