pub struct SnapshotManager { /* private fields */ }Expand description
Manages entity snapshots for fast state recovery
Implementations§
Source§impl SnapshotManager
impl SnapshotManager
Sourcepub fn new(config: SnapshotConfig) -> Self
pub fn new(config: SnapshotConfig) -> Self
Create a new snapshot manager
Sourcepub fn create_snapshot(
&self,
entity_id: String,
state: Value,
as_of: DateTime<Utc>,
event_count: usize,
snapshot_type: SnapshotType,
) -> Result<Snapshot>
pub fn create_snapshot( &self, entity_id: String, state: Value, as_of: DateTime<Utc>, event_count: usize, snapshot_type: SnapshotType, ) -> Result<Snapshot>
Create a new snapshot for an entity
Sourcepub fn get_latest_snapshot(&self, entity_id: &str) -> Option<Snapshot>
pub fn get_latest_snapshot(&self, entity_id: &str) -> Option<Snapshot>
Get the most recent snapshot for an entity
Sourcepub fn get_snapshot_as_of(
&self,
entity_id: &str,
as_of: DateTime<Utc>,
) -> Option<Snapshot>
pub fn get_snapshot_as_of( &self, entity_id: &str, as_of: DateTime<Utc>, ) -> Option<Snapshot>
Get the best snapshot to use for reconstruction as of a specific time
Sourcepub fn get_all_snapshots(&self, entity_id: &str) -> Vec<Snapshot>
pub fn get_all_snapshots(&self, entity_id: &str) -> Vec<Snapshot>
Get all snapshots for an entity
Sourcepub fn should_create_snapshot(
&self,
entity_id: &str,
current_event_count: usize,
last_event_time: DateTime<Utc>,
) -> bool
pub fn should_create_snapshot( &self, entity_id: &str, current_event_count: usize, last_event_time: DateTime<Utc>, ) -> bool
Check if a new snapshot should be created for an entity
Sourcepub fn delete_snapshots(&self, entity_id: &str) -> Result<usize>
pub fn delete_snapshots(&self, entity_id: &str) -> Result<usize>
Delete all snapshots for an entity
Sourcepub fn delete_snapshot(
&self,
entity_id: &str,
snapshot_id: Uuid,
) -> Result<bool>
pub fn delete_snapshot( &self, entity_id: &str, snapshot_id: Uuid, ) -> Result<bool>
Delete a specific snapshot by ID
Sourcepub fn stats(&self) -> SnapshotStats
pub fn stats(&self) -> SnapshotStats
Get snapshot statistics
Sourcepub fn config(&self) -> &SnapshotConfig
pub fn config(&self) -> &SnapshotConfig
Get configuration
Sourcepub fn list_entities(&self) -> Vec<String>
pub fn list_entities(&self) -> Vec<String>
List all entities with snapshots
Auto Trait Implementations§
impl Freeze for SnapshotManager
impl !RefUnwindSafe for SnapshotManager
impl Send for SnapshotManager
impl Sync for SnapshotManager
impl Unpin 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
Mutably borrows from an owned value. Read more
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>
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 more