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>

source

pub fn at(cid: &Cid, store: &S) -> Sphere<S>

source

pub fn cid(&self) -> &Cid

Get the CID that points to the sphere’s wrapping memo that corresponds to this revision of the sphere

source

pub async fn try_as_memo(&self) -> Result<MemoIpld>

Load the wrapping MemoIpld of the sphere data

source

pub async fn try_as_body(&self) -> Result<SphereIpld>

Load the body SphereIpld of this sphere

source

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

source

pub async fn try_bundle_until_ancestor( &self, cid: Option<&Cid> ) -> Result<Bundle>

Produce a bundle that contains the sparse set of blocks needed to produce a series of sequential revisions of this sphere, up to but excluding the given Cid (or until the genesis revision of the sphere if no Cid is given).

source

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

Attempt to load the Links of this sphere. If no links have been set for this sphere yet, this initializes an empty Links and returns it for the caller to populate.

source

pub async fn try_get_authority(&self) -> Result<Authority<S>>

Attempt to load the Authority of this sphere. If no authorizations or revocations have been added to this sphere yet, this initializes an empty Authority and returns it for the caller to populate.

source

pub async fn try_get_names(&self) -> Result<Names<S>>

Attempt to load the Names of this sphere. If no names have been added to this sphere yet, this initializes an empty Names and returns it for the caller to populate.

source

pub async fn try_get_identity(&self) -> Result<Did>

Get the Did identity of the sphere

source

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.

source

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.

source

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

source

pub async fn try_rebase(&self, onto: &Cid) -> Result<SphereRevision<S>>

source

pub async fn try_rebase_with_cid( cid: &Cid, onto: &Cid, store: &mut S ) -> Result<SphereRevision<S>>

source

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.

source

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.

source

pub async fn try_hydrate_with_cid(cid: &Cid, store: &mut S) -> Result<()>

Same as try_hydrate, but specifying the CID to hydrate at

source

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.

source

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).

source

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.

Consume the Sphere and get a [Stream] that yields the ChangelogIpld for content slugs at each version of the sphere.

Trait Implementations§

source§

impl<S: Clone + BlockStore> Clone for Sphere<S>

source§

fn clone(&self) -> Sphere<S>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Sphere<S>where S: RefUnwindSafe,

§

impl<S> Send for Sphere<S>

§

impl<S> Sync for Sphere<S>

§

impl<S> Unpin for Sphere<S>where S: Unpin,

§

impl<S> UnwindSafe for Sphere<S>where S: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> References<RawCodec> for T

source§

fn references<R, E>(_c: RawCodec, _r: &mut R, _set: &mut E) -> Result<(), Error>where R: Read, E: Extend<Cid<64>>,

Scrape the references from an impl Read. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> BlockStoreSend for Twhere T: Send,

source§

impl<T> BlockStoreSendSync for Twhere T: Send + Sync,

source§

impl<T> KeyValueSendSync for Twhere T: Send + Sync,

source§

impl<T> KeyValueStoreSend for Twhere T: Send,

source§

impl<S> KuboStorageConditionalSendSync for Swhere S: Send + Sync,

source§

impl<T> SphereDbSendSync for Twhere T: Send + Sync,

source§

impl<S> StoreConditionalSendSync for Swhere S: Send + Sync,

source§

impl<S> TargetConditionalSendSync for Swhere S: Send + Sync,

source§

impl<U> UcanStoreConditionalSend for Uwhere U: Send,

source§

impl<U> UcanStoreConditionalSendSync for Uwhere U: Send + Sync,