pub trait Logic: Sized + 'static {
type Frame: 'static;
type Value: Clone + Debug + 'static;
type Binding: Clone + Debug + 'static;
type Action: Clone + Debug + 'static;
type Region: Debug + 'static;
type Error: 'static;
Show 15 methods
// Required methods
fn text(
&self,
text: &Self::Value,
frame: &Self::Frame,
) -> Result<String, Self::Error>;
fn number(
&self,
number: &Self::Value,
frame: &Self::Frame,
) -> Result<i64, Self::Error>;
fn flag(
&self,
flag: &Self::Value,
frame: &Self::Frame,
) -> Result<bool, Self::Error>;
fn texts(
&self,
texts: &Self::Value,
frame: &Self::Frame,
) -> Result<Vec<String>, Self::Error>;
fn read_text(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
) -> Result<String, Self::Error>;
fn read_checked(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
) -> Result<bool, Self::Error>;
fn read_number(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
) -> Result<i64, Self::Error>;
fn write_text(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
text: &str,
) -> Result<(), Self::Error>;
fn write_checked(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
checked: bool,
) -> Result<(), Self::Error>;
fn write_number(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
number: i64,
) -> Result<(), Self::Error>;
fn write_texts(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
texts: Vec<String>,
) -> Result<(), Self::Error>;
fn run(
&self,
action: &Self::Action,
frame: &Self::Frame,
) -> Result<(), Self::Error>;
fn expand(
&self,
region: &Self::Region,
frame: &Rc<Self::Frame>,
) -> Result<Vec<Shown<Self>>, Self::Error>;
fn take_changed(&self) -> StateSet;
fn take_window_requests(&self) -> Vec<WindowRequest>;
}Expand description
The program behind an app’s UI. Templates hold its handles to values, bindings, actions and regions, and the engine asks it to evaluate them against a frame of locals.
The interpreter implements it by walking checked code, and compiled apps by calling compiled functions.
Required Associated Types§
Sourcetype Frame: 'static
type Frame: 'static
The locals visible to a piece of UI, such as loop variables and view parameters.
Sourcetype Value: Clone + Debug + 'static
type Value: Clone + Debug + 'static
A value the UI shows, or reads when the user acts, such as a label’s text or a nav item’s value. Each is read as the type the checker gave it.
Sourcetype Binding: Clone + Debug + 'static
type Binding: Clone + Debug + 'static
A place a text field or checkbox shows, and writes the user’s edits to.
type Error: 'static
Required Methods§
Sourcefn text(
&self,
text: &Self::Value,
frame: &Self::Frame,
) -> Result<String, Self::Error>
fn text( &self, text: &Self::Value, frame: &Self::Frame, ) -> Result<String, Self::Error>
§Errors
When evaluating the text fails.
Sourcefn number(
&self,
number: &Self::Value,
frame: &Self::Frame,
) -> Result<i64, Self::Error>
fn number( &self, number: &Self::Value, frame: &Self::Frame, ) -> Result<i64, Self::Error>
§Errors
When evaluating the number fails.
Sourcefn flag(
&self,
flag: &Self::Value,
frame: &Self::Frame,
) -> Result<bool, Self::Error>
fn flag( &self, flag: &Self::Value, frame: &Self::Frame, ) -> Result<bool, Self::Error>
§Errors
When evaluating the flag fails.
Sourcefn texts(
&self,
texts: &Self::Value,
frame: &Self::Frame,
) -> Result<Vec<String>, Self::Error>
fn texts( &self, texts: &Self::Value, frame: &Self::Frame, ) -> Result<Vec<String>, Self::Error>
§Errors
When evaluating the list fails.
Sourcefn read_text(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
) -> Result<String, Self::Error>
fn read_text( &self, binding: &Self::Binding, frame: &Self::Frame, ) -> Result<String, Self::Error>
§Errors
When reading the bound place fails.
Sourcefn read_checked(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
) -> Result<bool, Self::Error>
fn read_checked( &self, binding: &Self::Binding, frame: &Self::Frame, ) -> Result<bool, Self::Error>
§Errors
When reading the bound place fails.
Sourcefn read_number(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
) -> Result<i64, Self::Error>
fn read_number( &self, binding: &Self::Binding, frame: &Self::Frame, ) -> Result<i64, Self::Error>
§Errors
When reading the bound place fails.
Sourcefn write_text(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
text: &str,
) -> Result<(), Self::Error>
fn write_text( &self, binding: &Self::Binding, frame: &Self::Frame, text: &str, ) -> Result<(), Self::Error>
§Errors
When writing the bound place fails.
Sourcefn write_checked(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
checked: bool,
) -> Result<(), Self::Error>
fn write_checked( &self, binding: &Self::Binding, frame: &Self::Frame, checked: bool, ) -> Result<(), Self::Error>
§Errors
When writing the bound place fails.
Sourcefn write_number(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
number: i64,
) -> Result<(), Self::Error>
fn write_number( &self, binding: &Self::Binding, frame: &Self::Frame, number: i64, ) -> Result<(), Self::Error>
§Errors
When writing the bound place fails.
Sourcefn write_texts(
&self,
binding: &Self::Binding,
frame: &Self::Frame,
texts: Vec<String>,
) -> Result<(), Self::Error>
fn write_texts( &self, binding: &Self::Binding, frame: &Self::Frame, texts: Vec<String>, ) -> Result<(), Self::Error>
§Errors
When writing the bound place fails.
Sourcefn run(
&self,
action: &Self::Action,
frame: &Self::Frame,
) -> Result<(), Self::Error>
fn run( &self, action: &Self::Action, frame: &Self::Frame, ) -> Result<(), Self::Error>
§Errors
When the action fails part-way.
Sourcefn expand(
&self,
region: &Self::Region,
frame: &Rc<Self::Frame>,
) -> Result<Vec<Shown<Self>>, Self::Error>
fn expand( &self, region: &Self::Region, frame: &Rc<Self::Frame>, ) -> Result<Vec<Shown<Self>>, Self::Error>
What region shows now, in order: lists of templates, each with its own frame.
§Errors
When evaluating what decides the region’s contents fails.
Sourcefn take_changed(&self) -> StateSet
fn take_changed(&self) -> StateSet
The states changed since the last call.
Sourcefn take_window_requests(&self) -> Vec<WindowRequest>
fn take_window_requests(&self) -> Vec<WindowRequest>
What code asked of the app’s windows since the last call, in order.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".