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
impl SurfaceHub
Sourcepub fn new() -> Self
pub fn new() -> Self
A new hub with the universal default lens registered (writable) and no resources, surfaces, bindings, or ledger rows.
Sourcepub fn seed(&mut self, resource: Symbol, value: Expr)
pub fn seed(&mut self, resource: Symbol, value: Expr)
Set (or replace) the canonical value of resource.
Sourcepub fn register_surface(&mut self, surface: Symbol, caps: SurfaceCaps)
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.
Sourcepub fn open(
&mut self,
surface: &Symbol,
pane: Symbol,
resource: Symbol,
) -> Result<Expr>
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.
Sourcepub fn submit(
&mut self,
surface: &Symbol,
pane: &Symbol,
intent: &Expr,
) -> Result<Vec<Broadcast>>
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.
Sourcepub fn handoff(
&mut self,
from: &Symbol,
to: &Symbol,
resource: Symbol,
pane: Symbol,
) -> Result<Expr>
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.