1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use core::fmt::Debug;
use downcast_rs::{impl_downcast, Downcast};
use crate::state::StateManager;
use crate::ExtractorValue;
pub mod state;
mod u16_filter;
pub use u16_filter::*;
mod flip_flop_filter;
pub use flip_flop_filter::*;
mod count_filter;
pub use count_filter::*;
pub const U8_INCREMENT_STATE_FILTER: u16 = 0x0000;
pub const U16_IS_EQUAL_FILTER_CODE: u16 = 0x0001;
pub const U32_IS_EQUAL_STATE_FILTER_CODE: u16 = 0x0002;
pub const U32_INCREMENT_STATE_FILTER_CODE: u16 = 0x0003;
pub const U32_SET_STATE_FILTER_CODE: u16 = 0x0004;
pub const FLIP_FLOP_FILTER_CODE: u16 = 0x0005;
pub const COUNT_FILTER_CODE: u16 = 0x0006;
pub const COUNT_STATE_FILTER_CODE: u16 = 0x0007;
pub const BOOL_IS_EQUAL_STATE_FILTER_CODE: u16 = 0x0008;
pub const BOOL_SET_STATE_FILTER_CODE: u16 = 0x0009;
#[derive(Debug, PartialEq)]
pub enum FilterError {
WrongValueType,
WrongStateType
}
pub trait Filter: Downcast + Debug {
fn filter(&mut self, value: &ExtractorValue, state_manager: &mut StateManager) -> Result<bool, FilterError>;
}
impl_downcast!(Filter);