diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ef7d569 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org +root = true +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 4 +[*.rs] +max_line_length = 100 +[*.md] +# double whitespace at end of line +# denotes a line break in Markdown +trim_trailing_whitespace = false +[*.yml] +indent_size = 2 +[Makefile] +indent_style = tab diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..768987b --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,7 @@ +edition = "2024" +style_edition = "2024" +comment_width = 100 +format_code_in_doc_comments = true +imports_granularity = "Crate" +imports_layout = "Vertical" +wrap_comments = true diff --git a/src/error.rs b/src/error.rs index 9d36050..16e210d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,7 +1,10 @@ // Just a way to unify error handling. Can translate eyre Reports into // axum responses. -use axum::{http::StatusCode, response::IntoResponse}; +use axum::{ + http::StatusCode, + response::IntoResponse, +}; use color_eyre::eyre::Report; use std::fmt::Display; diff --git a/src/main.rs b/src/main.rs index 8c66f1a..d4ac841 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,23 +1,50 @@ // TODO: Add general description of the workings. // TODO: Add ability to run a temporary pastebin +use crate::error::GBError; use axum::{ - BoxError, Router, + BoxError, + Router, error_handling::HandleErrorLayer, - extract::{DefaultBodyLimit, Multipart, Path, State}, + extract::{ + DefaultBodyLimit, + Multipart, + Path, + State, + }, http::StatusCode, - response::{Html, IntoResponse, Response}, - routing::{get, post}, + response::{ + Html, + IntoResponse, + Response, + }, + routing::{ + get, + post, + }, }; use clap::Parser; -use crate::error::GBError; use nanoid::nanoid; -use std::{path::PathBuf, time::Duration}; +use std::{ + path::PathBuf, + time::Duration, +}; use store::Store; use tokio::fs; -use tower::{ServiceBuilder, buffer::BufferLayer, limit::rate::RateLimitLayer}; -use tower_http::{compression::CompressionLayer, limit::RequestBodyLimitLayer, trace::TraceLayer}; -use tracing::{Level, event}; +use tower::{ + ServiceBuilder, + buffer::BufferLayer, + limit::rate::RateLimitLayer, +}; +use tower_http::{ + compression::CompressionLayer, + limit::RequestBodyLimitLayer, + trace::TraceLayer, +}; +use tracing::{ + Level, + event, +}; mod error; mod store; @@ -107,8 +134,11 @@ async fn paste_request(State(state): State, Path(paste_id): Path) // RUST_LOG environment variable. fn install_tracing() { use tracing_error::ErrorLayer; - use tracing_subscriber::prelude::*; - use tracing_subscriber::{EnvFilter, fmt}; + use tracing_subscriber::{ + EnvFilter, + fmt, + prelude::*, + }; let fmt_layer = fmt::layer().with_target(false); let filter_layer = EnvFilter::try_from_default_env() diff --git a/src/store.rs b/src/store.rs index 621b7d2..dd6ac62 100644 --- a/src/store.rs +++ b/src/store.rs @@ -1,7 +1,12 @@ use color_eyre::Result; use rocksdb::DB; -use std::path::{Path, PathBuf}; -use std::sync::Arc; +use std::{ + path::{ + Path, + PathBuf, + }, + sync::Arc, +}; #[derive(Clone)] pub struct Store {