Commit graph

181 commits

Author SHA1 Message Date
Jonas Schäfer
2b346c4e87 parsers: port more things to derive macros 2024-08-03 13:05:37 +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
5c3ed1435f parsers: delete now-unused generate_element_enum macro 2024-08-03 12:19:42 +02:00
Jonas Schäfer
6afd0ef52f parsers: port enums over to derive macros 2024-08-03 12:19:42 +02:00
Jonas Schäfer
c028c3b91a xso: implement exhaustive enums
These more closely mirror how enums work currently with the macros.
Non-exhaustive enums may be useful though and kind of were the natural
thing to implement.
2024-08-03 12:19:28 +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
xmppftw
5110d5fa96 Support <stream:features> in parsers 2024-08-02 18:25:32 +00:00
Jonas Schäfer
4845715add xso: implement support for enums 2024-08-01 15:28:22 +02:00
Jonas Schäfer
507a3df652 xso-proc: remove Span information from generated type names
By removing that, the lint won't trigger for identifiers with trailing
underscores (which become then embedded underscores which normally trips
the `non_camel_case_types` lint).
2024-08-01 12:53:20 +00: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
Emmanuel Gil Peyrot
d752d8c8fe xmpp-parsers: Convert Tune to xso
The Tune::new() constructor wasn’t pub before that.
2024-07-31 15:38:10 +00:00
Emmanuel Gil Peyrot
c85bde3d2e xmpp-parsers: Convert MetadataResponse to xso 2024-07-31 15:38:10 +00:00
Jonas Schäfer
819a869ffb parsers: replace some more generate_element! calls with derive macros 2024-07-27 09:39:13 +02: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
5d284bbd3a parsers: port some elements with children to derive macros 2024-07-26 22:31:42 +02:00
Jonas Schäfer
5bd36eccfc xso-proc: add support for child elements 2024-07-26 22:31:42 +02:00
Emmanuel Gil Peyrot
09c5ad5976 xmpp-parsers: Convert jingle_s5b’s Candidate to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
726801610f xmpp-parsers: Convert ibb to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
1a7dec6f1e xmpp-parsers: Convert sm’s Enable and Enabled to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
01a61c6099 xmpp-parsers: Convert pubsub’s Default to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
5b5df16ac9 xmpp-parsers: Convert jingle_rtp_hdrext to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
0b92061433 xmpp-parsers: Convert jingle_ibb to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
2eb6ca2f94 xmpp-parsers: Remove util::text_node_codecs
This codec system was useful for the previous parser style, but we have
converted them all to xso now!
2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
0c9e478994 xmpp-parsers: Convert media_element to xso
The API changed here, URI became Uri to be more in line with the coding
style.

Also we don’t attempt to trim them any more because that was only used
in the examples, and nowhere in the text of the specification did it say
that those had to be trimmed.
2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
4be297de11 xmpp-parsers: Convert component to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
e9b6fd5d8b xmpp-parsers: Convert avatar to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
a2ece705cc xmpp-parsers: Convert vcard to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
dc0db38cf3 xmpp-parsers: Convert jingle_dtls_srtp to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
8a48244bc3 xmpp-parsers: Convert vcard_update to xso 2024-07-25 18:42:18 +02:00
Emmanuel Gil Peyrot
7b66de1166 xmpp-parsers: Stop reexporting extra symbols
Let’s continue reexporting jid and minidom, but not their inner pub
items, users of this crate can go one level deeper if they need that.

Only xso::error::Error is still useful to reexport, as this is part of
the public API of all of our parsers.
2024-07-25 14:36:09 +00:00
Emmanuel Gil Peyrot
62b2966b9d xmpp-parsers: Simplify the page-flip logic for MAM
This only has to be a bool, no need for this Option<bool>.
2024-07-25 08:04:49 +00:00
Emmanuel Gil Peyrot
fa2846024f xmpp-parsers: Fix typos noticed by codespell 2024-07-25 07:54:30 +00:00
Jonas Schäfer
ccf38cdf9b Port everything over to AsXml 2024-07-24 16:05:06 +02:00
Emmanuel Gil Peyrot
c631e4eff4 xmpp-parsers: Implement XEP-0386: Bind 2
This depends on XEP-0313 for its MAM metadata, and many others such as
XEP-0198, XEP-0280 and XEP-0352 for the inline features, but we
currently provide those as minidom Elements instead.
2024-07-03 23:11:23 +00:00
Emmanuel Gil Peyrot
69f480e709 xmpp-parsers: Fix most of the clippy warnings
Only the non-looping loop is kept for now, until we find a better
solution.
2024-07-03 16:28:11 +02:00
Emmanuel Gil Peyrot
b51d6cec3a xmpp-parsers: Reorder the XEP-0122 and XEP-0484 namespaces
We keep the list ordered by XEP number, so that it is easier to search
into.
2024-07-02 07:36:46 +00:00
Emmanuel Gil Peyrot
05651545f8 xmpp-parsers: Update XEP-0313 to its latest version
We didn’t have support for the <metadata/> element, which is a
requirement for XEP-0386: Bind 2.
2024-07-02 07:31:14 +00:00
Emmanuel Gil Peyrot
b94919ae99 xmpp-parsers: Fix tests on 32-bit
This has been tested on ARMv7.
2024-07-02 07:13:56 +00:00
Jonas Schäfer
1367764f85 parsers: use Base64 codec to derive more things 2024-07-02 06:56:30 +02:00
Jonas Schäfer
4ec12fab16 parsers: make use of text codecs and derive more things 2024-07-02 06:56:30 +02:00
Jonas Schäfer
c83ff286e0 xso-proc: add support for text codecs
Text codecs allow to customize the conversion of data from/to XML,
in particular in two scenarios:

1. When the type for which the behaviour is to be defined comes from a
   foreign crate, preventing the implementation of
   FromXmlText/IntoXmlText.

2. When there is not one obvious, or more than one sensible, way to
   convert a value to XML text and back.
2024-07-02 06:56:30 +02:00
Jonas Schäfer
ae30221e3c xso: only fail on non-whitespace unknown text
We hereby ignore whitespace-only unexpected text, because that's
generally harmless.
2024-07-01 08:01:42 +02:00
Jonas Schäfer
1e3c075fbf parsers: remove now-obsolete JidCodec 2024-07-01 08:01:42 +02:00
Jonas Schäfer
298bf006bf parsers: use derive macros for simple text-based elements 2024-07-01 08:01:42 +02:00
Jonas Schäfer
b0803f831b xso-proc: add support for parsing text content 2024-07-01 08:01:42 +02:00
Emmanuel Gil Peyrot
32e8f2ec2e xmpp-parsers: Implement XEP-0484: Fast Authentication Streamlining Tokens
This specification defines a token-based method to streamline
authentication in XMPP, allowing fully authenticated stream
establishment within a single round-trip.
2024-07-01 05:53:48 +00:00
Emmanuel Gil Peyrot
972a8427b0 xmpp-parsers: Use the new macro for the feature element 2024-06-30 21:46:25 +02:00