Commit graph

14 commits

Author SHA1 Message Date
Emmanuel Gil Peyrot
972a8427b0 xmpp-parsers: Use the new macro for the feature element 2024-06-30 21:46:25 +02:00
Jonas Schäfer
0e4865006c parsers: port more elements to derive macros 2024-06-30 13:14:06 +02:00
Jonas Schäfer
6ef8dbefa3 parsers: use Error type from xso
This is a large change and as such, it needs good motivation. Let me
remind you of the ultimate goal: we want a derive macro which allows us
to FromXml/IntoXml, and that derive macro should be usable from
`xmpp_parsers` and other crates.

For that, any code generated by the derive macro mustn't depend on any
code in the `xmpp_parsers` crate, because you cannot name the crate you
are in portably (`xmpp_parsers::..` wouldn't resolve within
`xmpp_parsers`, and `crate::..` would point at other crates if the macro
was used in other crates).

We also want to interoperate with code already implementing
`TryFrom<Element>` and `Into<Element>` on structs. This ultimately
requires that we have an error type which is shared by the two
implementations and that error type must be declared in the `xso` crate
to be usable by the macros.

Thus, we port the error type over to use the type declared in `xso`.

This changes the structure of the error type greatly; I do not think
that `xso` should have to know about all the different types we are
parsing there and they don't deserve special treatment. Wrapping them in
a `Box<dyn ..>` seems more appropriate.
2024-06-23 09:40:52 +02:00
Jonas Schäfer
80efd2eb19 Ignore missing disco#info feature in disco#info responses
xmpp-rs normally has the stance to get buggy implementations fixed
rather than dropping checks. In this particular case I think this is not
a good use of resources:

- The disco#info feature var conveys no actual information:
  If an implementation replies properly to a disco#info query, it is
  already implied that it supports the protocol.

- There are broken server implementations out there.
  A lot of them (all recent (>= 0.10 && < 0.13 AFAICT) Prosody IM
  instances). At this point in time, xmpp-rs is unable to query
  disco#info from MUCs hosted on such prosody versions, except by
  workarounds (such as the one removed in this diff).

- XEP-0030 now features a note which reads:

  > Note: Some entities are known not to advertise the
  > `http://jabber.org/protocol/disco#info` feature within their
  > responses, contrary to this specification. Entities receiving
  > otherwise valid responses which do not include this feature SHOULD
  > infer the support.

The case would be different if there were no (deployed) implementations
which had this bug or if the bug actually had an effect on clients.
Especially the latter is not the case though, as pointed out above.

Hence, I conclude that this check is overly pedantic and the resources
(time, emotional energy of dealing with bugs, punching patches through
to stable distributions, etc. etc.) spent on getting this fixed would
be better invested elsewhere.

In addition, the workaround is extremely ugly and, even in the xmpp-rs
implementation, has no test coverage. Without test coverage of such an
implementation, it is bound to break in funny ways when xmpp-rs changes
the strings of its error messages (which is something one might do even
outside a breaking release).
2024-06-16 10:52:51 +02:00
Jonas Schäfer
37481fb8f6 parsers: do not do extensive XEP-0030 validation with disable-validation
Other additional checks are already gated by the absence of this
feature. As the MR to remove these checks altogether is still blocked,
this should serve as at least as an intermediate solution to anyone
affected by buggy remote implementations.
2024-04-28 10:48:35 +02:00
Jonas Schäfer
2e9c9411a3 jid: rewrite public types
This moves InnerJid into Jid and reformulates BareJid and FullJid in
terms of Jid.

Doing this has the key advantage that FullJid and BareJid can deref to
and borrow as Jid. This, in turn, has the advantage that they can be
used much more flexibly in HashMaps. However, this is (as we say in
Germany) future music; this commit only does the internal reworking.

Oh and also, it saves 20% memory on Jid objects.

Fixes #122 more thoroughly, or rather the original intent behind it.
2024-04-15 18:21:24 +02:00
Jonas Schäfer
6f6f8abb53 Add fields for Result Set Management in disco#items
Note that this is a breaking change, as it changes the struct definition
and now requires additional fields when constructing the struct.
2024-03-03 14:54:30 +01:00
4089891f6c Update edition to 2021
- Remove TryFrom/Into and FromIterator imports
- Prevent impl_validator_using_provider macro in sasl crate from
  constructing trait object

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-12-15 19:40:09 +00:00
b522eaf7f3 parsers: clippy pass
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-12-15 19:26:06 +00:00
Emmanuel Gil Peyrot
c7887efbc7 xmpp-parsers: Fix size tests on 32-bit 2023-06-20 18:59:26 +02:00
Emmanuel Gil Peyrot
91736ec0ed xmpp-parsers: Fix size tests on 64-bit 2023-06-20 18:59:26 +02:00
Emmanuel Gil Peyrot
022a920300 xmpp-parsers: Update to the new jid crate 2023-06-20 18:59:26 +02:00
xmppftw
c8dcf5e7a7 Fix expected struct sizes for nightly optimizations (no more CI warnings) 2023-06-06 09:37:16 +00:00
Emmanuel Gil Peyrot
9410849d7a Rename the xmpp-parsers directory to parsers
This doesn’t change anything to the name of the crate, just makes
autocompletion easier by not sharing the same prefix as the xmpp crate.
2021-10-11 08:24:16 +02:00
Renamed from xmpp-parsers/src/disco.rs (Browse further)