-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add xml schema object. This allows users to define xml styles for properties of objects. * Add tests
- Loading branch information
Showing
11 changed files
with
422 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use std::borrow::Cow; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Default, Clone)] | ||
#[cfg_attr(feature = "debug", derive(Debug))] | ||
pub struct Xml { | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub name: Option<Cow<'static, str>>, | ||
|
||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub namespace: Option<Cow<'static, str>>, | ||
|
||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub prefix: Option<Cow<'static, str>>, | ||
|
||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub attribute: Option<bool>, | ||
|
||
#[serde(skip_serializing_if = "Option::is_none")] | ||
pub wrapped: Option<bool>, | ||
} | ||
|
||
impl Xml { | ||
pub fn new() -> Self { | ||
Self { | ||
..Default::default() | ||
} | ||
} | ||
|
||
pub fn name<S: Into<Cow<'static, str>>>(mut self, name: Option<S>) -> Self { | ||
self.name = name.map(|name| name.into()); | ||
|
||
self | ||
} | ||
|
||
pub fn namespace<S: Into<Cow<'static, str>>>(mut self, namespace: Option<S>) -> Self { | ||
self.namespace = namespace.map(|namespace| namespace.into()); | ||
|
||
self | ||
} | ||
|
||
pub fn prefix<S: Into<Cow<'static, str>>>(mut self, prefix: Option<S>) -> Self { | ||
self.prefix = prefix.map(|prefix| prefix.into()); | ||
|
||
self | ||
} | ||
|
||
pub fn attribute(mut self, attribute: Option<bool>) -> Self { | ||
self.attribute = attribute; | ||
|
||
self | ||
} | ||
|
||
pub fn wrapped(mut self, wrapped: Option<bool>) -> Self { | ||
self.wrapped = wrapped; | ||
|
||
self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.