dc8c3ea
parsers: port Iq to use the derive macros
Jonas Schäfer created
dc8c3ea
parsers: port Iq to use the derive macros
Jonas Schäfer created
8d8a193
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
Jonas Schäfer created
dae6e49
Add more documentation
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
xmppftw created
5d6759c
xmpp: Move single changelog entry to breaking
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Maxime “pep” Buquet created
6fe7f92
tokio-xmpp: derive Debug on multiple structures
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Maxime “pep” Buquet created
e3a4aae
tokio-xmpp: simplify examples by requiring specific TLS features
Jonas Schäfer created
fc8b581
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
```
Jonas Schäfer created
35a30b0
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.
Jonas Schäfer created
4e9e184
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.
Jonas Schäfer created
025e09a
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.
Jonas Schäfer created
7871447
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.
Jonas Schäfer created
8c7b503
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).
Jonas Schäfer created
4c47946
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.
Jonas Schäfer created
51ce661
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.
Jonas Schäfer created
7f0a7b2
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.
Link Mauve created
3f873d2
xmpp-parsers: Remove some unneeded clones
Link Mauve created
a222dc7
xso: provide nicer error messages on missing trait implementations
Jonas Schäfer created
de39f41
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 ...
Jonas Schäfer created
25d89e0
xso: make convert_via_fromstr_and_display available
Useful for dependent crates which want an easy way to provide the AsXmlText / FromXmlText traits.
Jonas Schäfer created
2a940fb
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
Jonas Schäfer created
c0262fb
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.
Jonas Schäfer created
f4b981d
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.
Jonas Schäfer created
847032e
xso-proc: add support for matching elements using `match`
The `match` expression will have to be provided by the caller. Use cases could be to express the `NameSwitchedEnum` more clearly (by switching on the XML element's name) or introducing new kinds of switched enums.
Jonas Schäfer created
4346e4b
xmpp::muc::room: reverse check for rooms_joined
skip-changelog, fixes bug introduced in the same release Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Maxime “pep” Buquet created
67f3ffa
xso: re-implement `#[xml(lang)]` on top of `#[xml(attribute)]`
This gives us all the goodies of `default`, `type_` and `codec` without having to duplicate lots of code (and I think the `match`-iness of the new macro code is still within limits). However, we still keep them as separate `#[xml(..)]` attributes, because their semantics are very different and it is sensible to make them stand out. skip-changelog, because `#[xml(lang)]` was introduced in this version.
Jonas Schäfer created
341d49f
xso: extend the documentation overall
Sprinkling it with examples, adding more words to make things (hopefully) clearer, using a similar structure for different items etc. etc.
Jonas Schäfer created
cffb5e7
xso: make Context use a builder-like pattern
That way, we can (hopefully) add more fields in the future without breaking stuff. I don't yet know what such fields could be, though.
Jonas Schäfer created
57972e9
xso: make from_bytes available without std
This also deuglifies some of the parsing code by avoiding the interaction with the I/O errors emitted from rxml::Reader.
Jonas Schäfer created
fe0050d
xso: fix build without std
Jonas Schäfer created
8f47c9d
minidom: fix build without std
Jonas Schäfer created
ebe53b8
xso: remove `#[doc(inline)]` from TextCodec
Using `#[doc(inline)]` there makes it appear in two places in the documentation, which may be confusing (as it's not fully obvious that both places are in fact the same trait).
Jonas Schäfer created
67e7e9d
xso: improve documentation around text traits for third-party types
The previous wording was a bit ominous in places ("Because of the
unfortunate situation as described in `FromXmlText`"). This should be
clearer and provides hopefully clearer instructions.
Jonas Schäfer created
8688524
xso: fix some documentation in minidom_compat
Jonas Schäfer created
a7d556c
xso: add useful note
I tried to remove it, fell into that trap. Let's save the next person some work.
Jonas Schäfer created
c4de872
xso: deprecate try_from_element
It is not necessary anymore, because we switched from `IntoXml` to `AsXml`, allowing `transform` to work with a reference instead of consuming its input. Before that, `try_from_element` was the only way to fallibly attempt to parse something from `Element` without having to clone the entire DOM.
Jonas Schäfer created
8856126
xso: fix documentation typos
Jonas Schäfer created
9fdb156
xso: reject attempts to match the same XML attribute in different fields
This was a bit tricky to build, because it is possible to have an indirection through a `static` there. Thanks to Rust's extensive const-fn capabilities, though, it's in fact possible to cover all cases. We still do two different checks to improve user experience. If we can, from within the proc macro, determine that two fields refer to the same XML attribute (because their namespace/name values use the same Rust tokens), then we reject the fields with a clear error message pointing at both fields. In the other case, when there's e.g. `#[xml(lang)]` and `#[xml(attribute(namespace = rxml::XMLNS_XML, name = "lang"))]`, the macro cannot be sure that XMLNS_XML is in fact the XML namespace. For that case, we generate code which is evaluated at compile time (and has no runtime impact) which panics if the namespace and name of two attribute-matching fields is the same. The error message will be less clear (because it contains extra, unchangeable wording like "evaluation of constant value failed" and "the evaluated program panicked at", which may be a bit confusing) than the message generated by the macros themselves, but it's a price we have to pay unfortunately. Note that this check may seem cosmetic and purely for better user experience, but it is in fact needed to avoid generating not-well-formed and/or not-namespace-well-formed XML: As `AsXml` generates `xso::Item`, where each attribute is emitted separated (and not aggregated in a map structure), a naive (and efficient) implementation of a writer might not double-check that no duplicate attributes are generated.
Jonas Schäfer created
174eea5
xso: clarify behaviour when two fields match the same xml attribute
Jonas Schäfer created
d9a21dd
Track xml:lang throughout parsing
Jonas Schäfer created
31d7bbf
xso: discard xml:lang implicitly
Because this attribute may occur in random places, it makes no sense failing on it. We discard it after attribute processing though, so it can still be captured by structs which are explicitly interested in it.
Jonas Schäfer created
70d635b
Bump rxml to 0.13.1
rxml 0.13.0 changed the quoting style to make it consistent, so we have to patch up all affected places where we match exact strings.
Jonas Schäfer created
477af3c
xmpp: new 'escape-hatch' feature
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Maxime “pep” Buquet created
a8c66bc
minidom, tokio-xmpp: Use Option::as_deref()
This simplifies the Option::as_ref().map(|foo| &**foo) pattern a lot. skip-changelog: Completely internal change.
Link Mauve created
75e0cb7
parsers: improve xml:lang handling
This is still far from being a full fix. Still, we can avoid the lang attribute (by allowing discarding the `xml:lang` value via the feature introduced a couple commits ago) and we can avoid emitting `xml:lang=""` where no language was previously set using the mechanism introduced for <message/> in 5172fb5e.
Jonas Schäfer created
5172fb5
parsers: port Message to use the derive macros
Jonas Schäfer created
0fd69d2
xso-proc: fix order-dependent compilation bug
The test case which is added fails to compile unless one puts the `parent` field before the `id` field. The cause is explained somewhat by the change, but I'll spell it out here nontheless. Previously, the loop in `Compound::make_as_item_iter_statemachine` assumed that the serialisation order of fields would match their declaration order. That is not generally true: attributes must be serialised before element content, because they must be emitted before the element header is closed. This change thus splits the generated states into "header" states (for everything before the end of the element header (think `>`)) and "body" states (for everything after and including the end of the element header). After all fields have been processed, we can then add the data fields of the body fields to the header states so that they are carried through the generated state machine until they are needed in the body.
Jonas Schäfer created
134255d
parsers: port data_forms to use derive macros
Jonas Schäfer created
8e81c41
xso: add support for post-deserialization callback
Jonas Schäfer created
da219d4
xmpp: handle SIGINT (^C) in hello_bot example
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Maxime “pep” Buquet created
23c947d
tokio-xmpp: clippy run
skip-changelog Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Maxime “pep” Buquet created