use super::global_state::FrozenGlobalState;
use crate::path::{PathMaybeWithLocale, PathWithoutLocale};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FrozenApp {
pub global_state: FrozenGlobalState,
pub route: Option<PathMaybeWithLocale>,
pub state_store: HashMap<PathMaybeWithLocale, String>,
}
#[derive(Debug, Clone)]
pub struct ThawPrefs {
pub page: PageThawPrefs,
pub global_prefer_frozen: bool,
}
#[derive(Debug, Clone)]
pub enum PageThawPrefs {
Include(Vec<String>),
IncludeAll,
Exclude(Vec<String>),
}
impl PageThawPrefs {
pub(crate) fn should_prefer_frozen_state(&self, url: &PathWithoutLocale) -> bool {
match &self {
Self::Include(pages) => pages.iter().any(|v| v == &**url),
Self::IncludeAll => true,
Self::Exclude(pages) => !pages.iter().any(|v| v == &**url),
}
}
}