summaryrefslogtreecommitdiffstats
path: root/src/client.rs
blob: 3557df8d104ee7f1f4201b21a0b6f1bda1a070f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use super::events::*;

pub fn event_handler<F>(f: F) -> Box<dyn FnMut(Event)>
        where F: FnMut(Event) + 'static
    {
        Box::new(f)
    }

pub struct FlicClient {
    map: Vec<Box<dyn FnMut(Event)>>,
}

impl FlicClient {
    pub fn new() -> FlicClient {
        FlicClient{map: vec![]}
    }
    pub fn register_event_handler(mut self, event: Box<dyn FnMut(Event)>) -> Self {
        self.map.push(event);
        self
    }
}