1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-27 17:22:57 +01:00

fixup other cargo manifests

This commit is contained in:
Rob Ede 2021-04-02 11:44:18 +01:00
parent bb1cc7443f
commit d0f0fb474b
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
6 changed files with 69 additions and 6 deletions

View File

@ -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"

View File

@ -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

View File

@ -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]

View File

@ -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"

View File

@ -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<actix_web::Error> 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<T> {
pub(crate) value: Option<T>,
pub(crate) error: InsertErrorKind,
}
impl<T> InsertError<T> {
/// 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<T> fmt::Debug for InsertError<T> {
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<T> fmt::Display for InsertError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.error, f)
}
}
impl<T: fmt::Debug> StdError for InsertError<T> {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(match &self.error {
InsertErrorKind::Json(err) => err,
})
}
}
impl<T> ResponseError for InsertError<T> {}

View File

@ -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"