aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2022-03-26 20:43:06 -0600
committerMelody Horn <melody@boringcactus.com>2022-03-26 20:43:06 -0600
commitcf6012c774df96fe62ddb6cbbacfb37fcab56815 (patch)
tree78a914cdd59a19b85fe682b25c8f18d0a1d31322 /src
parent4820db2b8ef7d63986fae061eccfcba5b30effce (diff)
downloadkdl-schema-cf6012c774df96fe62ddb6cbbacfb37fcab56815.tar.gz
kdl-schema-cf6012c774df96fe62ddb6cbbacfb37fcab56815.zip
add indirection in the feature names
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs142
1 files changed, 71 insertions, 71 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 695c973..f2b80cc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,118 +1,121 @@
-#[cfg(feature = "knuffel")]
+#[cfg(feature = "parse-knuffel")]
use knuffel::{Decode, DecodeScalar};
+mod schema_schema;
+pub use schema_schema::SCHEMA_SCHEMA;
+
pub trait BuildFromRef {
fn ref_to(query: impl Into<String>) -> Self;
}
#[derive(Debug, PartialEq, Eq, Default)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Schema {
- #[cfg_attr(feature = "knuffel", knuffel(child))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child))]
pub document: Document,
}
#[derive(Debug, PartialEq, Eq, Default)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Document {
- #[cfg_attr(feature = "knuffel", knuffel(child))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child))]
pub info: Info,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "node")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "node")))]
pub nodes: Vec<Node>,
}
#[derive(Debug, PartialEq, Eq, Default)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Info {
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "title")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "title")))]
pub title: Vec<TextValue>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "description")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "description")))]
pub description: Vec<TextValue>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "author")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "author")))]
pub authors: Vec<Person>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "contributor")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "contributor")))]
pub contributors: Vec<Person>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "link")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "link")))]
pub links: Vec<Link>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "license")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "license")))]
pub licenses: Vec<License>,
- #[cfg_attr(feature = "knuffel", knuffel(child))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child))]
pub published: Option<Date>,
- #[cfg_attr(feature = "knuffel", knuffel(child))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child))]
pub modified: Option<Date>,
}
#[derive(Debug, PartialEq, Eq)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct TextValue {
- #[cfg_attr(feature = "knuffel", knuffel(argument))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(argument))]
pub text: String,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub lang: Option<String>,
}
#[derive(Debug, PartialEq, Eq)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Person {
- #[cfg_attr(feature = "knuffel", knuffel(argument))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(argument))]
pub name: String,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub orcid: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "link")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "link")))]
pub links: Vec<Link>,
}
#[derive(Debug, PartialEq, Eq)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Link {
- #[cfg_attr(feature = "knuffel", knuffel(argument))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(argument))]
pub iri: String,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub rel: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub lang: Option<String>,
}
#[derive(Debug, PartialEq, Eq)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct License {
- #[cfg_attr(feature = "knuffel", knuffel(argument))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(argument))]
pub name: String,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub spdx: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "link")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "link")))]
pub link: Vec<Link>,
}
#[derive(Debug, PartialEq, Eq)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Date {
- #[cfg_attr(feature = "knuffel", knuffel(argument))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(argument))]
pub date: String,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub time: Option<String>,
}
#[derive(Debug, PartialEq, Eq, Default)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Node {
- #[cfg_attr(feature = "knuffel", knuffel(argument))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(argument))]
pub name: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub id: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub description: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub ref_: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))]
pub min: Option<usize>,
- #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))]
pub max: Option<usize>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "prop")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "prop")))]
pub props: Vec<Prop>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "value")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "value")))]
pub values: Vec<Value>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "children")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "children")))]
pub children: Vec<Children>,
}
@@ -126,19 +129,19 @@ impl BuildFromRef for Node {
}
#[derive(Debug, PartialEq, Eq, Default)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Prop {
- #[cfg_attr(feature = "knuffel", knuffel(argument))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(argument))]
pub key: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub id: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub description: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub ref_: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(child))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child))]
pub required: bool,
- #[cfg_attr(feature = "knuffel", knuffel(children))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children))]
pub validations: Vec<Validation>,
}
@@ -152,19 +155,19 @@ impl BuildFromRef for Prop {
}
#[derive(Debug, PartialEq, Eq, Default)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Value {
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub id: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub description: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub ref_: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))]
pub min: Option<usize>,
- #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))]
pub max: Option<usize>,
- #[cfg_attr(feature = "knuffel", knuffel(children))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children))]
pub validations: Vec<Validation>,
}
@@ -178,15 +181,15 @@ impl BuildFromRef for Value {
}
#[derive(Debug, PartialEq, Eq, Default)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub struct Children {
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub id: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub description: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(property))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(property))]
pub ref_: Option<String>,
- #[cfg_attr(feature = "knuffel", knuffel(children(name = "node")))]
+ #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "node")))]
pub nodes: Vec<Node>,
}
@@ -200,16 +203,16 @@ impl BuildFromRef for Children {
}
#[derive(Debug, PartialEq, Eq)]
-#[cfg_attr(feature = "knuffel", derive(Decode))]
+#[cfg_attr(feature = "parse-knuffel", derive(Decode))]
pub enum Validation {
- Type(#[cfg_attr(feature = "knuffel", knuffel(argument))] String),
- Enum(#[cfg_attr(feature = "knuffel", knuffel(arguments))] Vec<String>),
- Pattern(#[cfg_attr(feature = "knuffel", knuffel(argument))] String),
- Format(#[cfg_attr(feature = "knuffel", knuffel(arguments))] Vec<Format>),
+ Type(#[cfg_attr(feature = "parse-knuffel", knuffel(argument))] String),
+ Enum(#[cfg_attr(feature = "parse-knuffel", knuffel(arguments))] Vec<String>),
+ Pattern(#[cfg_attr(feature = "parse-knuffel", knuffel(argument))] String),
+ Format(#[cfg_attr(feature = "parse-knuffel", knuffel(arguments))] Vec<Format>),
}
#[derive(Debug, PartialEq, Eq)]
-#[cfg_attr(feature = "knuffel", derive(DecodeScalar))]
+#[cfg_attr(feature = "parse-knuffel", derive(DecodeScalar))]
pub enum Format {
DateTime,
Date,
@@ -236,6 +239,3 @@ pub enum Format {
Base64,
KdlQuery,
}
-
-mod schema_schema;
-pub use schema_schema::SCHEMA_SCHEMA;