Drop ElementName trait and macros crate
This commit is contained in:
parent
99f90f3c08
commit
6478cff2e0
|
@ -1,6 +1,2 @@
|
|||
[workspace]
|
||||
|
||||
members = [
|
||||
'epp-client-macros',
|
||||
'epp-client'
|
||||
]
|
||||
members = ['epp-client']
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
/target
|
||||
Cargo.lock
|
|
@ -1,16 +0,0 @@
|
|||
[package]
|
||||
name = "epp-client-macros"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
authors = ["Ritesh Chitlangi <ritesh@ayravat.com>"]
|
||||
description = "Macros for the epp-client Library"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = { version = "1", features = ["full", "fold"] }
|
||||
quote = "1"
|
|
@ -1,3 +0,0 @@
|
|||
# Macros for the EPP Client Library
|
||||
|
||||
Macros for the [epp-client](https://crates.io/crates/epp-client) rust library for Internet domain registration and management.
|
|
@ -1,53 +0,0 @@
|
|||
//! # Macros for the epp-client Library.
|
||||
//!
|
||||
//! ## Description
|
||||
//!
|
||||
//! `epp-client` is a client library for Internet domain registration and management for domain registrars.
|
||||
//! This macro crate contains a few macros to simplify serialization of generic types used in some places
|
||||
//! in the `epp-client` library
|
||||
//!
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
fn element_name_macro(ast: &syn::DeriveInput) -> TokenStream {
|
||||
let name = &ast.ident;
|
||||
let mut elem_name = ast.ident.to_string();
|
||||
let (impl_generics, type_generics, _) = &ast.generics.split_for_impl();
|
||||
|
||||
if !ast.attrs.is_empty() {
|
||||
let attribute = &ast.attrs[0];
|
||||
match attribute.parse_meta() {
|
||||
Ok(syn::Meta::List(meta)) => {
|
||||
if !meta.nested.is_empty() {
|
||||
elem_name = match &meta.nested[0] {
|
||||
syn::NestedMeta::Meta(syn::Meta::NameValue(v)) => match &v.lit {
|
||||
syn::Lit::Str(lit) => lit.value(),
|
||||
_ => panic!("Invalid element_name attribute"),
|
||||
},
|
||||
_ => panic!("Invalid element_name attribute"),
|
||||
};
|
||||
} else {
|
||||
panic!("Invalid element_name attribute");
|
||||
}
|
||||
}
|
||||
_ => panic!("Invalid element_name attribute"),
|
||||
};
|
||||
}
|
||||
|
||||
let implement = quote! {
|
||||
impl #impl_generics ElementName for #name #type_generics {
|
||||
const ELEMENT: &'static str = #elem_name;
|
||||
}
|
||||
};
|
||||
implement.into()
|
||||
}
|
||||
|
||||
#[proc_macro_derive(ElementName, attributes(element_name))]
|
||||
pub fn element_name_derive(input: TokenStream) -> TokenStream {
|
||||
let ast = syn::parse(input).expect("Error while parsing ElementName macro input");
|
||||
|
||||
element_name_macro(&ast)
|
||||
}
|
|
@ -7,10 +7,7 @@ authors = ["Ritesh Chitlangi <ritesh@ayravat.com>"]
|
|||
description = "EPP (Extensible Provisioning Protocol) Client Library for Domain Registration and Management"
|
||||
repository = "https://github.com/masalachai/epp-client"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
epp-client-macros = { version = "0.1", path = "../epp-client-macros" }
|
||||
celes = "2.1"
|
||||
chrono = "0.4"
|
||||
quick-xml = { version = "0.22", features = [ "serialize" ] }
|
||||
|
|
|
@ -31,11 +31,6 @@ impl From<String> for StringValue {
|
|||
}
|
||||
}
|
||||
|
||||
/// Trait to set correct value for xml tags when tags are being generated from generic types
|
||||
pub trait ElementName {
|
||||
const ELEMENT: &'static str;
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
/// An empty placeholder tag. To be refactored to something more compliant later.
|
||||
pub struct NoExtension;
|
||||
|
|
Loading…
Reference in New Issue