pzzld_server/platform/
interface.rs

1/*
2    Appellation: interface <module>
3    Contrib: @FL03
4*/
5pub use self::inner::Context;
6
7mod inner;
8
9use crate::config::Settings;
10use std::sync::Arc;
11
12#[derive(Clone, Debug)]
13pub struct Platform {
14    pub(crate) inner: Arc<Context>,
15}
16
17impl Platform {
18    pub fn new() -> super::Initializer {
19        super::Initializer::new(Settings::build().unwrap_or_default())
20    }
21
22    pub fn from_config(config: Settings) -> super::Initializer {
23        super::Initializer::new(config)
24    }
25
26    pub fn inner(&self) -> &Context {
27        &self.inner
28    }
29
30    pub fn inner_mut(&mut self) -> &mut Context {
31        Arc::make_mut(&mut self.inner)
32    }
33}
34
35impl core::ops::Deref for Platform {
36    type Target = Context;
37
38    fn deref(&self) -> &Self::Target {
39        self.inner()
40    }
41}
42
43impl core::ops::DerefMut for Platform {
44    fn deref_mut(&mut self) -> &mut Self::Target {
45        self.inner_mut()
46    }
47}