Commit graph

2,418 commits

Author SHA1 Message Date
Link Mauve
0a1b291574 xmpp-parsers: Remove optional child from sm element
When the required child was added and subsequently reverted, it was
noted that optional and required were never defined, and only appeared
in old XEP-0198 examples.  The XEP has been fixed already[1].

This basically reverts 0f0759b207.

[1] https://github.com/xsf/xeps/pull/1447
2025-08-29 12:48:55 +02:00
Maxime “pep” Buquet
621c5882cf
parsers: re-export xso::error::FromElementError
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-08-14 15:24:09 +02:00
Maxime “pep” Buquet
653a10b170
tokio-xmpp: impl PartialEq on event::Stanza
skip-changelog: Stanza hasn't been in a release yet.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-08-12 15:30:34 +02:00
Saarko
7c87d879d8 parsers: fix text field namespacing in StreamError
skip-changelog
2025-08-07 12:43:21 +00:00
Maxime “pep” Buquet
0ebc3ca04c tokio_xmpp/examples: Use server arg in echo_component
skip-changelog: not yet released? Not so much important anyway

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-08-07 12:08:07 +00:00
Maxime “pep” Buquet
9803546795
tokio-xmpp: Re-export xso::error::FromElementError
skip-changelog: code requiring xso hasn't been released yet

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-08-07 13:39:34 +02:00
Link Mauve
a58fb7e2f9 tokio-xmpp: Bump rustls-native-certs and webpki-roots
skip-changelog: This is just a dependency bump.
2025-07-28 15:20:01 +02:00
Link Mauve
e70dd957f4 tokio-xmpp: Bump hickory-resolver to 0.25 2025-07-28 14:59:11 +02:00
Link Mauve
c11075d1d4 tokio-xmpp: Bump rand to 0.9 2025-07-28 14:39:48 +02:00
Link Mauve
4f270bff7a sasl: Bump getrandom to 0.3
They renamed getrandom::getrandom() to getrandom::fill().
2025-07-28 14:21:58 +02:00
Saarko
e3b167687f tokio-xmpp: remove code duplicates for direct tls and starttls connectors 2025-07-25 18:50:44 +02:00
Saarko
c674c14597 tokio-xmpp/client: add directTLS connection method 2025-07-25 18:50:30 +02:00
Maxime “pep” Buquet
02a70edf99
Fix 'elided lifetime' warning from nightly
Nightly 1.90. The fix passes on stable 1.88.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-07-20 16:01:44 +02:00
Jonas Schäfer
bdae845b14 xso: relax the feature = "std" requirement for xso::dynxso 2025-07-13 11:10:51 +00:00
Jonas Schäfer
345209bce9 xso: add specialized Xso<dyn Trait> container 2025-07-13 11:10:51 +00:00
Jonas Schäfer
7f5542e8d4 xso: add support for dynamically typed XSOs 2025-07-13 11:10:51 +00:00
Jonas Schäfer
59af49c691 xso-proc: provide FromXml::xml_name_matcher on derived impls
That way, derived implementations can also make use of the performance
benefits.
2025-07-13 11:10:51 +00:00
Jonas Schäfer
126588b47d xso: allow FromXml implementations to provide matching hints
That way, callers can put multiple candidate implementations in, for
example, a sorted vector and more efficiently select candidates to try
when looking at a new element.
2025-07-13 11:10:51 +00:00
Jonas Schäfer
d7b62488dc xso: add type-erased and dyn-compatible variant of AsXml
That way, we don't need to know the specific type of iterator or even
iteree anymore. This can turn out useful when working with `Box<dyn _>`,
that is, in contexts where we don't know the (possible or actual) types
at compile time.
2025-07-13 11:10:51 +00:00
Jonas Schäfer
ee9ffb2d9c xso: make FromEventsBuilder implementations around Box more versatile
By removing the implicit `Sized` bound, they can be used with `dyn _`.
The `Sized` bound is unnecessary for a boxed value, so it is a
superfluous restriction. Also, the use with `dyn _` may turn out useful
in the future when we want to allow type-erased XSOs.
2025-07-13 11:10:51 +00:00
Jonas Schäfer
1262b560e9 Fix parsing of stream errors
skip-changelog, because there's no release with the stream_error module
yet.
2025-07-13 12:53:43 +02:00
Jonas Schäfer
e438813fb2 tokio_xmpp: properly process <stream:error/> while waiting for features
Before this, a stream error would not be readable by user code, as the
`recv_features()` function would not even attempt to parse it. This
change allows application code to react to stream errors which are
received before stream features are received.

skip-changelog, because there's no release with the xmlstream module
yet.
2025-07-13 12:53:43 +02:00
Jonas Schäfer
af7e47a791 Add changelog entry for starttls nonzas
They have been added in 54e1a98cd already.
2025-07-09 17:18:31 +02:00
Jonas Schäfer
c229ab0127 Add support for <failure xmlns=starttls/>
Specified in RFC 6120 §5.4.2.2
2025-07-09 17:18:13 +02:00
Maxime “pep” Buquet
dc2477eec3 Revert "xmpp-parsers: Support required in SM feature"
This reverts commit 4e0cd5d96b.
2025-06-03 23:18:10 +02:00
Link Mauve
4e0cd5d96b xmpp-parsers: Support required in SM feature
This was forgotten in 0f0759b207.

That element is only specified in the XML schema, its semantics aren’t
defined anywhere, but we can guess them anyway.
2025-06-03 23:03:13 +02:00
Link Mauve
74f67b9585 xmpp-parsers: Port Jingle MI to use the derive macros
The only missing check is that #[xml(element)] doesn’t support filtering
on elements with a specific name yet.

skip-changelog: This isn’t a user-visible change.
2025-05-19 20:05:14 +02:00
Link Mauve
3920ad3819 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.
2025-05-14 02:09:26 +02:00
Jonas Schäfer
dc8c3eac4c parsers: port Iq to use the derive macros 2025-05-13 12:01:21 +00:00
Jonas Schäfer
8d8a19380a xso-proc: avoid an ambiguous_associated_items error
rustc forbids cases where an enum variant and an associated type of a
trait conflict for a while now [1].

We must thus avoid referring to associated items on types we do not
control in the macros. There was only one case I found, and it was in
the TryFrom implementation, and could be easily resolved by explicitly
spelling out Self::Error.

   [1]: https://github.com/rust-lang/rust/issues/57644
2025-05-13 12:01:21 +00:00
dae6e49cce
Add more documentation
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-05-12 02:27:03 +02:00
Maxime “pep” Buquet
5d6759caa1 xmpp: Move single changelog entry to breaking
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-05-11 20:25:04 +00:00
Maxime “pep” Buquet
6fe7f92e7d tokio-xmpp: derive Debug on multiple structures
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-05-10 22:11:12 +02:00
Jonas Schäfer
e3a4aae42d tokio-xmpp: simplify examples by requiring specific TLS features 2025-05-10 22:02:40 +02:00
Jonas Schäfer
fc8b581593 Clean up tls-related feature flags
This provides a clear and consistent interface for selecting TLS-related
features on both (xmpp and tokio-xmpp) crates. All feature checks have
been revamped. All working combinations have been tested (including a
connectivity test + --all-features docs build) using:

```
set -xeuo pipefail
features=(aws_lc_rs ring ktls,aws_lc_rs ktls,ring aws_lc_rs,ring aws_lc_rs,ring,ktls native-tls rustls-any-backend)
export RUSTFLAGS=" -D warnings"
cargo test --no-default-features
cargo test
for feature in ${features[@]}; do
  echo ">>> BUILDING with $feature" 2>&1
  # Running code or building examples cannot succeed with rustls-any-backend.
  features="starttls,$feature"
  if [ "$feature" != 'rustls-any-backend' ]; then
    if ! cargo test --no-default-features --features="$features"; then
      echo ">>> BUILD FAILED for tls feature set: $features" >&2
      exit 1
    fi
    set +e
    timeout -sINT -p -k 2 3 cargo run --no-default-features --features="$features" --example keep_connection -- test@hub.sotecware.net "$(pass xmpp/test@hub.sotecware.net)"
    status="$?"
    set -e
    if [ $status -ne 0 ]; then
      echo ">>> keep_connection did not shut down cleanly! (status: $status)" >&2
      exit 1
    fi
  else
    if ! cargo build --no-default-features --features="$feature"; then
      echo ">>> BUILD FAILED for tls feature set: $features" >&2
      exit 1
    fi
  fi
done
RUSTDOCFLAGS="--cfg docsrs" RUSTFLAGS="--cfg xmpprs_doc_build" cargo +nightly doc -Zrustdoc-map --all-features
```
2025-05-10 22:02:39 +02:00
Jonas Schäfer
35a30b0486 tokio-xmpp: fix running examples with native-tls
The dev-dependencies of tokio-xmpp accidentally pulled in the rustls
feature by default, causing attempts to run it with native-tls to
fail.
2025-05-10 11:39:21 +02:00
Jonas Schäfer
4e9e18444c Avoid enabling multiple rustls backends by accident
For this, we had to:

- Make the choice(s) of backend explicit in tokio-xmpp features
- Avoid picking a backend through transitive dependencies in xmpp
  (reqwest->hyper->rustls).

In addition, we choose the default rustls backend by default and adapt
the examples so that they can cope with either situation.
2025-05-10 11:39:21 +02:00
Jonas Schäfer
025e09aca6 tokio-xmpp: explicitly set default CryptoProvider in all examples
This way, we don't end up with breakage if rustls is built with more
than one provider enabled. This can (and does) happen if a transitive
dependency (such as reqwest *hinthint*) depends on a specific,
non-default rustls backend.
2025-05-10 11:39:18 +02:00
Jonas Schäfer
78714475b2 tokio-xmpp: re-export rustls if using rustls backend
The user may have to call some global rustls functions depending on the
exact feature set of rustls enabled. Hence, we have to expose it.

Concretely, if the user somehow ends up with more than one rustls
backend, they have to configure one of the backends as default backend
at startup.
2025-05-10 11:09:58 +02:00
Jonas Schäfer
8c7b503f12 xso: reorganise the code a little
The main lib.rs is getting a bit cluttered, so I'm trying to bring some
order into the chaos by moving some things into other modules.

skip-changelog, because there are no user-facing changes (names which
have been moved are doc(inline)'d and pub use'd in the main lib, and
other things (trait implementations) aren't addressable by users).
2025-05-06 07:42:57 +02:00
Jonas Schäfer
4c47946b81 xso-proc: update inline comment with resolution from upstream bug
Reminder: when something feels too good to be true, it likely is.

skip-changelog, because this is no user-facing change.
2025-05-03 17:57:15 +02:00
Jonas Schäfer
51ce661f8d tokio-xmpp: do not discard XmlLangStack when boxing the stream
The stream may have read some data already (such as the stream
header). When initially writing this code, I had missed that we do
actually also carry the parser state over: I misread the
AsyncReader::wrap(..) command as something like AsyncReader::new, i.e.
starting off with fresh parser state, so I assumed that we need a fresh
XmlLangStack, too.

This is wrong: `p` comes from `self.parser.into_inner()` above and is
the parser state, so we need to carry the lang stack along, as well.

This fixes:

```
thread 'tokio-runtime-worker' panicked at […]/rxml-0.13.1/src/xml_lang.rs:87:13:
pop from empty XmlLangStack
```

happening during stream shutdown. The panic was first reported by
@ppjet6, so thanks for that and the keen eye.

skip-changelog, because the bug has not been released yet.
2025-05-03 17:41:13 +02:00
Link Mauve
7f0a7b2247 xmpp-parsers: Switch to #[xml(lang)] wherever it’s possible
So far this new meta doesn’t work for the BTreeMap<Lang, String>
pattern, which is often used to provide multiple versions of a payload.

skip-changelog: This isn’t a user-facing change.
2025-05-03 10:07:54 +02:00
Link Mauve
3f873d2b42 xmpp-parsers: Remove some unneeded clones 2025-05-03 10:06:59 +02:00
Jonas Schäfer
a222dc70de xso: provide nicer error messages on missing trait implementations 2025-05-02 17:16:59 +02:00
Jonas Schäfer
de39f410d5 xso-proc: improve spans for error messages
For codec-based error messages, this reduces the amount of errors per
violation to one. For all others, it improves the placement of the error
slightly, but we still get duplicates.

I couldn't figure out the remaining discrepancies in the spans ...
2025-05-02 17:16:59 +02:00
Jonas Schäfer
25d89e02ea xso: make convert_via_fromstr_and_display available
Useful for dependent crates which want an easy way to provide the
AsXmlText / FromXmlText traits.
2025-05-02 17:16:59 +02:00
Jonas Schäfer
2a940fb5e0 xso-proc: work around regression in rustc nightly
skip-changelog, this is no user-facing change.

See-Also: https://github.com/rust-lang/rust/issues/140585
2025-05-02 16:29:58 +02:00
Jonas Schäfer
c0262fbafb xso: add support for attribute-switched enums
skip-changelog, because enums have been introduced in the same release,
so this is merely an addition to the already changelogged enum feature.
2025-04-27 18:34:48 +00:00
Jonas Schäfer
f4b981dc78 xso-proc: allow injecting states into the AsItemsSubmachine
This is useful if constant data is to be emitted into the element
header and a prerequisite for attribute-switched enums.
2025-04-27 18:34:48 +00:00