pub struct Decision {
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 reads_presence: 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 — the fact that decides eligibility.
reads_presence: boolTrue when the view reads presence(), which is the second fact that decides it.
span: SpanWhere the component is declared, for a diagnostic.
Implementations§
Source§impl Decision
impl Decision
Sourcepub fn of(
roles: &Roles,
is_application: bool,
declared: Option<(Mode, Span)>,
span: Span,
) -> Decision
pub fn of( roles: &Roles, 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.
One condition, and the reason there is only one is worth writing down. Mode B puts the
accumulator on the wire, so the obvious second 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.