SphereRenderer

Struct SphereRenderer 

Source
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> Freeze for SphereRenderer<C, S>
where C: Freeze,

§

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

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> FitForCBox for T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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 T
where 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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ManuallyDropMut for T

Source§

type Ret = ManuallyDrop<T>

Source§

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

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

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

Source§

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

Source§

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<S> ConditionalSend for S
where S: Send,

Source§

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

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

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

Source§

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

Source§

impl<U> UcanStoreConditionalSend for U
where U: Send,

Source§

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

Source§

impl<F> ZeroSizedElseWrathOfTheGඞds for F