added any lifetime to macro

This commit is contained in:
Franklin 2022-08-31 14:05:11 -04:00
parent f6deba70ba
commit edc50440e4
3 changed files with 4 additions and 6 deletions

2
Cargo.lock generated
View File

@ -183,7 +183,7 @@ dependencies = [
[[package]] [[package]]
name = "actix-web-utils" name = "actix-web-utils"
version = "0.2.8" version = "0.2.9"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"log", "log",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-web-utils" name = "actix-web-utils"
version = "0.2.8" version = "0.2.9"
edition = "2021" edition = "2021"
authors = ["Franklin E. Blanco"] authors = ["Franklin E. Blanco"]
description = "Just some useful addons for actix web." description = "Just some useful addons for actix web."

View File

@ -1,6 +1,4 @@
use std::fmt::Display; use std::fmt::Display;
use log::debug;
use serde::Serialize; use serde::Serialize;
use crate::{dtos::message::MessageResource, enums::error::Error, extensions::typed_response::TypedHttpResponse}; use crate::{dtos::message::MessageResource, enums::error::Error, extensions::typed_response::TypedHttpResponse};
@ -17,7 +15,7 @@ impl ReturnableErrorShape for MessageResource {
} }
impl ReturnableErrorShape for Error { impl ReturnableErrorShape for Error {
fn convert_to_returnable<T: Serialize>(&self, status_code: u16) -> TypedHttpResponse<T> { fn convert_to_returnable<T: Serialize>(&self, status_code: u16) -> TypedHttpResponse<T> {
debug!("Converted error to returnable. Error: {}", self.to_string()); //debug!("Converted error to returnable. Error: {}", self.to_string());
match self { match self {
Error::Unspecified => TypedHttpResponse::return_standard_error(status_code, MessageResource::new_empty()), Error::Unspecified => TypedHttpResponse::return_standard_error(status_code, MessageResource::new_empty()),
Error::NetworkError(message) => TypedHttpResponse::return_standard_error(status_code, message.clone()), Error::NetworkError(message) => TypedHttpResponse::return_standard_error(status_code, message.clone()),
@ -34,7 +32,7 @@ impl ReturnableErrorShape for Vec<MessageResource> {
TypedHttpResponse::return_standard_error_list(status_code, self.to_vec()) TypedHttpResponse::return_standard_error_list(status_code, self.to_vec())
} }
} }
impl ReturnableErrorShape for dyn Display { impl<'a> ReturnableErrorShape for dyn Display + 'a {
fn convert_to_returnable<T: Serialize>(&self, status_code: u16) -> TypedHttpResponse<T> { fn convert_to_returnable<T: Serialize>(&self, status_code: u16) -> TypedHttpResponse<T> {
TypedHttpResponse::return_standard_error(status_code, MessageResource::new_from_err(self)) TypedHttpResponse::return_standard_error(status_code, MessageResource::new_from_err(self))
} }