pub trait Caching: Main + GenerateHtml + Converters {
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 model_to_json_for_admin() -> Result<String, Box<dyn Error>> { ... }
fn to_html(
url_action: Option<&str>,
http_method: Option<HttpMethod>,
enctype: Option<Enctype>
) -> Result<String, Box<dyn Error>> { ... }
fn get_cache_data_for_query(
) -> Result<(ModelCache, Client), Box<dyn Error>> { ... }
fn update_dyn_wig(dyn_data: Value) -> Result<(), Box<dyn Error>> { ... }
}
Expand description
Caching inmodelation 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 field attributes in Json modelat 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 model of Model for page templates.
Example:
let html = UserProfile::to_html(None, None, None)?;
// OR
let html = UserProfile::to_html(Some("/login"), Some(HttpMethod::POST), Some(Enctype::Multipart))?;
println!("{}", html);
fn get_cache_data_for_query() -> Result<(ModelCache, Client), Box<dyn Error>>
fn get_cache_data_for_query() -> Result<(ModelCache, Client), Box<dyn Error>>
Get cached Model data.
Example:
let (model_cache, client_cache) = UserProfile::get_cache_data_for_query()?;
println!("{:?}", model_cache);
Update data for dynamic widgets. Hint: For more convenience, use the admin panel - https://github.com/kebasyaty/mango-panel
Example:
// Field attributes for "value":
// minlength - for string type ; Default = 0
// maxlength - for string type ; Default = 256
// min - for numeric type
// max - for numeric type
let dyn_data = json!({
"field_name": "field_name",
"value": 5, // restrict with field attributes
"title": "Title", // maximum title length = 150 characters
"is_delete": false
});
assert!(ModelName::update_dyn_wig(dyn_data).is_ok());