pub trait ModelStore {
Show 24 methods
// Required methods
fn read(&self, name: &str) -> Option<String>;
fn write(&self, name: &str, contents: &str) -> Result<(), String>;
// Provided methods
fn backend_label(&self) -> String { ... }
fn list(&self) -> Vec<String> { ... }
fn remove(&self, _name: &str) -> Result<(), String> { ... }
fn take_persistence_errors(&self) -> Vec<String> { ... }
fn browser_location(&self) -> String { ... }
fn browser_entries(&self, _extensions: &[&str]) -> Vec<BrowserEntry> { ... }
fn browser_enter(&self, _identity: &str) -> Result<(), String> { ... }
fn browser_up(&self) -> Result<(), String> { ... }
fn browser_home(&self) -> Result<(), String> { ... }
fn browser_root(&self) -> Result<(), String> { ... }
fn browser_navigate(&self, _location: &str) -> Result<(), String> { ... }
fn browser_places(&self) -> Vec<BrowserPlace> { ... }
fn browser_create_dir(&self, _name: &str) -> Result<(), String> { ... }
fn browser_write(
&self,
name: &str,
contents: &str,
) -> Result<String, String> { ... }
fn list_external_files(&self, _extensions: &[&str]) -> Vec<String> { ... }
fn read_external_file(&self, _name: &str) -> Option<Vec<u8>> { ... }
fn supports_file_interchange(&self) -> bool { ... }
fn export_file(
&self,
name: &str,
contents: &str,
) -> Result<Option<String>, String> { ... }
fn begin_import(&self) -> Result<(), String> { ... }
fn take_import(&self) -> Option<ImportedFile> { ... }
fn begin_import_filtered(
&self,
_filter: (&str, &[&str]),
) -> Result<(), String> { ... }
fn export_file_named(
&self,
_file_name: &str,
_contents: &str,
) -> Result<(), String> { ... }
}Expand description
The application’s single persistent-storage abstraction. Reserved application
keys and named model documents are read and written through the same methods.
All methods take &self; mutable backend state lives behind interior mutability.
Required Methods§
Provided Methods§
Sourcefn backend_label(&self) -> String
fn backend_label(&self) -> String
A short human label of where documents persist, for the panel header
(e.g. "filesystem: ~/.config/brep-app/models" or "browser storage").
Sourcefn list(&self) -> Vec<String>
fn list(&self) -> Vec<String>
The names of the documents currently available to Open (bare names, no extension). May be empty on a backend that cannot enumerate — then the panel falls back to the name field / import.
Sourcefn remove(&self, _name: &str) -> Result<(), String>
fn remove(&self, _name: &str) -> Result<(), String>
Delete the document name (best-effort; Ok if it is already gone).
Sourcefn take_persistence_errors(&self) -> Vec<String>
fn take_persistence_errors(&self) -> Vec<String>
Persistence failures that surfaced AFTER a write / remove already
returned Ok — the price of a WRITE-BEHIND backend (see
[mirror_store]). The app shell drains this once per frame into the toast
overlay, so a save that never reached storage is never silent: the
in-memory copy means nothing is lost mid-session, but the user has to know
it will not survive a reload. Empty on a backend that writes synchronously
(native files), which reports through write’s Err instead.
Sourcefn browser_location(&self) -> String
fn browser_location(&self) -> String
Current directory shown by the embedded explorer.
Sourcefn browser_entries(&self, _extensions: &[&str]) -> Vec<BrowserEntry>
fn browser_entries(&self, _extensions: &[&str]) -> Vec<BrowserEntry>
Directories and matching files at the current explorer location. Directories are never filtered. The default implementation presents the backend’s named model collection as a flat virtual directory.
fn browser_enter(&self, _identity: &str) -> Result<(), String>
fn browser_up(&self) -> Result<(), String>
fn browser_home(&self) -> Result<(), String>
fn browser_root(&self) -> Result<(), String>
Navigate the explorer directly to location — a value previously returned
by Self::browser_location, a BrowserPlace::location, a breadcrumb
ancestor, or a user-typed path. Err if it is not a directory this backend
can browse. Powers the breadcrumb, the sidebar, back/forward, and the
path-edit field. Default: unsupported.
Sourcefn browser_places(&self) -> Vec<BrowserPlace>
fn browser_places(&self) -> Vec<BrowserPlace>
Quick-access places for the explorer’s left sidebar (home, documents, the models root, disks…). Default: none, and the sidebar hides itself.
Sourcefn browser_create_dir(&self, _name: &str) -> Result<(), String>
fn browser_create_dir(&self, _name: &str) -> Result<(), String>
Create a child directory at the current browser location.
Sourcefn browser_write(&self, name: &str, contents: &str) -> Result<String, String>
fn browser_write(&self, name: &str, contents: &str) -> Result<String, String>
Write a filename at the current browser location and return its stable identity for subsequent plain Save operations.
Sourcefn list_external_files(&self, _extensions: &[&str]) -> Vec<String>
fn list_external_files(&self, _extensions: &[&str]) -> Vec<String>
Files available to the in-app explorer for a foreign-format import. Names retain their extension. Browser storage returns none and offers an Upload button instead; desktop enumerates its application files directory.
Sourcefn read_external_file(&self, _name: &str) -> Option<Vec<u8>>
fn read_external_file(&self, _name: &str) -> Option<Vec<u8>>
Read one entry returned by Self::list_external_files.
Sourcefn supports_file_interchange(&self) -> bool
fn supports_file_interchange(&self) -> bool
Whether this backend can exchange files with the user’s real filesystem
(browser download+upload). The panel shows the Upload affordance only when
this is true.
Sourcefn export_file(
&self,
name: &str,
contents: &str,
) -> Result<Option<String>, String>
fn export_file( &self, name: &str, contents: &str, ) -> Result<Option<String>, String>
Hand contents to the user as a file named after name (browser: a
download; native w/ dialog: a Save-As). Returns the saved document’s
identity — the full path the user chose on native (so the caller can
re-save straight to it), the bare download name on the web — or None
when the user cancelled. No-op (None) by default.
Sourcefn begin_import(&self) -> Result<(), String>
fn begin_import(&self) -> Result<(), String>
Begin importing a real file — opens the platform picker. The result is
retrieved later via Self::take_import (upload/read is async in the
browser). No-op by default.
Sourcefn take_import(&self) -> Option<ImportedFile>
fn take_import(&self) -> Option<ImportedFile>
Poll for a completed import, consuming it.
None until a begin_import finishes. Default: never any.
Sourcefn begin_import_filtered(&self, _filter: (&str, &[&str])) -> Result<(), String>
fn begin_import_filtered(&self, _filter: (&str, &[&str])) -> Result<(), String>
Begin importing a real file behind a specific picker filter (a human
label + dot-less extensions, e.g. ("STEP", &["step","stp"])). The chosen
file’s contents + its FULL name (extension preserved, so the panel can
route it) arrive via Self::take_import. Default: reuse Self::begin_import.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".