Decision

Struct Decision 

Source
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: Ty

What crosses to the browser: Html in Mode A, the fold’s accumulator in Mode B.

§optimistic: bool

Whether the client may apply a command speculatively before the server answers.

§no_optimism: Option<NoOptimism>§per_session: bool

True when the view reads the session — the fact that decides eligibility.

§reads_presence: bool

True when the view reads presence(), which is the second fact that decides it.

§span: Span

Where the component is declared, for a diagnostic.

Implementations§

Source§

impl Decision

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Decision

Source§

fn clone(&self) -> Decision

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Decision

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.