A type-safe Rust XMPP library.
Find a file
Jonas Schäfer 1f679c3af7 xso: add traits for XML text <-> value conversion
The traits have undergone a couple iterations and this is what we end up
with. The core issue which makes this entire thing ugly is the
Orphan Rule, preventing some trait implementations relating to types
which haven't been defined in this crate.

In an ideal world, we would implement FromXmlText and IntoXmlText for
all types implementing FromStr and/or fmt::Display.

This comes with two severe issues:

1. Downstream crates cannot chose to have different
   parsing/serialisation behaviour for "normal" text vs. xml.

2. We ourselves cannot define a behaviour for `Option<T>`. `Option<T>`
   does not implement `FromStr` (nor `Display`), but the standard
   library *could* do that at some point, and thus Rust doesn't let us
   implement e.g. `FromXmlText for Option<T> where T: FromXmlText`,
   if we also implement it on `T: FromStr`.

The second one hurts particularly once we get to optional attributes:
For these, we need to "detect" that the type is in fact `Option<T>`,
because we then need to invoke `FromXmlText` on `T` instead of
`Option<T>`. Unfortunately, we cannot do that: macros operate on token
streams and we have no type information available.

We can of course match on the name `Option`, but that breaks down when
users re-import `Option` under a different name. Even just enumerating
all the possible correct ways of using `Option` from the standard
library (there are more than three) would be a nuisance at best.

Hence, we need *another* trait or at least a specialized implementation
of `FromXmlText for Option<T>`, and we cannot do that if we blanket-impl
`FromXmlText` on `T: FromStr`.

That makes the traits what they are, and introduces the requirement that
we know about any upstream crate which anyone might want to parse from
or to XML. This sucks a lot, but that's the state of the world. We are
late to the party, and we cannot expect everyone to do the same they
have done for `serde` (many crates have a `feature = "serde"` which then
provides Serialize/Deserialize trait impls for their types).
2024-06-30 13:01:36 +02:00
.forgejo/workflows CI: Stop running ignored tests 2024-06-25 12:27:01 +02:00
jid Add more specific into_* conversion functions to specific JID subtypes 2024-05-14 17:53:53 +02:00
minidom xso: create library for streamed XML parsing 2024-06-18 16:54:11 +02:00
parsers parsers: re-arrange data_forms validation implementation 2024-06-30 11:25:45 +02:00
sasl sasl: remove ignore from toml snippet 2024-06-25 07:30:33 +02:00
tokio-xmpp Revert "tokio-xmpp: rustfmt pass in examples" 2024-06-18 20:32:46 +02:00
xmpp Ignore missing disco#info feature in disco#info responses 2024-06-16 10:52:51 +02:00
xso xso: add traits for XML text <-> value conversion 2024-06-30 13:01:36 +02:00
xso-proc xso-proc: fix renaming attributes using a static item 2024-06-25 13:55:07 +00:00
.gitea Support Github Actions (for a migration to forgejo) 2023-12-03 14:20:51 +00:00
.github Deny warnings in github/gitea/forgejo CI and act local runner 2024-01-21 13:55:39 +01:00
.gitignore Hello world! 2019-03-21 18:43:27 +01:00
.gitlab-ci.yml CI: Stop running ignored tests 2024-06-25 12:27:01 +02:00
Cargo.toml xso-proc: start making derive macros for FromXml and IntoXml 2024-06-23 12:20:02 +02:00
CODE_OF_CONDUCT.md Code of Conduct 2024-01-21 21:50:31 +01:00
CONTRIBUTING.md CONTRIBUTING: Split in categories 2024-02-02 22:26:00 +01:00
LICENSE Readd global LICENSE file 2020-02-25 22:13:34 +01:00
README.md CONTRIBUTING: Split in categories 2024-02-02 22:26:00 +01:00

xmpp-rs

What's this?

A very much WIP set of rust XMPP library with the goals of being type-safe and well-tested.

  • xmpp-rs provides a high-level API for the protocol. You shouldn't need to know about the protocol to use it.
  • tokio-xmpp is a lower-level library that handles the XMPP stream(s).
  • xmpp-parsers parses XML into Rust and back.
  • minidom is a DOM library quite specific for XMPP
  • jid is a Jid parsing library.

Contact

There is an XMPP MUC for the discussion of this library, feel free to join! :)

chat@xmpp.rs

Community

A Code of Conduct is available as CODE_OF_CONDUCT.md in the repository for the well-being of the community. Please refer to it in case of a possible conflict in any of the xmpp-rs venues (channel, forge, etc.).

License

Mozilla Public License 2 (MPL2). See the LICENSE file.

Building

Dependencies should be provided by crates if you use the default features. If you use tokio-xmpp's tls-native feature you will need an ssl library (openssl, libressl, etc.).

cargo build

The various features available should be explained in the crates themselves.

Contributing

Thank you for your interest in the project!

Contributing rules are available as CONTRIBUTING.md in the repository.