pub enum ContentMode {
Auto,
Enum,
Struct,
}Expand description
Tells the Generator what type should be generated for
the content of an XML element.
Variants§
Auto
The mode is selected depending on the type definition of the element.
xs:choice types will be rendered as enum, xs:all and xs:sequence
types will be rendered as struct.
§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:complexType>
<xs:complexType name="MyChoice">
<xs:choice>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:choice>
</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:complexType>
</xs:schema>If the content mode is set to ContentMode::Auto the following code is rendered:
#[derive(Debug, Clone)]
pub struct MyAllType {
pub a: i32,
pub b: String,
}
#[derive(Debug, Clone)]
pub struct MyChoiceType {
pub content: MyChoiceTypeContent,
}
#[derive(Debug, Clone)]
pub enum MyChoiceTypeContent {
A(i32),
B(String),
}
#[derive(Debug, Clone)]
pub struct MySequenceType {
pub a: i32,
pub b: String,
}Enum
The content of a XML element is always rendered as enum.
§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:complexType>
<xs:complexType name="MyChoice">
<xs:choice>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:choice>
</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:complexType>
</xs:schema>If the content mode is set to ContentMode::Enum the following code is rendered:
#[derive(Debug, Clone)]
pub struct MyAllType {
pub content: [MyAllTypeContent; 2usize],
}
#[derive(Debug, Clone)]
pub enum MyAllTypeContent {
A(i32),
B(String),
}
#[derive(Debug, Clone)]
pub struct MyChoiceType {
pub content: MyChoiceTypeContent,
}
#[derive(Debug, Clone)]
pub enum MyChoiceTypeContent {
A(i32),
B(String),
}
#[derive(Debug, Clone)]
pub struct MySequenceType {
pub content: [MySequenceTypeContent; 2usize],
}
#[derive(Debug, Clone)]
pub enum MySequenceTypeContent {
A(i32),
B(String),
}Struct
The content of a XML element is always rendered as struct.
§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:complexType>
<xs:complexType name="MyChoice">
<xs:choice>
<xs:element name="a" type="xs:int" />
<xs:element name="b" type="xs:string" />
</xs:choice>
</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:complexType>
</xs:schema>If the content mode is set to ContentMode::Struct the following code is rendered:
#[derive(Debug, Clone)]
pub struct MyAllType {
pub a: i32,
pub b: String,
}
#[derive(Debug, Clone)]
pub struct MyChoiceType {
pub a: Option<i32>,
pub b: Option<String>,
}
#[derive(Debug, Clone)]
pub struct MySequenceType {
pub a: i32,
pub b: String,
}Trait Implementations§
Source§impl Clone for ContentMode
impl Clone for ContentMode
Source§fn clone(&self) -> ContentMode
fn clone(&self) -> ContentMode
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 ContentMode
impl Debug for ContentMode
Source§impl Default for ContentMode
impl Default for ContentMode
Source§fn default() -> ContentMode
fn default() -> ContentMode
Returns the “default value” for a type. Read more
Source§impl PartialEq for ContentMode
impl PartialEq for ContentMode
impl Copy for ContentMode
impl Eq for ContentMode
impl StructuralPartialEq for ContentMode
Auto Trait Implementations§
impl Freeze for ContentMode
impl RefUnwindSafe for ContentMode
impl Send for ContentMode
impl Sync for ContentMode
impl Unpin for ContentMode
impl UnwindSafe for ContentMode
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