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:
Link Mauve 2025-05-14 02:01:31 +02:00
commit 3920ad3819
8 changed files with 12 additions and 9 deletions

View file

@ -473,7 +473,7 @@ pub struct ReasonElement {
/// A human-readable description of this reason. /// A human-readable description of this reason.
#[xml(extract(n = .., namespace = ns::JINGLE, name = "text", fields( #[xml(extract(n = .., namespace = ns::JINGLE, name = "text", fields(
attribute(type_ = String, name = "xml:lang", default), lang(type_ = Lang, default),
text(type_ = String), text(type_ = String),
)))] )))]
pub texts: BTreeMap<Lang, String>, pub texts: BTreeMap<Lang, String>,

View file

@ -58,7 +58,7 @@ pub struct File {
/// The description of this file, possibly localised. /// The description of this file, possibly localised.
#[xml(extract(n = .., name = "desc", fields( #[xml(extract(n = .., name = "desc", fields(
attribute(name = "xml:lang", type_ = String), lang(type_ = Lang, default),
text(type_ = String) text(type_ = String)
)))] )))]
pub descs: BTreeMap<Lang, String>, pub descs: BTreeMap<Lang, String>,

View file

@ -167,7 +167,7 @@ pub struct Message {
/// A list of bodies, sorted per language. Use /// A list of bodies, sorted per language. Use
/// [get_best_body()](#method.get_best_body) to access them on reception. /// [get_best_body()](#method.get_best_body) to access them on reception.
#[xml(extract(n = .., name = "body", fields( #[xml(extract(n = .., name = "body", fields(
attribute(name = "xml:lang", type_ = Lang, default), lang(type_ = Lang, default),
text(type_ = String), text(type_ = String),
)))] )))]
pub bodies: BTreeMap<Lang, String>, pub bodies: BTreeMap<Lang, String>,
@ -176,7 +176,7 @@ pub struct Message {
/// [get_best_subject()](#method.get_best_subject) to access them on /// [get_best_subject()](#method.get_best_subject) to access them on
/// reception. /// reception.
#[xml(extract(n = .., name = "subject", fields( #[xml(extract(n = .., name = "subject", fields(
attribute(name = "xml:lang", type_ = Lang, default), lang(type_ = Lang, default),
text(type_ = String), text(type_ = String),
)))] )))]
pub subjects: BTreeMap<Lang, String>, pub subjects: BTreeMap<Lang, String>,

View file

@ -163,7 +163,7 @@ pub struct Presence {
/// A localised list of statuses defined in this presence. /// A localised list of statuses defined in this presence.
#[xml(extract(n = .., name = "status", fields( #[xml(extract(n = .., name = "status", fields(
attribute(type_ = Lang, name = "xml:lang", default), lang(type_ = Lang, default),
text(type_ = String), text(type_ = String),
)))] )))]
pub statuses: BTreeMap<Lang, Status>, pub statuses: BTreeMap<Lang, Status>,

View file

@ -157,7 +157,7 @@ pub struct Failure {
/// A human-readable explanation for the failure. /// A human-readable explanation for the failure.
#[xml(extract(n = .., name = "text", fields( #[xml(extract(n = .., name = "text", fields(
attribute(type_ = String, name = "xml:lang", default), lang(type_ = Lang, default),
text(type_ = String), text(type_ = String),
)))] )))]
pub texts: BTreeMap<Lang, String>, pub texts: BTreeMap<Lang, String>,

View file

@ -37,7 +37,7 @@ pub struct Report {
/// Some text explaining the reason for this report. /// Some text explaining the reason for this report.
#[xml(extract(n = .., name = "text", fields( #[xml(extract(n = .., name = "text", fields(
attribute(name = "xml:lang", type_ = Lang), lang(type_ = Lang, default),
text(type_ = String) text(type_ = String)
)))] )))]
texts: BTreeMap<Lang, String>, texts: BTreeMap<Lang, String>,

View file

@ -245,7 +245,7 @@ pub struct StanzaError {
/// Human-readable description of this error. /// Human-readable description of this error.
#[xml(extract(n = .., namespace = ns::XMPP_STANZAS, name = "text", fields( #[xml(extract(n = .., namespace = ns::XMPP_STANZAS, name = "text", fields(
attribute(name = "xml:lang", type_ = Lang, default), lang(type_ = Lang, default),
text(type_ = String), text(type_ = String),
)))] )))]
pub texts: BTreeMap<Lang, String>, pub texts: BTreeMap<Lang, String>,

View file

@ -307,7 +307,10 @@ pub struct StreamError {
/// Optional error text. The first part is the optional `xml:lang` /// Optional error text. The first part is the optional `xml:lang`
/// language tag, the second part is the actual text content. /// 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)>, pub text: Option<(Option<String>, String)>,
/// Optional application-defined element which refines the specified /// Optional application-defined element which refines the specified