Added Wrapper types and DateTimeInterval

This commit is contained in:
Martin Berg Alstad
2024-08-19 23:15:55 +02:00
parent ae775f4e9e
commit 00e894140f
10 changed files with 161 additions and 1 deletions

View File

@ -4,3 +4,5 @@ pub mod load;
#[cfg(feature = "serde")]
pub mod response;
pub mod router;
#[cfg(feature = "serde")]
pub mod wrappers;

20
src/axum/wrappers.rs Normal file
View File

@ -0,0 +1,20 @@
use axum::response::{IntoResponse, Response};
use derive_more::{Constructor, From};
use into_response_derive::IntoResponse;
use serde::Serialize;
#[derive(Debug, Clone, Serialize, From, Constructor)]
pub struct Array<T: Serialize> {
pub data: Vec<T>,
}
#[derive(Debug, Clone, Copy, Serialize, IntoResponse, From, Constructor)]
pub struct Count {
pub count: usize,
}
impl<T: Serialize> IntoResponse for Array<T> {
fn into_response(self) -> Response {
crate::from!(self).into_response()
}
}