Skip to content

Commit

Permalink
build(deps): update derive_more to v1.0 (#458)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
jayvdb and robjtede authored Aug 18, 2024
1 parent 275675e commit 48646d1
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 59 deletions.
2 changes: 1 addition & 1 deletion actix-cors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions actix-cors/src/error.rs
Original file line number Diff line number Diff line change
@@ -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,
}

Expand Down
2 changes: 1 addition & 1 deletion actix-identity/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
18 changes: 9 additions & 9 deletions actix-identity/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -17,23 +17,23 @@ 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.
///
/// 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]
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;

Expand All @@ -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),
}

Expand Down
2 changes: 1 addition & 1 deletion actix-limitation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions actix-limitation/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
use derive_more::{Display, Error, From};
use derive_more::derive::{Display, Error, From};

use crate::status::Status;

/// Failure modes of the rate limiter.
#[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),
}
Expand Down
2 changes: 1 addition & 1 deletion actix-protobuf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
14 changes: 8 additions & 6 deletions actix-protobuf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _,
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions actix-session/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion actix-session/src/config.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
6 changes: 3 additions & 3 deletions actix-session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions actix-session/src/storage/interface.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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),
}

Expand All @@ -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),
}

Expand All @@ -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),
}

Expand Down
4 changes: 2 additions & 2 deletions actix-session/src/storage/session_key.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -45,7 +45,7 @@ impl From<SessionKey> 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 {
Expand Down
2 changes: 1 addition & 1 deletion actix-settings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading

0 comments on commit 48646d1

Please sign in to comment.