You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
633 B
40 lines
633 B
//! 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
|
|
}
|
|
}
|
|
|