Skip to main content

MemoryEngine

Struct MemoryEngine 

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

In-memory engine used to prove the storage boundary.

§Examples

use thingd_core::{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

Source

pub fn new() -> Self

Create a new empty in-memory engine.

Trait Implementations§

Source§

impl Default for MemoryEngine

Source§

fn default() -> MemoryEngine

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

impl EventLog for MemoryEngine

Source§

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

List events, optionally filtered by stream, with pagination. Read more
Source§

fn count_events(&self) -> ThingdResult<u64>

Count total events across all streams. Read more
Source§

fn list_streams(&self) -> ThingdResult<Vec<String>>

List all unique stream names. Read more
Source§

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

Create a new graph link. Read more
Delete a graph link by id. Read more
Get a graph link by id. Read more
Source§

fn get_neighbors( &self, reference: &str, direction: LinkDirection, options: LinkQueryOptions, ) -> ThingdResult<Vec<Link>>

Get neighbors of a reference (outgoing, incoming, or both). Read more
Count total links. Read more
Source§

impl ObjectStore for MemoryEngine

Source§

fn put_object(&mut self, object: MemoryObject) -> ThingdResult<MemoryObject>

Insert or replace an object. Read more
Source§

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]>, ) -> ThingdResult<Vec<MemoryObject>>

List objects, optionally restricted to the provided collections. Read more
Source§

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>

Count total objects across all collections. Read more
Source§

fn list_collections(&self) -> ThingdResult<Vec<String>>

List all unique collection names. Read more
Source§

fn put_objects_batch( &mut self, objects: Vec<MemoryObject>, ) -> ThingdResult<Vec<MemoryObject>>

Insert or replace multiple objects in a single transaction. Read more
Source§

impl QueueStore for MemoryEngine

Source§

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

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

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

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

List all jobs in a queue. Read more
Source§

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

List all unique queue names. Read more
Source§

fn count_active_jobs(&self) -> ThingdResult<u64>

Count total active jobs across all queues. Read more
Source§

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

Push multiple jobs onto a queue in a single transaction. Read more
Source§

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

Claim and immediately ack a job in a single transaction. Read more
Source§

fn nack_job(&mut self, queue: &str, id: &str) -> ThingdResult<Option<QueueJob>>

Reject a leased job for retry or dead-letter routing. Read more
Source§

impl Searcher for MemoryEngine

Source§

fn search( &self, query: &str, options: SearchOptions, ) -> ThingdResult<Vec<SearchHit>>

Search memory objects and event logs by query text. Read more

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> ThingStore for T

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.