pub trait App: Sized {
type Action: DeserializeOwned;
type Effect: Serialize;
// Required methods
fn boot(boot: &Value, ctx: &mut Ctx<Self::Effect>) -> Self;
fn update(&mut self, action: Self::Action, ctx: &mut Ctx<Self::Effect>);
fn resolve(
&mut self,
id: u64,
result: Result<Value, String>,
ctx: &mut Ctx<Self::Effect>,
);
fn view(&self, key: &str) -> Option<Value>;
fn screen(&self) -> String;
fn actions(&self) -> Vec<ActionSpec>;
// Provided methods
fn pointer(&mut self, _pointer: Pointer, _ctx: &mut Ctx<Self::Effect>) { ... }
fn blob(&mut self, _name: &str, _bytes: &[u8], _ctx: &mut Ctx<Self::Effect>) { ... }
}Expand description
The app: a model plus pure transitions. All time comes from ctx.at().
Required Associated Types§
Sourcetype Action: DeserializeOwned
type Action: DeserializeOwned
User intents, decoded from the act field (serde external tagging: "Inc", {"Add":{"n":2}}).
Required Methods§
Sourcefn boot(boot: &Value, ctx: &mut Ctx<Self::Effect>) -> Self
fn boot(boot: &Value, ctx: &mut Ctx<Self::Effect>) -> Self
Build the model from the shell’s boot facts.
fn update(&mut self, action: Self::Action, ctx: &mut Ctx<Self::Effect>)
Sourcefn resolve(
&mut self,
id: u64,
result: Result<Value, String>,
ctx: &mut Ctx<Self::Effect>,
)
fn resolve( &mut self, id: u64, result: Result<Value, String>, ctx: &mut Ctx<Self::Effect>, )
The answer to effect id: Ok(value) or Err(message).
Sourcefn view(&self, key: &str) -> Option<Value>
fn view(&self, key: &str) -> Option<Value>
The JSON of one view key, or None when the key is unknown.
Sourcefn actions(&self) -> Vec<ActionSpec>
fn actions(&self) -> Vec<ActionSpec>
Actions legal right now.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".