Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
e1d512e82f |
2 changed files with 31 additions and 1 deletions
|
@ -8,11 +8,13 @@ description = "Reimplementation of the Scansion project in Rust"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nom = "7.1"
|
nom = "7.1"
|
||||||
jid = { version = "*", features = [ "minidom" ] }
|
jid = { version = "*", features = [ "minidom", "quote" ] }
|
||||||
minidom = "*"
|
minidom = "*"
|
||||||
xmpp-parsers = "0.20"
|
xmpp-parsers = "0.20"
|
||||||
nom_locate = "4.0.0"
|
nom_locate = "4.0.0"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
proc-macro2 = "*"
|
||||||
|
quote = "1.0"
|
||||||
|
|
||||||
# [patch.crates-io]
|
# [patch.crates-io]
|
||||||
# jid = { path = "../xmpp-rs/jid" }
|
# jid = { path = "../xmpp-rs/jid" }
|
||||||
|
|
28
src/types.rs
28
src/types.rs
|
@ -7,6 +7,8 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
|
use proc_macro2::TokenStream;
|
||||||
|
use quote::{quote, ToTokens};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum VariableAttr {
|
pub enum VariableAttr {
|
||||||
|
@ -67,11 +69,37 @@ impl Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToTokens for Client {
|
||||||
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||||
|
let custom_host = if self.custom_host.is_none() { quote! { None } } else { quote! { #self.custom_host } };
|
||||||
|
let custom_port = if self.custom_port.is_none() { quote! { None } } else { quote! { #self.custom_port } };
|
||||||
|
|
||||||
|
let t = quote! {
|
||||||
|
Client {
|
||||||
|
jid: #self.jid,
|
||||||
|
password: String::from(#self.password),
|
||||||
|
custom_host: #custom_host,
|
||||||
|
custom_port: #custom_port,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
tokens.extend(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub enum Entity {
|
pub enum Entity {
|
||||||
Client(Client),
|
Client(Client),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToTokens for Entity {
|
||||||
|
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||||
|
tokens.extend(match self {
|
||||||
|
Entity::Client(client) => quote! { Entity::Client(#client) },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub type Context = HashMap<Name, Entity>;
|
pub type Context = HashMap<Name, Entity>;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
|
Loading…
Reference in a new issue