pub struct SurfaceHub { /* private fields */ }Expand description
The canonical multi-surface coordination point.
Holds the single canonical value per resource, the universal LensRegistry
that renders and edits, 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 register_surface_with_role(
&mut self,
surface: Symbol,
caps: SurfaceCaps,
role: SurfaceRole,
)
pub fn register_surface_with_role( &mut self, surface: Symbol, caps: SurfaceCaps, role: SurfaceRole, )
Register a surface with an explicit role inside the hub.
Sourcepub fn surface_role(&self, surface: &Symbol) -> Option<SurfaceRole>
pub fn surface_role(&self, surface: &Symbol) -> Option<SurfaceRole>
Returns the role recorded for surface.
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 commit_value_from(
&mut self,
surface: &Symbol,
pane: &Symbol,
intent: &Expr,
new_value: Expr,
) -> Result<Vec<Broadcast>>
pub fn commit_value_from( &mut self, surface: &Symbol, pane: &Symbol, intent: &Expr, new_value: Expr, ) -> Result<Vec<Broadcast>>
Commit an already decoded value update from surface/pane.
Device coordinators use this when a physical Intent has already been
reduced to a canonical value update. The hub still validates the Intent,
enforces the source surface input capability, records exactly one
append-only ledger row, and broadcasts through the same atomic path as
Self::submit.
Sourcepub fn detach_surface(&mut self, surface: &Symbol) -> Vec<SurfaceBinding>
pub fn detach_surface(&mut self, surface: &Symbol) -> Vec<SurfaceBinding>
Detach a surface from this hub without changing canonical resources or ledger history.
Sourcepub fn bindings_for_resource(&self, resource: &Symbol) -> Vec<SurfaceBinding>
pub fn bindings_for_resource(&self, resource: &Symbol) -> Vec<SurfaceBinding>
Returns live bindings currently showing resource.
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.