pub struct SavedDataManager {
data_dir: Option<PathBuf>,
}Expand description
Typed saved-data storage for a loaded world.
Fields§
§data_dir: Option<PathBuf>Implementations§
Source§impl SavedDataManager
impl SavedDataManager
Sourcepub fn new(world_dir: Option<&Path>) -> Self
pub fn new(world_dir: Option<&Path>) -> Self
Creates saved-data storage rooted at world_dir/data.
None means the world is ephemeral, matching Steel’s RAM-only storage.
Sourcepub fn sync_load_wincode<T>(
&self,
name: WincodeSavedDataName,
) -> Result<Option<T>>where
for<'de> T: SchemaRead<'de, DefaultConfig, Dst = T>,
pub fn sync_load_wincode<T>(
&self,
name: WincodeSavedDataName,
) -> Result<Option<T>>where
for<'de> T: SchemaRead<'de, DefaultConfig, Dst = T>,
Loads a versioned wincode value, or returns None when it is absent or
this world has no persistent storage.
Sourcepub async fn load_or_default<T>(&self, name: SavedDataName) -> Result<T>where
T: DeserializeOwned + Default,
pub async fn load_or_default<T>(&self, name: SavedDataName) -> Result<T>where
T: DeserializeOwned + Default,
Loads saved data, or returns T::default() when the data file is absent
or this world has no persistent storage.
Sourcepub fn sync_save_wincode<T>(
&self,
name: WincodeSavedDataName,
data: &T,
) -> Result<()>where
T: SchemaWrite<DefaultConfig, Src = T>,
pub fn sync_save_wincode<T>(
&self,
name: WincodeSavedDataName,
data: &T,
) -> Result<()>where
T: SchemaWrite<DefaultConfig, Src = T>,
Saves a versioned wincode value.
Sourcepub async fn save<T>(&self, name: SavedDataName, data: &T) -> Result<()>where
T: Serialize,
pub async fn save<T>(&self, name: SavedDataName, data: &T) -> Result<()>where
T: Serialize,
Saves a typed saved-data value.
fn path_for(&self, name: SavedDataName) -> Option<PathBuf>
fn wincode_path_for(&self, name: WincodeSavedDataName) -> Option<PathBuf>
Trait Implementations§
Source§impl Clone for SavedDataManager
impl Clone for SavedDataManager
Source§fn clone(&self) -> SavedDataManager
fn clone(&self) -> SavedDataManager
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SavedDataManager
impl RefUnwindSafe for SavedDataManager
impl Send for SavedDataManager
impl Sync for SavedDataManager
impl Unpin for SavedDataManager
impl UnsafeUnpin for SavedDataManager
impl UnwindSafe for SavedDataManager
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>