pub enum SerdeSupport {
None,
QuickXml,
SerdeXmlRs,
}Variants§
None
No code for the serde crate is generated.
§Examples
Consider the following XML schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.com"
targetNamespace="http://example.com">
<xs:complexType name="MyAll">
<xs:all>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:all>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
<xs:complexType name="MyChoice">
<xs:choice>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:choice>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
<xs:complexType name="MySequence">
<xs:sequence>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:sequence>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
</xs:schema>If the serde support mode is set to SerdeSupport::None the following code is rendered:
#[derive(Debug, Clone)]
pub struct MyAllType {
pub x: Option<bool>,
pub a: i32,
pub b: String,
}
#[derive(Debug, Clone)]
pub struct MyChoiceType {
pub x: Option<bool>,
pub content: MyChoiceTypeContent,
}
#[derive(Debug, Clone)]
pub enum MyChoiceTypeContent {
A(i32),
B(String),
}
#[derive(Debug, Clone)]
pub struct MySequenceType {
pub x: Option<bool>,
pub a: i32,
pub b: String,
}QuickXml
Generates code that can be serialized and deserialized using the
serde create in combination with the with quick_xml crate.
§Examples
Consider the following XML schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.com"
targetNamespace="http://example.com">
<xs:complexType name="MyAll">
<xs:all>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:all>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
<xs:complexType name="MyChoice">
<xs:choice>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:choice>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
<xs:complexType name="MySequence">
<xs:sequence>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:sequence>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
</xs:schema>If the serde support mode is set to SerdeSupport::QuickXml the following code is rendered:
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyAllType {
#[serde(default, rename = "@x")]
pub x: Option<bool>,
#[serde(rename = "a")]
pub a: i32,
#[serde(rename = "b")]
pub b: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyChoiceType {
#[serde(default, rename = "@x")]
pub x: Option<bool>,
#[serde(rename = "$value")]
pub content: MyChoiceTypeContent,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MyChoiceTypeContent {
#[serde(rename = "a")]
A(i32),
#[serde(rename = "b")]
B(String),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MySequenceType {
#[serde(default, rename = "@x")]
pub x: Option<bool>,
#[serde(rename = "a")]
pub a: i32,
#[serde(rename = "b")]
pub b: String,
}SerdeXmlRs
Generates code that can be serialized and deserialized using the
serde create in combination with the with serde-xml-rs crate.
§Examples
Consider the following XML schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.com"
targetNamespace="http://example.com">
<xs:complexType name="MyAll">
<xs:all>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:all>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
<xs:complexType name="MyChoice">
<xs:choice>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:choice>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
<xs:complexType name="MySequence">
<xs:sequence>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:sequence>
<xs:attribute name="x" type="xs:boolean" />
</xs:complexType>
</xs:schema>If the serde support mode is set to SerdeSupport::SerdeXmlRs the following code is rendered:
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyAllType {
#[serde(default, rename = "x")]
pub x: Option<bool>,
#[serde(rename = "a")]
pub a: i32,
#[serde(rename = "b")]
pub b: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MyChoiceType {
#[serde(default, rename = "x")]
pub x: Option<bool>,
#[serde(rename = "$value")]
pub content: MyChoiceTypeContent,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum MyChoiceTypeContent {
#[serde(rename = "a")]
A(i32),
#[serde(rename = "b")]
B(String),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MySequenceType {
#[serde(default, rename = "x")]
pub x: Option<bool>,
#[serde(rename = "a")]
pub a: i32,
#[serde(rename = "b")]
pub b: String,
}Implementations§
Source§impl SerdeSupport
impl SerdeSupport
Sourcepub fn is_none(&self) -> bool
pub fn is_none(&self) -> bool
Returns true if this is equal to SerdeSupport::None, false otherwise.
Sourcepub fn is_some(&self) -> bool
pub fn is_some(&self) -> bool
Returns false if this is equal to SerdeSupport::None, true otherwise.
Trait Implementations§
Source§impl Clone for SerdeSupport
impl Clone for SerdeSupport
Source§fn clone(&self) -> SerdeSupport
fn clone(&self) -> SerdeSupport
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more