Skip to main content

Reactor

Struct Reactor 

Source
pub struct Reactor<E: AbstractEntity + Filterable + Send + 'static = Entity, Ev: Clone + Send + 'static = Attested<Event>>(/* private fields */);
Expand description

A Reactor is a collection of subscriptions, which are to be notified of changes to a set of entities

Implementations§

Source§

impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Reactor<E, Ev>

Source

pub fn new() -> Self

Source

pub fn subscribe(&self) -> ReactorSubscription<E, Ev>

Create a new subscription container

Source

pub fn remove_query( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, ) -> Result<(), SubscriptionError>

Remove a predicate from a subscription

Source

pub fn add_entity_subscriptions( &self, subscription_id: ReactorSubscriptionId, entity_ids: impl IntoIterator<Item = EntityId>, )

Add entity subscriptions to a subscription

Source

pub fn remove_entity_subscriptions( &self, subscription_id: ReactorSubscriptionId, entity_ids: impl IntoIterator<Item = EntityId>, )

Remove entity subscriptions from a subscription

Source§

impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Reactor<E, Ev>

Source

pub async fn add_query_and_notify<H: PreNotifyHook>( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, collection_id: CollectionId, selection: Selection, node: &dyn TNodeErased<E>, resultset: EntityResultSet<E>, gap_fetcher: Arc<dyn GapFetcher<E>>, pre_notify_hook: H, ) -> Result<()>

Add a new predicate to a subscription (initial subscription only) Fails if query_id already exists - use update_query for updates

Add a query and send initialization notification (for local subscriptions) Collects ReactorUpdateItems and sends them pre_notify_hook is called before sending notification (e.g., to mark LiveQuery initialized)

Source

pub async fn update_query_and_notify<H: PreNotifyHook>( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, collection_id: CollectionId, selection: Selection, node: &dyn TNodeErased<E>, version: u32, pre_notify_hook: H, ) -> Result<()>

Update an existing predicate (v>0) and send notifications Does diffing against the current resultset Used by local LiveQuery updates pre_notify_hook is called before sending notification (e.g., to mark LiveQuery initialized)

Source

pub async fn notify_change<C: ChangeNotification<Entity = E, Event = Ev> + Clone>( &self, changes: Vec<C>, )

Notify subscriptions about an entity change

Source

pub fn system_reset(&self)

Notify all subscriptions that their entities have been removed but do not remove the subscriptions

Source§

impl Reactor<Entity, Attested<Event>>

Source

pub async fn upsert_query<SE, PA>( &self, subscription_id: ReactorSubscriptionId, query_id: QueryId, collection_id: CollectionId, selection: Selection, node: &Node<SE, PA>, cdata: &PA::ContextData, version: u32, ) -> Result<Vec<Entity>>
where SE: StorageEngine + Send + Sync + 'static, PA: PolicyAgent + Send + Sync + 'static,

Add or update a query for remote subscriptions (server-side) This method is idempotent - it works whether the query exists or not Constructs gap_fetcher internally using the provided Node and ContextData Returns all entities that currently match the selection (for delta generation)

Trait Implementations§

Source§

impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Clone for Reactor<E, Ev>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Debug for Reactor<E, Ev>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: AbstractEntity + Filterable + Send + 'static, Ev: Clone + Send + 'static> Default for Reactor<E, Ev>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<E, Ev> Freeze for Reactor<E, Ev>

§

impl<E = Entity, Ev = Attested<Event>> !RefUnwindSafe for Reactor<E, Ev>

§

impl<E, Ev> Send for Reactor<E, Ev>

§

impl<E, Ev> Sync for Reactor<E, Ev>

§

impl<E, Ev> Unpin for Reactor<E, Ev>

§

impl<E = Entity, Ev = Attested<Event>> !UnwindSafe for Reactor<E, Ev>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Iterable<T> for T

Source§

type Iter<'a> = Once<&'a T> where T: 'a

Source§

fn iterable(&self) -> <T as Iterable<T>>::Iter<'_>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<M> Meta for M
where M: Default,

Source§

impl<T> ObserverBounds for T