parent
2cd0f81155
commit
382027647b
@ -0,0 +1,39 @@
|
||||
//! Program state management
|
||||
use super::*;
|
||||
|
||||
|
||||
/// Inner (immutable) state.
|
||||
#[derive(Debug)]
|
||||
struct StateInner
|
||||
{
|
||||
cfg: Config,
|
||||
banlist: ban::Banlist,
|
||||
}
|
||||
|
||||
/// Whole program state
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct State(Arc<StateInner>);
|
||||
|
||||
impl State
|
||||
{
|
||||
pub fn new(cfg: Config) -> Self
|
||||
{
|
||||
let banlist: ban::Banlist = cfg.static_bans.iter().collect();
|
||||
Self(Arc::new(StateInner {
|
||||
banlist,
|
||||
cfg,
|
||||
}))
|
||||
}
|
||||
|
||||
/// The static config the program was started on.
|
||||
#[inline] pub fn cfg(&self) -> &Config
|
||||
{
|
||||
&self.0.cfg
|
||||
}
|
||||
|
||||
#[inline] pub fn banlist(&self) -> &ban::Banlist
|
||||
{
|
||||
&self.0.banlist
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue