xmpp-parsers: Use the new lang meta everywhere
Stop parsing xml:lang manually, instead use the #[xml(lang)] meta which tracks it using the XML semantics, inheriting it from the most recent ancestor. skip-changelog: This isn’t a user-facing change.
This commit is contained in:
parent
dc8c3eac4c
commit
3920ad3819
8 changed files with 12 additions and 9 deletions
|
|
@ -473,7 +473,7 @@ pub struct ReasonElement {
|
|||
|
||||
/// A human-readable description of this reason.
|
||||
#[xml(extract(n = .., namespace = ns::JINGLE, name = "text", fields(
|
||||
attribute(type_ = String, name = "xml:lang", default),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String),
|
||||
)))]
|
||||
pub texts: BTreeMap<Lang, String>,
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pub struct File {
|
|||
|
||||
/// The description of this file, possibly localised.
|
||||
#[xml(extract(n = .., name = "desc", fields(
|
||||
attribute(name = "xml:lang", type_ = String),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String)
|
||||
)))]
|
||||
pub descs: BTreeMap<Lang, String>,
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ pub struct Message {
|
|||
/// A list of bodies, sorted per language. Use
|
||||
/// [get_best_body()](#method.get_best_body) to access them on reception.
|
||||
#[xml(extract(n = .., name = "body", fields(
|
||||
attribute(name = "xml:lang", type_ = Lang, default),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String),
|
||||
)))]
|
||||
pub bodies: BTreeMap<Lang, String>,
|
||||
|
|
@ -176,7 +176,7 @@ pub struct Message {
|
|||
/// [get_best_subject()](#method.get_best_subject) to access them on
|
||||
/// reception.
|
||||
#[xml(extract(n = .., name = "subject", fields(
|
||||
attribute(name = "xml:lang", type_ = Lang, default),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String),
|
||||
)))]
|
||||
pub subjects: BTreeMap<Lang, String>,
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ pub struct Presence {
|
|||
|
||||
/// A localised list of statuses defined in this presence.
|
||||
#[xml(extract(n = .., name = "status", fields(
|
||||
attribute(type_ = Lang, name = "xml:lang", default),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String),
|
||||
)))]
|
||||
pub statuses: BTreeMap<Lang, Status>,
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ pub struct Failure {
|
|||
|
||||
/// A human-readable explanation for the failure.
|
||||
#[xml(extract(n = .., name = "text", fields(
|
||||
attribute(type_ = String, name = "xml:lang", default),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String),
|
||||
)))]
|
||||
pub texts: BTreeMap<Lang, String>,
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub struct Report {
|
|||
|
||||
/// Some text explaining the reason for this report.
|
||||
#[xml(extract(n = .., name = "text", fields(
|
||||
attribute(name = "xml:lang", type_ = Lang),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String)
|
||||
)))]
|
||||
texts: BTreeMap<Lang, String>,
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ pub struct StanzaError {
|
|||
|
||||
/// Human-readable description of this error.
|
||||
#[xml(extract(n = .., namespace = ns::XMPP_STANZAS, name = "text", fields(
|
||||
attribute(name = "xml:lang", type_ = Lang, default),
|
||||
lang(type_ = Lang, default),
|
||||
text(type_ = String),
|
||||
)))]
|
||||
pub texts: BTreeMap<Lang, String>,
|
||||
|
|
|
|||
|
|
@ -307,7 +307,10 @@ pub struct StreamError {
|
|||
|
||||
/// Optional error text. The first part is the optional `xml:lang`
|
||||
/// language tag, the second part is the actual text content.
|
||||
#[xml(extract(default, fields(attribute(name = "xml:lang", default, type_ = Option<String>), text(type_ = String))))]
|
||||
#[xml(extract(default, fields(
|
||||
lang(type_ = Option<String>, default),
|
||||
text(type_ = String),
|
||||
)))]
|
||||
pub text: Option<(Option<String>, String)>,
|
||||
|
||||
/// Optional application-defined element which refines the specified
|
||||
|
|
|
|||
Loading…
Reference in a new issue