Skip to main content

Crate thingd

Crate thingd 

Source
Expand description

Core primitives for thingd.

This crate owns the durable engine boundary: object storage, append-only events, and queue storage. The default implementation is in-memory, with a feature-gated SQLite adapter available for durable object, event, and queue storage.

§Feature Flags

FeatureDefaultDescription
sqliteNoEnables SqliteThingStore with FTS5 search, WAL mode, and auto-migration
connectorsNoEnables CSV/JSON file connectors for data import

§Example (in-memory)

use thingd::{MemoryEngine, ObjectStore, EventLog, MemoryObject, MemoryEvent};

let mut engine = MemoryEngine::new();

let obj = MemoryObject::new("users", "alice", r#"{"name":"Alice"}"#);
engine.put_object(obj).unwrap();

let user = engine.get_object("users", "alice").unwrap();
assert_eq!(user.unwrap().body, r#"{"name":"Alice"}"#);

let event = MemoryEvent::new("audit", "user.created", r#"{"user":"alice"}"#);
engine.append_event(event).unwrap();

§Example (SQLite — requires sqlite feature)

#[cfg(feature = "sqlite")]
{
    use thingd::{SqliteThingStore, ObjectStore, MemoryObject};

    let mut db = SqliteThingStore::open_in_memory().unwrap();
    db.put_object(MemoryObject::new("users", "alice", r#"{"name":"Alice"}"#)).unwrap();
    let user = db.get_object("users", "alice").unwrap();
    assert_eq!(user.unwrap().body, r#"{"name":"Alice"}"#);
}

Structs§

Link
A graph link connecting two references.
LinkQueryOptions
Options for querying graph links.
ListEventsOptions
Options for listing events.
ListObjectsOptions
Options for listing objects in a collection.
MemoryEngine
In-memory engine used to prove the storage boundary.
MemoryEvent
An append-only event stored in a thingd stream.
MemoryObject
An object stored in a thingd collection.
ObjectKey
Stable object key inside a collection.
PutObjectOptions
Options for putting an object.
QueueClaimOptions
Options used when claiming a queue job.
QueueJob
A queued unit of work.
QueueNackOptions
Options used when rejecting a leased queue job.
SearchHit
A single match returned by a search query.
SearchOptions
Options used when performing a search.
SortBy
Sort specification for list queries.
SqliteThingStoresqlite
SQLite-backed memory store.

Enums§

LinkDirection
Direction for neighbor queries.
QueueJobStatus
Queue job lifecycle state.
SortDirection
Sort direction for list queries.
ThingdError
Error type returned by thingd core operations.

Constants§

DEFAULT_QUEUE_LEASE_MS
Default queue lease duration in milliseconds.
SQLITE_SCHEMA_VERSIONsqlite
Current SQLite schema version.

Traits§

EventLog
Append-only event log operations.
LinkStore
Graph link operations.
ObjectStore
Object storage operations.
QueueStore
Queue storage operations.
Searcher
Search operations.
ThingStore
Full storage interface expected from thingd engine adapters.

Type Aliases§

ThingdResult
Result type returned by thingd core operations.