chore: rust fmpt

This commit is contained in:
realaravinth
2022-05-10 22:48:07 +05:30
parent b7a8716a82
commit 1d8554cb36
7 changed files with 16 additions and 15 deletions

View File

@@ -17,8 +17,6 @@
//! Test utilities //! Test utilities
use crate::prelude::*; use crate::prelude::*;
pub async fn database_works<'a, T: MCDatabase>( pub async fn database_works<'a, T: MCDatabase>(db: &T) {
db: &T,
) {
unimplemented!("database tests"); unimplemented!("database tests");
} }

View File

@@ -18,8 +18,8 @@ use db_core::dev::*;
use std::str::FromStr; use std::str::FromStr;
use sqlx::postgres::PgPoolOptions; use sqlx::postgres::PgPoolOptions;
use sqlx::PgPool;
use sqlx::types::time::OffsetDateTime; use sqlx::types::time::OffsetDateTime;
use sqlx::PgPool;
pub mod errors; pub mod errors;
#[cfg(test)] #[cfg(test)]

View File

@@ -1,4 +1,3 @@
/* /*
* Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net> * Copyright (C) 2022 Aravinth Manivannan <realaravinth@batsense.net>
* *

View File

@@ -72,7 +72,6 @@ pub fn handle_embedded_file(path: &str) -> HttpResponse {
} }
} }
#[my_codegen::get(path = "DOCS.assets")] #[my_codegen::get(path = "DOCS.assets")]
async fn dist(path: web::Path<String>) -> impl Responder { async fn dist(path: web::Path<String>) -> impl Responder {
handle_embedded_file(&path) handle_embedded_file(&path)

View File

@@ -121,7 +121,6 @@ impl Settings {
pub fn new() -> Result<Self, ConfigError> { pub fn new() -> Result<Self, ConfigError> {
let mut s = Config::new(); let mut s = Config::new();
const CURRENT_DIR: &str = "./config/default.toml"; const CURRENT_DIR: &str = "./config/default.toml";
const ETC: &str = "/etc/mcaptcha/config.toml"; const ETC: &str = "/etc/mcaptcha/config.toml";
@@ -163,8 +162,6 @@ impl Settings {
s.set("database.pool", 2.to_string()) s.set("database.pool", 2.to_string())
.expect("Couldn't set database pool count"); .expect("Couldn't set database pool count");
match s.try_into() { match s.try_into() {
Ok(val) => Ok(val), Ok(val) => Ok(val),
Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/mcaptcha#configuration to learn more about how mcaptcha reads configuration\n\n", e))), Err(e) => Err(ConfigError::Message(format!("\n\nError: {}. If it says missing fields, then please refer to https://github.com/mCaptcha/mcaptcha#configuration to learn more about how mcaptcha reads configuration\n\n", e))),

View File

@@ -100,7 +100,6 @@ fn handle_assets(path: &str) -> HttpResponse {
} }
} }
#[get("/assets/{_:.*}")] #[get("/assets/{_:.*}")]
pub async fn static_files(path: web::Path<String>) -> impl Responder { pub async fn static_files(path: web::Path<String>) -> impl Responder {
handle_assets(&path) handle_assets(&path)
@@ -131,7 +130,6 @@ fn handle_favicons(path: &str) -> HttpResponse {
} }
} }
#[get("/{file}")] #[get("/{file}")]
pub async fn favicons(path: web::Path<String>) -> impl Responder { pub async fn favicons(path: web::Path<String>) -> impl Responder {
debug!("searching favicons"); debug!("searching favicons");

View File

@@ -2,8 +2,10 @@ use std::sync::Arc;
use actix_web::test; use actix_web::test;
use actix_web::{ use actix_web::{
dev::ServiceResponse, error::ResponseError, http::StatusCode, body::{BoxBody, EitherBody},
body::{EitherBody, BoxBody}, dev::ServiceResponse,
error::ResponseError,
http::StatusCode,
middleware as actix_middleware, middleware as actix_middleware,
}; };
use libmcaptcha::defense::Level; use libmcaptcha::defense::Level;
@@ -110,7 +112,10 @@ pub async fn register(name: &str, email: &str, password: &str) {
} }
/// signin util /// signin util
pub async fn signin(name: &str, password: &str) -> (Arc<Data>, Login, ServiceResponse<EitherBody<BoxBody>>) { pub async fn signin(
name: &str,
password: &str,
) -> (Arc<Data>, Login, ServiceResponse<EitherBody<BoxBody>>) {
let data = Data::new().await; let data = Data::new().await;
let app = get_app!(data.clone()).await; let app = get_app!(data.clone()).await;
@@ -173,7 +178,12 @@ pub fn get_level_data() -> CreateCaptcha {
pub async fn add_levels_util( pub async fn add_levels_util(
name: &str, name: &str,
password: &str, password: &str,
) -> (Arc<data::Data>, Login, ServiceResponse<EitherBody<BoxBody>>, MCaptchaDetails) { ) -> (
Arc<data::Data>,
Login,
ServiceResponse<EitherBody<BoxBody>>,
MCaptchaDetails,
) {
let (data, creds, signin_resp) = signin(name, password).await; let (data, creds, signin_resp) = signin(name, password).await;
let cookies = get_cookie!(signin_resp); let cookies = get_cookie!(signin_resp);
let app = get_app!(data).await; let app = get_app!(data).await;