pub struct SnapshotManager { /* private fields */ }Expand description
Manager for handling state snapshots.
Implementations§
Source§impl SnapshotManager
impl SnapshotManager
pub fn new(config: PersistenceConfig) -> Self
Sourcepub fn snapshot_path(&self) -> PathBuf
pub fn snapshot_path(&self) -> PathBuf
Get the path to the snapshot file.
Sourcepub fn legacy_profiles_path(&self) -> PathBuf
pub fn legacy_profiles_path(&self) -> PathBuf
Get the path to the legacy profiles file (for migration).
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if persistence is enabled.
Sourcepub fn start_background_saver<F>(
self: Arc<Self>,
fetch_snapshot: F,
) -> Result<()>
pub fn start_background_saver<F>( self: Arc<Self>, fetch_snapshot: F, ) -> Result<()>
Start the background saver task with unified snapshot.
§Arguments
fetch_snapshot- A closure that returns the current WAF state snapshot.
§Returns
Ok(()) if the background saver started successfully, or an error if:
- Persistence is disabled (returns Ok with early return)
- Thread spawning failed
§Errors
Returns io::Error if the background thread cannot be spawned.
Sourcepub fn save_snapshot(snapshot: &WafSnapshot, path: &Path) -> Result<()>
pub fn save_snapshot(snapshot: &WafSnapshot, path: &Path) -> Result<()>
Save a unified snapshot to disk (Synchronous/Blocking).
Uses atomic write (temp file + rename) to prevent corruption.
Sourcepub fn load_snapshot(path: &Path) -> Result<Option<WafSnapshot>>
pub fn load_snapshot(path: &Path) -> Result<Option<WafSnapshot>>
Load a unified snapshot from disk (Synchronous/Blocking).
Sourcepub fn load_on_startup(&self) -> Result<Option<WafSnapshot>>
pub fn load_on_startup(&self) -> Result<Option<WafSnapshot>>
Load snapshot on startup if configured.
Returns the loaded snapshot or None if loading is disabled or file doesn’t exist.
Sourcepub fn save_profiles(profiles: &[EndpointProfile], path: &Path) -> Result<()>
pub fn save_profiles(profiles: &[EndpointProfile], path: &Path) -> Result<()>
Save profiles to disk (Synchronous/Blocking). @deprecated Use save_snapshot instead.
Sourcepub fn load_profiles(path: &Path) -> Result<Vec<EndpointProfile>>
pub fn load_profiles(path: &Path) -> Result<Vec<EndpointProfile>>
Load profiles from disk (Synchronous/Blocking). @deprecated Use load_snapshot instead.
Auto Trait Implementations§
impl Freeze for SnapshotManager
impl RefUnwindSafe for SnapshotManager
impl Send for SnapshotManager
impl Sync for SnapshotManager
impl Unpin for SnapshotManager
impl UnsafeUnpin for SnapshotManager
impl UnwindSafe for SnapshotManager
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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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