ayun-view 0.24.0

The RUST Framework for Web Rustceans.
Documentation
use ayun_config::support::default;
use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize)]
pub struct View {
    #[serde(default = "default_path")]
    pub path: String,

    #[serde(default)]
    pub asset: Asset,
}

fn default_path() -> String {
    "resources/views/**/*".to_string()
}

impl Default for View {
    fn default() -> Self {
        default::<Self>().expect("Failed to get default value")
    }
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Asset {
    #[serde(default = "default_assets_url")]
    pub url: String,

    #[serde(default = "default_assets_path")]
    pub path: String,

    #[serde(default = "default_assets_fallback")]
    pub fallback: String,

    #[serde(default = "default_assets_gzip")]
    pub gzip: bool,
}

fn default_assets_url() -> String {
    "/public".to_string()
}

fn default_assets_path() -> String {
    "public".to_string()
}

fn default_assets_fallback() -> String {
    "public/404.html".to_string()
}

fn default_assets_gzip() -> bool {
    true
}

impl Default for Asset {
    fn default() -> Self {
        default::<Self>().expect("Failed to get default value")
    }
}