Commit graph xmpp-rs/xso/ChangeLog
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
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
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
Jonas Schäfer
3ffff2614a Bump xso version to 0.2.0 2025-09-17 20:03:18 +02: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
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
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
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
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
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
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
Jonas Schäfer
4148e9d165 xso-proc: hide generated FromXml / AsXml types
They really clutter the documentation, because they show up in the
module's index. Downside is that users can't inspect the documentation
of those types anymore, but it's not useful anyway: the parts are
private and they just impl some traits.
2025-01-28 18:26:55 +01:00
Emmanuel Gil Peyrot
1823afbc71 xso-proc: Add the default flag to the element meta
This allows the payload to be absent, and requires the field type to be
Option<minidom::Element>.
2025-01-26 16:40:05 +00:00
Emmanuel Gil Peyrot
c72cf3ddd1 xso-proc: Add n = 1 flag to element meta
This allows exactly one arbitrary payload in any element, and is handled
after every other element with a more specific matcher has been parsed.

Both the #[xml(element(n = 1))] meta and its shortcut #[xml(element)]
are allowed and treated the exact same way.
2025-01-26 16:40:05 +00:00
Jonas Schäfer
beae4ae66b xso: fix no_std support
This reverts the Revert in 6ec275d3 which had to be done in order to
un-break usage of xso in std crates.
2025-01-26 15:07:17 +00: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
Jonas Schäfer
69787569c9 xso: implement TextCodec<_> on all T: base64::engine::Engine
The `xso::text::Base64` struct remains as a shorthand (because frankly,
I find the const names in the base64 crate very unwieldly), but you can
now use any of the base64 engines as codec.
2025-01-25 12:22:05 +01:00
Jonas Schäfer
727e57b756 Implement #[xml(flag)] meta 2025-01-21 19:12:43 +01:00
8c033a3fa0 xso: Implement FromXmlText and AsXmlText for NodePart,DomainPart,ResourcePart 2024-12-18 15:43:09 +00:00
Jonas Schäfer
fda4a9ff29 xso: implement transparent structs 2024-08-05 15:13:39 +00:00
Jonas Schäfer
0361b5905b xso: implement catch-all for unknown elements 2024-08-05 15:33:57 +02:00
Jonas Schäfer
2c5f1f096b xso: implement support for extracting data from child elements 2024-08-03 15:17:30 +02:00
Jonas Schäfer
93ba2797be xso-proc: implement support for collections of children 2024-08-03 12:20:04 +02:00
Jonas Schäfer
2fe3c0cef2 xso-proc: add fancy hack to allow codec = Foo<Bar>
We can do this because we know that `x < y` cannot create a
`TextCodec<T>` for any `T`. This is because `<` is guaranteed to return
a boolean value, and we simply don't implement `TextCodec<T>` on bool.
2024-08-03 12:14:26 +02:00
Jonas Schäfer
271c31c9d4 xso: use values instead of types for text codecs
This allows stateful or configurable codecs without having to express
all configuration in the type name itself. For example, we could have a
Base64 type with configurable Base64 engines without having to duplicate
the Base64 type itself.

(Note that the different engines in the Base64 crate are values, not
types.)
2024-08-03 12:14:26 +02:00
Jonas Schäfer
4845715add xso: implement support for enums 2024-08-01 15:28:22 +02:00
Jonas Schäfer
3089832090 xso-proc: remove stripping of trailing _ from type names
Users can now rename the generated types altogether, which means that we
do not need this anymore to avoid lints.
2024-08-01 12:53:20 +00:00
Jonas Schäfer
c90752aa51 xso: add support for overriding names of generated types
In 1265f4b, we introduced a change which may cause a conflict of type
names when deriving the traits on two different types. While a
workaround existed (use `mod`s to isolate the implementation), that is
ugly.

This commit allows overriding the choice of type names.
2024-08-01 12:53:20 +00:00
Jonas Schäfer
cd9f2033f3 xso: add support for boxed children
This allows building recursive tree structures.
2024-07-27 08:24:25 +02:00
Jonas Schäfer
01336802b4 xso-proc: add support for optional children 2024-07-27 08:24:25 +02:00
Jonas Schäfer
5bd36eccfc xso-proc: add support for child elements 2024-07-26 22:31:42 +02:00
Jonas Schäfer
1265f4bb67 xso-proc: fix warnings when struct names end on _ 2024-07-26 22:31:41 +02:00
Jonas Schäfer
951d23cc21 xso: add changelog entry for release 2024-07-26 18:24:12 +02:00
Maxime “pep” Buquet
6b4bdc1641
xso: Bump version to 0.1.1
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2024-07-25 18:53:31 +02:00
Jonas Schäfer
ab35c234c8 xso: Bump version to 0.1.0 2024-07-25 08:25:39 +00:00
Jonas Schäfer
d6d9a7aaaf Add changelog stub files for xso crates 2024-07-24 16:27:33 +02:00