|
| 1 | +use syn::LitStr; |
| 2 | + |
| 3 | +/// Represents attribute contents that can be parsed from #[ld(...)] on structs. |
| 4 | +/// |
| 5 | +/// Possible formats: |
| 6 | +/// - type = "http://example.org/Person" |
| 7 | +/// - prefix("ex" = "http://example.org/") |
| 8 | +#[derive(Debug)] |
| 9 | +pub enum StructAttribute { |
| 10 | + Type(TypeAttribute), |
| 11 | + Prefix(PrefixAttribute), |
| 12 | +} |
| 13 | + |
| 14 | +/// Represents attribute contents that can be parsed from #[ld(...)] on enums. |
| 15 | +/// |
| 16 | +/// Possible formats: |
| 17 | +/// - prefix("ex" = "http://example.org/") |
| 18 | +#[derive(Debug)] |
| 19 | +pub enum EnumAttribute { |
| 20 | + Prefix(PrefixAttribute), |
| 21 | +} |
| 22 | + |
| 23 | +/// Represents attribute contents that can be parsed from #[ld(...)] on enum variants. |
| 24 | +/// |
| 25 | +/// Possible formats: |
| 26 | +/// - "http://example.org/property" |
| 27 | +#[derive(Debug)] |
| 28 | +pub enum VariantAttribute { |
| 29 | + Iri(LitStr), |
| 30 | +} |
| 31 | + |
| 32 | +/// Represents attribute contents that can be parsed from #[ld(...)] on struct fields. |
| 33 | +/// |
| 34 | +/// Possible formats: |
| 35 | +/// - ignore |
| 36 | +/// - "http://example.org/property" |
| 37 | +/// - flatten |
| 38 | +/// - id |
| 39 | +/// - type |
| 40 | +/// - graph |
| 41 | +#[derive(Debug)] |
| 42 | +pub enum FieldAttribute { |
| 43 | + /// Marks the field to be ignored during serialization/deserialization |
| 44 | + Ignore, |
| 45 | + /// Specifies the IRI for the field |
| 46 | + Iri(LitStr), |
| 47 | + /// Indicates that field's contents should be flattened |
| 48 | + Flatten, |
| 49 | + /// Marks the field as an ID field |
| 50 | + Id, |
| 51 | + /// Marks the field as a graph value |
| 52 | + Graph, |
| 53 | +} |
| 54 | + |
| 55 | +/// Represents a type attribute value. |
| 56 | +/// |
| 57 | +/// Format: type = "http://example.org/Type" or type = "prefix:Type" |
| 58 | +#[derive(Debug)] |
| 59 | +pub struct TypeAttribute { |
| 60 | + pub identifier: LitStr, |
| 61 | +} |
| 62 | + |
| 63 | +/// Represents a prefix attribute value. |
| 64 | +/// |
| 65 | +/// Format: prefix("ex" = "http://example.org/") |
| 66 | +#[derive(Debug)] |
| 67 | +pub struct PrefixAttribute { |
| 68 | + pub mapping: PrefixMapping, |
| 69 | +} |
| 70 | + |
| 71 | +/// Represents a prefix mapping with a prefix and an IRI. |
| 72 | +/// |
| 73 | +/// Format: "ex" = "http://example.org/" |
| 74 | +#[derive(Debug)] |
| 75 | +pub struct PrefixMapping { |
| 76 | + pub prefix: LitStr, |
| 77 | + pub iri: LitStr, |
| 78 | +} |
0 commit comments