lyrs/src/state.rs

25 lines
399 B
Rust
Raw Normal View History

2024-05-17 13:55:16 -05:00
use crate::{
db::{self, Data},
prelude::*,
};
2024-05-17 12:00:37 -05:00
use thiserror::Error;
2024-05-14 12:28:27 -05:00
#[derive(Clone)]
pub struct State {
2024-05-20 11:35:39 -05:00
pub db: Data,
2024-05-14 12:28:27 -05:00
}
impl State {
2024-05-20 11:35:39 -05:00
pub async fn try_new() -> Result<Self, NewStateError> {
2024-05-17 12:00:37 -05:00
Ok(Self {
2024-05-20 11:35:39 -05:00
db: Data::try_new()?,
2024-05-17 12:00:37 -05:00
})
2024-05-14 12:28:27 -05:00
}
}
2024-05-15 16:48:23 -05:00
#[derive(Error, Debug)]
pub enum NewStateError {
2024-05-17 12:00:37 -05:00
#[error("database error: {0}")]
2024-05-20 11:35:39 -05:00
Database(#[from] db::Error),
2024-05-15 16:48:23 -05:00
}