xso

Trait AsOptionalXmlText

Source
pub trait AsOptionalXmlText {
    // Required method
    fn as_optional_xml_text(&self) -> Result<Option<Cow<'_, str>>, Error>;
}
Expand description

Specialized variant of AsXmlText.

Normally, it should not be necessary to implement this trait as it is automatically implemented for all types implementing AsXmlText. However, if your type can only be serialised as an XML attribute (for example because an absent value has a particular meaning), it is correct to implement AsOptionalXmlText instead of AsXmlText.

 If your type can be serialised as both (text and attribute) but needs special handling in attributes, implement AsXmlText but provide a custom implementation of AsXmlText::as_optional_xml_text.

Required Methods§

Source

fn as_optional_xml_text(&self) -> Result<Option<Cow<'_, str>>, Error>

Convert the value to an XML string in a context where an absent value can be represented.

Implementations on Foreign Types§

Source§

impl<T: AsXmlText> AsOptionalXmlText for Option<T>

Implementors§