#[non_exhaustive]pub struct SnapshotEntry {
pub key: Vec<u8>,
pub ttl_ms: Option<u64>,
}Expand description
One entry from Snapshot::each_prefix / Snapshot::keys_prefix.
let s = kevy_embedded::Store::open(kevy_embedded::Config::default())?;
s.set(b"u:1", b"a")?;
let entries = s.snapshot().keys_prefix(b"u:");
assert_eq!((entries[0].key.as_slice(), entries[0].ttl_ms), (&b"u:1"[..], None));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.key: Vec<u8>The key.
let s = kevy_embedded::Store::open(kevy_embedded::Config::default())?;
s.set(b"u:1", b"a")?;
s.set(b"other", b"b")?;
let keys: Vec<Vec<u8>> = s.snapshot().keys_prefix(b"u:").into_iter().map(|e| e.key).collect();
assert_eq!(keys, [b"u:1".to_vec()]);ttl_ms: Option<u64>Remaining TTL in ms at freeze time (None = no expiry).
let s = kevy_embedded::Store::open(kevy_embedded::Config::default())?;
s.set_with_ttl(b"u:1", b"a", std::time::Duration::from_secs(60))?;
let ttl = s.snapshot().keys_prefix(b"u:")[0].ttl_ms;
assert!(ttl.is_some_and(|ms| ms > 50_000 && ms <= 60_000));Trait Implementations§
Source§impl Clone for SnapshotEntry
impl Clone for SnapshotEntry
Source§impl Debug for SnapshotEntry
impl Debug for SnapshotEntry
Source§impl Default for SnapshotEntry
impl Default for SnapshotEntry
impl Eq for SnapshotEntry
Source§impl Hash for SnapshotEntry
impl Hash for SnapshotEntry
Source§impl PartialEq for SnapshotEntry
impl PartialEq for SnapshotEntry
impl StructuralPartialEq for SnapshotEntry
Auto Trait Implementations§
impl Freeze for SnapshotEntry
impl RefUnwindSafe for SnapshotEntry
impl Send for SnapshotEntry
impl Sync for SnapshotEntry
impl Unpin for SnapshotEntry
impl UnsafeUnpin for SnapshotEntry
impl UnwindSafe for SnapshotEntry
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