diff options
-rwxr-xr-x | Cargo.lock | 1 | ||||
-rwxr-xr-x | Cargo.toml | 1 | ||||
-rwxr-xr-x | examples/simpleclient.rs | 5 | ||||
-rwxr-xr-x | src/client.rs | 6 | ||||
-rwxr-xr-x | src/events/stream_mapper.rs | 2 |
5 files changed, 6 insertions, 9 deletions
@@ -48,7 +48,6 @@ dependencies = [ name = "flicbtn" version = "0.1.0" dependencies = [ - "bytes", "futures", "num_enum", "regex", @@ -7,7 +7,6 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bytes = "0.5" futures = "0.3.5" num_enum = "0.4.2" regex = "1" diff --git a/examples/simpleclient.rs b/examples/simpleclient.rs index 52b4300..628edda 100755 --- a/examples/simpleclient.rs +++ b/examples/simpleclient.rs @@ -40,10 +40,9 @@ async fn main() -> Result<()> { let mut input = String::new(); stdin().read_line(&mut input).expect("Did not enter correct string!"); + let input = input.trim(); - println!("[{}]", &input.as_str()[0..input.len()-2]); - - match &input.as_str()[..input.len()-2] { + match input.as_str() { "X" => break, "1" => { println!("-- start scan wizard"); diff --git a/src/client.rs b/src/client.rs index a1a63f7..82781e8 100755 --- a/src/client.rs +++ b/src/client.rs @@ -12,11 +12,11 @@ use super::events::stream_mapper::*; use super::commands::stream_mapper::CommandToByteMapper; use super::commands::Command; -type EventClosure = dyn FnMut(Event) + Sync + Send + 'static; +type EventClosure = dyn FnMut(&Event) + Sync + Send + 'static; type EventClosureMutex = Box<EventClosure>; pub fn event_handler<F>(f: F) -> EventClosureMutex - where F: FnMut(Event) + Sync + Send + 'static + where F: FnMut(&Event) + Sync + Send + 'static { Box::new(f) } @@ -72,7 +72,7 @@ impl FlicClient { EventResult::Some(event) => { let mut map = self.map.lock().await; for ref mut f in &mut *map { - f(event.clone()); + f(&event); } } _ => {} diff --git a/src/events/stream_mapper.rs b/src/events/stream_mapper.rs index 5244d58..1dc6b60 100755 --- a/src/events/stream_mapper.rs +++ b/src/events/stream_mapper.rs @@ -54,7 +54,7 @@ impl ByteToEventMapper { } - pub fn has_packet(&self) -> HasPacketResult { + fn has_packet(&self) -> HasPacketResult { match (self.fifo.get(0), self.fifo.get(1), self.fifo.get(2)) { (Some(&lower), Some(&upper), Some(&opcode)) => { let len = ((upper as usize) << 8) + (lower as usize); |