Skip to main content

ReactiveIndex

Struct ReactiveIndex 

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

Reactive sorted index with primary key lookup and secondary sort order.

Emits Vec<IndexRow<K, V>> snapshots via a Core state node on every mutation.

Fields§

§node_id: NodeId

Implementations§

Source§

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

Source

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

Source

pub fn size(&self) -> usize

Source

pub fn has(&self, primary: &K) -> bool

Source

pub fn get(&self, primary: &K) -> Option<V>

Source

pub fn upsert( &self, core: &Core, primary: K, secondary: String, value: V, ) -> bool

Insert or update a row. Returns true if inserted (new primary key), false if updated or skipped by equals idempotency.

Source

pub fn upsert_with( &self, core: &Core, primary: K, secondary: String, value: V, opts: &UpsertOptions<K, V>, ) -> bool

Insert or update a row with per-call options.

If opts.equals (or the factory-level equals) returns true for the existing row vs the proposed row, the upsert is a no-op (no emission).

Source

pub fn upsert_many(&self, core: &Core, rows: Vec<(K, String, V)>)

Batch upsert. Rows matching the factory-level equals are skipped. If ALL rows are skipped, no emission occurs.

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn range_by_primary(&self, start: &K, end: &K) -> Vec<V>
where K: Ord,

Values of all rows whose primary key sorts within [start, end) (inclusive start, exclusive end), in ascending primary-key order (D205). start >= end or no matches → empty vec. The K: Ord bound is method-scoped so it does not constrain ReactiveIndex<K, V> itself.

Source

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<K, V> !UnwindSafe for ReactiveIndex<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.