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.
Trait Implementations§
Source§impl Clone for SerdeSupport
impl Clone for SerdeSupport
Source§fn clone(&self) -> SerdeSupport
fn clone(&self) -> SerdeSupport
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SerdeSupport
impl Debug for SerdeSupport
Source§impl Default for SerdeSupport
impl Default for SerdeSupport
Source§fn default() -> SerdeSupport
fn default() -> SerdeSupport
Returns the “default value” for a type. Read more
Source§impl PartialEq for SerdeSupport
impl PartialEq for SerdeSupport
impl Copy for SerdeSupport
impl Eq for SerdeSupport
impl StructuralPartialEq for SerdeSupport
Auto Trait Implementations§
impl Freeze for SerdeSupport
impl RefUnwindSafe for SerdeSupport
impl Send for SerdeSupport
impl Sync for SerdeSupport
impl Unpin for SerdeSupport
impl UnwindSafe for SerdeSupport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more