Commit graph xmpp-rs/xso
Author SHA1 Message Date
Jonas Schäfer
1710a6f99e Release all crates
Since we tie the versions rather tightly, we have to release the entire
bunch in order to allow people to upgrade to rxml 0.14.
2026-06-11 17:25:32 +02:00
Jonas Schäfer
a90d9fafb6 xso: fix build on no_std 2026-06-11 17:20:39 +02:00
Jonas Schäfer
e72394c658 minidom: Bump version to 0.19.0
Signed-off-by: Jonas Schäfer <jonas@zombofant.net>
2026-06-09 18:00:34 +02:00
Jonas Schäfer
e2dcd8ac66 Stop being pedantic by default
Up to now, the xmpp-rs projects have been very strict about incoming
data. This has served us, as developers of the libraries, well,
uncovering bugs in our and remote implementations which we could then
get fixed.

However, this behaviour is unexpected to users of the library. In the
XMPP world, unexpected child elements and attributes are generally
expected to be ignored. While this could be opted-into previously, the
feature flag for that sounded more dangerous than it was
("disable-validation"). In addition, the tribal knowledge needed to know
about that feature flag may not have reached some people who tried the
library and gave up because of that.

With this change, we make the non-pedantic behaviour the default. For
development and debugging purposes, users can always opt into the
pedantic behaviour as needed, using the newly-introduced `pedantic`
feature flags on all affected crates.
2026-03-27 12:51:51 +01:00
Jonas Schäfer
d9f030c07e xso: add support for passing rxml::Options 2026-02-21 13:56:50 +01:00
Jonas Schäfer
bb02836097 Bump rxml to 0.14.0 2026-02-21 13:56:50 +01:00
Jonas Schäfer
6cc0df47d7 xso: fix build with minidom and without std 2026-02-21 09:36:57 +01:00
Link Mauve
5ed958582b Fix all typos using the typos tool
See https://github.com/crate-ci/typos
2025-11-22 21:48:21 +00:00
pep
00b638fc38 xso{,-proc}: clippy
This doesn't fix all of the clippy warnings in these crates. There are
decisions that needs to be made in there that I'm not willing to make.

Signed-off-by: pep <pep@bouah.net>
2025-11-01 16:30:22 +01:00
pep
30b049a7d4 Bump xso to 0.3.0
Signed-off-by: pep <pep@bouah.net>
2025-10-28 13:06:51 +01:00
pep
bd986f5e5e minidom: Bump version to 0.18
Signed-off-by: pep <pep@bouah.net>
2025-10-28 13:06:51 +01:00
Maxime “pep” Buquet
19865e5f1e minidom: breaking: Allow getting Element attributes by namespace
- Move Element.attributes to `AttrMap`, slowly using rxml's features and
  unrolling our own.
- Add Element::attr_ns that requires the attribute namespace.
  Element:attr defaults to rxml::Namespace::none() but the interface
  changes nonetheless for a &NcNameStr. Similar changes on
  `ElementBuilder` methods.
- Remove iterator structs for attributes, return a ref on the AttrMap
  directly as we don't need to keep attributes' internals hidden
  anymore.
- Enable rxml's `macros` feature within tests to access the `xml_ncname`
  macro.

Signed-off-by: pep <pep@bouah.net>
2025-10-22 18:51:39 +02:00
Jonas Schäfer
ccdf27117d Fix docs build with current nightly
skip-changelog, we don't officially support nightly.

See-Also: https://github.com/rust-lang/rfcs/pull/3631
See-Also: https://github.com/rust-lang/rust/pull/138907
2025-10-08 13:03:39 +02:00
Jonas Schäfer
3ffff2614a Bump xso version to 0.2.0 2025-09-17 20:03:18 +02:00
Jonas Schäfer
5ab4f395e0 Bump xso_proc version to 0.2.0
skip-changelog, we do not keep a dedicated changelog for xso-proc.
2025-09-17 19:29:39 +02:00
Jonas Schäfer
ff9c3dc88c Bump minidom version to 0.17.0 2025-09-17 19:15:41 +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
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
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
a222dc70de xso: provide nicer error messages on missing trait implementations 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
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
67f3ffaced 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.
2025-04-27 14:19:31 +02:00
Jonas Schäfer
341d49fecf 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.
2025-04-27 14:08:38 +02:00
Jonas Schäfer
cffb5e7e65 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.
2025-04-27 14:08:38 +02:00
Jonas Schäfer
57972e9db0 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.
2025-04-27 14:08:38 +02:00
Jonas Schäfer
fe0050dbd8 xso: fix build without std 2025-04-27 14:08:38 +02:00
Jonas Schäfer
ebe53b8eab 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).
2025-04-27 14:08:38 +02:00
Jonas Schäfer
67e7e9da15 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.
2025-04-27 14:08:38 +02:00
Jonas Schäfer
8688524e1a xso: fix some documentation in minidom_compat 2025-04-27 13:44:07 +02:00
Jonas Schäfer
a7d556ce6f xso: add useful note
I tried to remove it, fell into that trap. Let's save the next person
some work.
2025-04-27 13:44:06 +02:00
Jonas Schäfer
c4de8725fc 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.
2025-04-27 13:44:06 +02:00
Jonas Schäfer
88561269bd xso: fix documentation typos 2025-04-27 13:43:48 +02:00
Jonas Schäfer
9fdb1564f6 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.
2025-04-27 11:18:50 +02:00
Jonas Schäfer
174eea5e5d xso: clarify behaviour when two fields match the same xml attribute 2025-04-23 17:25:18 +02:00
Jonas Schäfer
d9a21dd8c9 Track xml:lang throughout parsing 2025-04-22 17:55:44 +02:00
Jonas Schäfer
31d7bbf622 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.
2025-04-22 17:55:12 +02:00
Jonas Schäfer
70d635b0fb 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.
2025-04-22 17:47:45 +02:00
Jonas Schäfer
0fd69d2ff8 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.
2025-04-18 12:41:12 +02:00
Jonas Schäfer
8e81c41f59 xso: add support for post-deserialization callback 2025-04-18 10:49:26 +02:00
Maxime “pep” Buquet
5b62672541 xso: clippy run
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-04-08 12:47:56 +02:00
Maxime “pep” Buquet
ab7e6de3e1 xso: Add support for serde_json::Value
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-04-07 18:35:43 +00:00
Jonas Schäfer
b05ee0280a xso: add support for selectively discarding text and attributes 2025-04-06 08:36:15 +02:00
Emmanuel Gil Peyrot
9f9eaba7c5 jid: Bump version to 0.12.0 and release it! 2025-02-25 00:00:59 +01:00
Maxime “pep” Buquet
ca241faf7d PrintRawXml: Add changelog entry
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-02-14 18:02:13 +01:00
Maxime “pep” Buquet
b89d3ab04d xso: Add PrintRawXml helper struct with Display
Add a helper struct to be able to display Raw Xml, useful for debug
logs.

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2025-02-12 20:17:41 +01:00