From cf6012c774df96fe62ddb6cbbacfb37fcab56815 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sat, 26 Mar 2022 20:43:06 -0600 Subject: add indirection in the feature names --- src/lib.rs | 142 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 71 insertions(+), 71 deletions(-) (limited to 'src') 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) -> 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, } #[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, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "description")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "description")))] pub description: Vec, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "author")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "author")))] pub authors: Vec, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "contributor")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "contributor")))] pub contributors: Vec, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "link")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "link")))] pub links: Vec, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "license")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "license")))] pub licenses: Vec, - #[cfg_attr(feature = "knuffel", knuffel(child))] + #[cfg_attr(feature = "parse-knuffel", knuffel(child))] pub published: Option, - #[cfg_attr(feature = "knuffel", knuffel(child))] + #[cfg_attr(feature = "parse-knuffel", knuffel(child))] pub modified: Option, } #[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, } #[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, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "link")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "link")))] pub links: Vec, } #[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, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub lang: Option, } #[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, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "link")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "link")))] pub link: Vec, } #[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, } #[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, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub id: Option, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub description: Option, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub ref_: Option, - #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))] + #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))] pub min: Option, - #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))] + #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))] pub max: Option, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "prop")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "prop")))] pub props: Vec, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "value")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "value")))] pub values: Vec, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "children")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "children")))] pub children: Vec, } @@ -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, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub id: Option, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub description: Option, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub ref_: Option, - #[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, } @@ -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, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub description: Option, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub ref_: Option, - #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))] + #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))] pub min: Option, - #[cfg_attr(feature = "knuffel", knuffel(child, unwrap(argument)))] + #[cfg_attr(feature = "parse-knuffel", knuffel(child, unwrap(argument)))] pub max: Option, - #[cfg_attr(feature = "knuffel", knuffel(children))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children))] pub validations: Vec, } @@ -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, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub description: Option, - #[cfg_attr(feature = "knuffel", knuffel(property))] + #[cfg_attr(feature = "parse-knuffel", knuffel(property))] pub ref_: Option, - #[cfg_attr(feature = "knuffel", knuffel(children(name = "node")))] + #[cfg_attr(feature = "parse-knuffel", knuffel(children(name = "node")))] pub nodes: Vec, } @@ -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), - Pattern(#[cfg_attr(feature = "knuffel", knuffel(argument))] String), - Format(#[cfg_attr(feature = "knuffel", knuffel(arguments))] Vec), + Type(#[cfg_attr(feature = "parse-knuffel", knuffel(argument))] String), + Enum(#[cfg_attr(feature = "parse-knuffel", knuffel(arguments))] Vec), + Pattern(#[cfg_attr(feature = "parse-knuffel", knuffel(argument))] String), + Format(#[cfg_attr(feature = "parse-knuffel", knuffel(arguments))] Vec), } #[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; -- cgit v1.2.3