<commit_before>use std::rc::Rc;

use super::{config, Conditions, Message, TimerEvent};
use state::State;

#[derive(Debug)]
pub struct Context {
    conditions: Conditions,
    state: State
}

impl Context {
    pub fn new(conditions: Conditions) -> Context {
        Context {
            conditions: conditions,
            state: State::new()
        }
    }

    pub fn on_timer(&mut self, event: &TimerEvent) {
        self.conditions.on_timer(event, &mut self.state);
    }

    pub fn on_message(&mut self, event: Rc<Message>) {
        self.conditions.on_message(event, &mut self.state);<commit_msg>refactor Context into an enum<commit_after>use std::rc::Rc;

use super::{config, Conditions, Message, TimerEvent};
use state::State;

#[derive(Debug)]
pub enum Context {
    Linear(LinearContext),
}

impl Context {
    pub fn on_timer(&mut self, event: &TimerEvent) {
        match *self {
            Context::Linear(ref mut context) => context.on_timer(event)
        }
    }

    pub fn on_message(&mut self, event: Rc<Message>) {
        match *self {
            Context::Linear(ref mut context) => context.on_message(event)
        }
    }

    pub fn is_open(&self) -> bool {
        match *self {
            Context::Linear(ref context) => context.is_open()
        }
    }

    pub fn new(conditions: Conditions) -> Context {
        Context::Linear(
            LinearContext {
                conditions: conditions,
                state: State::new()
            }
        )
    }
}

#[derive(Debug)]
pub struct LinearContext {
    conditions: Conditions,
    state: State
}

impl LinearContext {
    pub fn on_timer(&mut self, event: &TimerEvent) {
        self.conditions.on_timer(event, &mut self.state);
    }

    pub fn on_message(&mut self, event: Rc<Message>) {
        self.conditions.on_message(event, &mut self.state);
{'fraction_non_alphanumeric': 0.12547322877230935, 'fraction_numerical': 0.0, 'mean_word_length': 2.5238095238095237, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '712299', 'n_tokens_mistral': 564, 'n_tokens_neox': 551, 'n_words': 138}