pub struct SphereRenderer<C, S>where
    C: HasSphereContext<S> + 'static,
    S: Storage + 'static,{ /* private fields */ }
Expand description

SphereRenderer embodies all of the work needed to render a sphere graph to a workspace file system location. Starting from the “root” sphere, the renderer will efficiently queue work to concurrently render the sphere graph up to a maximum depth.

The renderer produces a file system structure that is approximated by this diagram:

/workspace_root/
├── foo.subtext
├── bar/
│   └── baz.subtext
├── @my-peer/ -> ./.sphere/peers/bafyabc...x987
├── @other-peer/ -> ./.sphere/peers/bafyabc...y654
└── .sphere/
    ├── identity # The sphere ID of the root sphere
    ├── version  # Last rendered version of the root sphere
    ├── depth    # Last rendered depth
    ├── slugs    # Backward mapping of slugs to files; base64-encoded to escape
    │   │        # special characters that may occur in a slug (such as '/')
    │   ├── Zm9v -> ../../foo.subtext
    │   └── YmFyL2Jheg -> ../../bar/baz.subtext
    ├── storage/ # Storage folder distinguishes the root sphere
    │   └── ...  # Implementation-specific e.g., Sled will have its own DB structure
    ├── content/ # Hard links to content that appears in peer spheres
    │   ├── bafyabc...a123
    │   ├── bafyabc...b456
    │   ├── bafyabc...c789
    │   └── ...
    └── peers/
        ├── bafyabc...x987/
        │   ├── identity
        │   ├── version
        │   ├── link_record  # A valid link record for this peer at this version
        │   └── mount/       # The virtual root where a peers files an links to thier
        │       │            # peers are rendered
        │       ├── their-foo.subtext -> ../../../content/bafyabc...b456
        │       ├── @peer3 -> ../../../peers/bafyabc...y654/mount
        │       └── @peer4 -> ../../../peers/bafyabc...z321/mount
        ├── bafyabc...y654/
        │   ├── identity
        │   ├── version
        │   ├── link_record
        │   └── mount/
        │       └── ...
        ├── bafyabc...z321/
        │   ├── identity
        │   ├── version
        │   ├── link_record
        │   └── mount/
        │       └── ...
        └── ...

Peers throughout the graph are rendered into a flat structure. Each version of a peer sphere gets its own unique directory, and the “mount” subfolder therein contains a virtual file system representation of that sphere’s contents and peers. The word “virtual” is used because all content and spheres within the mount are represented as symlinks. This enables maximum re-use of content across revisions of peers over time.

Note that since peers may re-appear in address books at different depths of graph traversal, it’s possible to appear to have rendered more deeply than the “maximum” render depth (when in fact an already-rendered peer is just being re-used).

Implementations§

source§

impl<C, S> SphereRenderer<C, S>where C: HasSphereContext<S> + 'static, S: Storage + 'static,

source

pub fn new(context: C, paths: Arc<SpherePaths>) -> Self

Construct a SphereRenderer for the given root HasSphereContext and initialized SpherePaths.

source

pub async fn render( &self, depth: Option<u32>, force_full_render: bool ) -> Result<()>

Render the sphere graph up to the given depth; the renderer will attempt to render different edges from the root concurrently, efficiently and idempotently. If the specified render depth increases for a subsequent render, all rendered peers will be reset and rendered again (although the hard links to their content will remain unchanged).

Auto Trait Implementations§

§

impl<C, S> RefUnwindSafe for SphereRenderer<C, S>where C: RefUnwindSafe, S: RefUnwindSafe,

§

impl<C, S> Send for SphereRenderer<C, S>

§

impl<C, S> Sync for SphereRenderer<C, S>

§

impl<C, S> Unpin for SphereRenderer<C, S>where C: Unpin, S: Unpin,

§

impl<C, S> UnwindSafe for SphereRenderer<C, S>where C: UnwindSafe, 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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

impl<T> FitForCBox for T

§

type CBoxWrapped = Box_<T>

source§

impl<T> From<T> for T

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>,

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> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

§

impl<T> Pointable for T

§

const ALIGN: usize = _

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 for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
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.
source§

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

Performs the conversion.
§

impl<T> UpcastAny for Twhere T: 'static,

§

fn upcast_any(&self) -> &(dyn Any + 'static)

§

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
§

impl<S> ConditionalSend for Swhere S: Send,

§

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

§

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

source§

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

source§

impl<U> UcanStoreConditionalSend for Uwhere U: Send,

source§

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