From 51f4a63f5a6c3c64d1f199371f0807ae355477db Mon Sep 17 00:00:00 2001 From: kruserr <46799551+kruserr@users.noreply.github.com> Date: Sun, 26 May 2024 17:25:53 +0000 Subject: [PATCH] fix: clippy warnings --- rapiddb/src/db/mmav_db/mmav_async_database.rs | 8 ++++++-- rapiddb/src/db/mmav_db/mmav_database.rs | 8 ++++++-- rapiddb/src/db/mmav_db/mmav_unit.rs | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/rapiddb/src/db/mmav_db/mmav_async_database.rs b/rapiddb/src/db/mmav_db/mmav_async_database.rs index c12fce4..fb8efae 100644 --- a/rapiddb/src/db/mmav_db/mmav_async_database.rs +++ b/rapiddb/src/db/mmav_db/mmav_async_database.rs @@ -107,6 +107,7 @@ impl MMAVAsyncDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(&file_name) .unwrap_or_else(|error| { if error.kind() == std::io::ErrorKind::NotFound { @@ -126,6 +127,7 @@ impl MMAVAsyncDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(file_name) .unwrap() }); @@ -155,7 +157,7 @@ impl Default for MMAVAsyncDatabase { #[async_trait::async_trait] impl IAsyncDatabase for MMAVAsyncDatabase { async fn contains(&self, id: &str) -> bool { - self.sensors.get(id).is_some() + self.sensors.contains_key(id) } async fn get(&mut self, id: &str, rec_id: usize) -> Vec { @@ -215,6 +217,7 @@ impl IAsyncDatabase for MMAVAsyncDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(&file_name) .unwrap_or_else(|error| { if error.kind() == std::io::ErrorKind::NotFound { @@ -234,6 +237,7 @@ impl IAsyncDatabase for MMAVAsyncDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(file_name) .unwrap() }); @@ -243,7 +247,7 @@ impl IAsyncDatabase for MMAVAsyncDatabase { } async fn get_aggregates(&self, id: &str) -> Vec { - if self.aggregates.get(id).is_none() { + if !self.aggregates.contains_key(id) { return Default::default(); } diff --git a/rapiddb/src/db/mmav_db/mmav_database.rs b/rapiddb/src/db/mmav_db/mmav_database.rs index 4996e06..b7b7163 100644 --- a/rapiddb/src/db/mmav_db/mmav_database.rs +++ b/rapiddb/src/db/mmav_db/mmav_database.rs @@ -107,6 +107,7 @@ impl MMAVDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(&file_name) .unwrap_or_else(|error| { if error.kind() == std::io::ErrorKind::NotFound { @@ -126,6 +127,7 @@ impl MMAVDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(file_name) .unwrap() }); @@ -154,7 +156,7 @@ impl Default for MMAVDatabase { } impl IDatabase for MMAVDatabase { fn contains(&self, id: &str) -> bool { - self.sensors.get(id).is_some() + self.sensors.contains_key(id) } fn get(&mut self, id: &str, rec_id: usize) -> Vec { @@ -214,6 +216,7 @@ impl IDatabase for MMAVDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(&file_name) .unwrap_or_else(|error| { if error.kind() == std::io::ErrorKind::NotFound { @@ -233,6 +236,7 @@ impl IDatabase for MMAVDatabase { .read(true) .write(true) .create(true) + .truncate(false) .open(file_name) .unwrap() }); @@ -242,7 +246,7 @@ impl IDatabase for MMAVDatabase { } fn get_aggregates(&self, id: &str) -> Vec { - if self.aggregates.get(id).is_none() { + if !self.aggregates.contains_key(id) { return Default::default(); } diff --git a/rapiddb/src/db/mmav_db/mmav_unit.rs b/rapiddb/src/db/mmav_db/mmav_unit.rs index 283646d..02351eb 100644 --- a/rapiddb/src/db/mmav_db/mmav_unit.rs +++ b/rapiddb/src/db/mmav_db/mmav_unit.rs @@ -44,6 +44,7 @@ impl MMAVUnit { .read(true) .write(true) .create(true) + .truncate(false) .open(file_name) .unwrap_or_else(|error| { if error.kind() == std::io::ErrorKind::NotFound { @@ -55,6 +56,7 @@ impl MMAVUnit { .read(true) .write(true) .create(true) + .truncate(false) .open(file_name) .unwrap() });