Skip to main content

ProfileStore

Struct ProfileStore 

Source
pub struct ProfileStore { /* private fields */ }
Expand description

The Storage of the profile in use: each key is read and written as that profile’s (ProfileId::key), and list lists only its keys, without their prefix. What stays with the computer (the list of profiles, whatever the game keeps per computer) goes through computer.

Implementations§

Source§

impl ProfileStore

Source

pub fn new(computer: Box<dyn Storage>, profile: ProfileId) -> Self

The storage of profile in computer.

Source

pub fn profile(&self) -> ProfileId

The profile whose keys this reads and writes.

Source

pub fn computer(&self) -> &dyn Storage

The computer’s own storage, for what no profile holds.

Source

pub fn computer_mut(&mut self) -> &mut dyn Storage

computer, to write.

Source

pub fn into_computer(self) -> Box<dyn Storage>

The computer’s storage, for the next launch.

Trait Implementations§

Source§

impl Debug for ProfileStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ProfileStore

An empty MemoryStorage, as the first profile’s.

Source§

fn default() -> Self

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

impl Storage for ProfileStore

Source§

fn read(&self, key: &str) -> Result<Option<String>, StorageError>

The value stored at key, or None if nothing has been written there (or it was deleted).
Source§

fn write(&mut self, key: &str, value: &str) -> Result<(), StorageError>

Stores value at key, replacing whatever was there.
Source§

fn delete(&mut self, key: &str) -> Result<(), StorageError>

Removes key. Not an error if it didn’t exist.
Source§

fn list(&self) -> Result<Vec<String>, StorageError>

Every key currently stored, in no particular order.

Auto Trait Implementations§

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