5 Commits

7 changed files with 16 additions and 9 deletions

2
Cargo.lock generated
View File

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

View File

@ -1,15 +1,16 @@
[workspace]
members = ["crates/*"]
exclude = ["examples"]
[workspace.package]
edition = "2021"
rust-version = "1.79.0"
rust-version = "1.80.0"
authors = ["Martin Berg Alstad"]
homepage = "emberal.github.io"
[package]
name = "lib"
version = "1.4.1-hotfix"
version = "1.4.3"
description = "A library with utilities and helper fuctions."
edition = { workspace = true }
rust-version = { workspace = true }

View File

@ -7,8 +7,8 @@ pub fn into_response_derive_impl(input: DeriveInput) -> TokenStream {
let name = &input.ident;
let expanded = quote! {
impl IntoResponse for #name {
fn into_response(self) -> Response {
impl axum::response::IntoResponse for #name {
fn into_response(self) -> axum::response::Response {
let version = env!("CARGO_PKG_VERSION");
lib::serde::response::BaseResponse::new(version, self)
.into_response()

View File

@ -10,4 +10,4 @@ proc-macro = true
[dependencies]
syn = { workspace = true }
quote = { workspace = true }
regex = "1.10.5"
regex = "1.10"

View File

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

View File

@ -2,8 +2,8 @@
#[cfg(all(feature = "derive", feature = "serde"))]
pub extern crate into_response_derive;
#[cfg(feature = "load-files")]
pub extern crate load_files;
#[cfg(feature = "read-files")]
pub extern crate read_files;
#[cfg(feature = "axum")]
pub mod axum;

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)]
mod tests {
use super::*;