pub struct Store {
pub linux: Option<String>,
pub macos: Option<String>,
pub unix: Option<String>,
pub windows: Option<String>,
pub generic: Option<String>,
pub browser: Option<String>,
}Expand description
§Store
A simple file loader that allows user to specify different paths on various operating systems with fallbacks.
Fields§
§linux: Option<String>Path used on Linux (falls back to unix, then generic).
macos: Option<String>Path used on macOS (falls back to unix, then generic).
unix: Option<String>Path used on Unix targets (falls back to generic).
windows: Option<String>Path used on Windows (falls back to generic).
generic: Option<String>Fallback path for all operating systems.
browser: Option<String>Browser local-storage key (falls back to a hex hash of generic).
Implementations§
Source§impl Store
impl Store
Sourcepub fn with_linux(&mut self, linux: &str) -> &mut Store
pub fn with_linux(&mut self, linux: &str) -> &mut Store
Sets the path used on Linux targets.
Sourcepub fn with_macos(&mut self, macos: &str) -> &mut Store
pub fn with_macos(&mut self, macos: &str) -> &mut Store
Sets the path used on macOS targets.
Sourcepub fn with_unix(&mut self, unix: &str) -> &mut Store
pub fn with_unix(&mut self, unix: &str) -> &mut Store
Sets the Unix path, used as a fallback for Linux and macOS targets.
Sourcepub fn with_windows(&mut self, windows: &str) -> &mut Store
pub fn with_windows(&mut self, windows: &str) -> &mut Store
Sets the path used on Windows targets.
Sourcepub fn with_generic(&mut self, generic: &str) -> &mut Store
pub fn with_generic(&mut self, generic: &str) -> &mut Store
Sets the generic fallback path used when no OS-specific path matches.
Sourcepub fn with_browser(&mut self, browser: &str) -> &mut Store
pub fn with_browser(&mut self, browser: &str) -> &mut Store
Sets the browser local-storage key used under the wasm32 target.
Sourcepub fn filename(&self) -> String
pub fn filename(&self) -> String
Resolves the storage path for the current operating environment, applying the OS-specific fallback chain. Panics if no suitable path has been configured.
Sourcepub async fn exists(&self) -> Result<bool>
pub async fn exists(&self) -> Result<bool>
Returns true if a file exists at the resolved file path.
Sourcepub async fn read_to_string(&self) -> Result<String>
pub async fn read_to_string(&self) -> Result<String>
Reads the entire contents of the resolved file path into a string.
Sourcepub async fn write_string(&self, data: &str) -> Result<()>
pub async fn write_string(&self, data: &str) -> Result<()>
Writes the given string to the resolved file path, overwriting any existing contents.