Store an envelope at the given ARID.
This operation will fail if the ARID already exists. The implementation must check for existence before writing and return an appropriate error if the key is already present.
Cryptographic identifier for this storage location
The envelope to store
OptionalttlSeconds: numberOptional time-to-live in seconds. After this time, the envelope may be removed from storage.
Optionalverbose: booleanIf true, log operations with timestamps
A receipt containing storage metadata on success
const arid = ARID.new();
const envelope = Envelope.new("Hello, Hubert!");
// Store without TTL
const receipt = await store.put(arid, envelope);
// Store with 1 hour TTL and verbose logging
const arid2 = ARID.new();
const receipt2 = await store.put(arid2, envelope, 3600, true);
console.log("Stored at:", receipt2);
Retrieve an envelope for the given ARID.
Polls the storage backend until the envelope becomes available or the timeout is reached. This is useful for coordinating between parties where one party puts data and another polls for it.
The ARID to look up
OptionaltimeoutSeconds: numberMaximum time to wait for the envelope to appear. If
undefined, uses a backend-specific default (typically 30 seconds). After
timeout, returns null rather than continuing to poll.
Optionalverbose: booleanIf true, log operations with timestamps and print polling dots
The envelope if found within the timeout, or null if not found
Check if an envelope exists at the given ARID.
The ARID to check
true if the ARID exists, false otherwise
Unified interface for key-value storage backends using ARID-based addressing.
All implementations provide write-once semantics: once an envelope is stored at an ARID, subsequent attempts to write to the same ARID will fail with an
AlreadyExistsError.Security Model
Implementations
MainlineDhtKv: Fast, lightweight DHT storage (≤1 KB messages)IpfsKv: Large capacity, content-addressed storage (up to 10 MB messages)HybridKv: Automatic optimization by size, combining DHT speed with IPFS capacityServerKvClient: HTTP client for centralized server backendPort of
trait KvStorefrom kv_store.rs lines 81-214.