Skip to main content

Crate toddstack_frontend_engine

Crate toddstack_frontend_engine 

Source
Expand description

App-agnostic frontend core: the Elm-style loop update(model, msg) -> effects.

The core is pure: it reads no clock, network, disk or randomness. Effects are data; the shell (browser, iOS, Android, a test harness) runs them and answers with resolve. Shells only draw view models and run effects. See the README for the pattern and a minimal app.

Structs§

ActionSpec
A legal action with a hand-rolled JSON schema (an object whose fields are all required).
ClockOffset
Server clock offset from the best (lowest round trip) sample: the server’s time is assumed to be read at the call midpoint.
Ctx
What update may do besides mutating the model: mark views dirty and request effects.
EffectReq
An effect with its request id, serialized flat: {"id":3,"Http":{...}}.
HttpReply
The ok payload of an answered Effect::Http. sent and recv are local wall-clock ms.
Pending
Effect ids still waiting for their answer, each with what the app was doing when it asked. Keeps resolve a match on a state-machine enum instead of scattered flags.
Pointer
One pointer sample on the typed fast path. x and y are in units the app chooses (cells, pixels, a 0..1 canvas); the engine never interprets them.
RetryPolicy
Retry with exponential backoff and jitter.
Runtime
Drives an App with the protocol. Construct with Runtime::new.

Enums§

Effect
A capability the shell implements. The built-in set is small and universal; anything else (haptics, sound, share sheets, push registration, review prompts) is the app’s own effect type X, carried by Effect::App and serialized flat next to the built-ins, so a shell matches on one key: {"id":3,"Http":{...}} or {"id":4,"Vibrate":{"ms":20}}.
FieldType
JSON-schema type of one action field.
NavigateOp
How a Effect::Navigate changes the history.
NoEffect
The app-defined effect type of an app that needs none.

Constants§

BRIDGE_PROTOCOL
The bridge message format (shell to core): the boot message carries "v" and every response echoes it. Not an app’s API contract: apps version that themselves.
BUILT_IN_EFFECT_NAMES
The variant names of the built-in effects. An app effect serialized under one of these reads back as the built-in (the untagged Effect::App is tried last), so app effect names must avoid them. Runtime checks this in debug builds and tests.

Traits§

App
The app: a model plus pure transitions. All time comes from ctx.at().
Bridge
The surface every bridge (UniFFI, wasm-bindgen, a test harness) wraps. Bytes in, bytes out.

Functions§

builtin_collision
The built-in name an app effect collides with, if any.