pub struct Decision {Show 13 fields
pub component: Arc<str>,
pub mode: Mode,
pub why: Why,
pub carries: Ty,
pub optimistic: bool,
pub no_optimism: Option<NoOptimism>,
pub per_session: bool,
pub uses: SessionUse,
pub reads_presence: bool,
pub reads_awareness: bool,
pub reads_freshness: bool,
pub reads_gestures: bool,
pub span: Span,
}Expand description
How one component renders, and what follows from it.
Fields§
§component: Arc<str>§mode: Mode§why: Why§carries: TyWhat crosses to the browser: Html in Mode A, the fold’s accumulator in Mode B.
optimistic: boolWhether the client may apply a command speculatively before the server answers.
no_optimism: Option<NoOptimism>§per_session: boolTrue when the view reads the session at all — §3.8’s fanout fact, and §5.3’s shared cut.
uses: SessionUseWhat the view can observe about the session. This is what decides Mode B eligibility: a page may vary by where the browser is and may not vary by who is holding it.
reads_presence: boolTrue when the view reads presence(), which is the second fact that decides it.
reads_awareness: boolTrue when the view reads awareness(), which decides it for the same reason: a roster with
a payload is still a fact the server holds about its own sockets.
reads_freshness: boolTrue when the view reads freshness(). The only condition here that refuses Mode A:
a server renders the state it has recorded, so its answer is Confirmed and nothing else,
and a page that branches on it is a page with a dead branch.
reads_gestures: boolTrue when the view reads a gestures(step, init) — D30’s non-durable fold. The second
condition that refuses Mode A, and for reads_freshness’s reason on the other fact: a
server has received no gestures, so its answer is init and nothing else.
span: SpanWhere the component is declared, for a diagnostic.
Implementations§
Source§impl Decision
impl Decision
Sourcepub fn of(
roles: &Roles,
defs: &BTreeMap<Arc<str>, Def>,
is_application: bool,
declared: Option<(Mode, Span)>,
span: Span,
) -> Decision
pub fn of( roles: &Roles, defs: &BTreeMap<Arc<str>, Def>, is_application: bool, declared: Option<(Mode, Span)>, span: Span, ) -> Decision
The decision for one component: what it declared, and what follows.
Takes the roles rather than the crate::split::Placed they end up in because this is what decides a
field of that struct — and takes the declaration as an argument so that
beck explain render, beck build and the checker cannot disagree about where it came
from.
Sourcepub fn explain(&self, bundle: &Bundle) -> String
pub fn explain(&self, bundle: &Bundle) -> String
What beck explain render prints: the decision, what it puts on the wire, and what would
change it.
The counterfactual is the useful half. A reader who wants Mode B and has Mode A needs to
know whether one annotation would do it or whether the program’s shape refuses — and that
is a question only the compiler can answer, because the answer is view_is_per_session.
Sourcepub fn refuse(&self, diags: &mut Diagnostics)
pub fn refuse(&self, diags: &mut Diagnostics)
Refuse a component that may not render where it says it does.
Three conditions, and they do not all point the same way. Two are things a page can read
that a browser handed the accumulator would not have: who is asking (SessionUse)
and who is connected (presence). Where the browser is is not one of them — it chose
the route. The third is the mirror: whether a guess is outstanding (freshness) is
something only a browser can have, so a page reading it may not render on the server.
What is deliberately not a third condition is worth writing down. Mode B puts the
accumulator on the wire, so the obvious check is §3.5’s Sendable — and it is
already discharged: a durable fold’s state must be storable (B0411), storable is
strictly stronger than sendable (crate::secure), and the accumulator is what crosses.
A secret[T] therefore cannot reach a Mode B client because it cannot reach the log, and
a check here would be a second gate on a door that is shut. mode_b.rs asserts that
composition rather than trusting it.