Added Wrapper types and DateTimeInterval
This commit is contained in:
@ -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
20
src/axum/wrappers.rs
Normal 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()
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#![allow(dead_code)]
|
||||
extern crate self as lib;
|
||||
|
||||
#[cfg(all(feature = "derive", feature = "diesel"))]
|
||||
pub extern crate diesel_crud_derive;
|
||||
@ -17,6 +18,8 @@ pub mod io;
|
||||
pub mod nom;
|
||||
#[cfg(feature = "serde")]
|
||||
pub mod serde;
|
||||
#[cfg(feature = "time")]
|
||||
pub mod time;
|
||||
pub mod traits;
|
||||
#[cfg(feature = "iter")]
|
||||
pub mod vector;
|
||||
|
@ -19,7 +19,7 @@ impl<T: Serialize> BaseResponse<T> {
|
||||
#[macro_export]
|
||||
macro_rules! from {
|
||||
($body:expr) => {
|
||||
BaseResponse::new(env!("CARGO_PKG_VERSION"), $body)
|
||||
$crate::serde::response::BaseResponse::new(env!("CARGO_PKG_VERSION"), $body)
|
||||
};
|
||||
}
|
||||
|
||||
|
8
src/time/common.rs
Normal file
8
src/time/common.rs
Normal file
@ -0,0 +1,8 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use derive_more::Constructor;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Constructor)]
|
||||
pub struct DateTimeInterval {
|
||||
pub start: NaiveDateTime,
|
||||
pub end: NaiveDateTime,
|
||||
}
|
1
src/time/mod.rs
Normal file
1
src/time/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod common;
|
Reference in New Issue
Block a user