Skip to main content

ModelStore

Trait ModelStore 

Source
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§

Source

fn read(&self, name: &str) -> Option<String>

Read a stored document by name, or None if absent/unreadable.

Source

fn write(&self, name: &str, contents: &str) -> Result<(), String>

Create or overwrite the document name with contents. Err carries a message the panel surfaces in its status line.

Provided Methods§

Source

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").

Source

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.

Source

fn remove(&self, _name: &str) -> Result<(), String>

Delete the document name (best-effort; Ok if it is already gone).

Source

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.

Source

fn browser_location(&self) -> String

Current directory shown by the embedded explorer.

Source

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.

Source

fn browser_enter(&self, _identity: &str) -> Result<(), String>

Source

fn browser_up(&self) -> Result<(), String>

Source

fn browser_home(&self) -> Result<(), String>

Source

fn browser_root(&self) -> Result<(), String>

Source

fn browser_navigate(&self, _location: &str) -> 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.

Source

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.

Source

fn browser_create_dir(&self, _name: &str) -> Result<(), String>

Create a child directory at the current browser location.

Source

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.

Source

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.

Source

fn read_external_file(&self, _name: &str) -> Option<Vec<u8>>

Read one entry returned by Self::list_external_files.

Source

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.

Source

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.

Source

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.

Source

fn take_import(&self) -> Option<ImportedFile>

Poll for a completed import, consuming it. None until a begin_import finishes. Default: never any.

Source

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.

Source

fn export_file_named( &self, _file_name: &str, _contents: &str, ) -> Result<(), String>

Hand contents to the user under EXACTLY file_name (extension included, no model-extension munging) — the Save-As / download for a foreign export format. Default no-op (interchange unsupported).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§