Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann committed Nov 1, 2021
1 parent aaaf35b commit b5a97dc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions server/src/db_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct DBClient {
}

impl DBClient {
/// Create a new mongodb client, containing the repositories used throughout the server.
pub async fn new(client_uri: impl AsRef<str>, db_name: impl AsRef<str>) -> Result<Self, Error> {
let client = Client::with_uri_str(client_uri).await?;
let database = client.database(db_name.as_ref());
Expand All @@ -28,6 +29,7 @@ impl DBClient {
})
}

#[doc(hidden)]
pub async fn delete_db(&self) {
self.database.drop(None).await.expect("couldn't drop db");
}
Expand Down
7 changes: 7 additions & 0 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#![warn(clippy::all, clippy::pedantic)]
#![allow(
clippy::unused_async,
clippy::missing_errors_doc,
clippy::must_use_candidate
)]

pub mod auth;
pub mod db_connection;
pub mod error;
Expand Down
6 changes: 5 additions & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
//! - `DELETE /users/:id`: delete a specific User.
#![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::unused_async)]
#![allow(
clippy::unused_async,
clippy::missing_errors_doc,
clippy::must_use_candidate
)]
use std::env;

use axum::{
Expand Down
4 changes: 2 additions & 2 deletions server/src/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Users {
}

pub async fn get_user_for_token(&self, token: Token) -> Result<Option<User>, Error> {
let d = to_bson(&token).unwrap();
let d = to_bson(&token)?;
self.collection
.find_one(doc! { "tokens": {"$elemMatch": {"token": d}}}, None)
.await
Expand All @@ -111,7 +111,7 @@ impl Users {
user: &User,
token: &DatedToken,
) -> Result<UpdateResult, Error> {
let d = to_bson(token).unwrap();
let d = to_bson(token)?;
self.collection
.update_one(
doc! { "username": &user.username },
Expand Down

0 comments on commit b5a97dc

Please sign in to comment.