Skip to main content

ReactiveMap

Struct ReactiveMap 

Source
pub struct ReactiveMap<K, V>
where K: Clone + Eq + Hash + Send + Sync + 'static, V: Clone + Send + Sync + 'static,
{ pub node_id: NodeId, /* private fields */ }
Expand description

Reactive key-value map.

Emits Vec<(K, V)> snapshots via a Core state node on every mutation. (Vec of pairs rather than HashMap for serialization stability.)

Fields§

§node_id: NodeId

Implementations§

Source§

impl<K, V> ReactiveMap<K, V>
where K: Clone + Eq + Hash + Send + Sync + 'static, V: Clone + Send + Sync + 'static,

Source

pub fn new( core: &Core, intern: InternFn<Vec<(K, V)>>, opts: ReactiveMapOptions<K, V>, ) -> Result<Self, MapConfigError>

Create a new reactive map.

§Errors

Returns MapConfigError if both max_size (LRU) and retention are set.

Source

pub fn size(&self) -> usize

Source

pub fn has(&self, core: &Core, key: &K) -> bool

Check if key exists. Expired keys are pruned (observable side-effect). LRU touch: live key is marked as most-recently-used (no emission).

Source

pub fn get(&self, core: &Core, key: &K) -> Option<V>

Get value by key. Expired keys return None (observable side-effect). LRU touch: live key is marked as most-recently-used (no emission).

Source

pub fn set(&self, core: &Core, key: K, value: V)

Source

pub fn set_with_ttl(&self, core: &Core, key: K, value: V, ttl: Option<f64>)

Set a key with an optional per-call TTL override (seconds).

§Panics

Panics if ttl is Some with a non-positive or non-finite value.

Source

pub fn set_many(&self, core: &Core, entries: Vec<(K, V)>)

Source

pub fn set_many_with_ttl( &self, core: &Core, entries: Vec<(K, V)>, ttl: Option<f64>, )

Batch set with optional per-call TTL override (seconds).

§Panics

Panics if ttl is Some with a non-positive or non-finite value.

Source

pub fn delete(&self, core: &Core, key: &K)

Source

pub fn delete_many(&self, core: &Core, keys: &[K])

Source

pub fn clear(&self, core: &Core)

Source

pub fn prune_expired(&self, core: &Core) -> usize

Explicitly prune all expired keys. Returns the number of keys removed.

Source

pub fn to_vec(&self) -> Vec<(K, V)>

Source

pub fn mutation_log_snapshot(&self) -> Option<Vec<BaseChange<MapChange<K, V>>>>

Auto Trait Implementations§

§

impl<K, V> !Freeze for ReactiveMap<K, V>

§

impl<K, V> !RefUnwindSafe for ReactiveMap<K, V>

§

impl<K, V> Send for ReactiveMap<K, V>

§

impl<K, V> Sync for ReactiveMap<K, V>

§

impl<K, V> Unpin for ReactiveMap<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnsafeUnpin for ReactiveMap<K, V>

§

impl<K, V> !UnwindSafe for ReactiveMap<K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.