pub struct SphereDb<S>where
    S: Storage,
{ /* private fields */ }
Expand description

A SphereDb is a high-level storage primitive for Noosphere’s APIs. It takes a Storage and implements BlockStore and KeyValueStore, orchestrating writes so that as blocks are stored, links are also extracted and tracked separately, and also hosting metadata information such as sphere version records and other purely local configuration

Implementations§

Given a MemoryStore, store copies of all the blocks found within in the storage that backs this SphereDb.

Record the tip of a local sphere lineage as a Cid

Get the most recently recorded tip of a local sphere lineage

Get the most recently recorded tip of a local sphere lineage, returning an error if no version has ever been recorded

Get all links referenced by a block given its Cid

Given a Cid root and a predicate function, stream all links that are referenced by the root or its descendants (recursively). The predicate function is called with each Cid before it is yielded by the stream. If the predicate returns true, the Cid is yielded and its referenced links are queued to be yielded later by the stream. If the predicate returns false, the Cid is skipped and by extension so are its referenced links.

Stream all links that are referenced from the given root Cid or its DAG descendants (recursively).

Stream all the blocks in the DAG starting at the given root Cid.

Get an owned copy of the underlying primitive BlockStore for this SphereDb

Trait Implementations§

Given a CID and a block, store the links (any Cid that is part of the encoded data) in a suitable location for later retrieval. This method is optional, and its default implementation is a no-op. It should be implemented when possible to enable optimized traversal of a DAG given its root.
Given a block and its Cid, persist the block in storage.
Given the Cid of a block, retrieve the block bytes from storage.
Given some data structure that implements Encode for a given Codec, encode it as a block and persist it to storage for later retrieval by Cid.
Given the Cid of a block that refers to a type that implements Decode for some Codec, retrieve the block, decode it as the type and return the result.
Given some data structure that implements Serialize, convert it to an IPLD-compatible representation, encode it as a block with the desired Codec and persist it to the storage backend by its Cid
Given a Cid that refers to some data structure that implements [Deserialize], read the block bytes from storage, decode it as IPLD using the specified Codec and and deserialize it to the intended data structure, returning the result.
Same as load, but returns an error if no block is found locally for the given Cid
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Given some key that can be realized as bytes, persist a serializable value to storage so that it can later be retrieved by that key
Given some key that can be realized as bytes, unset the value stored against that key (if any)
Given some key that can be realized as bytes, retrieve some data that can be deserialized as the intended data structure
Same as get_key, but returns an error if no value is found to be stored against the key
Read a value from the store by CID, returning a Result<Option<…>> that unwraps to None if no value is found, otherwise Some
Write a value to the store, receiving a Result that wraps the values CID if the write was successful

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Scrape the references from an impl Read. Read more
Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more