pub trait CachingModel: ToModel {
fn to_cache() -> Result<(), Box<dyn Error>> { ... }
fn to_wig() -> Result<HashMap<String, Widget>, Box<dyn Error>> { ... }
fn to_json() -> Result<String, Box<dyn Error>> { ... }
fn to_json_for_admin() -> Result<String, Box<dyn Error>> { ... }
fn to_html() -> Result<String, Box<dyn Error>> { ... }
fn get_cache_data_for_query() -> Result<(FormCache, Client), Box<dyn Error>> { ... }
fn db_update_dyn_widgets(json_line: &str) -> Result<(), Box<dyn Error>> { ... }
}
Expand description
Caching information about Models for speed up work.
Provided Methods
Get an widgets map for page template.
Example:
let widgets_map = UserProfile::wig()?;
println!("{:?}", widgets_map);
Get Form attributes in Json format for page templates.
Example:
let json_line = UserProfile::to_json()?;
println!("{}", json_line);
Json-line for admin panel. ( converts a widget map to a list, in the order of the Model fields )
Example:
let json_line = UserProfile::to_json_for_admin()?;
println!("{}", json_line);
Get Html Form of Model for page templates.
Example:
let html = UserProfile::to_html()?;
println!("{}", html);
Get cached Model data.
Example:
let (form_cache, client_cache) = UserProfile::get_cache_data_for_query()?;
println!("{:?}", form_cache);
Accepts json-line to update data, for dynamic widgets. Hint: Used in conjunction with the admin panel.
Example:
let json-line = r#"{"field_name":[["value","Title"], ...]}"#;
// or
let json-line = r#"{
"field_name":[["value","Title"], ...],
"field_name_2":[["value","Title 2"], ...],
"field_name_3":[["value","Title 3"], ...]
}"#;
assert!(Dynamic::db_update_dyn_widgets(json-line).is_ok());