kjuulh ee323e99e8
All checks were successful
continuous-integration/drone/push Build is passing
feat: add discovery
Signed-off-by: kjuulh <contact@kjuulh.io>
2024-11-24 17:12:15 +01:00

37 lines
692 B
Rust

use std::{ops::Deref, sync::Arc};
use crate::server::config::ServerConfig;
#[derive(Clone)]
pub struct SharedState(Arc<State>);
impl SharedState {
pub async fn new(config: ServerConfig) -> anyhow::Result<Self> {
Ok(Self(Arc::new(State::new(config).await?)))
}
}
impl From<&SharedState> for SharedState {
fn from(value: &SharedState) -> Self {
value.clone()
}
}
impl Deref for SharedState {
type Target = Arc<State>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
pub struct State {
pub config: ServerConfig,
}
impl State {
pub async fn new(config: ServerConfig) -> anyhow::Result<Self> {
Ok(Self { config })
}
}