Trait xso::DynNamespaceEnum
source · pub trait DynNamespaceEnum: Sized + PartialEq<str> + IntoXmlText {
// Required method
fn from_xml_text(s: &str) -> Result<Self, DynNamespaceError>;
}
Expand description
Enumeration of possible dynamically determined namespaces.
This trait must be implemented on types used on #[xml(namespace)]
fields.
It allows to specify XML elements which can be parsed in different namespaces. This can be useful in weird protocols (looking at you, XMPP) where the same element occurs in multiple different namespaces. The namespace is then kept in the field and is thus available at serialisation time.
This trait depends on PartialEq<str>
; this is used to compare a value
against the value of an xmlns
attribute without requiring to go through
(potentially costly and also error-inducing) Self::from_xml_text
.
Required Methods§
sourcefn from_xml_text(s: &str) -> Result<Self, DynNamespaceError>
fn from_xml_text(s: &str) -> Result<Self, DynNamespaceError>
Parse the namespace from the xmlns
attribute data.
This should return Mismatch
for
namespaces which are not part of the enumeration of matching
namespaces. In such cases, the parser may attempt to parse using
another FromXml
implementation.
You can also return Invalid
to
abort parsing altogether; this is probably not what you want, though.