Skip to content

Commit

Permalink
Clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed May 30, 2024
1 parent ee2ebea commit da652c2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 62 deletions.
8 changes: 4 additions & 4 deletions src/cache/backends/persistent_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl FirestorePersistentCacheBackend {
fn write_document(&self, doc: &Document) -> FirestoreResult<()> {
let (collection_path, document_id) = split_document_path(&doc.name);

if self.config.collections.get(collection_path).is_some() {
if self.config.collections.contains_key(collection_path) {
let td: TableDefinition<&str, &[u8]> = TableDefinition::new(collection_path);

let write_txn = self.redb.begin_write()?;
Expand Down Expand Up @@ -338,7 +338,7 @@ impl FirestoreCacheDocsByPathSupport for FirestorePersistentCacheBackend {
document_path: &str,
) -> FirestoreResult<Option<FirestoreDocument>> {
let (collection_path, document_id) = split_document_path(document_path);
if self.config.collections.get(collection_path).is_some() {
if self.config.collections.contains_key(collection_path) {
let td: TableDefinition<&str, &[u8]> = TableDefinition::new(collection_path);
let read_tx = self.redb.begin_read()?;
let table = read_tx.open_table(td)?;
Expand All @@ -359,7 +359,7 @@ impl FirestoreCacheDocsByPathSupport for FirestorePersistentCacheBackend {
collection_path: &str,
) -> FirestoreResult<FirestoreCachedValue<BoxStream<'b, FirestoreResult<FirestoreDocument>>>>
{
if self.config.collections.get(collection_path).is_some() {
if self.config.collections.contains_key(collection_path) {
let td: TableDefinition<&str, &[u8]> = TableDefinition::new(collection_path);

let read_tx = self.redb.begin_read()?;
Expand Down Expand Up @@ -388,7 +388,7 @@ impl FirestoreCacheDocsByPathSupport for FirestorePersistentCacheBackend {
query: &FirestoreQueryParams,
) -> FirestoreResult<FirestoreCachedValue<BoxStream<'b, FirestoreResult<FirestoreDocument>>>>
{
if self.config.collections.get(collection_path).is_some() {
if self.config.collections.contains_key(collection_path) {
// For now only basic/simple query all supported
let simple_query_engine = FirestoreCacheQueryEngine::new(query);
if simple_query_engine.params_supported() {
Expand Down
2 changes: 2 additions & 0 deletions src/db/query_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum FirestoreQueryCollection {
Group(Vec<String>),
}

#[allow(clippy::to_string_trait_impl)]
impl ToString for FirestoreQueryCollection {
fn to_string(&self) -> String {
match self {
Expand Down Expand Up @@ -312,6 +313,7 @@ pub enum FirestoreQueryDirection {
Descending,
}

#[allow(clippy::to_string_trait_impl)]
impl ToString for FirestoreQueryDirection {
fn to_string(&self) -> String {
match self {
Expand Down
28 changes: 8 additions & 20 deletions src/firestore_serde/latlng_serializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,11 @@ pub fn serialize_latlng_for_firestore<T: ?Sized + Serialize>(
type Ok = FirestoreValue;
type Error = FirestoreError;

fn serialize_field<T: ?Sized>(
fn serialize_field<T: ?Sized + Serialize>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: Serialize,
{
) -> Result<(), Self::Error> {
let serializer = FirestoreValueSerializer {
none_as_null: false,
};
Expand All @@ -63,7 +60,7 @@ pub fn serialize_latlng_for_firestore<T: ?Sized + Serialize>(
FirestoreSerializationError::from_message(
"LatLng serializer doesn't recognize the structure of the object",
),
))
));
}
};

Expand Down Expand Up @@ -209,10 +206,7 @@ pub fn serialize_latlng_for_firestore<T: ?Sized + Serialize>(
))
}

fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
fn serialize_some<T: ?Sized + Serialize>(self, value: &T) -> Result<Self::Ok, Self::Error> {
value.serialize(self)
}

Expand All @@ -235,27 +229,21 @@ pub fn serialize_latlng_for_firestore<T: ?Sized + Serialize>(
self.serialize_str(variant)
}

fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T: ?Sized + Serialize>(
self,
_name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
) -> Result<Self::Ok, Self::Error> {
value.serialize(self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T: ?Sized + Serialize>(
self,
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
_value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
) -> Result<Self::Ok, Self::Error> {
Err(FirestoreError::SerializeError(
FirestoreSerializationError::from_message(
"LatLng serializer doesn't support this type",
Expand Down
19 changes: 5 additions & 14 deletions src/firestore_serde/reference_serializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,7 @@ pub fn serialize_reference_for_firestore<T: ?Sized + Serialize>(
}
}

fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
fn serialize_some<T: ?Sized + Serialize>(self, value: &T) -> Result<Self::Ok, Self::Error> {
value.serialize(self)
}

Expand All @@ -233,27 +230,21 @@ pub fn serialize_reference_for_firestore<T: ?Sized + Serialize>(
self.serialize_str(variant)
}

fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T: ?Sized + Serialize>(
self,
_name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
) -> Result<Self::Ok, Self::Error> {
value.serialize(self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T: ?Sized + Serialize>(
self,
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
_value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
) -> Result<Self::Ok, Self::Error> {
Err(FirestoreError::SerializeError(
FirestoreSerializationError::from_message(
"Reference serializer doesn't support this type",
Expand Down
14 changes: 4 additions & 10 deletions src/firestore_serde/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,11 @@ impl serde::ser::SerializeStruct for SerializeMap {
type Ok = FirestoreValue;
type Error = FirestoreError;

fn serialize_field<T: ?Sized>(
fn serialize_field<T: ?Sized + Serialize>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: Serialize,
{
) -> Result<(), Self::Error> {
let serializer = FirestoreValueSerializer {
none_as_null: self.none_as_null,
};
Expand Down Expand Up @@ -500,14 +497,11 @@ impl serde::ser::SerializeStructVariant for SerializeStructVariant {
type Ok = FirestoreValue;
type Error = FirestoreError;

fn serialize_field<T: ?Sized>(
fn serialize_field<T: ?Sized + Serialize>(
&mut self,
key: &'static str,
value: &T,
) -> Result<(), Self::Error>
where
T: Serialize,
{
) -> Result<(), Self::Error> {
let serializer = FirestoreValueSerializer {
none_as_null: self.none_as_null,
};
Expand Down
19 changes: 5 additions & 14 deletions src/firestore_serde/timestamp_serializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ pub fn serialize_timestamp_for_firestore<T: ?Sized + Serialize>(
}
}

fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
fn serialize_some<T: ?Sized + Serialize>(self, value: &T) -> Result<Self::Ok, Self::Error> {
value.serialize(self)
}

Expand All @@ -257,27 +254,21 @@ pub fn serialize_timestamp_for_firestore<T: ?Sized + Serialize>(
self.serialize_str(variant)
}

fn serialize_newtype_struct<T: ?Sized>(
fn serialize_newtype_struct<T: ?Sized + Serialize>(
self,
_name: &'static str,
value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
) -> Result<Self::Ok, Self::Error> {
value.serialize(self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T: ?Sized + Serialize>(
self,
_name: &'static str,
_variant_index: u32,
_variant: &'static str,
_value: &T,
) -> Result<Self::Ok, Self::Error>
where
T: Serialize,
{
) -> Result<Self::Ok, Self::Error> {
Err(FirestoreError::SerializeError(
FirestoreSerializationError::from_message(
"Timestamp serializer doesn't support this type",
Expand Down

0 comments on commit da652c2

Please sign in to comment.