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:
parent
275675e1c2
commit
48646d1bd3
@ -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"
|
||||
|
@ -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,
|
||||
}
|
||||
|
||||
|
@ -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"] }
|
||||
|
@ -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),
|
||||
}
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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),
|
||||
}
|
||||
|
@ -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 }
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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),
|
||||
}
|
||||
|
||||
|
@ -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<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 {
|
||||
|
@ -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"
|
||||
|
@ -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),
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user