Bundle

Struct Bundle 

Source
pub struct Bundle {
    pub component: Arc<str>,
    pub wire_id: String,
    pub view: Core,
    pub validate: Core,
    pub fold: Core,
    pub init: Core,
    pub defs: BTreeMap<Arc<str>, Core>,
    pub command: Schema,
    pub optimistic: bool,
    pub reads_freshness: bool,
    pub gestures: Option<Gestures>,
}
Expand description

A component’s slice: the code, and nothing else.

Fields§

§component: Arc<str>

The signal this bundle renders — the component’s name in the program, and what beck explain render prints.

§wire_id: String

The program’s content-derived command-channel id (§4.3). A client that reconnects to a server running a different program finds out here rather than by sending it a command it cannot decode.

§view: Core

(state, session, presence, awareness, freshness, interface) -> Html.

§validate: Core

(state, proposal) -> Result[list[Event], Rejection].

§fold: Core

(state, Envelope[Event]) -> state.

§init: Core

The fold’s initial accumulator, as an expression rather than a value: evaluating it is the kernel’s first act, and a Value would have needed a second encoding for the same thing.

§defs: BTreeMap<Arc<str>, Core>

Every definition the four roles reach, transitively.

§command: Schema

What the client may send, resolved: enough to turn a data-b-click attribute into the Command value validate expects, and to refuse anything else.

§optimistic: bool

Whether this component’s client may run Bundle::validate and Bundle::fold on what it holds — see crate::render for what decides it, and why holding the state is the whole question.

§reads_freshness: bool

Whether this component’s view reads freshness() — §3.7’s freshness dimension.

The client needs it for one reason and it is not rendering: a page that does not observe freshness must keep docs/94 §94.12’s shortcut, where a confirmation that does not move the state costs no render. Comparing the freshness unconditionally would make every confirmation move it — from Pending(1) to Confirmed — and hand every program in the tree back the second render that report removed.

§gestures: Option<Gestures>

gestures(step, init), when the page keeps client-local interface state — D30’s non-durable fold.

It travels in the bundle because this is the only side that can run it: a gesture never reaches the server, so a client that could not fold its own would have interface state nobody could advance. None for a page that keeps none, which is every page compiled before D30.

Implementations§

Source§

impl Bundle

Source

pub fn of(placed: &Placed) -> Bundle

The bundle for a placed program’s component.

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Bundle, BadBundle>

Source

pub fn nodes(&self) -> usize

How many Core nodes this bundle carries — what beck explain render reports as its size in the compiler’s own units, beside the bytes.

Trait Implementations§

Source§

impl Clone for Bundle

Source§

fn clone(&self) -> Bundle

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 Bundle

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Bundle

§

impl RefUnwindSafe for Bundle

§

impl Send for Bundle

§

impl Sync for Bundle

§

impl Unpin for Bundle

§

impl UnwindSafe for Bundle

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.