Trait xso::AsXmlText

source ·
pub trait AsXmlText {
    // Required method
    fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>;

    // Provided method
    fn as_optional_xml_text(&self) -> Result<Option<Cow<'_, str>>, Error> { ... }
}
Expand description

Trait to convert a value to an XML text string.

This trait is implemented for many standard library types implementing std::fmt::Display. In addition, the following feature flags can enable more implementations:

  • jid: jid::Jid, jid::BareJid, jid::FullJid
  • uuid: uuid::Uuid

Because of the unfortunate situation as described in FromXmlText, we are extremely liberal with accepting optional dependencies for this purpose. You are very welcome to make merge requests against this crate adding support for parsing third-party crates.

Required Methods§

source

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

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

Provided 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.

The provided implementation will always return the result of Self::as_xml_text wrapped into Some(.). By re-implementing this method, implementors can customize the behaviour for certain values.

Implementations on Foreign Types§

source§

impl AsXmlText for &str

source§

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

source§

impl AsXmlText for IpAddr

source§

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

source§

impl AsXmlText for SocketAddr

source§

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

source§

impl AsXmlText for bool

This provides an implementation compliant with xsd::bool.

source§

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

source§

impl AsXmlText for f32

source§

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

source§

impl AsXmlText for f64

source§

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

source§

impl AsXmlText for i8

source§

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

source§

impl AsXmlText for i16

source§

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

source§

impl AsXmlText for i32

source§

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

source§

impl AsXmlText for i64

source§

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

source§

impl AsXmlText for i128

source§

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

source§

impl AsXmlText for isize

source§

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

source§

impl AsXmlText for u8

source§

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

source§

impl AsXmlText for u16

source§

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

source§

impl AsXmlText for u32

source§

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

source§

impl AsXmlText for u64

source§

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

source§

impl AsXmlText for u128

source§

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

source§

impl AsXmlText for usize

source§

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

source§

impl AsXmlText for String

source§

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

source§

impl AsXmlText for Ipv4Addr

source§

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

source§

impl AsXmlText for Ipv6Addr

source§

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

source§

impl AsXmlText for SocketAddrV4

source§

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

source§

impl AsXmlText for SocketAddrV6

source§

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

source§

impl AsXmlText for Uuid

Available on crate feature uuid only.
source§

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

source§

impl AsXmlText for NonZeroI8

source§

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

source§

impl AsXmlText for NonZeroI16

source§

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

source§

impl AsXmlText for NonZeroI32

source§

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

source§

impl AsXmlText for NonZeroI64

source§

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

source§

impl AsXmlText for NonZeroI128

source§

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

source§

impl AsXmlText for NonZeroIsize

source§

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

source§

impl AsXmlText for NonZeroU8

source§

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

source§

impl AsXmlText for NonZeroU16

source§

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

source§

impl AsXmlText for NonZeroU32

source§

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

source§

impl AsXmlText for NonZeroU64

source§

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

source§

impl AsXmlText for NonZeroU128

source§

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

source§

impl AsXmlText for NonZeroUsize

source§

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

source§

impl AsXmlText for BareJid

Available on crate feature jid only.
source§

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

source§

impl AsXmlText for FullJid

Available on crate feature jid only.
source§

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

source§

impl AsXmlText for Jid

Available on crate feature jid only.
source§

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

source§

impl<B: AsXmlText + ToOwned> AsXmlText for Cow<'_, B>

source§

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

source§

impl<T: AsXmlText> AsXmlText for Box<T>

source§

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

Implementors§