lyrs/src/state.rs

27 lines
527 B
Rust
Raw Normal View History

2024-05-15 16:48:23 -05:00
use crate::{
prelude::*,
templates::{TemplateLoadError, Templates},
};
2024-05-14 12:28:27 -05:00
use std::sync::Arc;
#[derive(Clone)]
pub struct State {
pub templates: Arc<Templates>,
}
impl State {
2024-05-15 16:48:23 -05:00
pub async fn try_new() -> Result<Self, NewStateError> {
2024-05-14 12:28:27 -05:00
let templates = Arc::new(Templates::try_load("src/templates").await?);
Ok(Self { templates })
}
}
2024-05-15 16:48:23 -05:00
use thiserror::Error;
#[derive(Error, Debug)]
pub enum NewStateError {
#[error("template load error: {0}")]
TemplateLoad(#[from] TemplateLoadError),
}