summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomeo Disca <romeo.disca@gmail.com>2020-08-20 10:56:53 +0200
committerRomeo Disca <romeo.disca@gmail.com>2020-08-20 10:56:53 +0200
commitffa296117d9f5820730acb83ac6d6771a61cefd8 (patch)
tree79243bfc7a00ee0651d9331a75b53ad2cbbc4797
parentfc00a175dda64108f4a26e4b846bf0ae9e2eabe3 (diff)
downloadflicbtn-ffa296117d9f5820730acb83ac6d6771a61cefd8.tar.gz
flicbtn-ffa296117d9f5820730acb83ac6d6771a61cefd8.tar.xz
refactor: different things
-rwxr-xr-xCargo.lock1
-rwxr-xr-xCargo.toml1
-rwxr-xr-xexamples/simpleclient.rs5
-rwxr-xr-xsrc/client.rs6
-rwxr-xr-xsrc/events/stream_mapper.rs2
5 files changed, 6 insertions, 9 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f9b2e50..ebc360e 100755
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -48,7 +48,6 @@ dependencies = [
name = "flicbtn"
version = "0.1.0"
dependencies = [
- "bytes",
"futures",
"num_enum",
"regex",
diff --git a/Cargo.toml b/Cargo.toml
index 69d3fc1..1f3bb4c 100755
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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);