//! Main site server.

use std::path::{Path, PathBuf};

use arc_swap::ArcSwapOption;
use smol::lock::Mutex;

use crate::site::mfload::LoadState;

mod file;
mod handler;
mod mfload;
mod xman;

/// Main engine for serving static sites.
pub struct SiteEngine {
    root: PathBuf,
    manifest_file: PathBuf,
    manifest_state: ArcSwapOption<LoadState>,
    manifest_lock: Mutex<()>,
}

impl SiteEngine {
    /// Create a new site engine.
    pub fn create(root: &Path, manifest: &Path) -> SiteEngine {
        SiteEngine {
            root: root.to_path_buf(),
            manifest_file: manifest.to_path_buf(),
            manifest_state: ArcSwapOption::empty(),
            manifest_lock: Mutex::new(()),
        }
    }
}
