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 db_update_dyn_widgets(json_line: &str) -> Result<(), Box<dyn Error>> { ... } }
Expand description

Caching inmodelation about Models for speed up work.

Provided Methods

Add metadata and widgects map to cache.

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);

Get cached Model data.

Example:
let (model_cache, client_cache) = UserProfile::get_cache_data_for_query()?;
println!("{:?}", model_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());

Implementors