Skip to main content

Module writable_folder

Module writable_folder 

Source
Expand description

Cross-platform access to a user-chosen writable folder.

This is the write-side complement of crate::file_picker: where the picker reads files the user selects, this lets an app persist its own data into a folder the user grants — a local directory on desktop, a Storage Access Framework tree on Android — and read it back on later runs. The motivating use is cross-device sync, where each device writes a small document into a shared folder (e.g. on a Tailnet/WebDAV mount) and reads its peers’.

Two halves, mirroring the picker:

  • pick_writable_folder — asynchronous, UI-thread. Presents the system folder picker with a persistent read/write grant and resolves to an opaque, durable handle string the app stores.
  • open_writable_folder — synchronous and thread-safe. Rebuilds a WritableFolderStore from a stored handle. Its I/O methods are synchronous and Send + Sync, so a background worker can call them without touching the UI thread.

Read-only or unreachable folders surface as FolderError::ReadOnly / FolderError::Io so callers can degrade gracefully. iOS (security-scoped bookmarks) and the web are not supported yet and return FolderError::Unsupported.

Enums§

FolderError
Errors produced by writable-folder I/O.

Traits§

WritableFolderPicker
Presents the system “pick a writable folder” UI. Platform-provided (Android); desktop/web use the built-in backend.
WritableFolderStore
Synchronous, thread-safe access to a user-chosen writable folder.

Functions§

clear_platform_writable_folder_picker
Removes any registered platform picker (tests/teardown).
open_writable_folder
Reopens a writable folder from a stored handle. Synchronous and callable from any thread; returns None only when writable folders are unsupported here.
pick_writable_folder
Presents the writable-folder picker and resolves to a durable handle (or None if cancelled). Async; drive it from LaunchedEffectAsync.
set_platform_writable_folder_picker
Registers the platform writable-folder picker (Android SAF). The cranpose crate’s backend calls this during startup; once registered it takes precedence over the built-in desktop picker.
set_writable_folder_store_factory
Registers the platform store factory (Android). Called once at startup. No-op if already set.

Type Aliases§

WritableFolderPickerRef
Shared handle to a WritableFolderPicker.
WritableFolderStoreRef
Shared handle to a WritableFolderStore.