mirror of
https://gitlab.com/msrd0/gotham-restful.git
synced 2025-04-20 06:54:46 +00:00
start adding helper macros
This commit is contained in:
parent
3626e5360c
commit
e845d996d9
4 changed files with 49 additions and 17 deletions
31
src/helper.rs
Normal file
31
src/helper.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! rest_struct {
|
||||
($struct_name:ident { $($field_id:ident : $field_ty:ty),* }) => {
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
struct $struct_name
|
||||
{
|
||||
$($field_id : $field_ty),*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! rest_resource {
|
||||
($res_name:ident) => {
|
||||
struct $res_name;
|
||||
|
||||
impl ::gotham_restful::Resource for $res_name
|
||||
{
|
||||
fn name() -> String
|
||||
{
|
||||
stringify!($res_name).to_string()
|
||||
}
|
||||
|
||||
fn setup<D : ::gotham_restful::DrawResourceRoutes>(mut route : D)
|
||||
{
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue