Skip to main content

ReQueryObservable

Struct ReQueryObservable 

Source
pub struct ReQueryObservable { /* private fields */ }
Expand description

A re-query based observable that re-executes the query on each change. This leverages the query optimizer and indexes for optimal performance. The physical plan is cached to avoid repeated optimization overhead.

Implementations§

Source§

impl ReQueryObservable

Source

pub fn new( physical_plan: PhysicalPlan, cache: Rc<RefCell<TableCache>>, initial_result: Vec<Rc<Row>>, ) -> Self

Creates a new re-query observable with a pre-compiled physical plan.

Source

pub fn result(&self) -> &[Rc<Row>]

Returns the current result.

Source

pub fn len(&self) -> usize

Returns the number of rows.

Source

pub fn is_empty(&self) -> bool

Returns true if empty.

Source

pub fn subscribe<F: Fn(&[Rc<Row>]) + 'static>(&mut self, callback: F) -> usize

Subscribes to changes.

Source

pub fn unsubscribe(&mut self, id: usize) -> bool

Unsubscribes by ID.

Source

pub fn subscription_count(&self) -> usize

Returns subscription count.

Source

pub fn on_change(&mut self, changed_ids: &HashSet<u64>)

Called when the table changes - re-executes the cached physical plan. Only notifies subscribers if the result actually changed. Skips re-query entirely if there are no subscribers.

changed_ids contains the row IDs that were modified - used to optimize comparison by only checking these rows when the result set size is unchanged.

Auto Trait Implementations§

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, 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.