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 IpAddr

source§

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

source§

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 bool

This provides an implementation compliant with xsd::bool.

source§

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

Convert a boolean to XML text.

true is converted to "true" and false is converted to "false". This implementation never fails.

source§

impl AsXmlText for char

source§

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

Convert char to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for f32

source§

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

Convert f32 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for f64

source§

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

Convert f64 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for i8

source§

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

Convert i8 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for i16

source§

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

Convert i16 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for i32

source§

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

Convert i32 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for i64

source§

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

Convert i64 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for i128

source§

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

Convert i128 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for isize

source§

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

Convert isize to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for str

source§

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

Return the borrowed string contents.

source§

impl AsXmlText for u8

source§

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

Convert u8 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for u16

source§

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

Convert u16 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for u32

source§

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

Convert u32 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for u64

source§

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

Convert u64 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for u128

source§

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

Convert u128 to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for usize

source§

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

Convert usize to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for String

source§

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

Return the borrowed string contents.

source§

impl AsXmlText for Ipv4Addr

source§

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

source§

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

source§

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

source§

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 Uuid

Available on crate feature uuid only.
source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Convert std::num::NonZeroUsize to XML text via Display.

This implementation never fails.

source§

impl AsXmlText for BareJid

Available on crate feature jid only.
source§

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.
source§

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 Jid

Available on crate feature jid only.
source§

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

Convert [jid::Jid] to XML text via Display.

This implementation never fails.

source§

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

source§

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

Return the borrowed Cow contents.

source§

impl<T: AsXmlText> AsXmlText for &T

source§

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

Delegate to the AsXmlText implementation on T.

source§

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

source§

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

Return the borrowed Box contents.

Implementors§

impl AsXmlText for Autojoin

impl AsXmlText for DataFormType

impl AsXmlText for FieldType

impl AsXmlText for Action

impl AsXmlText for Restricted

impl AsXmlText for Transport

impl AsXmlText for Type

impl AsXmlText for Tls0Rtt

impl AsXmlText for Algo

impl AsXmlText for Stanza

impl AsXmlText for Action

impl AsXmlText for Creator

impl AsXmlText for Disposition

impl AsXmlText for Senders

impl AsXmlText for Setup

impl AsXmlText for Semantics

impl AsXmlText for Type

impl AsXmlText for Senders

impl AsXmlText for Mode

impl AsXmlText for Type

impl AsXmlText for Semantics

impl AsXmlText for IsPreKey

impl AsXmlText for Complete

impl AsXmlText for DefaultPrefs

impl AsXmlText for MessageType

impl AsXmlText for Affiliation

impl AsXmlText for Role

impl AsXmlText for AffiliationAttribute

impl AsXmlText for Subscription

impl AsXmlText for Notify

impl AsXmlText for Subscription

impl AsXmlText for Event

impl AsXmlText for Mechanism

impl AsXmlText for ResumeAttr

impl AsXmlText for ErrorType

impl AsXmlText for ContentId

impl AsXmlText for DateTime

impl AsXmlText for Sha1HexAttribute

impl AsXmlText for StreamId

impl AsXmlText for ContentId

impl AsXmlText for SessionId

impl AsXmlText for Desc

impl AsXmlText for CandidateId

impl AsXmlText for StreamId

impl AsXmlText for QueryId

impl AsXmlText for ChannelId

impl AsXmlText for ParticipantId

impl AsXmlText for ItemId

impl AsXmlText for NodeName

impl AsXmlText for SubscriptionId

impl AsXmlText for StreamId