Skip to main content

SurfaceHub

Struct SurfaceHub 

Source
pub struct SurfaceHub { /* private fields */ }
Expand description

The canonical multi-surface coordination point.

Holds the single canonical value per resource, the universal LensRegistry used to render and edit, an owned Cx, the registered surfaces and their SurfaceCaps, the live (surface, pane) bindings, and the append-only EditRow ledger.

Implementations§

Source§

impl SurfaceHub

Source

pub fn new() -> Self

A new hub with the universal default lens registered (writable) and no resources, surfaces, bindings, or ledger rows.

Source

pub fn seed(&mut self, resource: Symbol, value: Expr)

Set (or replace) the canonical value of resource.

Source

pub fn register_surface(&mut self, surface: Symbol, caps: SurfaceCaps)

Register a surface (identified by surface) with its capabilities. Re-registering replaces the stored caps.

Source

pub fn open( &mut self, surface: &Symbol, pane: Symbol, resource: Symbol, ) -> Result<Expr>

Bind (surface, pane) to resource, render the canonical value through the universal view (projected to the surface caps via reduce_for_caps), cache that Scene for the pane, and return it.

An existing binding for the same (surface, pane) is replaced. Fails if the surface is not registered or the resource has no canonical value.

Source

pub fn submit( &mut self, surface: &Symbol, pane: &Symbol, intent: &Expr, ) -> Result<Vec<Broadcast>>

Submit an Intent against the resource shown in (surface, pane).

The Intent is proposed and committed through the universal editor against the CURRENT canonical value; the resulting set-value operation is applied to the canonical store and appended to the ledger (attributed to the Intent origin’s operator and tick). Then, for EVERY (surface, pane) viewing that resource – including other surfaces – the new value is re-rendered, diffed against the pane’s cached Scene, the cache updated, and a Broadcast emitted. Returns all broadcasts.

Fails closed (returns an error, never panics) if the pane is not open, the resource is missing, the Intent is invalid, or the draft is not committable.

Source

pub fn handoff( &mut self, from: &Symbol, to: &Symbol, resource: Symbol, pane: Symbol, ) -> Result<Expr>

Hand resource off from from to to: open it on to in a new pane and return its Scene. The from surface keeps its binding, so the resource is now open on both and subsequent edits broadcast to both.

Fails if from does not currently hold resource.

Source

pub fn ledger(&self) -> &[EditRow]

The append-only edit ledger, in submit order.

Source

pub fn canonical(&self, resource: &Symbol) -> Option<&Expr>

The current canonical value of resource, if any.

Trait Implementations§

Source§

impl Default for SurfaceHub

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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