pub struct MemoryEngine { /* private fields */ }Expand description
In-memory engine used to prove the storage boundary.
§Examples
use thingd::{MemoryEngine, ObjectStore, EventLog, MemoryObject, MemoryEvent};
let mut engine = MemoryEngine::new();
engine.put_object(MemoryObject::new("users", "alice", r#"{"name":"Alice"}"#)).unwrap();
engine.append_event(MemoryEvent::new("audit", "login", r#"{"user":"alice"}"#)).unwrap();
assert_eq!(engine.count_objects().unwrap(), 1);
assert_eq!(engine.count_events().unwrap(), 1);Implementations§
Source§impl MemoryEngine
impl MemoryEngine
Trait Implementations§
Source§impl AggregateStore for MemoryEngine
impl AggregateStore for MemoryEngine
Source§fn aggregate(
&self,
collection: &str,
options: &AggregateOptions,
) -> ThingdResult<AggregateResult>
fn aggregate( &self, collection: &str, options: &AggregateOptions, ) -> ThingdResult<AggregateResult>
Run a general aggregation query over objects in a collection. Read more
Source§fn timeseries(
&self,
collection: &str,
options: &TimeSeriesOptions,
) -> ThingdResult<TimeSeriesResult>
fn timeseries( &self, collection: &str, options: &TimeSeriesOptions, ) -> ThingdResult<TimeSeriesResult>
Run a time-bucketed aggregation query. Read more
Source§impl Default for MemoryEngine
impl Default for MemoryEngine
Source§fn default() -> MemoryEngine
fn default() -> MemoryEngine
Returns the “default value” for a type. Read more
Source§impl EventLog for MemoryEngine
impl EventLog for MemoryEngine
Source§fn is_protected_stream(&self, stream: &str) -> bool
fn is_protected_stream(&self, stream: &str) -> bool
Returns
true if the stream is protected from deletion and external
mutation. Protected streams (e.g. "__thingd:mcp:audit") reject
delete_last_event and delete_stream calls.Source§fn append_event(&mut self, event: MemoryEvent) -> ThingdResult<MemoryEvent>
fn append_event(&mut self, event: MemoryEvent) -> ThingdResult<MemoryEvent>
Append an event to a stream. Read more
Source§fn list_events(
&self,
stream: Option<&str>,
options: ListEventsOptions,
) -> ThingdResult<Vec<MemoryEvent>>
fn list_events( &self, stream: Option<&str>, options: ListEventsOptions, ) -> ThingdResult<Vec<MemoryEvent>>
List events, optionally filtered by stream, with pagination. Read more
Source§fn count_events(&self) -> ThingdResult<u64>
fn count_events(&self) -> ThingdResult<u64>
Count total events across all streams. Read more
Source§fn list_streams(&self) -> ThingdResult<Vec<String>>
fn list_streams(&self) -> ThingdResult<Vec<String>>
List all unique stream names. Read more
Source§fn delete_last_event(
&mut self,
stream: &str,
) -> ThingdResult<Option<MemoryEvent>>
fn delete_last_event( &mut self, stream: &str, ) -> ThingdResult<Option<MemoryEvent>>
Delete the most recent event from a stream. Read more
Source§fn delete_stream(&mut self, stream: &str) -> ThingdResult<u64>
fn delete_stream(&mut self, stream: &str) -> ThingdResult<u64>
Delete all events in a stream. Read more
Source§fn append_events_batch(
&mut self,
events: Vec<MemoryEvent>,
) -> ThingdResult<Vec<MemoryEvent>>
fn append_events_batch( &mut self, events: Vec<MemoryEvent>, ) -> ThingdResult<Vec<MemoryEvent>>
Append multiple events to a stream in a single transaction. Read more
Source§impl LinkStore for MemoryEngine
impl LinkStore for MemoryEngine
Source§fn create_link(&mut self, link: Link) -> ThingdResult<Link>
fn create_link(&mut self, link: Link) -> ThingdResult<Link>
Create a new graph link. Read more
Source§fn delete_link(&mut self, id: &str) -> ThingdResult<bool>
fn delete_link(&mut self, id: &str) -> ThingdResult<bool>
Delete a graph link by id. Read more
Source§fn get_neighbors(
&self,
reference: &str,
direction: LinkDirection,
options: LinkQueryOptions,
) -> ThingdResult<Vec<Link>>
fn get_neighbors( &self, reference: &str, direction: LinkDirection, options: LinkQueryOptions, ) -> ThingdResult<Vec<Link>>
Get neighbors of a reference (outgoing, incoming, or both). Read more
Source§fn count_links(&self) -> ThingdResult<u64>
fn count_links(&self) -> ThingdResult<u64>
Count total links. Read more
Source§impl ObjectStore for MemoryEngine
impl ObjectStore for MemoryEngine
Source§fn put_object(&mut self, object: MemoryObject) -> ThingdResult<MemoryObject>
fn put_object(&mut self, object: MemoryObject) -> ThingdResult<MemoryObject>
Insert or replace an object. Read more
Source§fn put_object_with_options(
&mut self,
object: MemoryObject,
options: PutObjectOptions,
) -> ThingdResult<MemoryObject>
fn put_object_with_options( &mut self, object: MemoryObject, options: PutObjectOptions, ) -> ThingdResult<MemoryObject>
Insert or replace an object with explicit options. Read more
Source§fn put_object_with_source_metadata(
&mut self,
object: MemoryObject,
options: PutObjectOptions,
) -> ThingdResult<MemoryObject>
fn put_object_with_source_metadata( &mut self, object: MemoryObject, options: PutObjectOptions, ) -> ThingdResult<MemoryObject>
Apply an object received from a replication source while preserving the
source metadata carried by the object. Normal application writes should
continue to use
put_object so the local store owns versioning. Read moreSource§fn get_object(
&self,
collection: &str,
id: &str,
) -> ThingdResult<Option<MemoryObject>>
fn get_object( &self, collection: &str, id: &str, ) -> ThingdResult<Option<MemoryObject>>
Read an object by collection and id. Read more
Source§fn list_objects(
&self,
collections: Option<&[String]>,
options: &ListObjectsOptions,
) -> ThingdResult<Vec<MemoryObject>>
fn list_objects( &self, collections: Option<&[String]>, options: &ListObjectsOptions, ) -> ThingdResult<Vec<MemoryObject>>
List objects in one or more collections, with optional filtering, limit, and offset. Read more
Source§fn delete_object(&mut self, collection: &str, id: &str) -> ThingdResult<bool>
fn delete_object(&mut self, collection: &str, id: &str) -> ThingdResult<bool>
Delete an object by collection and id. Read more
Source§fn count_objects(&self) -> ThingdResult<u64>
fn count_objects(&self) -> ThingdResult<u64>
Count total objects across all collections. Read more
Source§fn count_objects_in_collection(&self, collection: &str) -> ThingdResult<u64>
fn count_objects_in_collection(&self, collection: &str) -> ThingdResult<u64>
Count objects in a specific collection. Read more
Source§fn list_collections(&self) -> ThingdResult<Vec<String>>
fn list_collections(&self) -> ThingdResult<Vec<String>>
List all unique collection names. Read more
Source§fn create_index(&mut self, collection: &str, field: &str) -> ThingdResult<()>
fn create_index(&mut self, collection: &str, field: &str) -> ThingdResult<()>
Create a functional index on a JSON body field for a collection. Read more
Source§fn create_index_definition(
&mut self,
index: IndexDefinition,
) -> ThingdResult<()>
fn create_index_definition( &mut self, index: IndexDefinition, ) -> ThingdResult<()>
Create or replace a functional index definition. Read more
Source§fn list_indexes(&self) -> ThingdResult<Vec<(String, String)>>
fn list_indexes(&self) -> ThingdResult<Vec<(String, String)>>
List all custom functional indexes. Read more
Source§fn delete_index(&mut self, collection: &str, field: &str) -> ThingdResult<bool>
fn delete_index(&mut self, collection: &str, field: &str) -> ThingdResult<bool>
Remove a functional index definition. Read more
Source§fn list_index_definitions(&self) -> ThingdResult<Vec<IndexDefinition>>
fn list_index_definitions(&self) -> ThingdResult<Vec<IndexDefinition>>
List index definitions, including uniqueness semantics. Read more
Source§fn schema(
&self,
collection: Option<&str>,
options: &SchemaOptions,
) -> ThingdResult<Vec<CollectionSchema>>
fn schema( &self, collection: Option<&str>, options: &SchemaOptions, ) -> ThingdResult<Vec<CollectionSchema>>
Reflect the schema of all or one collection by sampling stored objects. Read more
Source§fn put_objects_batch(
&mut self,
objects: Vec<MemoryObject>,
) -> ThingdResult<Vec<MemoryObject>>
fn put_objects_batch( &mut self, objects: Vec<MemoryObject>, ) -> ThingdResult<Vec<MemoryObject>>
Insert or replace multiple objects in a single transaction. Read more
Source§fn get_objects_batch(
&self,
collection: &str,
ids: &[String],
) -> ThingdResult<Vec<Option<MemoryObject>>>
fn get_objects_batch( &self, collection: &str, ids: &[String], ) -> ThingdResult<Vec<Option<MemoryObject>>>
Read multiple objects by collection and id in a single query. Read more
Source§fn delete_objects_batch(
&mut self,
keys: &[(String, String)],
) -> ThingdResult<u64>
fn delete_objects_batch( &mut self, keys: &[(String, String)], ) -> ThingdResult<u64>
Delete multiple objects in a single transaction. Read more
Source§fn retain(
&mut self,
_options: RetentionOptions,
) -> ThingdResult<RetentionReport>
fn retain( &mut self, _options: RetentionOptions, ) -> ThingdResult<RetentionReport>
Apply explicit retention. Adapters that cannot safely compact return an
unsupported-operation error rather than deleting records by default. Read more
Source§impl QueueStore for MemoryEngine
impl QueueStore for MemoryEngine
Source§fn push_job(&mut self, job: QueueJob) -> ThingdResult<QueueJob>
fn push_job(&mut self, job: QueueJob) -> ThingdResult<QueueJob>
Push a job onto a queue. Read more
Source§fn claim_job_with_options(
&mut self,
queue: &str,
options: QueueClaimOptions,
) -> ThingdResult<Option<QueueJob>>
fn claim_job_with_options( &mut self, queue: &str, options: QueueClaimOptions, ) -> ThingdResult<Option<QueueJob>>
Claim the next ready job from a queue with explicit options. Read more
Source§fn ack_job(&mut self, queue: &str, id: &str) -> ThingdResult<Option<QueueJob>>
fn ack_job(&mut self, queue: &str, id: &str) -> ThingdResult<Option<QueueJob>>
Acknowledge a leased job as completed. Read more
Source§fn nack_job_with_options(
&mut self,
queue: &str,
id: &str,
options: QueueNackOptions,
) -> ThingdResult<Option<QueueJob>>
fn nack_job_with_options( &mut self, queue: &str, id: &str, options: QueueNackOptions, ) -> ThingdResult<Option<QueueJob>>
Reject a leased job for retry or dead-letter routing with explicit options. Read more
Source§fn list_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>
fn list_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>
List all jobs in a queue. Read more
Source§fn list_dead_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>
fn list_dead_jobs(&self, queue: &str) -> ThingdResult<Vec<QueueJob>>
List dead-letter jobs in a queue. Read more
Source§fn list_queues(&self) -> ThingdResult<Vec<String>>
fn list_queues(&self) -> ThingdResult<Vec<String>>
List all unique queue names. Read more
Source§fn count_active_jobs(&self) -> ThingdResult<u64>
fn count_active_jobs(&self) -> ThingdResult<u64>
Count total active jobs across all queues. Read more
Source§fn count_dead_jobs(&self) -> ThingdResult<u64>
fn count_dead_jobs(&self) -> ThingdResult<u64>
Count total dead-letter jobs across all queues. Read more
Source§fn push_jobs_batch(
&mut self,
jobs: Vec<QueueJob>,
) -> ThingdResult<Vec<QueueJob>>
fn push_jobs_batch( &mut self, jobs: Vec<QueueJob>, ) -> ThingdResult<Vec<QueueJob>>
Push multiple jobs onto a queue in a single transaction. Read more
Source§fn claim_job(&mut self, queue: &str) -> ThingdResult<Option<QueueJob>>
fn claim_job(&mut self, queue: &str) -> ThingdResult<Option<QueueJob>>
Claim the next ready job from a queue. Read more
Source§fn claim_and_ack(
&mut self,
queue: &str,
options: QueueClaimOptions,
) -> ThingdResult<Option<QueueJob>>
fn claim_and_ack( &mut self, queue: &str, options: QueueClaimOptions, ) -> ThingdResult<Option<QueueJob>>
Claim and immediately ack a job in a single transaction. Read more
Source§impl SchemaStore for MemoryEngine
impl SchemaStore for MemoryEngine
Source§fn get_schema_document(&self) -> ThingdResult<Option<StoredSchema>>
fn get_schema_document(&self) -> ThingdResult<Option<StoredSchema>>
Read the last applied canonical schema, if any. Read more
Source§fn put_schema_document(&mut self, schema: StoredSchema) -> ThingdResult<()>
fn put_schema_document(&mut self, schema: StoredSchema) -> ThingdResult<()>
Store the canonical schema metadata. Read more
Source§fn list_migrations(&self) -> ThingdResult<Vec<MigrationRecord>>
fn list_migrations(&self) -> ThingdResult<Vec<MigrationRecord>>
List applied migrations in deterministic order. Read more
Source§fn record_migration(&mut self, migration: MigrationRecord) -> ThingdResult<()>
fn record_migration(&mut self, migration: MigrationRecord) -> ThingdResult<()>
Record an applied migration. Read more
Source§impl Searcher for MemoryEngine
impl Searcher for MemoryEngine
Source§fn search(
&self,
query: &str,
options: SearchOptions,
) -> ThingdResult<Vec<SearchHit>>
fn search( &self, query: &str, options: SearchOptions, ) -> ThingdResult<Vec<SearchHit>>
Search memory objects and event logs by query text. Read more
Source§impl ThingStore for MemoryEngine
impl ThingStore for MemoryEngine
Source§fn recovery_budget(&self) -> RecoveryBudget
fn recovery_budget(&self) -> RecoveryBudget
Return the configured bounded recovery budget.
Source§fn fail_storage_recovery(&mut self, message: String)
fn fail_storage_recovery(&mut self, message: String)
Mark recovery failed without dropping durable data.
Source§fn search_rebuild_required(&self) -> bool
fn search_rebuild_required(&self) -> bool
Return whether the adapter has an asynchronous derived search rebuild
that should be progressed by the hosting runtime.
Source§fn search_rebuild_step(&mut self, _batch_size: usize) -> ThingdResult<bool>
fn search_rebuild_step(&mut self, _batch_size: usize) -> ThingdResult<bool>
Process one bounded asynchronous search rebuild batch. Read more
Source§fn retry_search_rebuild(&mut self) -> bool
fn retry_search_rebuild(&mut self) -> bool
Retry a degraded search rebuild when bounded recovery permits another generation.
Source§fn search_rebuild_status(&self) -> Option<SearchRebuildStatus>
fn search_rebuild_status(&self) -> Option<SearchRebuildStatus>
Available on crate feature
persistent only.Return backend-specific asynchronous search rebuild status, when supported.
Source§fn storage_maintenance_status(&self) -> StorageMaintenanceStatus
fn storage_maintenance_status(&self) -> StorageMaintenanceStatus
Return backend-specific storage maintenance state.
Source§fn compact_storage(&mut self) -> ThingdResult<()>
fn compact_storage(&mut self) -> ThingdResult<()>
Compact the primary durable store when supported. Read more
Source§fn storage_diagnostics(&self) -> ThingdResult<StorageDiagnostics>
fn storage_diagnostics(&self) -> ThingdResult<StorageDiagnostics>
Return bounded storage diagnostics. Adapters may add backend-specific
details through their own APIs without changing this stable summary. Read more
Source§impl VectorStore for MemoryEngine
impl VectorStore for MemoryEngine
Source§fn vector_search(
&self,
collection: &str,
query_vector: &[f32],
options: VectorSearchOptions,
) -> ThingdResult<Vec<VectorSearchHit>>
fn vector_search( &self, collection: &str, query_vector: &[f32], options: VectorSearchOptions, ) -> ThingdResult<Vec<VectorSearchHit>>
Search objects by cosine similarity to the query vector. Read more
Source§fn add_vector(
&mut self,
collection: &str,
id: &str,
vector: &[f32],
) -> ThingdResult<()>
fn add_vector( &mut self, collection: &str, id: &str, vector: &[f32], ) -> ThingdResult<()>
Add or update a vector for an object. Read more
Source§fn remove_vector(&mut self, collection: &str, id: &str) -> ThingdResult<()>
fn remove_vector(&mut self, collection: &str, id: &str) -> ThingdResult<()>
Remove a vector for an object. Read more
Auto Trait Implementations§
impl Freeze for MemoryEngine
impl RefUnwindSafe for MemoryEngine
impl Send for MemoryEngine
impl Sync for MemoryEngine
impl Unpin for MemoryEngine
impl UnsafeUnpin for MemoryEngine
impl UnwindSafe for MemoryEngine
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
Mutably borrows from an owned value. Read more
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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
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> ⓘ
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 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> ⓘ
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