pub trait FromXmlText: Sized {
// Required method
fn from_xml_text(data: String) -> Result<Self, Error>;
}
Expand description
Trait allowing to convert XML text to a value.
This trait is similar to core::str::FromStr
, however, due to
restrictions imposed by the orphan rule, a separate trait is needed.
Implementations for many standard library types are available. In
addition, the following feature flags can enable more implementations:
jid
:jid::Jid
,jid::BareJid
,jid::FullJid
uuid
:uuid::Uuid
Because of this unfortunate situation, 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§
Sourcefn from_xml_text(data: String) -> Result<Self, Error>
fn from_xml_text(data: String) -> Result<Self, Error>
Convert the given XML text to a value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl FromXmlText for IpAddr
impl FromXmlText for IpAddr
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::net::IpAddr
from XML text via FromStr
.
Source§impl FromXmlText for SocketAddr
impl FromXmlText for SocketAddr
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::net::SocketAddr
from XML text via FromStr
.
Source§impl FromXmlText for bool
This provides an implementation compliant with xsd::bool.
impl FromXmlText for bool
This provides an implementation compliant with xsd::bool.
Source§impl FromXmlText for char
impl FromXmlText for char
Source§impl FromXmlText for f32
impl FromXmlText for f32
Source§impl FromXmlText for f64
impl FromXmlText for f64
Source§impl FromXmlText for i8
impl FromXmlText for i8
Source§impl FromXmlText for i16
impl FromXmlText for i16
Source§impl FromXmlText for i32
impl FromXmlText for i32
Source§impl FromXmlText for i64
impl FromXmlText for i64
Source§impl FromXmlText for i128
impl FromXmlText for i128
Source§impl FromXmlText for isize
impl FromXmlText for isize
Source§impl FromXmlText for u8
impl FromXmlText for u8
Source§impl FromXmlText for u16
impl FromXmlText for u16
Source§impl FromXmlText for u32
impl FromXmlText for u32
Source§impl FromXmlText for u64
impl FromXmlText for u64
Source§impl FromXmlText for u128
impl FromXmlText for u128
Source§impl FromXmlText for usize
impl FromXmlText for usize
Source§impl FromXmlText for DomainPart
Available on crate feature jid
only.
impl FromXmlText for DomainPart
jid
only.Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse jid::DomainPart
from XML text via FromStr
.
Source§impl FromXmlText for NodePart
Available on crate feature jid
only.
impl FromXmlText for NodePart
jid
only.Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse jid::NodePart
from XML text via FromStr
.
Source§impl FromXmlText for ResourcePart
Available on crate feature jid
only.
impl FromXmlText for ResourcePart
jid
only.Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse jid::ResourcePart
from XML text via FromStr
.
Source§impl FromXmlText for BareJid
Available on crate feature jid
only.
impl FromXmlText for BareJid
jid
only.Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse jid::BareJid
from XML text via FromStr
.
Source§impl FromXmlText for FullJid
Available on crate feature jid
only.
impl FromXmlText for FullJid
jid
only.Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse jid::FullJid
from XML text via FromStr
.
Source§impl FromXmlText for Jid
Available on crate feature jid
only.
impl FromXmlText for Jid
jid
only.Source§impl FromXmlText for String
impl FromXmlText for String
Source§impl FromXmlText for Ipv4Addr
impl FromXmlText for Ipv4Addr
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::net::Ipv4Addr
from XML text via FromStr
.
Source§impl FromXmlText for Ipv6Addr
impl FromXmlText for Ipv6Addr
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::net::Ipv6Addr
from XML text via FromStr
.
Source§impl FromXmlText for SocketAddrV4
impl FromXmlText for SocketAddrV4
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::net::SocketAddrV4
from XML text via FromStr
.
Source§impl FromXmlText for SocketAddrV6
impl FromXmlText for SocketAddrV6
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::net::SocketAddrV6
from XML text via FromStr
.
Source§impl FromXmlText for Uuid
Available on crate feature uuid
only.
impl FromXmlText for Uuid
uuid
only.Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse uuid::Uuid
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroI8
impl FromXmlText for NonZeroI8
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroI8
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroI16
impl FromXmlText for NonZeroI16
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroI16
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroI32
impl FromXmlText for NonZeroI32
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroI32
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroI64
impl FromXmlText for NonZeroI64
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroI64
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroI128
impl FromXmlText for NonZeroI128
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroI128
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroIsize
impl FromXmlText for NonZeroIsize
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroIsize
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroU8
impl FromXmlText for NonZeroU8
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroU8
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroU16
impl FromXmlText for NonZeroU16
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroU16
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroU32
impl FromXmlText for NonZeroU32
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroU32
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroU64
impl FromXmlText for NonZeroU64
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroU64
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroU128
impl FromXmlText for NonZeroU128
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroU128
from XML text via FromStr
.
Source§impl FromXmlText for NonZeroUsize
impl FromXmlText for NonZeroUsize
Source§fn from_xml_text(s: String) -> Result<Self, Error>
fn from_xml_text(s: String) -> Result<Self, Error>
Parse core::num::NonZeroUsize
from XML text via FromStr
.
Source§impl<T: FromXmlText> FromXmlText for Option<T>
impl<T: FromXmlText> FromXmlText for Option<T>
Source§impl<T: FromXmlText> FromXmlText for Box<T>
impl<T: FromXmlText> FromXmlText for Box<T>
Source§impl<T: FromXmlText, B: ToOwned<Owned = T>> FromXmlText for Cow<'_, B>
impl<T: FromXmlText, B: ToOwned<Owned = T>> FromXmlText for Cow<'_, B>
Source§fn from_xml_text(data: String) -> Result<Self, Error>
fn from_xml_text(data: String) -> Result<Self, Error>
Return a Cow::Owned
containing the parsed value.