Read files macro for loading reading files to string at compile-time
Makefile for formatting and linting Workspace for subcrates. Moved crates to subdir and moved subcrate configs to workspace.*
This commit is contained in:
20
crates/into_response_derive/src/derive.rs
Normal file
20
crates/into_response_derive/src/derive.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
use quote::quote;
|
||||
use syn::DeriveInput;
|
||||
|
||||
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 {
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
lib::serde::response::BaseResponse::new(version, self)
|
||||
.into_response()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TokenStream::from(expanded)
|
||||
}
|
13
crates/into_response_derive/src/lib.rs
Normal file
13
crates/into_response_derive/src/lib.rs
Normal file
@ -0,0 +1,13 @@
|
||||
extern crate proc_macro;
|
||||
use {
|
||||
proc_macro::TokenStream,
|
||||
syn::{parse_macro_input, DeriveInput},
|
||||
};
|
||||
|
||||
mod derive;
|
||||
|
||||
#[proc_macro_derive(IntoResponse)]
|
||||
pub fn into_response_derive(input: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
derive::into_response_derive_impl(input)
|
||||
}
|
Reference in New Issue
Block a user