pzzld-server 0.0.2

A production ready server optimized for WASM applications
Documentation
/*
    Appellation: interface <module>
    Contrib: @FL03
*/
pub use self::inner::Context;

mod inner;

use crate::config::Settings;
use std::sync::Arc;

#[derive(Clone, Debug)]
pub struct Platform {
    pub(crate) inner: Arc<Context>,
}

impl Platform {
    pub fn new() -> super::Initializer {
        super::Initializer::new(Settings::build().unwrap_or_default())
    }

    pub fn from_config(config: Settings) -> super::Initializer {
        super::Initializer::new(config)
    }

    pub fn inner(&self) -> &Context {
        &self.inner
    }

    pub fn inner_mut(&mut self) -> &mut Context {
        Arc::make_mut(&mut self.inner)
    }
}

impl core::ops::Deref for Platform {
    type Target = Context;

    fn deref(&self) -> &Self::Target {
        self.inner()
    }
}

impl core::ops::DerefMut for Platform {
    fn deref_mut(&mut self) -> &mut Self::Target {
        self.inner_mut()
    }
}