Commit graph xmpp-rs/parsers
Author SHA1 Message Date
Emmanuel Gil Peyrot
0adca163f8 xmpp-parsers: Don’t use anything from std
The remaining two were core::str::FromStr and
alloc::collections::BTreeMap.

Note that this doesn’t allow us to be no_std yet.

skip-changelog: This isn’t in any way user-visible, except that some
structs are now slightly smaller.
2025-01-26 10:22:37 +00:00
Emmanuel Gil Peyrot
fefc898fdf xso-proc: Allow #[xml(flag)] without params
The namespace defaults to the parent’s namespace, and the name to the
field name, so we can avoid needlessly duplicating that info.
2025-01-25 20:07:47 +01:00
Emmanuel Gil Peyrot
244a9bbbf2 xmpp-parsers: Switch from zero-sized types to #[xml(flag)]
That way we can simply use true/false, instead of
Some(TheZeroSizedType)/None.
2025-01-25 20:07:47 +01:00
Jonas Schäfer
330b216f3d parsers: add support for mediated invite syntax 2025-01-25 19:27:58 +01:00
Emmanuel Gil Peyrot
c0e45b6a0f xmpp-parsers: Migrate Caps to xso
The hash member has been split into a hash and a ver members, to reflect
the attributes.
2025-01-25 18:07:44 +01:00
Emmanuel Gil Peyrot
01a0c51a2f xso-proc: Add support for the codec field on attribute meta
This allows a custom TextCodec to be used for encoding and decoding the
attribute’s value, instead of FromXmlText and AsOptionalXmlText.
2025-01-25 18:07:44 +01:00
Emmanuel Gil Peyrot
07f3dc4785 xmpp-parsers: Fix vCard-temp test
xso::text::TextCodec is now generic on base64::Engine, which causes a
base64 engine to have two encode() methods, needing to disambiguate
them.
2025-01-25 13:22:50 +01:00
Jonas Schäfer
727e57b756 Implement #[xml(flag)] meta 2025-01-21 19:12:43 +01:00
Jonas Schäfer
4eff6303dc Fix compatibility with uuid 1.12
uuid 1.12 introduced the NonNilUuid type, which can, like the Uuid
type, be parsed from a string. The Uuid type now implements
PartialEq<Self> and PartialEq<NonNilUuid>. That breaks type inferrence,
because the compiler now cannot know whether we want to parse a Uuid or
a NonNilUuid.

We thus have to be explicit.
2025-01-21 19:12:23 +01:00
33098e6f2c Message and message_correct::Replace now has typed Id 2024-12-30 20:50:43 +00:00
Emmanuel Gil Peyrot
ec72d71551 xmpp-parsers: Convert SetResult to xso
The API has changed a little but nothing much.
2024-12-22 07:54:12 +00:00
Emmanuel Gil Peyrot
3d18d83d90 xmpp-parsers: Convert SetQuery to xso 2024-12-22 07:54:12 +00:00
Emmanuel Gil Peyrot
944c5c7c87 xmpp-parsers: Implement XEP-0377: Spam Reporting 2024-12-21 17:44:55 +01:00
Jonas Schäfer
b8af0d8fa2 xmpp_parsers: --features disable-validation
It was broken in multiple ways:

- xso did not honour it: unknown children and attributes would cause a
  parse error even with `--features disable-validation` set on parsers.
  For this, we introduce a new feature flag on xso, `non-pedantic`,
  which defaults unknown children and attributes to discard instead of
  fail.

  Note that individual XSOs can still choose to be always pedantic or
  always lenient by explicitly declaring the intent via the
  `on_unknown_child` and `on_unknown_attribute` metas.

- Many tests in `xmpp_parsers` were broken with `--features
  disable-validation`. They now all pass while *still* being rn with
  `disable-validation` set: In that case, they test that parsing in fact
  succeeds.
2024-12-20 14:50:14 +01:00
Jonas Schäfer
58698f633f xso: only take reference in transform
This avoids the need for an expensive clone. Since we switched to AsXml
instead of IntoXml, we don't necessarily have to clone the data when
building new elements, only when it's absolutely necessary. The clones
then happen implicitly in the ItemToEvent iterator used internally.

This mostly fixes #86, with the caveat that there's no absolutely cheap
test: On success, the entire element will be copied, while on failure,
you learn about it rather quickly.
2024-12-20 12:44:43 +01:00
9901141b5f parsers: Rename Message::get_best_owned to get_best_cloned 2024-12-20 00:29:03 +01:00
087534be1e parsers: Replace std stuff with alloc/core stuff 2024-12-19 20:45:38 +01:00
6e3f31ef46 parsers: Add get_best_{body,subject}_owned methods for Message 2024-12-19 17:46:01 +01:00
50425617b5 parsers: Add Message::extract_valid_payload helper 2024-12-19 17:36:10 +01:00
7991cef904 Add tests for crate exports ; add structure to imports/exports 2024-12-18 18:03:18 +00:00
Emmanuel Gil Peyrot
1b4a307919 xmpp-parsers: Convert DiscoInfoResult to xso
This disables some tests, but those were controversial anyway.

I was thinking about replacing the Feature struct with a plain String,
what do you think about it?
2024-12-18 18:50:50 +01:00
Emmanuel Gil Peyrot
893a2f8e47 xmpp-parsers: Convert Presence to xso
The two remaining issues, which led to two ignored tests, are that
priority now gets always serialized, and that we don’t reject duplicated
identical xml:lang in statuses.
2024-12-18 15:49:06 +00:00
c16456f381 parsers/xmpp: MUC bookmarks have nickname typed as ResourcePart 2024-12-18 15:43:09 +00:00
Emmanuel Gil Peyrot
3c77ee0cc7 xmpp-parsers: Add support for <alternative-session><sid/></>
This was previously unimplemented due to how the enum was treated, now
that we moved the reason element to xso we can describe it properly and
thus implement everything it supports.

This causes one regression on xml:lang validation, but we can live with
that until xso implements such verification.
2024-12-18 16:08:24 +01:00
Emmanuel Gil Peyrot
cd43aa2fcb xmpp-parsers: Convert the Actor enum into a struct
XEP-0045 doesn’t specify what to do in the case the actor contains both
a @jid and a @nick, so let’s not encode anything special about that
here.

In addition this converted it to use xso.

Supersedes !196.

Fixes #88.
2024-12-17 18:20:52 +01:00
Jonas Schäfer
80f899daa0 tokio_xmpp: implement high-level, resilient stanza stream 2024-12-17 18:16:02 +01:00
Emmanuel Gil Peyrot
7fca02958b xmpp-parsers: Fix jingle thumbnails wrt the XEP changes
Version 0.4.2 added a restriction on width and height to be in the
0..65535 range.  The media-type attribute has always been optional as
well.
2024-12-17 00:27:15 +01:00
580fdeffa9 Added a test for prosody bug 1664 workaround 2024-12-16 15:19:54 +00:00
Emmanuel Gil Peyrot
011585594f xmpp: Adapt to xmpp-parsers changes wrt autojoin
This attribute is now a simple bool instead of an enum.
2024-12-16 13:32:49 +00:00
Emmanuel Gil Peyrot
866991bda5 xmpp-parsers: Replace all instances of bool attributes with bool
These bring basically nothing, so we can throw them away alongside their
generator macro.
2024-12-16 13:32:49 +00:00
Emmanuel Gil Peyrot
16b232523d xmpp-parsers: Convert vCard-temp to xso
This also keeps all additional elements in the vCard, so they get
serialized back on the wire instead of being dropped.
2024-12-15 17:38:56 +00:00
Emmanuel Gil Peyrot
aaf2dd7925 xmpp-parsers: Convert bookmarks2 to xso 2024-12-15 17:38:56 +00:00
Emmanuel Gil Peyrot
1c22e17955 xmpp-parsers: Convert Jingle File Transfer to xso 2024-12-15 17:38:56 +00:00
Emmanuel Gil Peyrot
af0bd35e7a xmpp-parsers: Implement XEP-0490: Message Displayed Synchronization
This XEP is used to synchronize where each client has stopped reading a
conversation, so that we can e.g. stop displaying a notification when
the user has read this particular message on a different device.
2024-12-15 17:30:24 +00:00
Emmanuel Gil Peyrot
d738939f89 xmpp-parsers: Simplify hash conversion to Vec
Use `GenericArray::to_vec()` and `slice::to_vec()` directly.
2024-12-15 17:17:01 +00:00
Emmanuel Gil Peyrot
57e6e98c6a xmpp-parsers: Add test for StartTLS
This tests each element we support, and also keep track of the sizes.

Additionally the copyright year was wrong.
2024-12-15 17:45:26 +01:00
Jonas Schäfer
7d8ffe45a7 xso: add support for ignoring unknown stuff in extracts 2024-10-26 17:37:32 +00:00
Jonas Schäfer
66233b0150 xso: add support for ignoring unknown children 2024-10-26 17:37:32 +00:00
Jonas Schäfer
290460ba9d xso: add support for ignoring unknown attributes 2024-10-26 17:37:32 +00:00
Alvaro Parker
2ff89a9e42 fix typos 2024-09-16 18:29:44 -03:00
Jonas Schäfer
a503c8534f parsers: add support for handled-count-too-high error 2024-09-01 13:01:29 +02:00
Jonas Schäfer
0f0759b207 parsers: add support for <optional/> in stream management feature 2024-09-01 13:01:29 +02:00
Jonas Schäfer
bfe723cf46 parsers: make stream errors more ergonomic for error processing 2024-09-01 08:54:50 +00:00
Jonas Schäfer
b39ad99ecd parsers: add stream error XSO 2024-09-01 08:54:50 +00:00
df106dfbaf Relative dependencies 2024-08-12 10:39:09 +00:00
Jonas Schäfer
54e1a98cde parsers: add starttls XSOs 2024-08-12 12:35:26 +02:00
Jonas Schäfer
3c78310272 parsers: add umbrella enum for SASL elements
This is useful if, for example during stream negotiation, you want to
parse SASL elements and nothing else. It is also useful if you want to
write down an enum of all XMPP-related stream-level elements you accept
and don't want to loose your fingers typing all the SASL options.
2024-08-12 12:32:12 +02:00
Jonas Schäfer
fc68a57757 parsers: provide stub FromXml/AsXml implementations on Presence 2024-08-12 12:32:12 +02:00
Jonas Schäfer
b931af3c25 parsers: provide stub FromXml/AsXml implementations on Iq 2024-08-12 12:32:12 +02:00
e153468117 Link is link, remove doc warning 2024-08-11 17:22:31 +00:00