Skip to content

Commit

Permalink
モデル定義用クレートを少し調整
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Dec 29, 2023
1 parent bc431bf commit 3ce0640
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
11 changes: 10 additions & 1 deletion nusamai-citygml/macros/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,16 @@ fn generate_citygml_impl_for_struct(
continue;
}
attr.parse_nested_meta(|meta| {
if meta.path.is_ident("path") {
if meta.path.is_ident("required") {
// TODO: required
Ok(())

Check warning on line 80 in nusamai-citygml/macros/src/derive.rs

View check run for this annotation

Codecov / codecov/patch

nusamai-citygml/macros/src/derive.rs#L80

Added line #L80 was not covered by tests
}
else if meta.path.is_ident("codelist") {
// TODO: codelist
let _codelist: LitStr = meta.value()?.parse()?;
Ok(())

Check warning on line 85 in nusamai-citygml/macros/src/derive.rs

View check run for this annotation

Codecov / codecov/patch

nusamai-citygml/macros/src/derive.rs#L84-L85

Added lines #L84 - L85 were not covered by tests
}
else if meta.path.is_ident("path") {
let path: LitByteStr = meta.value()?.parse()?;

if path.value().starts_with(b"@") {
Expand Down
8 changes: 4 additions & 4 deletions nusamai-citygml/macros/src/type_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ fn modify(ty: &ElementType, args: &FeatureArgs, input: &mut DeriveInput) -> Resu
add_named_field(
fields,
quote! {
#[citygml(path = b"gml:name")]
pub name: Vec<String>
#[citygml(path = b"gml:description")]
pub description: Option<String>
},
);
add_named_field(
fields,
quote! {
#[citygml(path = b"gml:description")]
pub description: Option<String>
#[citygml(path = b"gml:name")]
pub name: Vec<String>
},
);
add_named_field(
Expand Down
9 changes: 8 additions & 1 deletion nusamai-citygml/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ use serde::{Deserialize, Serialize};
use std::io::BufRead;

pub type Date = chrono::NaiveDate;
pub type GYear = String; // TODO?
pub type GYearMonth = String; // TODO?
pub type MeasureOrNullList = String; // TODO?
pub type BuildingLODType = String; // TODO?
pub type DoubleList = String; // TODO?

impl CityGMLElement for String {
const ELEMENT_TYPE: ElementType = ElementType::BasicType;
Expand Down Expand Up @@ -201,12 +206,14 @@ impl CityGMLElement for bool {
}
}

#[derive(Debug, Default, serde::Serialize, serde::Deserialize)]
#[derive(Debug, Default, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct Measure {
pub value: f64,
// pub uom: Option<String>,
}

pub type Length = Measure;

impl CityGMLElement for Measure {
const ELEMENT_TYPE: ElementType = ElementType::BasicType;

Expand Down

0 comments on commit 3ce0640

Please sign in to comment.