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::FullJiduuid: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§
Provided Methods§
Sourcefn as_optional_xml_text(&self) -> Result<Option<Cow<'_, str>>, Error>
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 IpAddr
impl AsXmlText for IpAddr
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::net::IpAddr to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for SocketAddr
impl AsXmlText for SocketAddr
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::net::SocketAddr to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for Ipv4Addr
impl AsXmlText for Ipv4Addr
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::net::Ipv4Addr to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for Ipv6Addr
impl AsXmlText for Ipv6Addr
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::net::Ipv6Addr to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for SocketAddrV4
impl AsXmlText for SocketAddrV4
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::net::SocketAddrV4 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for SocketAddrV6
impl AsXmlText for SocketAddrV6
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::net::SocketAddrV6 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for BareJid
Available on crate feature jid only.
impl AsXmlText for BareJid
jid only.Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert jid::BareJid to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for FullJid
Available on crate feature jid only.
impl AsXmlText for FullJid
jid only.Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert jid::FullJid to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for Uuid
Available on crate feature uuid only.
impl AsXmlText for Uuid
uuid only.Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert uuid::Uuid to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroI8
impl AsXmlText for NonZeroI8
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroI8 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroI16
impl AsXmlText for NonZeroI16
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroI16 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroI32
impl AsXmlText for NonZeroI32
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroI32 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroI64
impl AsXmlText for NonZeroI64
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroI64 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroI128
impl AsXmlText for NonZeroI128
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroI128 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroIsize
impl AsXmlText for NonZeroIsize
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroIsize to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroU8
impl AsXmlText for NonZeroU8
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroU8 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroU16
impl AsXmlText for NonZeroU16
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroU16 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroU32
impl AsXmlText for NonZeroU32
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroU32 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroU64
impl AsXmlText for NonZeroU64
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroU64 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroU128
impl AsXmlText for NonZeroU128
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroU128 to XML text via Display.
This implementation never fails.
Source§impl AsXmlText for NonZeroUsize
impl AsXmlText for NonZeroUsize
Source§fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
fn as_xml_text(&self) -> Result<Cow<'_, str>, Error>
Convert std::num::NonZeroUsize to XML text via Display.
This implementation never fails.