Skip to main content

Store

Struct Store 

Source
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

Source

pub fn new() -> Store

Creates a new Store with all paths unset.

Source

pub fn with_linux(&mut self, linux: &str) -> &mut Store

Sets the path used on Linux targets.

Source

pub fn with_macos(&mut self, macos: &str) -> &mut Store

Sets the path used on macOS targets.

Source

pub fn with_unix(&mut self, unix: &str) -> &mut Store

Sets the Unix path, used as a fallback for Linux and macOS targets.

Source

pub fn with_windows(&mut self, windows: &str) -> &mut Store

Sets the path used on Windows targets.

Source

pub fn with_generic(&mut self, generic: &str) -> &mut Store

Sets the generic fallback path used when no OS-specific path matches.

Source

pub fn with_browser(&mut self, browser: &str) -> &mut Store

Sets the browser local-storage key used under the wasm32 target.

Source

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.

Source

pub async fn exists(&self) -> Result<bool>

Returns true if a file exists at the resolved file path.

Source

pub async fn read_to_string(&self) -> Result<String>

Reads the entire contents of the resolved file path into a string.

Source

pub async fn write_string(&self, data: &str) -> Result<()>

Writes the given string to the resolved file path, overwriting any existing contents.

Trait Implementations§

Source§

impl Default for Store

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl UnwindSafe for Store

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more