Struct noosphere_core::view::Sphere
source · pub struct Sphere<S: BlockStore> { /* private fields */ }Expand description
High-level Sphere I/O
Implementations§
source§impl<S: BlockStore> Sphere<S>
impl<S: BlockStore> Sphere<S>
pub fn at(cid: &Cid, store: &S) -> Sphere<S>
sourcepub fn cid(&self) -> &Cid
pub fn cid(&self) -> &Cid
Get the CID that points to the sphere’s wrapping memo that corresponds to this revision of the sphere
sourcepub async fn try_as_memo(&self) -> Result<MemoIpld>
pub async fn try_as_memo(&self) -> Result<MemoIpld>
Load the wrapping MemoIpld of the sphere data
sourcepub async fn try_as_body(&self) -> Result<SphereIpld>
pub async fn try_as_body(&self) -> Result<SphereIpld>
Load the body SphereIpld of this sphere
sourcepub async fn try_as_bundle(&self) -> Result<Bundle>
pub async fn try_as_bundle(&self) -> Result<Bundle>
Produce a bundle that contains the sparse set of blocks needed to produce this revision to the sphere
sourcepub async fn try_get_parent(&self) -> Result<Option<Sphere<S>>>
pub async fn try_get_parent(&self) -> Result<Option<Sphere<S>>>
Get a Sphere view over the parent revision of the sphere relative to this revision, if one exists
sourcepub async fn try_get_links(&self) -> Result<Links<S>>
pub async fn try_get_links(&self) -> Result<Links<S>>
sourcepub async fn try_get_names(&self) -> Result<Names<S>>
pub async fn try_get_names(&self) -> Result<Names<S>>
sourcepub async fn try_get_identity(&self) -> Result<Did>
pub async fn try_get_identity(&self) -> Result<Did>
Get the Did identity of the sphere
sourcepub async fn try_derive_mutation(&self) -> Result<SphereMutation>
pub async fn try_derive_mutation(&self) -> Result<SphereMutation>
Derive the mutation that would be required to produce the current sphere revision given its immediate ancestral parent. Note that this only considers changes that are internal to the sphere, and is not inclusive of the headers of the sphere’s memo.
sourcepub async fn try_apply_mutation(
&self,
mutation: &SphereMutation
) -> Result<SphereRevision<S>>
pub async fn try_apply_mutation( &self, mutation: &SphereMutation ) -> Result<SphereRevision<S>>
Apply a mutation to the sphere, producing a new sphere revision that must then be signed as an additional step.
sourcepub async fn try_apply_mutation_with_cid(
cid: &Cid,
mutation: &SphereMutation,
store: &mut S
) -> Result<SphereRevision<S>>
pub async fn try_apply_mutation_with_cid( cid: &Cid, mutation: &SphereMutation, store: &mut S ) -> Result<SphereRevision<S>>
Apply a mutation to the sphere given a revision CID, producing a new sphere revision that must then be signed as an additional step
pub async fn try_rebase(&self, onto: &Cid) -> Result<SphereRevision<S>>
pub async fn try_rebase_with_cid( cid: &Cid, onto: &Cid, store: &mut S ) -> Result<SphereRevision<S>>
sourcepub async fn try_hydrate_range(
from: Option<&Cid>,
to: &Cid,
store: &S
) -> Result<()>
pub async fn try_hydrate_range( from: Option<&Cid>, to: &Cid, store: &S ) -> Result<()>
“Hydrate” a range of revisions of a sphere. See the comments on
the try_hydrate method for details and implications.
sourcepub async fn try_hydrate(&self) -> Result<()>
pub async fn try_hydrate(&self) -> Result<()>
Attempt to “hydrate” the sphere at the current revision by replaying all of the changes that were made according to the sphere’s changelogs. This is necessary if the blocks of the sphere were retrieved using sparse synchronization in order to ensure that interstitial nodes in the various versioned maps (which are each backed by a HAMT) are populated.
sourcepub async fn try_hydrate_with_cid(cid: &Cid, store: &mut S) -> Result<()>
pub async fn try_hydrate_with_cid(cid: &Cid, store: &mut S) -> Result<()>
Same as try_hydrate, but specifying the CID to hydrate at
sourcepub async fn try_sync<Credential: KeyMaterial>(
&self,
old_base: &Cid,
new_base: &Cid,
credential: &Credential,
authorization: Option<&Authorization>
) -> Result<Cid>
pub async fn try_sync<Credential: KeyMaterial>( &self, old_base: &Cid, new_base: &Cid, credential: &Credential, authorization: Option<&Authorization> ) -> Result<Cid>
Attempt to linearize the canonical history of the sphere by re-basing the history onto a branch with an implicitly common lineage.
sourcepub async fn try_generate(
owner_did: &str,
store: &mut S
) -> Result<(Sphere<S>, Authorization, String)>
pub async fn try_generate( owner_did: &str, store: &mut S ) -> Result<(Sphere<S>, Authorization, String)>
Generate a new sphere and assign a DID as its owner. The returned tuple includes the UCAN authorization that enables the owner to manage the the sphere, as well as a mnemonic string that should be stored side-band by the owner for the case that they wish to transfer ownership (e.g., if key rotation is called for).
sourcepub async fn try_change_owner(
&self,
mnemonic: &str,
next_owner_did: &str,
current_authorization: &Authorization,
did_parser: &mut DidParser
) -> Result<(Sphere<S>, Authorization)>
pub async fn try_change_owner( &self, mnemonic: &str, next_owner_did: &str, current_authorization: &Authorization, did_parser: &mut DidParser ) -> Result<(Sphere<S>, Authorization)>
Change ownership of the sphere, producing a new UCAN authorization for the new owner and registering a revocation of the previous owner’s authorization within the sphere.
sourcepub fn into_link_changelog_stream(
self,
since: Option<&Cid>
) -> impl Stream<Item = Result<(Cid, ChangelogIpld<MapOperation<String, Cid>>)>>
pub fn into_link_changelog_stream( self, since: Option<&Cid> ) -> impl Stream<Item = Result<(Cid, ChangelogIpld<MapOperation<String, Cid>>)>>
Consume the Sphere and get a [Stream] that yields the ChangelogIpld for content slugs at each version of the sphere.