1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-23 15:51:06 +01:00

rename settings modules

This commit is contained in:
Rob Ede 2022-07-31 15:30:50 +01:00
parent 90766e5d68
commit da32c1bb49
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
12 changed files with 25 additions and 27 deletions

View File

@ -20,17 +20,17 @@ use serde::{de, Deserialize};
#[macro_use]
mod error;
mod actix;
mod core;
mod parse;
mod settings;
pub use self::actix::{
pub use self::error::{AtError, AtResult};
pub use self::parse::Parse;
pub use self::settings::{
ActixSettings, Address, Backlog, KeepAlive, MaxConnectionRate, MaxConnections, Mode,
NumWorkers, Timeout, Tls,
};
pub use self::core::Parse;
pub use self::error::{AtError, AtResult};
#[derive(Debug, Clone, Deserialize, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
#[serde(bound = "A: Deserialize<'de>")]
pub struct BasicSettings<A> {
pub actix: ActixSettings,
@ -648,10 +648,9 @@ mod tests {
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "kebab-case")]
struct AppSettings {
#[serde(rename = "example-name")]
example_name: String,
#[serde(rename = "nested-field")]
nested_field: NestedSetting,
}

View File

@ -1,6 +1,6 @@
use std::{path::PathBuf, str::FromStr};
use crate::error::AtError;
use crate::AtError;
pub trait Parse: Sized {
fn parse(string: &str) -> Result<Self, AtError>;

View File

@ -2,7 +2,7 @@ use once_cell::sync::Lazy;
use regex::Regex;
use serde::Deserialize;
use crate::{core::Parse, error::AtError};
use crate::{AtError, Parse};
static ADDR_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(

View File

@ -2,7 +2,7 @@ use std::fmt;
use serde::de;
use crate::{core::Parse, error::AtError};
use crate::{AtError, AtResult, Parse};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Backlog {
@ -11,7 +11,7 @@ pub enum Backlog {
}
impl Parse for Backlog {
fn parse(string: &str) -> std::result::Result<Self, AtError> {
fn parse(string: &str) -> AtResult<Self> {
match string {
"default" => Ok(Backlog::Default),
string => match string.parse::<usize>() {

View File

@ -4,7 +4,7 @@ use once_cell::sync::Lazy;
use regex::Regex;
use serde::de;
use crate::{core::Parse, error::AtError};
use crate::{AtError, AtResult, Parse};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum KeepAlive {
@ -15,7 +15,7 @@ pub enum KeepAlive {
}
impl Parse for KeepAlive {
fn parse(string: &str) -> std::result::Result<Self, AtError> {
fn parse(string: &str) -> AtResult<Self> {
pub(crate) static FMT: Lazy<Regex> =
Lazy::new(|| Regex::new(r"^\d+ seconds$").expect("Failed to compile regex: FMT"));

View File

@ -2,7 +2,7 @@ use std::fmt;
use serde::de;
use crate::{core::Parse, error::AtError};
use crate::{AtError, AtResult, Parse};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum MaxConnectionRate {
@ -11,7 +11,7 @@ pub enum MaxConnectionRate {
}
impl Parse for MaxConnectionRate {
fn parse(string: &str) -> std::result::Result<Self, AtError> {
fn parse(string: &str) -> AtResult<Self> {
match string {
"default" => Ok(MaxConnectionRate::Default),
string => match string.parse::<usize>() {

View File

@ -2,7 +2,7 @@ use std::fmt;
use serde::de;
use crate::{core::Parse, error::AtError};
use crate::{AtError, AtResult, Parse};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum MaxConnections {
@ -11,7 +11,7 @@ pub enum MaxConnections {
}
impl Parse for MaxConnections {
fn parse(string: &str) -> std::result::Result<Self, AtError> {
fn parse(string: &str) -> AtResult<Self> {
match string {
"default" => Ok(MaxConnections::Default),
string => match string.parse::<usize>() {

View File

@ -1,18 +1,17 @@
use serde::Deserialize;
use crate::{core::Parse, error::AtError};
use crate::{AtResult, Parse};
///
#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Mode {
#[serde(rename = "development")]
Development,
#[serde(rename = "production")]
Production,
}
impl Parse for Mode {
fn parse(string: &str) -> std::result::Result<Self, AtError> {
fn parse(string: &str) -> AtResult<Self> {
match string {
"development" => Ok(Self::Development),
"production" => Ok(Self::Production),

View File

@ -2,7 +2,7 @@ use std::fmt;
use serde::de;
use crate::{core::Parse, error::AtError};
use crate::{AtError, AtResult, Parse};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum NumWorkers {
@ -11,7 +11,7 @@ pub enum NumWorkers {
}
impl Parse for NumWorkers {
fn parse(string: &str) -> std::result::Result<Self, AtError> {
fn parse(string: &str) -> AtResult<Self> {
match string {
"default" => Ok(NumWorkers::Default),
string => match string.parse::<usize>() {

View File

@ -4,7 +4,7 @@ use once_cell::sync::Lazy;
use regex::Regex;
use serde::de;
use crate::{core::Parse, error::AtError};
use crate::{AtError, AtResult, Parse};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Timeout {
@ -14,7 +14,7 @@ pub enum Timeout {
}
impl Parse for Timeout {
fn parse(string: &str) -> std::result::Result<Self, AtError> {
fn parse(string: &str) -> AtResult<Self> {
pub static FMT: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"^\d+ (milliseconds|seconds)$").expect("Failed to compile regex: FMT")
});