pub struct EntityIndex<CS, PS>where
CS: ChainStore,
PS: PendingStore,{ /* private fields */ }Expand description
Manages and index entities and their traits stored in the chain and pending store of the chain layer. The index accepts mutations from the chain layer through its event stream, and manages both indices to be consistent.
The chain index is persisted on disk, while the pending store index is an in-memory index. Since the persistence in the chain is not definitive until blocks and their operations (entity mutations) are stored at a certain depth, a part of the chain is actually indexed in the in-memory index. Once they reach a certain depth, they are persisted in the chain index.
Implementations§
Source§impl<CS, PS> EntityIndex<CS, PS>where
CS: ChainStore,
PS: PendingStore,
impl<CS, PS> EntityIndex<CS, PS>where
CS: ChainStore,
PS: PendingStore,
Sourcepub fn open_or_create(
cell: FullCell,
config: EntityIndexConfig,
chain_handle: EngineHandle<CS, PS>,
clock: Clock,
) -> Result<EntityIndex<CS, PS>, Error>
pub fn open_or_create( cell: FullCell, config: EntityIndexConfig, chain_handle: EngineHandle<CS, PS>, clock: Clock, ) -> Result<EntityIndex<CS, PS>, Error>
Opens or create an entities index
pub fn handle_chain_engine_event( &mut self, event: Event, ) -> Result<(Vec<OperationId>, usize), Error>
Sourcepub fn handle_chain_engine_events<E>(
&mut self,
events: E,
) -> Result<(Vec<OperationId>, usize), Error>
pub fn handle_chain_engine_events<E>( &mut self, events: E, ) -> Result<(Vec<OperationId>, usize), Error>
Handles events coming from the chain layer. These events allow keeping the index consistent with the chain layer, up to the consistency guarantees that the layer offers. Returns operations that have been involved and the number of index operations applied.
Since the events stream is buffered, we may receive a discontinuity if the chain layer couldn’t send us an event. In that case, we re-index the pending index since we can’t guarantee that we didn’t lose an event.
pub fn maybe_index_chain_blocks(&mut self) -> Result<Vec<OperationId>, Error>
pub fn search<Q: Borrow<EntityQuery>>( &self, query: Q, ) -> Result<EntityResults, Error>
Sourcepub fn run_garbage_collector(&self) -> Result<Vec<EntityMutation>, Error>
pub fn run_garbage_collector(&self) -> Result<Vec<EntityMutation>, Error>
Calls the garbage collector to run a pass on entities that got flagged and generates deletion mutations.
Auto Trait Implementations§
impl<CS, PS> !Freeze for EntityIndex<CS, PS>
impl<CS, PS> !RefUnwindSafe for EntityIndex<CS, PS>
impl<CS, PS> Send for EntityIndex<CS, PS>
impl<CS, PS> Sync for EntityIndex<CS, PS>
impl<CS, PS> Unpin for EntityIndex<CS, PS>
impl<CS, PS> !UnwindSafe for EntityIndex<CS, PS>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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