diff --git a/actix-cors/Cargo.toml b/actix-cors/Cargo.toml index 6d2469a8d..e779c0057 100644 --- a/actix-cors/Cargo.toml +++ b/actix-cors/Cargo.toml @@ -29,7 +29,6 @@ once_cell = "1" tinyvec = { version = "1", features = ["alloc"] } [dev-dependencies] -actix-service = "2.0.0-beta.5" actix-rt = "2" pretty_env_logger = "0.4" regex = "1.4" diff --git a/actix-cors/README.md b/actix-cors/README.md index 4f0492c8d..3204a89fd 100644 --- a/actix-cors/README.md +++ b/actix-cors/README.md @@ -11,5 +11,4 @@ - [API Documentation](https://docs.rs/actix-cors) - [Example Project](https://github.com/actix/examples/tree/master/security/web-cors) -- [Chat on Gitter](https://gitter.im/actix/actix-web) - Minimum Supported Rust Version (MSRV): 1.46.0 diff --git a/actix-protobuf/Cargo.toml b/actix-protobuf/Cargo.toml index 31fc6cf00..867b0100e 100644 --- a/actix-protobuf/Cargo.toml +++ b/actix-protobuf/Cargo.toml @@ -19,10 +19,10 @@ name = "actix_protobuf" path = "src/lib.rs" [dependencies] -actix-web = { version = "4.0.0-beta.4", default_features = false } actix-rt = "2" +actix-web = { version = "4.0.0-beta.5", default_features = false } +derive_more = "0.99.5" futures-util = { version = "0.3.7", default-features = false } -derive_more = "0.99" prost = "0.7" [dev-dependencies] diff --git a/actix-protobuf/examples/prost-example/Cargo.toml b/actix-protobuf/examples/prost-example/Cargo.toml index fc21c4e93..7e5728fff 100644 --- a/actix-protobuf/examples/prost-example/Cargo.toml +++ b/actix-protobuf/examples/prost-example/Cargo.toml @@ -8,7 +8,7 @@ authors = [ ] [dependencies] -actix-web = "4.0.0-beta.4" +actix-web = "4.0.0-beta.5" actix-protobuf = { path = "../../" } env_logger = "0.8" diff --git a/actix-session/src/_error.rs b/actix-session/src/_error.rs new file mode 100644 index 000000000..b82e4cd3e --- /dev/null +++ b/actix-session/src/_error.rs @@ -0,0 +1,66 @@ +use std::{error::Error as StdError, fmt}; + +use actix_web::ResponseError; +use derive_more::Display; + +#[derive(Debug, Display)] +pub(crate) enum InsertErrorKind { + #[display(fmt = "{}", _0)] + Json(serde_json::Error), +} + +impl Into for InsertErrorKind { + fn into(self) -> actix_web::Error { + match self { + InsertErrorKind::Json(err) => err.into(), + } + } +} + +/// Error returned by [`Session::insert`][crate::Session::insert]. Allows access to value that +/// failed to be inserted. +pub struct InsertError { + pub(crate) value: Option, + pub(crate) error: InsertErrorKind, +} + +impl InsertError { + /// Takes value out of error. + /// + /// # Panics + /// Panics if called more than once. + pub fn take_value(&mut self) -> T { + self.value + .take() + .expect("take_value should only be called once") + } +} + +impl fmt::Debug for InsertError { + fn fmt<'a>(&'a self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut dbg = f.debug_struct("SessionInsertError"); + + match &self.value { + Some(_) => dbg.field("value", &"Some([value])" as _), + None => dbg.field("value", &None::<()> as _), + }; + + dbg.field("error", &self.error).finish() + } +} + +impl fmt::Display for InsertError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&self.error, f) + } +} + +impl StdError for InsertError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + Some(match &self.error { + InsertErrorKind::Json(err) => err, + }) + } +} + +impl ResponseError for InsertError {} diff --git a/actix-web-httpauth/Cargo.toml b/actix-web-httpauth/Cargo.toml index db757cf9c..3e6ad6910 100644 --- a/actix-web-httpauth/Cargo.toml +++ b/actix-web-httpauth/Cargo.toml @@ -28,4 +28,3 @@ futures-util = { version = "0.3.7", default-features = false } [dev-dependencies] actix-cors = "1.0.0-beta.1" actix-rt = "2" -actix-service = "2.0.0-beta.5"