Skip to main content

Crate spacedb_sdk

Crate spacedb_sdk 

Source
Expand description

§spacedb-sdk — the developer’s whole world

One surface over the entire SpaceDB stack. You open an offline-first local replica, define a Schema where each field declares its CrdtType and consistency Tier, and run ops that are mID-authorized, budget-bounded, and honest — every write and read returns the Outcome it actually achieved (Local, Committed{tier}, Stale{lag}, Unavailable{reason}). Strong-tier fields go through a quorum that fails safe under partition; reactive Watchers and CRDT export/import sync round it out.

use spacedb_sdk::{Database, Schema, CrdtType, Tier, Identity};

let owner = Identity::generate("did:mata:owner").unwrap();
let mut db = Database::open(Identity::generate("did:mata:home-1").unwrap());
db.register_identity(&owner).unwrap();
db.define(
    Schema::new("profile")
        .field("bio", CrdtType::Text, Tier::Convergent)
        .field("username", CrdtType::Register, Tier::Strong),
);

Open-core (MIT). Composes spacedb-crdt, -access, -consistency, -meter.

Structs§

Budget
A remaining spend allowance, in micro-$MATA.
Capability
A grant of access from an issuer to a bearer.
Database
An offline-first SpaceDB replica.
Did
An identity reference: who an issuer/bearer is. Resolved to a key via the directory.
FieldSpec
A field’s representation and guarantee.
Identity
A P-256 keypair bound to a Did. Signs capabilities and sub-grants; its public key is published to a directory for verifiers.
MemKeyDirectory
In-memory DID → key directory, for tests and single-machine use.
Ops
The operations a capability grants — a bitset of read / write / compute.
RevocationSet
The set of revoked capability ids known to a node.
Schema
The fields of a collection.
Session
An authenticated, budgeted context for operations.
SignedCapability
A capability plus the issuer’s signature over its canonical bytes.
Watcher
Watches a document’s revision counter for changes.

Enums§

CrdtType
The CRDT a field is represented by — its merge semantics.
Outcome
The consistency a read or write actually achieved.
RejectReason
Why a strong op was refused by the invariant (the quorum was reached).
Scope
What a capability applies to.
SdkError
StrongResult
The result of a strong op. Committed/Rejected mean the quorum was reached and gave a definitive, linearizable answer; Unavailable means it was not reached and nothing was committed.
Tier
The consistency a field is served at.
UnavailableReason
Why a (strong) op could not be served.

Functions§

rusty_alloc_enabled
Whether this build installed rusty_alloc as the global allocator.
secure_allocator_enabled
Whether the hardened secure profile (guard pages, encrypted free lists) is compiled in.

Type Aliases§

SdkResult