#[non_exhaustive]pub struct Config {
pub add_space_before_slash_in_empty_elements: bool,
}Expand description
A struct that holds a writer configuration.
Current writer configuration can be retrieved by calling Writer::config()
and changed by changing properties of the object returned by a call to
Writer::config_mut().
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.add_space_before_slash_in_empty_elements: boolWhether to add a space before the closing slash in empty elements. According to the W3C guidelines, this is recommended as for maximum compatibility.
When set to true, empty elements will be terminated with “ />”.
When set to false, empty elements will be terminated with “/>”.
Default: false
§Example
use quick_xml::reader::Reader;
use quick_xml::writer::Writer;
use std::io::Cursor;
let mut writer = Writer::new(Cursor::new(Vec::new()));
writer.config_mut().add_space_before_slash_in_empty_elements = true;
writer.create_element("tag")
.with_attribute(("attr1", "value1"))
.write_empty()
.unwrap();
let result = writer.into_inner().into_inner();
let expected = r#"<tag attr1="value1" />"#;
assert_eq!(result, expected.as_bytes());Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for Config
impl<'arbitrary> Arbitrary<'arbitrary> for Config
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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