2019-08-31 14:07:45 +00:00
|
|
|
use crate::matcher::{Match, MatchReceiver};
|
|
|
|
use crate::keyboard::KeyboardSender;
|
|
|
|
|
|
|
|
pub struct Engine<'a>{
|
2019-09-01 18:46:46 +00:00
|
|
|
sender: &'a dyn KeyboardSender
|
2019-08-31 14:07:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl <'a> Engine<'a> {
|
2019-09-01 18:46:46 +00:00
|
|
|
pub fn new(sender: &'a dyn KeyboardSender) -> Engine<'a> {
|
2019-08-31 14:07:45 +00:00
|
|
|
Engine{sender}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl <'a> MatchReceiver for Engine<'a>{
|
2019-08-31 15:00:23 +00:00
|
|
|
fn on_match(&self, m: &Match) {
|
2019-08-31 14:07:45 +00:00
|
|
|
self.sender.delete_string(m.trigger.len() as i32);
|
|
|
|
self.sender.send_string(m.result.as_str());
|
|
|
|
}
|
|
|
|
}
|