dependency cleanup, documentation

This commit is contained in:
Dietrich 2021-06-16 09:38:23 +02:00 committed by Franz Dietrich
parent 36da54e587
commit 38800bb33c
5 changed files with 14 additions and 67 deletions

63
Cargo.lock generated
View File

@ -196,19 +196,6 @@ dependencies = [
"pin-project 0.4.28", "pin-project 0.4.28",
] ]
[[package]]
name = "actix-slog"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c697a62a2f51c5c26af6b1dded0622f15bec690da191615947e0c1b2b7b75198"
dependencies = [
"actix-web",
"chrono",
"futures 0.3.15",
"pin-project 0.4.28",
"slog",
]
[[package]] [[package]]
name = "actix-testing" name = "actix-testing"
version = "1.0.1" version = "1.0.1"
@ -453,12 +440,6 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "anyhow"
version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61"
[[package]] [[package]]
name = "app" name = "app"
version = "0.3.1" version = "0.3.1"
@ -1533,16 +1514,6 @@ dependencies = [
"version_check 0.9.3", "version_check 0.9.3",
] ]
[[package]]
name = "gethostname"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e692e296bfac1d2533ef168d0b60ff5897b8b70a4009276834014dd8924cc028"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "getopts" name = "getopts"
version = "0.2.21" version = "0.2.21"
@ -1612,9 +1583,9 @@ checksum = "8be18de09a56b60ed0edf84bc9df007e30040691af7acd1c41874faac5895bfb"
[[package]] [[package]]
name = "globset" name = "globset"
version = "0.4.6" version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c152169ef1e421390738366d2f796655fec62621dabbd0fd476f905934061e4a" checksum = "f0fc1b9fa0e64ffb1aa5b95daa0f0f167734fd528b7c02eabc581d9d843649b1"
dependencies = [ dependencies = [
"aho-corasick", "aho-corasick",
"bstr", "bstr",
@ -1874,9 +1845,9 @@ dependencies = [
[[package]] [[package]]
name = "ignore" name = "ignore"
version = "0.4.17" version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b287fb45c60bb826a0dc68ff08742b9d88a2fea13d6e0c286b3172065aaf878c" checksum = "713f1b139373f96a2e0ce3ac931cd01ee973c3c5dd7c40c0c2efe96ad2b6751d"
dependencies = [ dependencies = [
"crossbeam-utils", "crossbeam-utils",
"globset", "globset",
@ -2733,10 +2704,8 @@ dependencies = [
"actix-identity", "actix-identity",
"actix-rt", "actix-rt",
"actix-server", "actix-server",
"actix-slog",
"actix-web", "actix-web",
"actix-web-static-files", "actix-web-static-files",
"anyhow",
"argonautica", "argonautica",
"async-trait", "async-trait",
"chrono", "chrono",
@ -2761,7 +2730,6 @@ dependencies = [
"tokio 0.2.25", "tokio 0.2.25",
"tracing", "tracing",
"tracing-actix-web", "tracing-actix-web",
"tracing-bunyan-formatter",
"tracing-opentelemetry", "tracing-opentelemetry",
"tracing-subscriber", "tracing-subscriber",
] ]
@ -3469,12 +3437,6 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527"
[[package]]
name = "slog"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06"
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.6.1" version = "1.6.1"
@ -4100,23 +4062,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "tracing-bunyan-formatter"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dce1eae70720bd6bb3944f7cf501761aeae658bd1f9293aa373c71a195064910"
dependencies = [
"chrono",
"gethostname",
"log",
"serde",
"serde_json",
"tracing",
"tracing-core",
"tracing-log",
"tracing-subscriber",
]
[[package]] [[package]]
name = "tracing-core" name = "tracing-core"
version = "0.1.18" version = "0.1.18"

View File

@ -3,8 +3,8 @@ use fluent::fluent_args;
use image::{DynamicImage, ImageOutputFormat, Luma}; use image::{DynamicImage, ImageOutputFormat, Luma};
use qrcode::{render::svg, QrCode}; use qrcode::{render::svg, QrCode};
use seed::{ use seed::{
a, attrs, button, div, h1, img, input, log, nodes, prelude::*, raw, section, span, table, td, a, attrs, div, h1, img, input, log, nodes, prelude::*, raw, section, span, table, td, th, tr,
th, tr, Url, C, IF, Url, C, IF,
}; };
use shared::{ use shared::{

View File

@ -1,7 +1,5 @@
use enum_map::EnumMap; use enum_map::EnumMap;
use seed::{ use seed::{a, attrs, div, h1, input, log, p, prelude::*, section, table, td, th, tr, Url, C, IF};
a, attrs, button, div, h1, input, log, p, prelude::*, section, table, td, th, tr, Url, C, IF,
};
use shared::{ use shared::{
apirequests::general::{Operation, Ordering}, apirequests::general::{Operation, Ordering},
apirequests::{ apirequests::{

View File

@ -16,11 +16,9 @@ actix-web-static-files = "3.0"
[dependencies] [dependencies]
actix-identity = "0.3" actix-identity = "0.3"
actix-rt = "1.1" actix-rt = "1.1"
actix-slog = "0.2"
actix-web = "3" actix-web = "3"
actix-web-static-files = "3" actix-web-static-files = "3"
actix-files = "0.5" actix-files = "0.5"
anyhow = "1.0"
argonautica = "0.2" argonautica = "0.2"
clap = "2.33" clap = "2.33"
dotenv = "0.15.0" dotenv = "0.15.0"
@ -34,7 +32,6 @@ rpassword = "5.0"
serde = "1.0" serde = "1.0"
thiserror = "1.0" thiserror = "1.0"
tracing-actix-web = "0.2.1" tracing-actix-web = "0.2.1"
tracing-bunyan-formatter = "0.2.0"
tracing-opentelemetry = "0.12" tracing-opentelemetry = "0.12"
async-trait = "0.1" async-trait = "0.1"
enum-map = {version="1", features = ["serde"]} enum-map = {version="1", features = ["serde"]}

View File

@ -18,6 +18,7 @@ use thiserror::Error;
use tracing::{error, info, trace}; use tracing::{error, info, trace};
use tracing_actix_web::TracingLogger; use tracing_actix_web::TracingLogger;
/// The Error type that is returned by most function calls if anything failed.
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum ServerError { pub enum ServerError {
#[error("Failed to encrypt the password {0} - aborting!")] #[error("Failed to encrypt the password {0} - aborting!")]
@ -42,6 +43,7 @@ impl From<argonautica::Error> for ServerError {
} }
} }
/// Any error can be rendered to a html string.
impl ServerError { impl ServerError {
fn render_error(title: &str, content: &str) -> String { fn render_error(title: &str, content: &str) -> String {
format!( format!(
@ -68,6 +70,7 @@ impl ServerError {
} }
} }
/// Make the error type work nicely with the actix server.
impl actix_web::error::ResponseError for ServerError { impl actix_web::error::ResponseError for ServerError {
fn error_response(&self) -> HttpResponse { fn error_response(&self) -> HttpResponse {
match self { match self {
@ -119,6 +122,7 @@ impl actix_web::error::ResponseError for ServerError {
} }
} }
/// The qr-code can contain two different protocolls
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub enum Protocol { pub enum Protocol {
Http, Http,
@ -146,6 +150,7 @@ impl FromStr for Protocol {
} }
} }
/// The configuration of the server. It is accessible by the views and other parts of the program. Globally valid settings should be stored here.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct ServerConfig { pub struct ServerConfig {
pub secret: Secret, pub secret: Secret,
@ -159,6 +164,7 @@ pub struct ServerConfig {
pub brand_name: String, pub brand_name: String,
} }
/// The configuration can be serialized into an environment-file.
impl ServerConfig { impl ServerConfig {
#[must_use] #[must_use]
pub fn to_env_strings(&self) -> Vec<String> { pub fn to_env_strings(&self) -> Vec<String> {
@ -186,6 +192,7 @@ impl ServerConfig {
} }
} }
// include the static files into the binary
include!(concat!(env!("OUT_DIR"), "/generated.rs")); include!(concat!(env!("OUT_DIR"), "/generated.rs"));
static_loader! { static_loader! {