Skip to content

Commit

Permalink
Make the schema field optional
Browse files Browse the repository at this point in the history
Some devices that have created fake SVDs, such as for the MSP430, may not
have schemas listed.

Co-authored-by:  =?UTF-8?q?Emil=20Gardstr=C3=B6m?=
<emil.gardstrom@gmail.com>
  • Loading branch information
James Munns authored and Emilgardis committed Nov 18, 2018
1 parent 6aa4fdc commit 42903dd
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/svd/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use svd::peripheral::Peripheral;
#[derive(Clone, Debug)]
pub struct Device {
pub name: String,
schema_version: String,
schema_version: Option<String>,
pub version: Option<String>,
pub description: Option<String>,
pub address_unit_bits: Option<u32>,
Expand All @@ -40,8 +40,7 @@ impl Parse for Device {
name: tree.get_child_text("name")?,
schema_version: tree.attributes
.get("schemaVersion")
.unwrap()
.clone(),
.map(|s| s.clone()),
cpu: parse::optional::<Cpu>("cpu", tree)?,
version: tree.get_child_text_opt("version")?,
description: tree.get_child_text_opt("description")?,
Expand Down Expand Up @@ -79,7 +78,10 @@ impl Encode for Device {
);
elem.attributes.insert(
String::from("schemaVersion"),
format!("{}", self.schema_version),
match self.schema_version {
Some(schema_version) => format!("{}", self.schema_version),
None => format!(""),
}
);
elem.attributes.insert(
String::from("xs:noNamespaceSchemaLocation"),
Expand Down

0 comments on commit 42903dd

Please sign in to comment.