ayun_view/
config.rs

1use ayun_config::support::default;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Serialize, Deserialize)]
5pub struct View {
6    #[serde(default = "default_path")]
7    pub path: String,
8
9    #[serde(default)]
10    pub asset: Asset,
11}
12
13fn default_path() -> String {
14    "resources/views/**/*".to_string()
15}
16
17impl Default for View {
18    fn default() -> Self {
19        default::<Self>().expect("Failed to get default value")
20    }
21}
22
23#[derive(Debug, Serialize, Deserialize)]
24pub struct Asset {
25    #[serde(default = "default_assets_url")]
26    pub url: String,
27
28    #[serde(default = "default_assets_path")]
29    pub path: String,
30
31    #[serde(default = "default_assets_fallback")]
32    pub fallback: String,
33
34    #[serde(default = "default_assets_gzip")]
35    pub gzip: bool,
36}
37
38fn default_assets_url() -> String {
39    "/public".to_string()
40}
41
42fn default_assets_path() -> String {
43    "public".to_string()
44}
45
46fn default_assets_fallback() -> String {
47    "public/404.html".to_string()
48}
49
50fn default_assets_gzip() -> bool {
51    true
52}
53
54impl Default for Asset {
55    fn default() -> Self {
56        default::<Self>().expect("Failed to get default value")
57    }
58}