Added From<T> for BaseResponse

This commit is contained in:
Martin Berg Alstad 2024-08-14 20:37:10 +02:00
parent 347314460a
commit cd558eebfa
4 changed files with 9 additions and 3 deletions

2
Cargo.lock generated
View File

@ -303,7 +303,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "lib" name = "lib"
version = "1.4.2-hotfix" version = "1.4.3"
dependencies = [ dependencies = [
"axum", "axum",
"into-response-derive", "into-response-derive",

View File

@ -10,7 +10,7 @@ homepage = "emberal.github.io"
[package] [package]
name = "lib" name = "lib"
version = "1.4.2-hotfix" version = "1.4.3"
description = "A library with utilities and helper fuctions." description = "A library with utilities and helper fuctions."
edition = { workspace = true } edition = { workspace = true }
rust-version = { workspace = true } rust-version = { workspace = true }

View File

@ -286,7 +286,7 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "lib" name = "lib"
version = "1.4.2-hotfix" version = "1.4.3"
dependencies = [ dependencies = [
"axum", "axum",
"thiserror", "thiserror",

View File

@ -16,6 +16,12 @@ impl<T: Serialize> BaseResponse<T> {
} }
} }
impl<T: Serialize> From<T> for BaseResponse<T> {
fn from(body: T) -> Self {
Self::new(env!("CARGO_PKG_VERSION"), body)
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;