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

build(deps): update derive_more to v1.0 (#458)

* build(deps): update derive_more to v1.0

* chore: remove overspecified deps

* chore: use from the derive module

* chore: restore unrelated version reqs

---------

Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
John Vandenberg 2024-08-18 22:21:56 +08:00 committed by GitHub
parent 275675e1c2
commit 48646d1bd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 61 additions and 59 deletions

View File

@ -24,7 +24,7 @@ draft-private-network-access = []
actix-utils = "3" actix-utils = "3"
actix-web = { version = "4", default-features = false } actix-web = { version = "4", default-features = false }
derive_more = "0.99.7" derive_more = { version = "1", features = ["display", "error"] }
futures-util = { version = "0.3.17", default-features = false, features = ["std"] } futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
log = "0.4" log = "0.4"
once_cell = "1" once_cell = "1"

View File

@ -1,40 +1,40 @@
use actix_web::{http::StatusCode, HttpResponse, ResponseError}; use actix_web::{http::StatusCode, HttpResponse, ResponseError};
use derive_more::{Display, Error}; use derive_more::derive::{Display, Error};
/// Errors that can occur when processing CORS guarded requests. /// Errors that can occur when processing CORS guarded requests.
#[derive(Debug, Clone, Display, Error)] #[derive(Debug, Clone, Display, Error)]
#[non_exhaustive] #[non_exhaustive]
pub enum CorsError { pub enum CorsError {
/// Allowed origin argument must not be wildcard (`*`). /// Allowed origin argument must not be wildcard (`*`).
#[display(fmt = "`allowed_origin` argument must not be wildcard (`*`)")] #[display("`allowed_origin` argument must not be wildcard (`*`)")]
WildcardOrigin, WildcardOrigin,
/// Request header `Origin` is required but was not provided. /// Request header `Origin` is required but was not provided.
#[display(fmt = "Request header `Origin` is required but was not provided")] #[display("Request header `Origin` is required but was not provided")]
MissingOrigin, MissingOrigin,
/// Request header `Access-Control-Request-Method` is required but is missing. /// Request header `Access-Control-Request-Method` is required but is missing.
#[display(fmt = "Request header `Access-Control-Request-Method` is required but is missing")] #[display("Request header `Access-Control-Request-Method` is required but is missing")]
MissingRequestMethod, MissingRequestMethod,
/// Request header `Access-Control-Request-Method` has an invalid value. /// Request header `Access-Control-Request-Method` has an invalid value.
#[display(fmt = "Request header `Access-Control-Request-Method` has an invalid value")] #[display("Request header `Access-Control-Request-Method` has an invalid value")]
BadRequestMethod, BadRequestMethod,
/// Request header `Access-Control-Request-Headers` has an invalid value. /// Request header `Access-Control-Request-Headers` has an invalid value.
#[display(fmt = "Request header `Access-Control-Request-Headers` has an invalid value")] #[display("Request header `Access-Control-Request-Headers` has an invalid value")]
BadRequestHeaders, BadRequestHeaders,
/// Origin is not allowed to make this request. /// Origin is not allowed to make this request.
#[display(fmt = "Origin is not allowed to make this request")] #[display("Origin is not allowed to make this request")]
OriginNotAllowed, OriginNotAllowed,
/// Request method is not allowed. /// Request method is not allowed.
#[display(fmt = "Requested method is not allowed")] #[display("Requested method is not allowed")]
MethodNotAllowed, MethodNotAllowed,
/// One or more request headers are not allowed. /// One or more request headers are not allowed.
#[display(fmt = "One or more request headers are not allowed")] #[display("One or more request headers are not allowed")]
HeadersNotAllowed, HeadersNotAllowed,
} }

View File

@ -23,7 +23,7 @@ actix-session = "0.10"
actix-utils = "3" actix-utils = "3"
actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] }
derive_more = "0.99.7" derive_more = { version = "1", features = ["display", "error", "from"] }
futures-core = "0.3.17" futures-core = "0.3.17"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] }

View File

@ -2,11 +2,11 @@
use actix_session::{SessionGetError, SessionInsertError}; use actix_session::{SessionGetError, SessionInsertError};
use actix_web::{cookie::time::error::ComponentRange, http::StatusCode, ResponseError}; use actix_web::{cookie::time::error::ComponentRange, http::StatusCode, ResponseError};
use derive_more::{Display, Error, From}; use derive_more::derive::{Display, Error, From};
/// Error that can occur during login attempts. /// Error that can occur during login attempts.
#[derive(Debug, Display, Error, From)] #[derive(Debug, Display, Error, From)]
#[display(fmt = "{_0}")] #[display("{_0}")]
pub struct LoginError(SessionInsertError); pub struct LoginError(SessionInsertError);
impl ResponseError for LoginError { impl ResponseError for LoginError {
@ -17,7 +17,7 @@ impl ResponseError for LoginError {
/// Error encountered when working with a session that has expired. /// Error encountered when working with a session that has expired.
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "The given session has expired and is no longer valid")] #[display("The given session has expired and is no longer valid")]
pub struct SessionExpiryError(#[error(not(source))] pub(crate) ComponentRange); pub struct SessionExpiryError(#[error(not(source))] pub(crate) ComponentRange);
/// The identity information has been lost. /// The identity information has been lost.
@ -25,7 +25,7 @@ pub struct SessionExpiryError(#[error(not(source))] pub(crate) ComponentRange);
/// Seeing this error in user code indicates a bug in actix-identity. /// Seeing this error in user code indicates a bug in actix-identity.
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display( #[display(
fmt = "The identity information in the current session has disappeared after having been \ "The identity information in the current session has disappeared after having been \
successfully validated. This is likely to be a bug." successfully validated. This is likely to be a bug."
)] )]
#[non_exhaustive] #[non_exhaustive]
@ -33,7 +33,7 @@ pub struct LostIdentityError;
/// There is no identity information attached to the current session. /// There is no identity information attached to the current session.
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
#[display(fmt = "There is no identity information attached to the current session")] #[display("There is no identity information attached to the current session")]
#[non_exhaustive] #[non_exhaustive]
pub struct MissingIdentityError; pub struct MissingIdentityError;
@ -42,21 +42,21 @@ pub struct MissingIdentityError;
#[non_exhaustive] #[non_exhaustive]
pub enum GetIdentityError { pub enum GetIdentityError {
/// The session has expired. /// The session has expired.
#[display(fmt = "{_0}")] #[display("{_0}")]
SessionExpiryError(SessionExpiryError), SessionExpiryError(SessionExpiryError),
/// No identity is found in a session. /// No identity is found in a session.
#[display(fmt = "{_0}")] #[display("{_0}")]
MissingIdentityError(MissingIdentityError), MissingIdentityError(MissingIdentityError),
/// Failed to accessing the session store. /// Failed to accessing the session store.
#[display(fmt = "{_0}")] #[display("{_0}")]
SessionGetError(SessionGetError), SessionGetError(SessionGetError),
/// Identity info was lost after being validated. /// Identity info was lost after being validated.
/// ///
/// Seeing this error indicates a bug in actix-identity. /// Seeing this error indicates a bug in actix-identity.
#[display(fmt = "{_0}")] #[display("{_0}")]
LostIdentityError(LostIdentityError), LostIdentityError(LostIdentityError),
} }

View File

@ -26,7 +26,7 @@ actix-utils = "3"
actix-web = { version = "4", default-features = false, features = ["cookies"] } actix-web = { version = "4", default-features = false, features = ["cookies"] }
chrono = "0.4" chrono = "0.4"
derive_more = "0.99.7" derive_more = { version = "1", features = ["display", "error", "from"] }
log = "0.4" log = "0.4"
redis = { version = "0.26", default-features = false, features = ["tokio-comp"] } redis = { version = "0.26", default-features = false, features = ["tokio-comp"] }
time = "0.3" time = "0.3"

View File

@ -1,4 +1,4 @@
use derive_more::{Display, Error, From}; use derive_more::derive::{Display, Error, From};
use crate::status::Status; use crate::status::Status;
@ -6,20 +6,20 @@ use crate::status::Status;
#[derive(Debug, Display, Error, From)] #[derive(Debug, Display, Error, From)]
pub enum Error { pub enum Error {
/// Redis client failed to connect or run a query. /// Redis client failed to connect or run a query.
#[display(fmt = "Redis client failed to connect or run a query")] #[display("Redis client failed to connect or run a query")]
Client(redis::RedisError), Client(redis::RedisError),
/// Limit is exceeded for a key. /// Limit is exceeded for a key.
#[display(fmt = "Limit is exceeded for a key")] #[display("Limit is exceeded for a key")]
#[from(ignore)] #[from(ignore)]
LimitExceeded(#[error(not(source))] Status), LimitExceeded(#[error(not(source))] Status),
/// Time conversion failed. /// Time conversion failed.
#[display(fmt = "Time conversion failed")] #[display("Time conversion failed")]
Time(time::error::ComponentRange), Time(time::error::ComponentRange),
/// Generic error. /// Generic error.
#[display(fmt = "Generic error")] #[display("Generic error")]
#[from(ignore)] #[from(ignore)]
Other(#[error(not(source))] String), Other(#[error(not(source))] String),
} }

View File

@ -19,7 +19,7 @@ all-features = true
[dependencies] [dependencies]
actix-web = { version = "4", default-features = false } actix-web = { version = "4", default-features = false }
derive_more = "0.99.7" derive_more = { version = "1", features = ["display"] }
futures-util = { version = "0.3.17", default-features = false, features = ["std"] } futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
prost = { version = "0.13", default-features = false } prost = { version = "0.13", default-features = false }

View File

@ -22,7 +22,7 @@ use actix_web::{
Error, FromRequest, HttpMessage, HttpRequest, HttpResponse, HttpResponseBuilder, Responder, Error, FromRequest, HttpMessage, HttpRequest, HttpResponse, HttpResponseBuilder, Responder,
ResponseError, ResponseError,
}; };
use derive_more::Display; use derive_more::derive::Display;
use futures_util::{ use futures_util::{
future::{FutureExt as _, LocalBoxFuture}, future::{FutureExt as _, LocalBoxFuture},
stream::StreamExt as _, stream::StreamExt as _,
@ -32,26 +32,28 @@ use prost::{DecodeError as ProtoBufDecodeError, EncodeError as ProtoBufEncodeErr
#[derive(Debug, Display)] #[derive(Debug, Display)]
pub enum ProtoBufPayloadError { pub enum ProtoBufPayloadError {
/// Payload size is bigger than 256k /// Payload size is bigger than 256k
#[display(fmt = "Payload size is bigger than 256k")] #[display("Payload size is bigger than 256k")]
Overflow, Overflow,
/// Content type error /// Content type error
#[display(fmt = "Content type error")] #[display("Content type error")]
ContentType, ContentType,
/// Serialize error /// Serialize error
#[display(fmt = "ProtoBuf serialize error: {_0}")] #[display("ProtoBuf serialize error: {_0}")]
Serialize(ProtoBufEncodeError), Serialize(ProtoBufEncodeError),
/// Deserialize error /// Deserialize error
#[display(fmt = "ProtoBuf deserialize error: {_0}")] #[display("ProtoBuf deserialize error: {_0}")]
Deserialize(ProtoBufDecodeError), Deserialize(ProtoBufDecodeError),
/// Payload error /// Payload error
#[display(fmt = "Error that occur during reading payload: {_0}")] #[display("Error that occur during reading payload: {_0}")]
Payload(PayloadError), Payload(PayloadError),
} }
// TODO: impl error for ProtoBufPayloadError
impl ResponseError for ProtoBufPayloadError { impl ResponseError for ProtoBufPayloadError {
fn error_response(&self) -> HttpResponse { fn error_response(&self) -> HttpResponse {
match *self { match *self {

View File

@ -31,7 +31,7 @@ actix-utils = "3"
actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] }
anyhow = "1" anyhow = "1"
derive_more = "0.99.7" derive_more = { version = "1", features = ["display", "error", "from"] }
rand = { version = "0.8", optional = true } rand = { version = "0.8", optional = true }
serde = { version = "1" } serde = { version = "1" }
serde_json = { version = "1" } serde_json = { version = "1" }
@ -43,7 +43,7 @@ deadpool-redis = { version = "0.16", optional = true }
[dev-dependencies] [dev-dependencies]
actix-session = { path = ".", features = ["cookie-session", "redis-session"] } actix-session = { path = ".", features = ["cookie-session", "redis-session"] }
actix-test = "0.1.0-beta.10" actix-test = "0.1"
actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies", "macros"] } actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies", "macros"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing = "0.1.30" tracing = "0.1.30"

View File

@ -1,7 +1,7 @@
//! Configuration options to tune the behaviour of [`SessionMiddleware`]. //! Configuration options to tune the behaviour of [`SessionMiddleware`].
use actix_web::cookie::{time::Duration, Key, SameSite}; use actix_web::cookie::{time::Duration, Key, SameSite};
use derive_more::From; use derive_more::derive::From;
use crate::{storage::SessionStore, SessionMiddleware}; use crate::{storage::SessionStore, SessionMiddleware};

View File

@ -14,7 +14,7 @@ use actix_web::{
FromRequest, HttpMessage, HttpRequest, HttpResponse, ResponseError, FromRequest, HttpMessage, HttpRequest, HttpResponse, ResponseError,
}; };
use anyhow::Context; use anyhow::Context;
use derive_more::{Display, From}; use derive_more::derive::{Display, From};
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
/// The primary interface to access and modify session state. /// The primary interface to access and modify session state.
@ -288,7 +288,7 @@ impl FromRequest for Session {
/// Error returned by [`Session::get`]. /// Error returned by [`Session::get`].
#[derive(Debug, Display, From)] #[derive(Debug, Display, From)]
#[display(fmt = "{_0}")] #[display("{_0}")]
pub struct SessionGetError(anyhow::Error); pub struct SessionGetError(anyhow::Error);
impl StdError for SessionGetError { impl StdError for SessionGetError {
@ -305,7 +305,7 @@ impl ResponseError for SessionGetError {
/// Error returned by [`Session::insert`]. /// Error returned by [`Session::insert`].
#[derive(Debug, Display, From)] #[derive(Debug, Display, From)]
#[display(fmt = "{_0}")] #[display("{_0}")]
pub struct SessionInsertError(anyhow::Error); pub struct SessionInsertError(anyhow::Error);
impl StdError for SessionInsertError { impl StdError for SessionInsertError {

View File

@ -1,7 +1,7 @@
use std::{collections::HashMap, future::Future}; use std::{collections::HashMap, future::Future};
use actix_web::cookie::time::Duration; use actix_web::cookie::time::Duration;
use derive_more::Display; use derive_more::derive::Display;
use super::SessionKey; use super::SessionKey;
@ -53,11 +53,11 @@ pub trait SessionStore {
#[derive(Debug, Display)] #[derive(Debug, Display)]
pub enum LoadError { pub enum LoadError {
/// Failed to deserialize session state. /// Failed to deserialize session state.
#[display(fmt = "Failed to deserialize session state")] #[display("Failed to deserialize session state")]
Deserialization(anyhow::Error), Deserialization(anyhow::Error),
/// Something went wrong when retrieving the session state. /// Something went wrong when retrieving the session state.
#[display(fmt = "Something went wrong when retrieving the session state")] #[display("Something went wrong when retrieving the session state")]
Other(anyhow::Error), Other(anyhow::Error),
} }
@ -74,11 +74,11 @@ impl std::error::Error for LoadError {
#[derive(Debug, Display)] #[derive(Debug, Display)]
pub enum SaveError { pub enum SaveError {
/// Failed to serialize session state. /// Failed to serialize session state.
#[display(fmt = "Failed to serialize session state")] #[display("Failed to serialize session state")]
Serialization(anyhow::Error), Serialization(anyhow::Error),
/// Something went wrong when persisting the session state. /// Something went wrong when persisting the session state.
#[display(fmt = "Something went wrong when persisting the session state")] #[display("Something went wrong when persisting the session state")]
Other(anyhow::Error), Other(anyhow::Error),
} }
@ -95,11 +95,11 @@ impl std::error::Error for SaveError {
/// Possible failures modes for [`SessionStore::update`]. /// Possible failures modes for [`SessionStore::update`].
pub enum UpdateError { pub enum UpdateError {
/// Failed to serialize session state. /// Failed to serialize session state.
#[display(fmt = "Failed to serialize session state")] #[display("Failed to serialize session state")]
Serialization(anyhow::Error), Serialization(anyhow::Error),
/// Something went wrong when updating the session state. /// Something went wrong when updating the session state.
#[display(fmt = "Something went wrong when updating the session state.")] #[display("Something went wrong when updating the session state.")]
Other(anyhow::Error), Other(anyhow::Error),
} }

View File

@ -1,4 +1,4 @@
use derive_more::{Display, From}; use derive_more::derive::{Display, From};
/// A session key, the string stored in a client-side cookie to associate a user with its session /// A session key, the string stored in a client-side cookie to associate a user with its session
/// state on the backend. /// state on the backend.
@ -45,7 +45,7 @@ impl From<SessionKey> for String {
} }
#[derive(Debug, Display, From)] #[derive(Debug, Display, From)]
#[display(fmt = "The provided string is not a valid session key")] #[display("The provided string is not a valid session key")]
pub struct InvalidSessionKeyError(anyhow::Error); pub struct InvalidSessionKeyError(anyhow::Error);
impl std::error::Error for InvalidSessionKeyError { impl std::error::Error for InvalidSessionKeyError {

View File

@ -22,7 +22,7 @@ openssl = ["dep:openssl", "actix-web/openssl"]
actix-http = "3" actix-http = "3"
actix-service = "2" actix-service = "2"
actix-web = { version = "4", default-features = false } actix-web = { version = "4", default-features = false }
derive_more = "0.99.7" derive_more = { version = "1", features = ["display", "error"] }
once_cell = "1.13" once_cell = "1.13"
openssl = { version = "0.10", features = ["v110"], optional = true } openssl = { version = "0.10", features = ["v110"], optional = true }
regex = "1.5" regex = "1.5"

View File

@ -1,6 +1,6 @@
use std::{env::VarError, io, num::ParseIntError, path::PathBuf, str::ParseBoolError}; use std::{env::VarError, io, num::ParseIntError, path::PathBuf, str::ParseBoolError};
use derive_more::{Display, Error}; use derive_more::derive::{Display, Error};
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
use openssl::error::ErrorStack as OpenSSLError; use openssl::error::ErrorStack as OpenSSLError;
use toml::de::Error as TomlError; use toml::de::Error as TomlError;
@ -9,16 +9,16 @@ use toml::de::Error as TomlError;
#[derive(Debug, Display, Error)] #[derive(Debug, Display, Error)]
pub enum Error { pub enum Error {
/// Environment variable does not exists or is invalid. /// Environment variable does not exists or is invalid.
#[display(fmt = "Env var error: {_0}")] #[display("Env var error: {_0}")]
EnvVarError(VarError), EnvVarError(VarError),
/// File already exists on disk. /// File already exists on disk.
#[display(fmt = "File exists: {}", "_0.display()")] #[display("File exists: {}", _0.display())]
FileExists(#[error(not(source))] PathBuf), FileExists(#[error(not(source))] PathBuf),
/// Invalid value. /// Invalid value.
#[allow(missing_docs)] #[allow(missing_docs)]
#[display(fmt = "Expected {expected}, got {got} (@ {file}:{line}:{column})")] #[display("Expected {expected}, got {got} (@ {file}:{line}:{column})")]
InvalidValue { InvalidValue {
expected: &'static str, expected: &'static str,
got: String, got: String,
@ -28,28 +28,28 @@ pub enum Error {
}, },
/// I/O error. /// I/O error.
#[display(fmt = "")] #[display("I/O error: {_0}")]
IoError(io::Error), IoError(io::Error),
/// OpenSSL Error. /// OpenSSL Error.
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
#[display(fmt = "OpenSSL error: {_0}")] #[display("OpenSSL error: {_0}")]
OpenSSLError(OpenSSLError), OpenSSLError(OpenSSLError),
/// Value is not a boolean. /// Value is not a boolean.
#[display(fmt = "Failed to parse boolean: {_0}")] #[display("Failed to parse boolean: {_0}")]
ParseBoolError(ParseBoolError), ParseBoolError(ParseBoolError),
/// Value is not an integer. /// Value is not an integer.
#[display(fmt = "Failed to parse integer: {_0}")] #[display("Failed to parse integer: {_0}")]
ParseIntError(ParseIntError), ParseIntError(ParseIntError),
/// Value is not an address. /// Value is not an address.
#[display(fmt = "Failed to parse address: {_0}")] #[display("Failed to parse address: {_0}")]
ParseAddressError(#[error(not(source))] String), ParseAddressError(#[error(not(source))] String),
/// Error deserializing as TOML. /// Error deserializing as TOML.
#[display(fmt = "TOML error: {_0}")] #[display("TOML error: {_0}")]
TomlError(TomlError), TomlError(TomlError),
} }