pub struct Roles {Show 19 fields
pub validate: Core,
pub fold: Core,
pub init: Core,
pub view: Core,
pub state_ty: Ty,
pub event_ty: Ty,
pub command_ty: Ty,
pub proposals_name: Arc<str>,
pub events_name: Arc<str>,
pub state_name: Arc<str>,
pub page_name: Arc<str>,
pub inlined: Vec<Arc<str>>,
pub shared: Vec<Arc<str>>,
pub states: Vec<StateRole>,
pub view_is_per_session: bool,
pub view_reads_presence: bool,
pub awareness: Option<Core>,
pub view_reads_freshness: bool,
pub gestures: Option<GestureRole>,
}Expand description
The five things the runtime needs, each a Core value it can call.
This is deliberately still five: a runtime that drives one log, one accumulator and one page is what Phase 1 built and what Phase 3 has not replaced. What changed is that these are now derived from the graph — fusing several folds, inlining or sharing intermediate signals — so the shape of the program and the shape of the runtime are no longer required to be the same.
Fields§
§validate: Core(state, proposal) -> Result[list[Event], Rejection] — the authority chokepoint.
fold: Core(state, Envelope[Event]) -> state — the replay-pure fold.
init: CoreThe fold’s initial accumulator.
view: Core(state, session, presence, awareness, freshness) -> Html — the client-placed view, with
intermediate signals inlined or shared.
Five parameters whether or not the program reads the last three: a role the runtime calls has one arity, and a view that ignores an argument is cheaper than two code paths that could disagree about which one it has.
state_ty: Ty§event_ty: Ty§command_ty: Ty§proposals_name: Arc<str>Names, for beck explain and for the report.
events_name: Arc<str>§state_name: Arc<str>§page_name: Arc<str>§inlined: Vec<Arc<str>>Signals that were inlined into the view rather than surviving as their own node.
Signals read by more than one consumer, and therefore bound once in the sliced view rather than recomputed per use. §5.3’s shared prefix, at compile time.
states: Vec<StateRole>The durable folds, in declaration order. One entry for the ordinary program; several when the accumulator is fused.
view_is_per_session: bool§view_reads_presence: boolWhether the page reads presence(), and therefore has an input the log does not contain.
awareness: Option<Core>awareness(f)’s f, when the page reads a roster with a payload: (Session) -> T.
A role rather than a signal, because the subscribers are the runtime’s fact and not the
graph’s — the runtime applies this to each connection’s Session and hands the view the
roster it builds. None when the program reads no awareness, which is every program that
existed before it.
view_reads_freshness: boolWhether the page reads freshness(), and therefore has an input only a Mode B client can
answer with anything but Confirmed.
gestures: Option<GestureRole>gestures(step, init)’s two halves, when the page reads a non-durable fold: D30’s
client-local accumulator.
A role for Roles::awareness’s reason and a different one: there is no signal to read it
from, because the stream it folds is one client’s and the graph has nothing on that side of
the seam. The runtime holds the accumulator per connection, applies step to each gesture,
and hands the view what it has. None for every program that keeps no interface state,
which is every program written before D30.