diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 300c4683fd57ea8bb0959bbd4fe80c06c0ddf438..1e12134ea8cf8e8d87d8cf7f8f6c69e3bb4c9270 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - name: Adding component run: rustup component add rustfmt - name: Checking code format - run: cargo fmt -- --check + run: cargo fmt -- --check --config use_try_shorthand=true,imports_granularity=Crate code_check: needs: pre_job diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ffc5f67b4cb07df1375a4ab92a51bcd55dc73b3d..64c437aa70db9dc64ecdb4217a629cdf5d201daf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,9 @@ repos: pass_filenames: false args: - fmt + - -- + - --config + - use_try_shorthand=true,imports_granularity=Crate - id: clippy types: diff --git a/src/config.rs b/src/config.rs index 78dbc02e494306e708c16193dd22ef409ad1e33c..50b8b79379c6a4183f91c1c2f82f816dc52e342b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,11 +1,12 @@ -use std::ffi::OsString; -use std::path::PathBuf; +use std::{ffi::OsString, path::PathBuf}; use structopt::StructOpt; -use crate::info_storages::AvailableInfoStores; -use crate::notifiers::{Format, Hook}; -use crate::protocol::extensions::Extensions; +use crate::{ + info_storages::AvailableInfoStores, + notifiers::{Format, Hook}, + protocol::extensions::Extensions, +}; use crate::storages::AvailableStores; diff --git a/src/errors.rs b/src/errors.rs index 99eaec55d95d85aa6e020cca891801d9ed9f4bd5..c2a4f49ae14e4e504cfbb4b7abb869c81572257d 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,7 +1,6 @@ use std::io::{Error, ErrorKind}; -use actix_web::http::StatusCode; -use actix_web::{HttpResponse, HttpResponseBuilder, ResponseError}; +use actix_web::{http::StatusCode, HttpResponse, HttpResponseBuilder, ResponseError}; use log::error; pub type RustusResult<T> = Result<T, RustusError>; diff --git a/src/info_storages/db_info_storage.rs b/src/info_storages/db_info_storage.rs index baa00921259278469143b02435bdfb385d685313..74901bf4c604eeedc4b1e8c7b86d87f54458270e 100644 --- a/src/info_storages/db_info_storage.rs +++ b/src/info_storages/db_info_storage.rs @@ -1,14 +1,12 @@ use std::time::Duration; use async_trait::async_trait; -use rbatis::crud::CRUD; -use rbatis::crud_table; -use rbatis::db::DBPoolOptions; -use rbatis::executor::Executor; -use rbatis::rbatis::Rbatis; +use rbatis::{crud::CRUD, crud_table, db::DBPoolOptions, executor::Executor, rbatis::Rbatis}; -use crate::errors::{RustusError, RustusResult}; -use crate::info_storages::{FileInfo, InfoStorage}; +use crate::{ + errors::{RustusError, RustusResult}, + info_storages::{FileInfo, InfoStorage}, +}; #[crud_table] struct DbModel { @@ -84,8 +82,7 @@ impl InfoStorage for DBInfoStorage { #[cfg(test)] mod tests { use super::{DBInfoStorage, DbModel}; - use crate::info_storages::FileInfo; - use crate::InfoStorage; + use crate::{info_storages::FileInfo, InfoStorage}; use rbatis::crud::CRUD; async fn get_info_storage() -> DBInfoStorage { diff --git a/src/info_storages/file_info_storage.rs b/src/info_storages/file_info_storage.rs index 309b47a02b66b12227d401f42aadb978c664e785..a2cdf351b933153d29e310944c10d150d1adcc72 100644 --- a/src/info_storages/file_info_storage.rs +++ b/src/info_storages/file_info_storage.rs @@ -1,14 +1,20 @@ -use std::io::{Read, Write}; -use std::path::PathBuf; +use std::{ + io::{Read, Write}, + path::PathBuf, +}; use async_trait::async_trait; use log::error; -use std::fs::{remove_file, File, OpenOptions}; -use std::io::{BufReader, BufWriter}; +use std::{ + fs::{remove_file, File, OpenOptions}, + io::{BufReader, BufWriter}, +}; use tokio::fs::DirBuilder; -use crate::errors::{RustusError, RustusResult}; -use crate::info_storages::{FileInfo, InfoStorage}; +use crate::{ + errors::{RustusError, RustusResult}, + info_storages::{FileInfo, InfoStorage}, +}; pub struct FileInfoStorage { info_dir: PathBuf, @@ -94,11 +100,12 @@ impl InfoStorage for FileInfoStorage { #[cfg(test)] mod tests { use super::FileInfoStorage; - use crate::info_storages::FileInfo; - use crate::InfoStorage; - use std::collections::HashMap; - use std::fs::File; - use std::io::{Read, Write}; + use crate::{info_storages::FileInfo, InfoStorage}; + use std::{ + collections::HashMap, + fs::File, + io::{Read, Write}, + }; #[actix_rt::test] async fn preparation() { diff --git a/src/info_storages/mod.rs b/src/info_storages/mod.rs index 66338b6b0513696b27dc1f44e9f7bf2ed8e8e7b2..fe5d56d7def939ce1781511b15d650f97d8a5992 100644 --- a/src/info_storages/mod.rs +++ b/src/info_storages/mod.rs @@ -7,6 +7,6 @@ pub mod redis_info_storage; pub mod models; -pub use models::available_info_storages::AvailableInfoStores; -pub use models::file_info::FileInfo; -pub use models::info_store::InfoStorage; +pub use models::{ + available_info_storages::AvailableInfoStores, file_info::FileInfo, info_store::InfoStorage, +}; diff --git a/src/info_storages/models/available_info_storages.rs b/src/info_storages/models/available_info_storages.rs index e5e481fb556dc20e606b3745689d36b7a644447c..698190a1c37f626e464928a8aefcec65a0fef37b 100644 --- a/src/info_storages/models/available_info_storages.rs +++ b/src/info_storages/models/available_info_storages.rs @@ -1,7 +1,6 @@ use derive_more::{Display, From}; -use crate::errors::RustusResult; -use crate::{from_str, RustusConf}; +use crate::{errors::RustusResult, from_str, RustusConf}; use crate::info_storages::{file_info_storage, InfoStorage}; use strum::EnumIter; diff --git a/src/info_storages/models/file_info.rs b/src/info_storages/models/file_info.rs index 806ef3ef254b3b0f018c0a854ec2942e20311be6..42089ab3f7eee772dd8cc77fab40d27e4d361095 100644 --- a/src/info_storages/models/file_info.rs +++ b/src/info_storages/models/file_info.rs @@ -1,9 +1,7 @@ use std::collections::HashMap; -use crate::errors::RustusError; -use crate::RustusResult; -use chrono::serde::ts_seconds; -use chrono::{DateTime, Utc}; +use crate::{errors::RustusError, RustusResult}; +use chrono::{serde::ts_seconds, DateTime, Utc}; use log::error; use serde::{Deserialize, Serialize}; diff --git a/src/info_storages/models/info_store.rs b/src/info_storages/models/info_store.rs index 66418e0317343f45eb2873bdf2fa1f57ae8a3055..ec5ffe6ce1e2708909977d748cbafd40e04155bd 100644 --- a/src/info_storages/models/info_store.rs +++ b/src/info_storages/models/info_store.rs @@ -1,5 +1,4 @@ -use crate::errors::RustusResult; -use crate::info_storages::FileInfo; +use crate::{errors::RustusResult, info_storages::FileInfo}; use async_trait::async_trait; /// Trait for every info storage. diff --git a/src/info_storages/redis_info_storage.rs b/src/info_storages/redis_info_storage.rs index 01bde229674858f30f3cf02858b559f8363a2115..07adebed38a177ee15cca0439379a969b3c1c1da 100644 --- a/src/info_storages/redis_info_storage.rs +++ b/src/info_storages/redis_info_storage.rs @@ -1,11 +1,11 @@ use async_trait::async_trait; -use mobc_redis::mobc::Pool; -use mobc_redis::redis; -use mobc_redis::RedisConnectionManager; +use mobc_redis::{mobc::Pool, redis, RedisConnectionManager}; use redis::aio::Connection; -use crate::errors::{RustusError, RustusResult}; -use crate::info_storages::{FileInfo, InfoStorage}; +use crate::{ + errors::{RustusError, RustusResult}, + info_storages::{FileInfo, InfoStorage}, +}; pub struct RedisStorage { pool: Pool<RedisConnectionManager>, @@ -66,10 +66,8 @@ impl InfoStorage for RedisStorage { #[cfg(feature = "test_redis")] mod tests { use super::RedisStorage; - use crate::info_storages::FileInfo; - use crate::InfoStorage; - use mobc_redis::redis; - use mobc_redis::redis::AsyncCommands; + use crate::{info_storages::FileInfo, InfoStorage}; + use mobc_redis::{redis, redis::AsyncCommands}; async fn get_storage() -> RedisStorage { let redis_url = std::env::var("TEST_REDIS_URL").unwrap(); diff --git a/src/main.rs b/src/main.rs index 99c82d3ad4bdcaddff24d56ac63fcd9633a80240..400db9f634bc7efa98514cc4047095d7291a6821 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,25 +1,25 @@ #![cfg_attr(coverage, feature(no_coverage))] -use std::str::FromStr; -use std::sync::Arc; +use std::{str::FromStr, sync::Arc}; use actix_web::{ dev::{Server, Service}, http::Method, middleware, web, App, HttpServer, }; -use fern::colors::{Color, ColoredLevelConfig}; -use fern::Dispatch; +use fern::{ + colors::{Color, ColoredLevelConfig}, + Dispatch, +}; use log::LevelFilter; use config::RustusConf; -use crate::errors::RustusResult; -use crate::info_storages::InfoStorage; -use crate::notifiers::models::notification_manager::NotificationManager; -use crate::server::rustus_service; -use crate::state::State; -use crate::storages::Storage; +use crate::{ + errors::RustusResult, info_storages::InfoStorage, + notifiers::models::notification_manager::NotificationManager, server::rustus_service, + state::State, storages::Storage, +}; mod config; mod errors; diff --git a/src/notifiers/amqp_notifier.rs b/src/notifiers/amqp_notifier.rs index a7088f96161c65163754ff60cbc62949ca80b7fa..8810a3f76ad9e00ad5fd755bf3b6f96e13946ae4 100644 --- a/src/notifiers/amqp_notifier.rs +++ b/src/notifiers/amqp_notifier.rs @@ -1,14 +1,15 @@ -use crate::notifiers::{Hook, Notifier}; -use crate::RustusResult; +use crate::{ + notifiers::{Hook, Notifier}, + RustusResult, +}; use actix_web::http::header::HeaderMap; use async_trait::async_trait; -use lapin::options::{ - BasicPublishOptions, ExchangeDeclareOptions, QueueBindOptions, QueueDeclareOptions, +use lapin::{ + options::{BasicPublishOptions, ExchangeDeclareOptions, QueueBindOptions, QueueDeclareOptions}, + types::FieldTable, + BasicProperties, ConnectionProperties, ExchangeKind, }; -use lapin::types::FieldTable; -use lapin::{BasicProperties, ConnectionProperties, ExchangeKind}; -use mobc_lapin::mobc::Pool; -use mobc_lapin::RMQConnectionManager; +use mobc_lapin::{mobc::Pool, RMQConnectionManager}; use strum::IntoEnumIterator; use tokio_amqp::LapinTokioExt; diff --git a/src/notifiers/dir_notifier.rs b/src/notifiers/dir_notifier.rs index 73b0b9ace6a1bdb7635d22b60d173cd7f75a30c2..303b21bd518ab00c5282347f41b48332a7289ace 100644 --- a/src/notifiers/dir_notifier.rs +++ b/src/notifiers/dir_notifier.rs @@ -1,6 +1,8 @@ -use crate::errors::RustusError; -use crate::notifiers::{Hook, Notifier}; -use crate::RustusResult; +use crate::{ + errors::RustusError, + notifiers::{Hook, Notifier}, + RustusResult, +}; use actix_web::http::header::HeaderMap; use async_trait::async_trait; use log::debug; @@ -53,10 +55,12 @@ mod tests { use super::DirNotifier; use crate::notifiers::{Hook, Notifier}; use actix_web::http::header::HeaderMap; - use std::fs::File; - use std::io::{Read, Write}; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; + use std::{ + fs::File, + io::{Read, Write}, + }; use tempdir::TempDir; #[actix_rt::test] diff --git a/src/notifiers/file_notifier.rs b/src/notifiers/file_notifier.rs index 5ac7e31484df5bf543483947075878968ce474fc..911c27991358e75638d782a86bc25812b7e4dda1 100644 --- a/src/notifiers/file_notifier.rs +++ b/src/notifiers/file_notifier.rs @@ -1,6 +1,8 @@ -use crate::errors::RustusError; -use crate::notifiers::{Hook, Notifier}; -use crate::RustusResult; +use crate::{ + errors::RustusError, + notifiers::{Hook, Notifier}, + RustusResult, +}; use actix_web::http::header::HeaderMap; use async_trait::async_trait; use log::debug; @@ -47,10 +49,12 @@ mod tests { use super::FileNotifier; use crate::notifiers::{Hook, Notifier}; use actix_web::http::header::HeaderMap; - use std::fs::File; - use std::io::{Read, Write}; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; + use std::{ + fs::File, + io::{Read, Write}, + }; #[cfg(unix)] #[actix_rt::test] diff --git a/src/notifiers/http_notifier.rs b/src/notifiers/http_notifier.rs index 36956d55c315cc1d991f7c04412370e6fc32b755..a6887cc50b608bfbfa4dbad362ea92af5fd92a9b 100644 --- a/src/notifiers/http_notifier.rs +++ b/src/notifiers/http_notifier.rs @@ -67,10 +67,8 @@ mod tests { use super::HttpNotifier; use crate::notifiers::{Hook, Notifier}; use actix_web::http::header::{HeaderMap, HeaderName, HeaderValue}; - use httptest::matchers::contains; - use httptest::responders::status_code; - use std::str::FromStr; - use std::time::Duration; + use httptest::{matchers::contains, responders::status_code}; + use std::{str::FromStr, time::Duration}; #[actix_rt::test] async fn success_request() { diff --git a/src/notifiers/mod.rs b/src/notifiers/mod.rs index 03595103b447fc29583de41caaf80e1ac392c031..d9957a1451c4b2399d3b37e92ced248e1b054202 100644 --- a/src/notifiers/mod.rs +++ b/src/notifiers/mod.rs @@ -6,6 +6,4 @@ mod file_notifier; pub mod http_notifier; pub mod models; -pub use models::hooks::Hook; -pub use models::message_format::Format; -pub use models::notifier::Notifier; +pub use models::{hooks::Hook, message_format::Format, notifier::Notifier}; diff --git a/src/notifiers/models/message_format.rs b/src/notifiers/models/message_format.rs index 6d80200adfa4e025ea06af83ae26d383fdc5d4c2..9a00077e20f0f4ffaef3594de2efb0e5d89f5b98 100644 --- a/src/notifiers/models/message_format.rs +++ b/src/notifiers/models/message_format.rs @@ -1,10 +1,8 @@ -use crate::errors::RustusResult; -use crate::info_storages::FileInfo; +use crate::{errors::RustusResult, info_storages::FileInfo}; use actix_web::HttpRequest; use derive_more::{Display, From}; use serde::Serialize; -use serde_json::Map; -use serde_json::Value; +use serde_json::{Map, Value}; use std::collections::HashMap; use crate::from_str; diff --git a/src/notifiers/models/notification_manager.rs b/src/notifiers/models/notification_manager.rs index 68c2ae9dfa8e7278ac7736bd736472ecd8a217fb..441c99a389f1781db1ca739acd05842841709809 100644 --- a/src/notifiers/models/notification_manager.rs +++ b/src/notifiers/models/notification_manager.rs @@ -1,12 +1,12 @@ -use crate::errors::RustusResult; #[cfg(feature = "amqp_notifier")] use crate::notifiers::amqp_notifier; -use crate::notifiers::dir_notifier::DirNotifier; -use crate::notifiers::file_notifier::FileNotifier; #[cfg(feature = "http_notifier")] use crate::notifiers::http_notifier; -use crate::notifiers::{Hook, Notifier}; -use crate::RustusConf; +use crate::{ + errors::RustusResult, + notifiers::{dir_notifier::DirNotifier, file_notifier::FileNotifier, Hook, Notifier}, + RustusConf, +}; use actix_web::http::header::HeaderMap; use log::debug; diff --git a/src/protocol/core/get_info.rs b/src/protocol/core/get_info.rs index 8daf5d6ca747b76f0977f37c9a3f9c44a8a133de..ddb014a95ddbdde9c53ebb58390aa745d159930f 100644 --- a/src/protocol/core/get_info.rs +++ b/src/protocol/core/get_info.rs @@ -68,8 +68,10 @@ mod tests { use actix_web::http::{Method, StatusCode}; use crate::{rustus_service, State}; - use actix_web::test::{call_service, init_service, TestRequest}; - use actix_web::{web, App}; + use actix_web::{ + test::{call_service, init_service, TestRequest}, + web, App, + }; #[actix_rt::test] async fn success() { diff --git a/src/protocol/core/server_info.rs b/src/protocol/core/server_info.rs index f5217cd49d43f88ff6ea25fde34e15a3a12c468b..3648e84ea46aadf08c003be733c86aaf1b627635 100644 --- a/src/protocol/core/server_info.rs +++ b/src/protocol/core/server_info.rs @@ -19,12 +19,10 @@ pub async fn server_info(state: web::Data<State>) -> HttpResponse { #[cfg(test)] mod tests { - use crate::protocol::extensions::Extensions; - use crate::{rustus_service, State}; + use crate::{protocol::extensions::Extensions, rustus_service, State}; use actix_web::test::{call_service, init_service, TestRequest}; - use actix_web::http::Method; - use actix_web::{web, App}; + use actix_web::{http::Method, web, App}; #[actix_rt::test] async fn test_server_info() { diff --git a/src/protocol/core/write_bytes.rs b/src/protocol/core/write_bytes.rs index 9adb0b4a2f017e556cf22340aece8b3196a35db9..93cf9000bbdaeb8b632301907866ccd2a936a483 100644 --- a/src/protocol/core/write_bytes.rs +++ b/src/protocol/core/write_bytes.rs @@ -1,10 +1,12 @@ use actix_web::{web, web::Bytes, HttpRequest, HttpResponse}; -use crate::errors::RustusError; -use crate::notifiers::Hook; -use crate::protocol::extensions::Extensions; -use crate::utils::headers::{check_header, parse_header}; -use crate::{RustusResult, State}; +use crate::{ + errors::RustusError, + notifiers::Hook, + protocol::extensions::Extensions, + utils::headers::{check_header, parse_header}, + RustusResult, State, +}; pub async fn write_bytes( request: HttpRequest, @@ -125,9 +127,11 @@ pub async fn write_bytes( #[cfg(test)] mod tests { use crate::{rustus_service, State}; - use actix_web::http::StatusCode; - use actix_web::test::{call_service, init_service, TestRequest}; - use actix_web::{web, App}; + use actix_web::{ + http::StatusCode, + test::{call_service, init_service, TestRequest}, + web, App, + }; #[actix_rt::test] /// Success test for writing bytes. diff --git a/src/protocol/creation/routes.rs b/src/protocol/creation/routes.rs index 7a6828b0777df72597ee7280a7075d76a4aa0a8f..c11fe66199e1efe4d8029561b9d7f92d7ef28d07 100644 --- a/src/protocol/creation/routes.rs +++ b/src/protocol/creation/routes.rs @@ -1,13 +1,14 @@ use std::collections::HashMap; -use actix_web::web::Bytes; -use actix_web::{web, HttpRequest, HttpResponse}; +use actix_web::{web, web::Bytes, HttpRequest, HttpResponse}; -use crate::info_storages::FileInfo; -use crate::notifiers::Hook; -use crate::protocol::extensions::Extensions; -use crate::utils::headers::{check_header, parse_header}; -use crate::State; +use crate::{ + info_storages::FileInfo, + notifiers::Hook, + protocol::extensions::Extensions, + utils::headers::{check_header, parse_header}, + State, +}; /// Get metadata info from request. /// @@ -218,11 +219,12 @@ pub async fn create_file( #[cfg(test)] mod tests { - use crate::server::rustus_service; - use crate::State; - use actix_web::http::StatusCode; - use actix_web::test::{call_service, init_service, TestRequest}; - use actix_web::{web, App}; + use crate::{server::rustus_service, State}; + use actix_web::{ + http::StatusCode, + test::{call_service, init_service, TestRequest}, + web, App, + }; #[actix_rt::test] async fn success() { diff --git a/src/protocol/getting/routes.rs b/src/protocol/getting/routes.rs index f16b8b5c95dcf207d33560ad5c031c74ed43c440..6371d6e0a6b72cd76fc81479a917dd9250a72ae0 100644 --- a/src/protocol/getting/routes.rs +++ b/src/protocol/getting/routes.rs @@ -1,8 +1,7 @@ use actix_files::NamedFile; use actix_web::{web, HttpRequest}; -use crate::errors::RustusError; -use crate::{RustusResult, State}; +use crate::{errors::RustusError, RustusResult, State}; /// Retrieve actual file. /// @@ -23,9 +22,11 @@ pub async fn get_file(request: HttpRequest, state: web::Data<State>) -> RustusRe #[cfg(test)] mod test { use crate::{rustus_service, State}; - use actix_web::http::StatusCode; - use actix_web::test::{call_service, init_service, TestRequest}; - use actix_web::{web, App}; + use actix_web::{ + http::StatusCode, + test::{call_service, init_service, TestRequest}, + web, App, + }; use bytes::Bytes; #[actix_rt::test] diff --git a/src/protocol/termination/routes.rs b/src/protocol/termination/routes.rs index 33f11a92887fabed9c9d38aa480f70698d1357e9..8da92a2a941570621cf593f949f3d77a8b8e6c23 100644 --- a/src/protocol/termination/routes.rs +++ b/src/protocol/termination/routes.rs @@ -1,8 +1,10 @@ use actix_web::{web, HttpRequest, HttpResponse}; -use crate::errors::{RustusError, RustusResult}; -use crate::notifiers::Hook; -use crate::State; +use crate::{ + errors::{RustusError, RustusResult}, + notifiers::Hook, + State, +}; /// Terminate uploading. /// @@ -41,9 +43,11 @@ pub async fn terminate( #[cfg(test)] mod tests { use crate::{rustus_service, State}; - use actix_web::http::StatusCode; - use actix_web::test::{call_service, init_service, TestRequest}; - use actix_web::{web, App}; + use actix_web::{ + http::StatusCode, + test::{call_service, init_service, TestRequest}, + web, App, + }; use std::path::PathBuf; #[actix_rt::test] diff --git a/src/server.rs b/src/server.rs index b688e88e56efa212bab91fa12605aa40f01b13a6..02496d354233a73b2bdb7d160df4c9769706e5d7 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,6 +1,5 @@ use crate::{protocol, State}; -use actix_web::web::PayloadConfig; -use actix_web::{middleware, web}; +use actix_web::{middleware, web, web::PayloadConfig}; pub fn rustus_service(state: web::Data<State>) -> Box<dyn Fn(&mut web::ServiceConfig)> { Box::new(move |web_app| { diff --git a/src/storages/file_storage.rs b/src/storages/file_storage.rs index 4f348d71f725cf59d8cc65dc2b69fcbb2e2591f8..537378fc68b3826852ad10bee628df4df41ad734 100644 --- a/src/storages/file_storage.rs +++ b/src/storages/file_storage.rs @@ -1,17 +1,20 @@ -use std::io::Write; -use std::path::PathBuf; +use std::{io::Write, path::PathBuf}; use actix_files::NamedFile; use async_trait::async_trait; use bytes::Bytes; use log::error; -use std::fs::{remove_file, DirBuilder, OpenOptions}; -use std::io::{copy, BufReader, BufWriter}; +use std::{ + fs::{remove_file, DirBuilder, OpenOptions}, + io::{copy, BufReader, BufWriter}, +}; -use crate::errors::{RustusError, RustusResult}; -use crate::info_storages::FileInfo; -use crate::storages::Storage; -use crate::utils::dir_struct::dir_struct; +use crate::{ + errors::{RustusError, RustusResult}, + info_storages::FileInfo, + storages::Storage, + utils::dir_struct::dir_struct, +}; use derive_more::Display; #[derive(Display)] @@ -188,12 +191,13 @@ impl Storage for FileStorage { #[cfg(test)] mod tests { use super::FileStorage; - use crate::info_storages::FileInfo; - use crate::Storage; + use crate::{info_storages::FileInfo, Storage}; use bytes::Bytes; - use std::fs::File; - use std::io::{Read, Write}; - use std::path::PathBuf; + use std::{ + fs::File, + io::{Read, Write}, + path::PathBuf, + }; #[actix_rt::test] async fn preparation() { diff --git a/src/storages/mod.rs b/src/storages/mod.rs index 083458b5caff04176d39a5ab2de45d0f6a007473..eba4b6334a5d27c8f5ba0d096bc72c6843e3c33b 100644 --- a/src/storages/mod.rs +++ b/src/storages/mod.rs @@ -1,5 +1,4 @@ pub mod file_storage; mod models; -pub use models::available_stores::AvailableStores; -pub use models::storage::Storage; +pub use models::{available_stores::AvailableStores, storage::Storage}; diff --git a/src/storages/models/available_stores.rs b/src/storages/models/available_stores.rs index 25ff19e1065e22c6e4d597cdd34478cf47934db0..b22c7a9db3b8df3f63c49e042279b4e36e69f32f 100644 --- a/src/storages/models/available_stores.rs +++ b/src/storages/models/available_stores.rs @@ -1,5 +1,4 @@ -use crate::storages::file_storage; -use crate::{from_str, RustusConf, Storage}; +use crate::{from_str, storages::file_storage, RustusConf, Storage}; use derive_more::{Display, From}; use strum::EnumIter; diff --git a/src/storages/models/storage.rs b/src/storages/models/storage.rs index c14820ba6a0577f681d475fa0a11bd07bda32e59..2ef0f6b7e5a6587f0379ab763e068f0f85383d46 100644 --- a/src/storages/models/storage.rs +++ b/src/storages/models/storage.rs @@ -1,5 +1,4 @@ -use crate::errors::RustusResult; -use crate::info_storages::FileInfo; +use crate::{errors::RustusResult, info_storages::FileInfo}; use actix_files::NamedFile; use async_trait::async_trait; use bytes::Bytes; diff --git a/src/utils/dir_struct.rs b/src/utils/dir_struct.rs index 9c1875729d0e960a24f4dc4de6f23405c83bc578..96bb690d3879863b78e495634f183e156437be1a 100644 --- a/src/utils/dir_struct.rs +++ b/src/utils/dir_struct.rs @@ -1,8 +1,7 @@ use chrono::{Datelike, Timelike}; use lazy_static::lazy_static; use log::error; -use std::collections::HashMap; -use std::env; +use std::{collections::HashMap, env}; lazy_static! { /// Freezing ENVS on startup.