Commit graph xmpp-rs/xso
Author SHA1 Message Date
Emmanuel Gil Peyrot
356ad0d46e xso: Fix all failing clippy tests
They are all sensible to me.

skip-changelog: Internal changes.
2025-02-12 19:11:32 +00: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
763a603e49 xso: fix documentation typos
skip-changelog
2025-01-25 12:32:41 +00:00
Jonas Schäfer
4c9a271842 xso: remove incorrect/obsolete comment 2025-01-25 12:24:03 +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
Jonas Schäfer
6ec275d381 Revert "xso-proc: Replace std stuff with alloc/core stuff"
This reverts commit 4e5f0bc961.

Unfortunately, in std contexts, the `alloc` crate is not imported. That
means we cannot rely on it being accessible and it in fact breaks builds
of crates which are not `no_std`.

Fixes #155.
2025-01-20 17:52:35 +01:00
Jonas Schäfer
b8af0d8fa2 xmpp_parsers: --features disable-validation
It was broken in multiple ways:

- xso did not honour it: unknown children and attributes would cause a
  parse error even with `--features disable-validation` set on parsers.
  For this, we introduce a new feature flag on xso, `non-pedantic`,
  which defaults unknown children and attributes to discard instead of
  fail.

  Note that individual XSOs can still choose to be always pedantic or
  always lenient by explicitly declaring the intent via the
  `on_unknown_child` and `on_unknown_attribute` metas.

- Many tests in `xmpp_parsers` were broken with `--features
  disable-validation`. They now all pass while *still* being rn with
  `disable-validation` set: In that case, they test that parsing in fact
  succeeds.
2024-12-20 14:50:14 +01:00
Jonas Schäfer
58698f633f xso: only take reference in transform
This avoids the need for an expensive clone. Since we switched to AsXml
instead of IntoXml, we don't necessarily have to clone the data when
building new elements, only when it's absolutely necessary. The clones
then happen implicitly in the ItemToEvent iterator used internally.

This mostly fixes #86, with the caveat that there's no absolutely cheap
test: On success, the entire element will be copied, while on failure,
you learn about it rather quickly.
2024-12-20 12:44:43 +01:00
c8d3c068e0 xso: Replace std::io calls with use std::io 2024-12-19 20:51:57 +01:00
6a662e6a2c xso: Replace std stuff with alloc/core stuff 2024-12-19 20:51:57 +01:00
4e5f0bc961 xso-proc: Replace std stuff with alloc/core stuff 2024-12-19 20:51:56 +01:00
1c1b960265 xso: Add std feature ; default-features compiles in no-std 2024-12-19 20:38:28 +01:00
8c033a3fa0 xso: Implement FromXmlText and AsXmlText for NodePart,DomainPart,ResourcePart 2024-12-18 15:43:09 +00:00
Jonas Schäfer
7074344834 xso: correctly handle I/O errors during start event in from_reader
Without this, it'd panic, which is "not ideal", as they say.
2024-12-18 14:47:08 +00:00
Jonas Schäfer
fa039c588b xso: improve wording in AsXmlText and AsOptionalXmlText 2024-12-16 19:04:23 +01:00
Emmanuel Gil Peyrot
5e9635add3 rustfmt has changed, so update xso so CI is happy again 2024-12-15 16:26:05 +01:00
Jonas Schäfer
7d8ffe45a7 xso: add support for ignoring unknown stuff in extracts 2024-10-26 17:37:32 +00:00
Jonas Schäfer
66233b0150 xso: add support for ignoring unknown children 2024-10-26 17:37:32 +00:00
Jonas Schäfer
290460ba9d xso: add support for ignoring unknown attributes 2024-10-26 17:37:32 +00:00
Jonas Schäfer
74c81b6a37 xso: add from_reader 2024-10-03 12:57:32 +02:00
Alvaro Parker
2ff89a9e42 fix typos 2024-09-16 18:29:44 -03:00
Jonas Schäfer
efc859abc0 xmlstream: re-introduce syntax-highlit logging of XML stream I/O 2024-09-01 10:02:36 +02:00
Jonas Schäfer
f77c21f0fc Update to rxml 0.12.0 2024-08-12 16:16:32 +02:00
df106dfbaf Relative dependencies 2024-08-12 10:39:09 +00:00
Jonas Schäfer
5c990a553c xso: enable rxml macros when enabling xso_proc
We build syn then anyway, so we can build rxml macros, too.
2024-08-12 12:32:12 +02:00
Jonas Schäfer
6b4886857e xso: offer is_xml_whitespace function 2024-08-12 12:32:12 +02:00
Jonas Schäfer
1ecb95881c xso: add support for extracting tuples 2024-08-11 07:58:12 +02:00
Jonas Schäfer
ad2c79cbe7 xso: document some specific trait implementations 2024-08-11 07:45:05 +02:00
Jonas Schäfer
2ff81b3923 xso: add support for fallible parsing and serialisation 2024-08-11 07:45:05 +02:00
Jonas Schäfer
02a928a47c xso: add some tests 2024-08-11 07:45:05 +02:00
Jonas Schäfer
f1ab857c6e xso: move helper iterators and builders into separate module
This declutters the main `xso` namespace. In addition, if (when) we
introduce more complex generic implementations, we might want to have
tests for these, and those can then live there, too, without making the
main `lib.rs` file gigantic (or moving the tests too far away from the
tested code).
2024-08-11 07:45:05 +02:00
Jonas Schäfer
230b72b052 xso: add ToC to FromXml docs 2024-08-08 15:25:40 +00:00
Jonas Schäfer
fb80bb7532 xso: add support for dynamic enums 2024-08-08 15:25:40 +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
2103ef0191 Remove manual doc_cfg feature because we have doc_auto_cfg 2024-08-05 11:14:41 +02:00
fa99c09585 Indicate which feature flag for each module/type 2024-08-05 11:14:41 +02:00
Jonas Schäfer
c7c180feb6 xso: implement support for defaulting extracts 2024-08-04 16:07:14 +02:00
Emmanuel Gil Peyrot
f318dd460d xso: Use core instead of std wherever possible 2024-08-04 12:41:17 +00:00
Emmanuel Gil Peyrot
aa518fd6c1 xso-proc: add support for extracting attributes into collections 2024-08-04 13:38:52 +02:00
Jonas Schäfer
8732ca9a28 xso: add support for extracting into collections 2024-08-03 18:19:31 +02:00
Jonas Schäfer
df63c2a78f xso: allow omission of namespace and name on extracts
This is a quality-of-life improvement, as it may save lots of typing in
the common case (see the diff in parsers).
2024-08-03 15:25:46 +02:00
Jonas Schäfer
2c5f1f096b xso: implement support for extracting data from child elements 2024-08-03 15:17:30 +02:00
Emmanuel Gil Peyrot
7f5b6fec7f xso: Allow any T: FromXmlText + AsXmlText in EmptyAsNone
This text codec was previously implemented only for Option<String>, this
extends it to all types implementing those two traits, such as numbers
or JIDs.
2024-08-03 13:43:44 +02:00
Jonas Schäfer
93ba2797be xso-proc: implement support for collections of children 2024-08-03 12:20:04 +02:00