pub struct PersistManager {
pub dev_file: PathBuf,
pub app_name: String,
pub organization: String,
pub auto_save: bool,
/* private fields */
}
Expand description
Resource that manages persistence.
This resource is automatically added by PersistPlugin
and handles
all saving and loading operations for persistent resources.
Fields§
§dev_file: PathBuf
Development file path (only used when not in production mode)
app_name: String
Application info for platform-specific paths
organization: String
§auto_save: bool
Whether auto-save is enabled globally
Implementations§
Source§impl PersistManager
impl PersistManager
Sourcepub fn new(organization: impl Into<String>, app_name: impl Into<String>) -> Self
pub fn new(organization: impl Into<String>, app_name: impl Into<String>) -> Self
Creates a new PersistManager.
Sourcepub fn get_resource_path(&self, type_name: &str, mode: PersistMode) -> PathBuf
pub fn get_resource_path(&self, type_name: &str, mode: PersistMode) -> PathBuf
Get the appropriate path for a resource based on its mode
Sourcepub fn save(&mut self) -> PersistResult<()>
pub fn save(&mut self) -> PersistResult<()>
Saves all persistent data to the file.
Sourcepub fn load(&mut self) -> PersistResult<()>
pub fn load(&mut self) -> PersistResult<()>
Reloads persistent data from the file.
Sourcepub fn get_persist_file(&self) -> &PersistFile
pub fn get_persist_file(&self) -> &PersistFile
Gets a reference to the underlying persist file.
Sourcepub fn get_persist_file_mut(&mut self) -> &mut PersistFile
pub fn get_persist_file_mut(&mut self) -> &mut PersistFile
Gets a mutable reference to the underlying persist file.
Sourcepub fn is_auto_save_enabled(&self, type_name: &str) -> bool
pub fn is_auto_save_enabled(&self, type_name: &str) -> bool
Checks if auto-save is enabled for a specific type.
Sourcepub fn set_type_auto_save(&mut self, type_name: String, enabled: bool)
pub fn set_type_auto_save(&mut self, type_name: String, enabled: bool)
Sets whether auto-save is enabled for a specific type.
Sourcepub fn set_type_mode(&mut self, type_name: String, mode: PersistMode)
pub fn set_type_mode(&mut self, type_name: String, mode: PersistMode)
Sets the persistence mode for a specific type.
Sourcepub fn get_type_mode(&self, type_name: &str) -> PersistMode
pub fn get_type_mode(&self, type_name: &str) -> PersistMode
Gets the persistence mode for a specific type.
Sourcepub fn set_type_embed_file(&mut self, type_name: String, file_path: String)
pub fn set_type_embed_file(&mut self, type_name: String, file_path: String)
Sets the embed file path for a specific type.
Sourcepub fn get_type_embed_file(&self, type_name: &str) -> Option<&String>
pub fn get_type_embed_file(&self, type_name: &str) -> Option<&String>
Gets the embed file path for a specific type.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PersistManager
impl RefUnwindSafe for PersistManager
impl Send for PersistManager
impl Sync for PersistManager
impl Unpin for PersistManager
impl UnwindSafe for PersistManager
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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>
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>
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 more