pub struct Store { /* private fields */ }Expand description
A mod’s store of a scope: values of any Schema type by key, kept in
memory and written when it’s flushed. Handles to one store share it.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(root: &Path, mod_id: &str, scope: Scope<'_>) -> Store
pub fn open(root: &Path, mod_id: &str, scope: Scope<'_>) -> Store
mod_id’s store of scope under root (the game’s folder or the world’s).
Sourcepub fn session(mod_id: &str) -> Store
pub fn session(mod_id: &str) -> Store
mod_id’s session store: kept while the game runs, never written.
Sourcepub fn get<T>(&self, key: &str) -> Option<T>where
T: Schema,
pub fn get<T>(&self, key: &str) -> Option<T>where
T: Schema,
The value at key, if there’s one of type T.
Sourcepub fn get_or_default<T>(&self, key: &str) -> T
pub fn get_or_default<T>(&self, key: &str) -> T
The value at key, or T’s default.
Sourcepub fn record(&self, key: &str) -> Option<Vec<u8>>
pub fn record(&self, key: &str) -> Option<Vec<u8>>
The record at key: bytes kept as they were given (Store::set_record),
never decoded — what a Yog Script object’s state is.
Sourcepub fn set_record(&self, key: &str, bytes: &[u8])
pub fn set_record(&self, key: &str, bytes: &[u8])
bytes at key as a record: kept and written as they are (its
owner’s codec reads them back).
Sourcepub fn remove_under(&self, prefix: &str) -> usize
pub fn remove_under(&self, prefix: &str) -> usize
Takes out every value whose key starts with prefix; how many.
Sourcepub fn update<T, R>(&self, key: &str, change: impl FnOnce(&mut T) -> R) -> R
pub fn update<T, R>(&self, key: &str, change: impl FnOnce(&mut T) -> R) -> R
The value at key changed by change (its default when there’s none); what change returns.
pub fn contains(&self, key: &str) -> bool
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more