use std::path::PathBuf;
use std::sync::Arc;
use async_trait::async_trait;
use tokio::sync::RwLock;
use crate::catalog::graph::CatalogGraph;
use crate::catalog::hydrate::Catalog;
use crate::map_server::error::MapServerError;
use crate::priority::graph::PriorityGraph;
pub(crate) struct DataStores {
#[expect(
dead_code,
reason = "stored alongside priority_graph for atomic refresh; not yet read directly by handlers"
)]
pub(crate) catalog: Catalog,
pub(crate) priority_graph: PriorityGraph,
pub(crate) graph: CatalogGraph,
}
pub(crate) struct AppState {
pub(crate) root: PathBuf,
pub(crate) stores: Arc<RwLock<DataStores>>,
pub(crate) dot_renderer: Arc<dyn DotRenderer>,
}
pub(crate) struct Config {
pub(crate) root: PathBuf,
#[expect(dead_code, reason = "serve() now hydrates stores from root at startup")]
pub(crate) graph: CatalogGraph,
pub(crate) port: u16,
pub(crate) open: bool,
pub(crate) focus: Option<String>,
pub(crate) depth: u8,
}
#[async_trait]
pub(crate) trait DotRenderer: Send + Sync {
async fn render_svg(&self, _dot: &[u8]) -> Result<Vec<u8>, MapServerError>;
}
pub(crate) struct RealDotRenderer;