From 48646d1bd3c8194a4996c83f332248263dc81240 Mon Sep 17 00:00:00 2001 From: John Vandenberg Date: Sun, 18 Aug 2024 22:21:56 +0800 Subject: [PATCH] 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 --- actix-cors/Cargo.toml | 2 +- actix-cors/src/error.rs | 18 +++++++++--------- actix-identity/Cargo.toml | 2 +- actix-identity/src/error.rs | 18 +++++++++--------- actix-limitation/Cargo.toml | 2 +- actix-limitation/src/errors.rs | 10 +++++----- actix-protobuf/Cargo.toml | 2 +- actix-protobuf/src/lib.rs | 14 ++++++++------ actix-session/Cargo.toml | 4 ++-- actix-session/src/config.rs | 2 +- actix-session/src/session.rs | 6 +++--- actix-session/src/storage/interface.rs | 14 +++++++------- actix-session/src/storage/session_key.rs | 4 ++-- actix-settings/Cargo.toml | 2 +- actix-settings/src/error.rs | 20 ++++++++++---------- 15 files changed, 61 insertions(+), 59 deletions(-) diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 8d3375eeb..a29c93779 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -24,7 +24,7 @@ draft-private-network-access = [] actix-utils = "3" 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"] } log = "0.4" once_cell = "1" diff --git a/actix-cors/src/error.rs b/actix-cors/src/error.rs index 687ab0804..a9d363d90 100644 --- a/actix-cors/src/error.rs +++ b/actix-cors/src/error.rs @@ -1,40 +1,40 @@ 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. #[derive(Debug, Clone, Display, Error)] #[non_exhaustive] pub enum CorsError { /// 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, /// 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, /// 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, /// 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, /// 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, /// 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, /// Request method is not allowed. - #[display(fmt = "Requested method is not allowed")] + #[display("Requested method is not allowed")] MethodNotAllowed, /// 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, } diff --git a/actix-identity/Cargo.toml b/actix-identity/Cargo.toml index 846019a3d..ab7ae6314 100644 --- a/actix-identity/Cargo.toml +++ b/actix-identity/Cargo.toml @@ -23,7 +23,7 @@ actix-session = "0.10" actix-utils = "3" 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" serde = { version = "1", features = ["derive"] } tracing = { version = "0.1.30", default-features = false, features = ["log"] } diff --git a/actix-identity/src/error.rs b/actix-identity/src/error.rs index 2db521f92..fb0a83acf 100644 --- a/actix-identity/src/error.rs +++ b/actix-identity/src/error.rs @@ -2,11 +2,11 @@ use actix_session::{SessionGetError, SessionInsertError}; 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. #[derive(Debug, Display, Error, From)] -#[display(fmt = "{_0}")] +#[display("{_0}")] pub struct LoginError(SessionInsertError); impl ResponseError for LoginError { @@ -17,7 +17,7 @@ impl ResponseError for LoginError { /// Error encountered when working with a session that has expired. #[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); /// 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. #[derive(Debug, Display, Error)] #[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." )] #[non_exhaustive] @@ -33,7 +33,7 @@ pub struct LostIdentityError; /// There is no identity information attached to the current session. #[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] pub struct MissingIdentityError; @@ -42,21 +42,21 @@ pub struct MissingIdentityError; #[non_exhaustive] pub enum GetIdentityError { /// The session has expired. - #[display(fmt = "{_0}")] + #[display("{_0}")] SessionExpiryError(SessionExpiryError), /// No identity is found in a session. - #[display(fmt = "{_0}")] + #[display("{_0}")] MissingIdentityError(MissingIdentityError), /// Failed to accessing the session store. - #[display(fmt = "{_0}")] + #[display("{_0}")] SessionGetError(SessionGetError), /// Identity info was lost after being validated. /// /// Seeing this error indicates a bug in actix-identity. - #[display(fmt = "{_0}")] + #[display("{_0}")] LostIdentityError(LostIdentityError), } diff --git a/actix-limitation/Cargo.toml b/actix-limitation/Cargo.toml index 81c80b381..3bf630bee 100644 --- a/actix-limitation/Cargo.toml +++ b/actix-limitation/Cargo.toml @@ -26,7 +26,7 @@ actix-utils = "3" actix-web = { version = "4", default-features = false, features = ["cookies"] } chrono = "0.4" -derive_more = "0.99.7" +derive_more = { version = "1", features = ["display", "error", "from"] } log = "0.4" redis = { version = "0.26", default-features = false, features = ["tokio-comp"] } time = "0.3" diff --git a/actix-limitation/src/errors.rs b/actix-limitation/src/errors.rs index 9f535d64d..71f768571 100644 --- a/actix-limitation/src/errors.rs +++ b/actix-limitation/src/errors.rs @@ -1,4 +1,4 @@ -use derive_more::{Display, Error, From}; +use derive_more::derive::{Display, Error, From}; use crate::status::Status; @@ -6,20 +6,20 @@ use crate::status::Status; #[derive(Debug, Display, Error, From)] pub enum Error { /// 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), /// Limit is exceeded for a key. - #[display(fmt = "Limit is exceeded for a key")] + #[display("Limit is exceeded for a key")] #[from(ignore)] LimitExceeded(#[error(not(source))] Status), /// Time conversion failed. - #[display(fmt = "Time conversion failed")] + #[display("Time conversion failed")] Time(time::error::ComponentRange), /// Generic error. - #[display(fmt = "Generic error")] + #[display("Generic error")] #[from(ignore)] Other(#[error(not(source))] String), } diff --git a/actix-protobuf/Cargo.toml b/actix-protobuf/Cargo.toml index adedf5f87..1c78b1b29 100644 --- a/actix-protobuf/Cargo.toml +++ b/actix-protobuf/Cargo.toml @@ -19,7 +19,7 @@ all-features = true [dependencies] 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"] } prost = { version = "0.13", default-features = false } diff --git a/actix-protobuf/src/lib.rs b/actix-protobuf/src/lib.rs index 6c3e7f9b2..6ada5aa4a 100644 --- a/actix-protobuf/src/lib.rs +++ b/actix-protobuf/src/lib.rs @@ -22,7 +22,7 @@ use actix_web::{ Error, FromRequest, HttpMessage, HttpRequest, HttpResponse, HttpResponseBuilder, Responder, ResponseError, }; -use derive_more::Display; +use derive_more::derive::Display; use futures_util::{ future::{FutureExt as _, LocalBoxFuture}, stream::StreamExt as _, @@ -32,26 +32,28 @@ use prost::{DecodeError as ProtoBufDecodeError, EncodeError as ProtoBufEncodeErr #[derive(Debug, Display)] pub enum ProtoBufPayloadError { /// Payload size is bigger than 256k - #[display(fmt = "Payload size is bigger than 256k")] + #[display("Payload size is bigger than 256k")] Overflow, /// Content type error - #[display(fmt = "Content type error")] + #[display("Content type error")] ContentType, /// Serialize error - #[display(fmt = "ProtoBuf serialize error: {_0}")] + #[display("ProtoBuf serialize error: {_0}")] Serialize(ProtoBufEncodeError), /// Deserialize error - #[display(fmt = "ProtoBuf deserialize error: {_0}")] + #[display("ProtoBuf deserialize error: {_0}")] Deserialize(ProtoBufDecodeError), /// Payload error - #[display(fmt = "Error that occur during reading payload: {_0}")] + #[display("Error that occur during reading payload: {_0}")] Payload(PayloadError), } +// TODO: impl error for ProtoBufPayloadError + impl ResponseError for ProtoBufPayloadError { fn error_response(&self) -> HttpResponse { match *self { diff --git a/actix-session/Cargo.toml b/actix-session/Cargo.toml index 92bd64461..c50926b84 100644 --- a/actix-session/Cargo.toml +++ b/actix-session/Cargo.toml @@ -31,7 +31,7 @@ actix-utils = "3" actix-web = { version = "4", default-features = false, features = ["cookies", "secure-cookies"] } anyhow = "1" -derive_more = "0.99.7" +derive_more = { version = "1", features = ["display", "error", "from"] } rand = { version = "0.8", optional = true } serde = { version = "1" } serde_json = { version = "1" } @@ -43,7 +43,7 @@ deadpool-redis = { version = "0.16", optional = true } [dev-dependencies] 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"] } tracing-subscriber = { version = "0.3", features = ["env-filter"] } tracing = "0.1.30" diff --git a/actix-session/src/config.rs b/actix-session/src/config.rs index 7b85a017d..393d4a6cc 100644 --- a/actix-session/src/config.rs +++ b/actix-session/src/config.rs @@ -1,7 +1,7 @@ //! Configuration options to tune the behaviour of [`SessionMiddleware`]. use actix_web::cookie::{time::Duration, Key, SameSite}; -use derive_more::From; +use derive_more::derive::From; use crate::{storage::SessionStore, SessionMiddleware}; diff --git a/actix-session/src/session.rs b/actix-session/src/session.rs index 1cd20cd42..d7e9286d3 100644 --- a/actix-session/src/session.rs +++ b/actix-session/src/session.rs @@ -14,7 +14,7 @@ use actix_web::{ FromRequest, HttpMessage, HttpRequest, HttpResponse, ResponseError, }; use anyhow::Context; -use derive_more::{Display, From}; +use derive_more::derive::{Display, From}; use serde::{de::DeserializeOwned, Serialize}; /// The primary interface to access and modify session state. @@ -288,7 +288,7 @@ impl FromRequest for Session { /// Error returned by [`Session::get`]. #[derive(Debug, Display, From)] -#[display(fmt = "{_0}")] +#[display("{_0}")] pub struct SessionGetError(anyhow::Error); impl StdError for SessionGetError { @@ -305,7 +305,7 @@ impl ResponseError for SessionGetError { /// Error returned by [`Session::insert`]. #[derive(Debug, Display, From)] -#[display(fmt = "{_0}")] +#[display("{_0}")] pub struct SessionInsertError(anyhow::Error); impl StdError for SessionInsertError { diff --git a/actix-session/src/storage/interface.rs b/actix-session/src/storage/interface.rs index 7030dbb28..05b731a8f 100644 --- a/actix-session/src/storage/interface.rs +++ b/actix-session/src/storage/interface.rs @@ -1,7 +1,7 @@ use std::{collections::HashMap, future::Future}; use actix_web::cookie::time::Duration; -use derive_more::Display; +use derive_more::derive::Display; use super::SessionKey; @@ -53,11 +53,11 @@ pub trait SessionStore { #[derive(Debug, Display)] pub enum LoadError { /// Failed to deserialize session state. - #[display(fmt = "Failed to deserialize session state")] + #[display("Failed to deserialize session state")] Deserialization(anyhow::Error), /// 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), } @@ -74,11 +74,11 @@ impl std::error::Error for LoadError { #[derive(Debug, Display)] pub enum SaveError { /// Failed to serialize session state. - #[display(fmt = "Failed to serialize session state")] + #[display("Failed to serialize session state")] Serialization(anyhow::Error), /// 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), } @@ -95,11 +95,11 @@ impl std::error::Error for SaveError { /// Possible failures modes for [`SessionStore::update`]. pub enum UpdateError { /// Failed to serialize session state. - #[display(fmt = "Failed to serialize session state")] + #[display("Failed to serialize session state")] Serialization(anyhow::Error), /// 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), } diff --git a/actix-session/src/storage/session_key.rs b/actix-session/src/storage/session_key.rs index 659b80a7f..348f1d2b4 100644 --- a/actix-session/src/storage/session_key.rs +++ b/actix-session/src/storage/session_key.rs @@ -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 /// state on the backend. @@ -45,7 +45,7 @@ impl From for String { } #[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); impl std::error::Error for InvalidSessionKeyError { diff --git a/actix-settings/Cargo.toml b/actix-settings/Cargo.toml index 0ad6c69ba..6bfeb7ac4 100644 --- a/actix-settings/Cargo.toml +++ b/actix-settings/Cargo.toml @@ -22,7 +22,7 @@ openssl = ["dep:openssl", "actix-web/openssl"] actix-http = "3" actix-service = "2" actix-web = { version = "4", default-features = false } -derive_more = "0.99.7" +derive_more = { version = "1", features = ["display", "error"] } once_cell = "1.13" openssl = { version = "0.10", features = ["v110"], optional = true } regex = "1.5" diff --git a/actix-settings/src/error.rs b/actix-settings/src/error.rs index c60fe08bd..b4c73726d 100644 --- a/actix-settings/src/error.rs +++ b/actix-settings/src/error.rs @@ -1,6 +1,6 @@ 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")] use openssl::error::ErrorStack as OpenSSLError; use toml::de::Error as TomlError; @@ -9,16 +9,16 @@ use toml::de::Error as TomlError; #[derive(Debug, Display, Error)] pub enum Error { /// Environment variable does not exists or is invalid. - #[display(fmt = "Env var error: {_0}")] + #[display("Env var error: {_0}")] EnvVarError(VarError), /// File already exists on disk. - #[display(fmt = "File exists: {}", "_0.display()")] + #[display("File exists: {}", _0.display())] FileExists(#[error(not(source))] PathBuf), /// Invalid value. #[allow(missing_docs)] - #[display(fmt = "Expected {expected}, got {got} (@ {file}:{line}:{column})")] + #[display("Expected {expected}, got {got} (@ {file}:{line}:{column})")] InvalidValue { expected: &'static str, got: String, @@ -28,28 +28,28 @@ pub enum Error { }, /// I/O error. - #[display(fmt = "")] + #[display("I/O error: {_0}")] IoError(io::Error), /// OpenSSL Error. #[cfg(feature = "openssl")] - #[display(fmt = "OpenSSL error: {_0}")] + #[display("OpenSSL error: {_0}")] OpenSSLError(OpenSSLError), /// Value is not a boolean. - #[display(fmt = "Failed to parse boolean: {_0}")] + #[display("Failed to parse boolean: {_0}")] ParseBoolError(ParseBoolError), /// Value is not an integer. - #[display(fmt = "Failed to parse integer: {_0}")] + #[display("Failed to parse integer: {_0}")] ParseIntError(ParseIntError), /// Value is not an address. - #[display(fmt = "Failed to parse address: {_0}")] + #[display("Failed to parse address: {_0}")] ParseAddressError(#[error(not(source))] String), /// Error deserializing as TOML. - #[display(fmt = "TOML error: {_0}")] + #[display("TOML error: {_0}")] TomlError(TomlError), }