Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
330 changes: 265 additions & 65 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion wsdl-parser-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ path = "src/main.rs"
[dependencies]
anyhow = "1.0.42"
clap = "2.33.3"
roxmltree = { version = "0.14.0", features = ["std"] }
roxmltree = { version = "0.16.0", features = ["std"] }
wsdl-parser = { path = "../wsdl-parser" }
xsd-parser = { path = "../xsd-parser" }
2 changes: 1 addition & 1 deletion wsdl-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0"

[dependencies]
Inflector = "0.11.4"
roxmltree = "0.14.0"
roxmltree = "0.16.0"

[dev-dependencies]
syn = { version = "1.0.58", features = ["full"] }
Expand Down
6 changes: 3 additions & 3 deletions xsd-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "MIT OR Apache-2.0"

[dependencies]
Inflector = "0.11.4"
roxmltree = "0.14.0"
roxmltree = "0.16.0"

[dev-dependencies]
num-bigint = "0.4.2"
Expand All @@ -21,5 +21,5 @@ text-diff = "0.4.0"
xml-rs = "0.8.3"
xsd-macro-utils = { path = "../xsd-macro-utils" }
xsd-types = { path = "../xsd-types" }
yaserde = "0.7.1"
yaserde_derive = "0.7.1"
yaserde = "0.8.0"
yaserde_derive = "0.8.0"
4 changes: 2 additions & 2 deletions xsd-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ chrono = "0.4.19"
num-bigint = "0.4.2"
xml-rs = "0.8.3"
xsd-macro-utils = { path = "../xsd-macro-utils" }
yaserde = "0.7.1"
yaserde = "0.8.0"

[dev-dependencies]
yaserde_derive = "0.7.1"
yaserde_derive = "0.8.0"
40 changes: 20 additions & 20 deletions xsd-types/src/types/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Date {
impl Default for Date {
fn default() -> Date {
Self {
value: NaiveDate::from_ymd(1, 1, 1),
value: NaiveDate::from_ymd_opt(1, 1, 1).unwrap(),
timezone: None,
}
}
Expand All @@ -43,7 +43,7 @@ impl FromStr for Date {
if let Some(s) = s.strip_suffix('Z') {
return Ok(Date {
value: parse_naive_date(s)?,
timezone: Some(FixedOffset::east(0)),
timezone: Some(FixedOffset::east_opt(0).unwrap()),
});
}

Expand Down Expand Up @@ -100,7 +100,7 @@ mod tests {
assert_eq!(
Date::from_str("2020-02-02"),
Ok(Date {
value: NaiveDate::from_ymd(2020, 2, 2),
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: None
})
);
Expand All @@ -109,26 +109,26 @@ mod tests {
assert_eq!(
Date::from_str("2020-02-02Z"),
Ok(Date {
value: NaiveDate::from_ymd(2020, 2, 2),
timezone: Some(FixedOffset::east(0))
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: Some(FixedOffset::east_opt(0).unwrap())
})
);

// Positive offset.
assert_eq!(
Date::from_str("2020-02-02+06:30"),
Ok(Date {
value: NaiveDate::from_ymd(2020, 2, 2),
timezone: Some(FixedOffset::east(6 * 3600 + 30 * 60))
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: Some(FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap())
})
);

// Negative offset.
assert_eq!(
Date::from_str("2020-02-02-06:30"),
Ok(Date {
value: NaiveDate::from_ymd(2020, 2, 2),
timezone: Some(FixedOffset::west(6 * 3600 + 30 * 60))
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: Some(FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap())
})
);
}
Expand All @@ -138,7 +138,7 @@ mod tests {
// No timezone.
assert_eq!(
Date {
value: NaiveDate::from_ymd(2020, 2, 2),
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: None
}
.to_string(),
Expand All @@ -148,8 +148,8 @@ mod tests {
// Timezone +00:00.
assert_eq!(
Date {
value: NaiveDate::from_ymd(2020, 2, 2),
timezone: Some(FixedOffset::east(0))
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: Some(FixedOffset::east_opt(0).unwrap())
}
.to_string(),
"2020-02-02+00:00"
Expand All @@ -158,8 +158,8 @@ mod tests {
// Positive offset.
assert_eq!(
Date {
value: NaiveDate::from_ymd(2020, 2, 2),
timezone: Some(FixedOffset::east(6 * 3600 + 30 * 60))
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: Some(FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap())
}
.to_string(),
"2020-02-02+06:30"
Expand All @@ -168,8 +168,8 @@ mod tests {
// Negative offset.
assert_eq!(
Date {
value: NaiveDate::from_ymd(2020, 2, 2),
timezone: Some(FixedOffset::west(6 * 3600 + 30 * 60))
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: Some(FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap())
}
.to_string(),
"2020-02-02-06:30"
Expand Down Expand Up @@ -197,8 +197,8 @@ mod tests {
"#;
let m = Message {
created_at: Date {
value: NaiveDate::from_ymd(2020, 2, 2),
timezone: Some(FixedOffset::east(6 * 3600 + 30 * 60)),
value: NaiveDate::from_ymd_opt(2020, 2, 2).unwrap(),
timezone: Some(FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap()),
},
text: "Hello world".to_string(),
};
Expand All @@ -216,10 +216,10 @@ mod tests {
</t:Message>
"#;
let m: Message = yaserde::de::from_str(s).unwrap();
assert_eq!(m.created_at.value, NaiveDate::from_ymd(2020, 2, 2));
assert_eq!(m.created_at.value, NaiveDate::from_ymd_opt(2020, 2, 2).unwrap());
assert_eq!(
m.created_at.timezone,
Some(FixedOffset::west(6 * 3600 + 30 * 60)),
Some(FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap()),
);
assert_eq!(m.text, "Hello world".to_string());
}
Expand Down
32 changes: 16 additions & 16 deletions xsd-types/src/types/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ mod tests {
#[test]
fn datetime_parse_test() {
// No timezone.
let offset = FixedOffset::east(0);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(0).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTime::from_str("2020-03-07T04:40:00"),
Expand All @@ -78,17 +78,17 @@ mod tests {
);

// Positive offset.
let offset = FixedOffset::east(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTime::from_str("2020-03-07T04:40:00+06:30"),
Ok(DateTime { value: dt })
);

// Negative offset.
let offset = FixedOffset::west(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTime::from_str("2020-03-07T04:40:00-06:30"),
Expand All @@ -99,26 +99,26 @@ mod tests {
#[test]
fn datetime_display_test() {
// Timezone +00:00.
let offset = FixedOffset::east(0);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(0).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTime { value: dt }.to_string(),
"2020-03-07T04:40:00+00:00"
);

// Positive offset.
let offset = FixedOffset::east(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTime { value: dt }.to_string(),
"2020-03-07T04:40:00+06:30"
);

// Negative offset.
let offset = FixedOffset::west(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTime { value: dt }.to_string(),
Expand Down Expand Up @@ -146,8 +146,8 @@ mod tests {
</t:Message>
"#;

let offset = FixedOffset::east(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
let m = Message {
created_at: DateTime { value: dt },
Expand All @@ -168,8 +168,8 @@ mod tests {
"#;
let m: Message = yaserde::de::from_str(s).unwrap();

let offset = FixedOffset::west(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);

assert_eq!(m.created_at.value, dt);
Expand Down
35 changes: 19 additions & 16 deletions xsd-types/src/types/datetimestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ mod tests {
#[test]
fn datetime_parse_test() {
// No timezone.
let offset = FixedOffset::east(0);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(0).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7)
.unwrap()
.and_hms_opt(4, 40, 0).unwrap()
- offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert!(DateTimeStamp::from_str("2020-03-07T04:40:00").is_err());
// Timezone "Z".
Expand All @@ -60,17 +63,17 @@ mod tests {
);

// Positive offset.
let offset = FixedOffset::east(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTimeStamp::from_str("2020-03-07T04:40:00+06:30"),
Ok(DateTimeStamp::from_chrono_datetime(dt))
);

// Negative offset.
let offset = FixedOffset::west(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTimeStamp::from_str("2020-03-07T04:40:00-06:30"),
Expand All @@ -81,26 +84,26 @@ mod tests {
#[test]
fn datetime_display_test() {
// Timezone +00:00.
let offset = FixedOffset::east(0);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(0).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTimeStamp::from_chrono_datetime(dt).to_string(),
"2020-03-07T04:40:00+00:00"
);

// Positive offset.
let offset = FixedOffset::east(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTimeStamp::from_chrono_datetime(dt).to_string(),
"2020-03-07T04:40:00+06:30"
);

// Negative offset.
let offset = FixedOffset::west(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
assert_eq!(
DateTimeStamp::from_chrono_datetime(dt).to_string(),
Expand Down Expand Up @@ -128,8 +131,8 @@ mod tests {
</t:Message>
"#;

let offset = FixedOffset::east(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::east_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);
let m = Message {
created_at: DateTimeStamp::from_chrono_datetime(dt),
Expand All @@ -150,8 +153,8 @@ mod tests {
"#;
let m: Message = yaserde::de::from_str(s).unwrap();

let offset = FixedOffset::west(6 * 3600 + 30 * 60);
let dt_utc = NaiveDate::from_ymd(2020, 3, 7).and_hms(4, 40, 0) - offset;
let offset = FixedOffset::west_opt(6 * 3600 + 30 * 60).unwrap();
let dt_utc = NaiveDate::from_ymd_opt(2020, 3, 7).unwrap().and_hms_opt(4, 40, 0).unwrap() - offset;
let dt = CDateTime::<FixedOffset>::from_utc(dt_utc, offset);

assert_eq!(m.created_at.value, DateTime::from_chrono_datetime(dt));
Expand Down
Loading