pub struct TensorStateSnapshot {
pub snapshots: HashMap<u64, StateSnapshot>,
pub next_id: u64,
}Expand description
Manages captures and retrieval of StateSnapshots.
Fields§
§snapshots: HashMap<u64, StateSnapshot>All retained snapshots keyed by their snapshot_id.
next_id: u64Counter used to assign the next unique id.
Implementations§
Source§impl TensorStateSnapshot
impl TensorStateSnapshot
Sourcepub fn capture(
&mut self,
node_id: &str,
fields: Vec<FieldData>,
now_secs: u64,
) -> u64
pub fn capture( &mut self, node_id: &str, fields: Vec<FieldData>, now_secs: u64, ) -> u64
Capture a snapshot for node_id containing fields at now_secs.
Returns the assigned snapshot_id.
Sourcepub fn get(&self, id: u64) -> Option<&StateSnapshot>
pub fn get(&self, id: u64) -> Option<&StateSnapshot>
Retrieve a snapshot by id.
Sourcepub fn delete(&mut self, id: u64) -> bool
pub fn delete(&mut self, id: u64) -> bool
Delete a snapshot by id. Returns true when the snapshot existed.
Sourcepub fn diff(&self, old_id: u64, new_id: u64) -> Option<SnapshotDelta>
pub fn diff(&self, old_id: u64, new_id: u64) -> Option<SnapshotDelta>
Compute the difference between snapshot old_id and snapshot new_id.
Returns None if either id is not found.
Sourcepub fn latest(&self) -> Option<&StateSnapshot>
pub fn latest(&self) -> Option<&StateSnapshot>
Return a reference to the snapshot with the highest snapshot_id.
Sourcepub fn stats(&self) -> StateSnapshotStats
pub fn stats(&self) -> StateSnapshotStats
Aggregate statistics over all retained snapshots.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TensorStateSnapshot
impl RefUnwindSafe for TensorStateSnapshot
impl Send for TensorStateSnapshot
impl Sync for TensorStateSnapshot
impl Unpin for TensorStateSnapshot
impl UnsafeUnpin for TensorStateSnapshot
impl UnwindSafe for TensorStateSnapshot
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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