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 dac5c83
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 3 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,8 @@ impl DBClient {
})
}


#[doc(hidden)]
pub async fn delete_db(&self) {
self.database.drop(None).await.expect("couldn't drop db");
}
Expand Down
3 changes: 3 additions & 0 deletions server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#![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
2 changes: 1 addition & 1 deletion server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! - `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 dac5c83

Please sign in to comment.