lumeohq / xsd-parser-rs

A xsd/wsdl => rust code generator written in rust
Apache License 2.0
100 stars 39 forks source link

Support for restriction emumerations #7

Closed LeonidKrutovsky closed 4 years ago

LeonidKrutovsky commented 4 years ago
<xs:simpleType name="PropertyOperation">
  <xs:restriction base="xs:string">
    <xs:enumeration value="Initialized"/>
    <xs:enumeration value="Deleted"/>
    <xs:enumeration value="Changed"/>
  </xs:restriction>
</xs:simpleType>
LeonidKrutovsky commented 4 years ago
pub enum PropertyOperation {
  Initialized,
  Deleted,
  Changed,
  __Unknown__(String)
}

impl PropertyOperation {
  pub fn new(s: &str) -> Self {
    match s {
      "Initialized" => Self::Initialized,
      "Deleted" => Self::Deleted,
      "Changed" => Self::Changed,
      value => Self::__Unknown__(value.to_string()),
    }
  }
}