removed the traits so this thing works
This commit is contained in:
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -2,10 +2,22 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-trait"
|
||||||
|
version = "0.1.88"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_http"
|
name = "derive_http"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"async-trait",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
|
@ -7,6 +7,7 @@ edition = "2024"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
async-trait = "0.1.88"
|
||||||
proc-macro2 = "1.0.95"
|
proc-macro2 = "1.0.95"
|
||||||
quote = "1.0.40"
|
quote = "1.0.40"
|
||||||
syn = { version = "2.0.104", features = ["full"] }
|
syn = { version = "2.0.104", features = ["full"] }
|
||||||
|
16
src/lib.rs
16
src/lib.rs
@ -1,22 +1,8 @@
|
|||||||
|
use async_trait::async_trait;
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::{parse_macro_input, ItemEnum, Lit, DeriveInput, Fields, Data};
|
use syn::{parse_macro_input, ItemEnum, Lit, DeriveInput, Fields, Data};
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
pub trait Queryable {
|
|
||||||
///send the query types query and get the response returned as the
|
|
||||||
///proper response type
|
|
||||||
pub fn send(
|
|
||||||
&self,
|
|
||||||
base_url: &str,
|
|
||||||
headers: Option<Vec<(&str, &str)>>,
|
|
||||||
) -> Result<Response, std::io::Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Responsable {
|
|
||||||
pub fn receive(resp: Response) -> Result<Self, std::error::Error>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[proc_macro_derive(HttpRequest, attributes(http_get))]
|
#[proc_macro_derive(HttpRequest, attributes(http_get))]
|
||||||
pub fn derive_http_get_request(input: TokenStream) -> TokenStream {
|
pub fn derive_http_get_request(input: TokenStream) -> TokenStream {
|
||||||
let input = parse_macro_input!(input as DeriveInput);
|
let input = parse_macro_input!(input as DeriveInput);
|
||||||
|
Reference in New Issue
Block a user