- 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>
This causes issues in crates using it because they need to have "jid"
listed as a direct dependency when it's not always obvious (version
mismatch etc. when something already uses jid as a dep)
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
The idna crate validates against UTS 46, which supports domains using
either IDNA2003 or IDNA2008. This allows us to support both old and
new internationalized domain names.
This dependency isn’t a new one in the tree, as hickory-proto, url and
tokio-xmpp all were already depending on it.
There are a bunch of other checks that have to be performed, this is
inspired by slixmpp’s JID implementation.
This additionally should optimize the parsing a tiny bit by looking for
both @ and / at the same time and iterating on them, instead of one by
one.
Thanks nicoco for the report!
Jid("foo@bar/baz") instead of Jid { normalized: "foo@bar/baz", at:
Some(3), slash: Some(7) }, which I find much more readable.
Same for BareJid and FullJid.
Paths are already patched in the workspace's [patch.crates-io] block.
Not sure why this was added in the first place.
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
By defining the variables in the parent scope, we can avoid one level of
indentation for the tuple, which makes things more readable.
Additionally, we don’t need to call .to_str() on the passed objects,
they automatically Deref to &str for the format!() call.
This is necessary because `into_inner()` as implemented on Jid
consumes the value. That means it cannot be called through Deref
(because that only takes a reference).
This does not matter much because users need to replace usages of these
anyway, but it's better to have it right here to not cause additional
confusion.
This moves InnerJid into Jid and reformulates BareJid and FullJid in
terms of Jid.
Doing this has the key advantage that FullJid and BareJid can deref to
and borrow as Jid. This, in turn, has the advantage that they can be
used much more flexibly in HashMaps. However, this is (as we say in
Germany) future music; this commit only does the internal reworking.
Oh and also, it saves 20% memory on Jid objects.
Fixes#122 more thoroughly, or rather the original intent behind it.
This provides a non-copying API, which is generally favourable. The
other accessors were removed, because the intent was to provide this
"most sensible" API via the "default" (i.e. shortest, most concisely
named) functions.
This introduces a str-like type for each of these, which will allow
returning a ref instead of the copied data from various methods in
{Full,Bare}Jid.
The use of a macro ensures that all types are declared consistently.