xmpp-parsers: Remove util::text_node_codecs

This codec system was useful for the previous parser style, but we have
converted them all to xso now!
This commit is contained in:
Emmanuel Gil Peyrot 2024-07-24 17:50:35 +02:00 committed by Maxime “pep” Buquet
commit 2eb6ca2f94
3 changed files with 1 additions and 253 deletions

View file

@ -693,13 +693,7 @@ macro_rules! generate_element {
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, children: [$($(#[$child_meta:meta])* $child_ident:ident: $coucou:tt<$child_type:ty> = ($child_name:tt, $child_ns:tt) => $child_constructor:ident),+$(,)?]) => (
generate_element!($(#[$meta])* $elem, $name, $ns, attributes: [], children: [$($(#[$child_meta])* $child_ident: $coucou<$child_type> = ($child_name, $child_ns) => $child_constructor),*]);
);
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, text: ($(#[$text_meta:meta])* $text_ident:ident: $codec:ty )) => (
generate_element!($(#[$meta])* $elem, $name, $ns, attributes: [], children: [], text: ($(#[$text_meta])* $text_ident: $codec));
);
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_action:tt<$attr_type:ty> = $attr_name:tt),+$(,)?], text: ($(#[$text_meta:meta])* $text_ident:ident: $codec:ty )) => (
generate_element!($(#[$meta])* $elem, $name, $ns, attributes: [$($(#[$attr_meta])* $attr: $attr_action<$attr_type> = $attr_name),*], children: [], text: ($(#[$text_meta])* $text_ident: $codec));
);
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_action:tt<$attr_type:ty> = $attr_name:tt),*$(,)?], children: [$($(#[$child_meta:meta])* $child_ident:ident: $coucou:tt<$child_type:ty> = ($child_name:tt, $child_ns:tt) => $child_constructor:ident),*$(,)?] $(, text: ($(#[$text_meta:meta])* $text_ident:ident: $codec:ty ))*) => (
($(#[$meta:meta])* $elem:ident, $name:tt, $ns:ident, attributes: [$($(#[$attr_meta:meta])* $attr:ident: $attr_action:tt<$attr_type:ty> = $attr_name:tt),*$(,)?], children: [$($(#[$child_meta:meta])* $child_ident:ident: $coucou:tt<$child_type:ty> = ($child_name:tt, $child_ns:tt) => $child_constructor:ident),*$(,)?]) => (
$(#[$meta])*
#[derive(Debug, Clone, PartialEq)]
pub struct $elem {
@ -711,10 +705,6 @@ macro_rules! generate_element {
$(#[$child_meta])*
pub $child_ident: start_decl!($coucou, $child_type),
)*
$(
$(#[$text_meta])*
pub $text_ident: <$codec as Codec>::Decoded,
)*
}
impl ::xso::FromXml for $elem {
@ -743,22 +733,6 @@ macro_rules! generate_element {
$(
start_parse_elem!($child_ident: $coucou);
)*
// We must pull the texts out of the Element before we pull
// the children, because take_elements_as_children drains
// *all* child nodes, including texts.
// To deal with the genericity of this macro, we need a local
// struct decl to carry the identifier around.
struct Texts {
$(
$text_ident: <$codec as Codec>::Decoded,
)*
}
#[allow(unused_variables)]
let texts = Texts {
$(
$text_ident: <$codec>::decode(&elem.text())?,
)*
};
for _child in elem.take_contents_as_children() {
let residual = _child;
$(
@ -783,9 +757,6 @@ macro_rules! generate_element {
$(
$child_ident: finish_parse_elem!($child_ident: $coucou = $child_name, $name),
)*
$(
$text_ident: texts.$text_ident,
)*
})
}
}
@ -799,9 +770,6 @@ macro_rules! generate_element {
$(
builder = generate_serialiser!(builder, elem, $child_ident, $coucou, $child_constructor, ($child_name, $child_ns));
)*
$(
builder = builder.append_all(<$codec>::encode(&elem.$text_ident).map(::minidom::Node::Text).into_iter());
)*
builder.build()
}