diff --git a/aw-client-rust/tests/test.rs b/aw-client-rust/tests/test.rs index 5e728aaf..c6634700 100644 --- a/aw-client-rust/tests/test.rs +++ b/aw-client-rust/tests/test.rs @@ -27,9 +27,7 @@ mod test { Ok(_) => break, Err(err) => { if i == timeout_s - 1 { - panic!( - "Timed out starting aw-server after {timeout_s}s: {err:?}" - ); + panic!("Timed out starting aw-server after {timeout_s}s: {err:?}"); } } } diff --git a/aw-datastore/src/worker.rs b/aw-datastore/src/worker.rs index 63f7e9cb..86f82ae7 100644 --- a/aw-datastore/src/worker.rs +++ b/aw-datastore/src/worker.rs @@ -135,9 +135,9 @@ impl DatastoreWorker { if self.legacy_import { let transaction = match conn.transaction_with_behavior(TransactionBehavior::Immediate) { Ok(transaction) => transaction, - Err(err) => panic!( - "Unable to start immediate transaction on SQLite database! {err}" - ), + Err(err) => { + panic!("Unable to start immediate transaction on SQLite database! {err}") + } }; match ds.ensure_legacy_import(&transaction) { Ok(_) => (), diff --git a/aw-datastore/tests/datastore.rs b/aw-datastore/tests/datastore.rs index bf3375d0..746c8e85 100644 --- a/aw-datastore/tests/datastore.rs +++ b/aw-datastore/tests/datastore.rs @@ -34,8 +34,6 @@ mod datastore_tests { } } - #[cfg(not(target_os = "android"))] - #[cfg(not(target_os = "android"))] use std::fs; use std::path::PathBuf; diff --git a/aw-models/src/bucket.rs b/aw-models/src/bucket.rs index fa43635d..c0537d2b 100644 --- a/aw-models/src/bucket.rs +++ b/aw-models/src/bucket.rs @@ -30,16 +30,13 @@ pub struct Bucket { pub last_updated: Option>, // TODO: Should probably be moved into metadata field } -#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug)] -#[derive(Default)] +#[derive(Serialize, Deserialize, JsonSchema, Clone, Debug, Default)] pub struct BucketMetadata { #[serde(default)] pub start: Option>, pub end: Option>, } - - #[derive(Serialize, Deserialize, JsonSchema, Clone)] pub struct BucketsExport { pub buckets: HashMap, diff --git a/aw-models/src/event.rs b/aw-models/src/event.rs index 1160840f..3b62b28b 100644 --- a/aw-models/src/event.rs +++ b/aw-models/src/event.rs @@ -40,8 +40,7 @@ impl Event { } } pub fn calculate_endtime(&self) -> DateTime { - self.timestamp - + chrono::Duration::nanoseconds(self.duration.num_nanoseconds().unwrap()) + self.timestamp + chrono::Duration::nanoseconds(self.duration.num_nanoseconds().unwrap()) } pub fn interval(&self) -> TimeInterval { TimeInterval::new(self.timestamp, self.calculate_endtime()) diff --git a/aw-models/src/tryvec.rs b/aw-models/src/tryvec.rs index 35b65dd4..60716ce4 100644 --- a/aw-models/src/tryvec.rs +++ b/aw-models/src/tryvec.rs @@ -119,9 +119,7 @@ where let res = match access.next_element() { Ok(val) => val, Err(err) => { - println!( - "Failed to parse event because '{err}', the event will be discarded" - ); + println!("Failed to parse event because '{err}', the event will be discarded"); continue; } }; diff --git a/aw-query/src/functions.rs b/aw-query/src/functions.rs index 31c8f1e5..53e7d9bb 100644 --- a/aw-query/src/functions.rs +++ b/aw-query/src/functions.rs @@ -212,11 +212,14 @@ mod qfunctions { ))) } }; - let bucketname = - match aw_transform::find_bucket(&bucket_filter, &hostname_filter, buckets.values()) { - Some(bucketname) => bucketname, - None => { - return Err(QueryError::BucketQueryError(match hostname_filter { + let bucketname = match aw_transform::find_bucket( + &bucket_filter, + &hostname_filter, + buckets.values(), + ) { + Some(bucketname) => bucketname, + None => { + return Err(QueryError::BucketQueryError(match hostname_filter { None => { format!("Failed to find bucket matching filter '{bucket_filter}'") } @@ -224,8 +227,8 @@ mod qfunctions { "Failed to find bucket matching filter '{bucket_filter}' and hostname '{hostname_filter}'" ), })); - } - }; + } + }; Ok(DataType::String(bucketname)) } diff --git a/aw-query/tests/query.rs b/aw-query/tests/query.rs index a6f92db6..71969aaa 100644 --- a/aw-query/tests/query.rs +++ b/aw-query/tests/query.rs @@ -20,7 +20,7 @@ macro_rules! json_map { #[cfg(test)] mod query_tests { - + use chrono::Duration; use serde_json::json; use std::convert::TryFrom; diff --git a/aw-server/src/endpoints/bucket.rs b/aw-server/src/endpoints/bucket.rs index fec7e816..c77a6d9c 100644 --- a/aw-server/src/endpoints/bucket.rs +++ b/aw-server/src/endpoints/bucket.rs @@ -82,9 +82,8 @@ pub fn bucket_events_get( Some(dt_str) => match DateTime::parse_from_rfc3339(&dt_str) { Ok(dt) => Some(dt.with_timezone(&Utc)), Err(e) => { - let err_msg = format!( - "Failed to parse endtime, datetime needs to be in rfc3339 format: {e}" - ); + let err_msg = + format!("Failed to parse endtime, datetime needs to be in rfc3339 format: {e}"); warn!("{}", err_msg); return Err(HttpErrorJson::new(Status::BadRequest, err_msg)); } diff --git a/aw-sync/tests/sync.rs b/aw-sync/tests/sync.rs index f4062b94..7de35c97 100644 --- a/aw-sync/tests/sync.rs +++ b/aw-sync/tests/sync.rs @@ -151,8 +151,7 @@ mod sync_tests { &SyncSpec::default(), ); - let all_datastores: Vec<&Datastore> = - [&state.ds_src, &state.ds_dest].to_vec(); + let all_datastores: Vec<&Datastore> = [&state.ds_src, &state.ds_dest].to_vec(); let all_buckets_map = get_all_buckets_map(all_datastores); // Check that all synced buckets are identical to source bucket @@ -190,8 +189,7 @@ mod sync_tests { &SyncSpec::default(), ); - let all_datastores: Vec<&Datastore> = - [&state.ds_src, &state.ds_dest].to_vec(); + let all_datastores: Vec<&Datastore> = [&state.ds_src, &state.ds_dest].to_vec(); let all_buckets_map = get_all_buckets_map(all_datastores); // Check that all synced buckets are identical to source bucket diff --git a/aw-transform/src/filter_period.rs b/aw-transform/src/filter_period.rs index 910ae1af..6ab5c00f 100644 --- a/aw-transform/src/filter_period.rs +++ b/aw-transform/src/filter_period.rs @@ -81,8 +81,7 @@ mod tests { data: json_map! {"test": json!(1)}, }; - let filtered_events = - filter_period_intersect(&vec![e1, e2, e3, e4, e5], &[filter_event]); + let filtered_events = filter_period_intersect(&vec![e1, e2, e3, e4, e5], &[filter_event]); assert_eq!(filtered_events.len(), 3); assert_eq!(filtered_events[0].duration, Duration::milliseconds(500)); assert_eq!(filtered_events[1].duration, Duration::milliseconds(1000));