Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
use std::{ops::Deref, sync::Arc};
|
||||
|
||||
use crate::server::config::ServerConfig;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SharedState(Arc<State>);
|
||||
|
||||
impl SharedState {
|
||||
pub async fn new() -> anyhow::Result<Self> {
|
||||
Ok(Self(Arc::new(State::new().await?)))
|
||||
pub async fn new(config: ServerConfig) -> anyhow::Result<Self> {
|
||||
Ok(Self(Arc::new(State::new(config).await?)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +25,12 @@ impl Deref for SharedState {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct State {}
|
||||
pub struct State {
|
||||
pub config: ServerConfig,
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub async fn new() -> anyhow::Result<Self> {
|
||||
Ok(Self {})
|
||||
pub async fn new(config: ServerConfig) -> anyhow::Result<Self> {
|
||||
Ok(Self { config })
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user