Skip to content

Commit

Permalink
Clippy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ecton committed Nov 27, 2023
1 parent c01f891 commit f501aef
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion crates/bonsaidb-core/src/key/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ pub mod limited {
/// to be converted to a value relative to the unix epoch.
pub fn to_timestamp_string(&self) -> Result<String, TimeError> {
let mut string = String::new();
self.display(&mut string).map(|_| string)
self.display(&mut string).map(|()| string)
}

fn display(&self, f: &mut impl Write) -> Result<(), TimeError> {
Expand Down
7 changes: 2 additions & 5 deletions crates/bonsaidb-core/src/schema/schematic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,10 @@ impl Schematic {
let unique_views = self
.eager_views_by_collection
.entry(collection.clone())
.or_insert_with(Vec::new);
.or_default();
unique_views.push(TypeId::of::<V>());
}
let views = self
.views_by_collection
.entry(collection)
.or_insert_with(Vec::new);
let views = self.views_by_collection.entry(collection).or_default();
views.push(TypeId::of::<V>());

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-files/src/direct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ impl<'a, Config: FileConfig, Database: AsyncConnection + Clone + 'static> tokio:
}
} else if self.buffer.capacity() == self.buffer.len() {
match ready!(std::pin::Pin::new(&mut self).poll_flush(cx)) {
Ok(_) => {}
Ok(()) => {}
Err(err) => {
return Poll::Ready(Err(err));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-local/src/database/keyvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ pub fn background_worker(
// fails. So, we will cap the sleep time at 1 day.
let remaining = remaining.min(Duration::from_secs(60 * 60 * 24));
match timestamp_receiver.watch_timeout(remaining) {
Ok(_) | Err(watchable::TimeoutError::Timeout) => {
Ok(()) | Err(watchable::TimeoutError::Timeout) => {
perform_operations = true;
}
Err(watchable::TimeoutError::Disconnected) => break,
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-local/src/database/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl PubSub for super::Database {
pubsub_topic_resource_name(self.name(), &topic),
&BonsaiAction::Database(DatabaseAction::PubSub(PubSubAction::Publish)),
)
.map(|_| OwnedBytes::from(database_topic(&self.data.name, &topic)))
.map(|()| OwnedBytes::from(database_topic(&self.data.name, &topic)))
})
.collect::<Result<Vec<_>, _>>()?,
payload,
Expand Down
9 changes: 4 additions & 5 deletions crates/bonsaidb-local/src/hpke_util.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use generic_array::GenericArray;
use hpke::{
kem::{DhP256HkdfSha256, Kem as KemTrait},
Deserializable, Serializable,
};
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use hpke::kem::{DhP256HkdfSha256, Kem as KemTrait};
use hpke::{Deserializable, Serializable};
use serde::de::Error;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

// Helpful aliases for the HPKE types we use in vault encryption

Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-local/src/storage/argon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl HashingThread {
let argon = Argon2::new(algorithm, version, argon2::Params::try_from(&hash)?);

hash.verify_password(&[&argon], request.password.0.as_bytes())
.map(|_| HashResponse::Verified)
.map(|()| HashResponse::Verified)
.map_err(Error::from)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-local/src/tasks/manager/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ where
id: Id,
) -> Handle<T, E> {
let (sender, receiver) = flume::bounded(1);
let senders = self.result_senders.entry(id).or_insert_with(Vec::default);
let senders = self.result_senders.entry(id).or_default();
senders.push(Box::new(sender));

Handle { id, receiver }
Expand Down
10 changes: 5 additions & 5 deletions crates/bonsaidb-local/src/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
//! used directly. This variant of `ChaCha20Poly1305` extends the nonce from 12
//! bytes to 24 bytes, which allows for random nonces to be used.
use crate::hpke_util::{
serde_encapped_key, serde_privkey, serde_pubkey, VaultP256EncappedKey, VaultP256Kem,
VaultP256PrivateKey, VaultP256PublicKey,
};

use std::borrow::Cow;
use std::collections::HashMap;
use std::fmt::{Debug, Display};
Expand All @@ -76,6 +71,11 @@ use rand::{thread_rng, Rng};
use serde::{Deserialize, Serialize};
use zeroize::{Zeroize, Zeroizing};

use crate::hpke_util::{
serde_encapped_key, serde_privkey, serde_pubkey, VaultP256EncappedKey, VaultP256Kem,
VaultP256PrivateKey, VaultP256PublicKey,
};

/// A private encryption key.
#[derive(Serialize, Deserialize)]
pub enum KeyPair {
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-local/src/views/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl<'a> DocumentRequest<'a> {
let key_mappings = batch
.new_mappings
.entry(ArcBytes::from(mapping.key.to_vec()))
.or_insert_with(Vec::default);
.or_default();
key_mappings.push(mapping);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bonsaidb-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn core_path() -> Path {
() if cfg!(feature = "server-path") => parse_quote!(::bonsaidb_server::core),
() if cfg!(feature = "local-path") => parse_quote!(::bonsaidb_local::core),
() if cfg!(feature = "client-path") => parse_quote!(::bonsaidb_client::core),
_ => parse_quote!(::bonsaidb_core),
() => parse_quote!(::bonsaidb_core),
},
},
}
Expand Down

0 comments on commit f501aef

Please sign in to comment.