Commit graph

70 commits

Author SHA1 Message Date
xmppftw
df106dfbaf Relative dependencies 2024-08-12 10:39:09 +00:00
Emmanuel Gil Peyrot
9960cfd965 jid: Make Debug more readable on Jid
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.
2024-08-06 16:53:58 +02:00
xmppftw
fa99c09585 Indicate which feature flag for each module/type 2024-08-05 11:14:41 +02:00
0ef646db86 jid: Bump version to 0.11.1
Some checks failed
Build / lint (push) Has been cancelled
Build / test-stable (push) Has been cancelled
Build / test-nightly (push) Has been cancelled
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2024-07-23 19:02:46 +02:00
f35bbcb36d minidom: Bump version to 0.16
Some checks failed
Build / lint (push) Has been cancelled
Build / test-stable (push) Has been cancelled
Build / test-nightly (push) Has been cancelled
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2024-07-23 19:02:46 +02:00
86c13611ba Remove unused paths in multiple Cargo.toml
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>
2024-07-23 16:28:38 +00:00
93288307d3
jid: bump version to 0.11
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2024-07-23 18:06:03 +02:00
318e5a19cc jid: Update Changelog
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2024-07-23 14:32:13 +02:00
Emmanuel Gil Peyrot
b4b0a7dbba jid: Simplify from_parts() a bit
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.
2024-07-15 18:27:35 +02:00
Emmanuel Gil Peyrot
ff588d834e jid: Fix a clippy warning
The other three are about missing Self in the new method’s return type,
but these return the Cow type instead so that’s how they’re meant to be.
2024-07-03 16:28:11 +02:00
Jonas Schäfer
9b2663a28b Add more specific into_* conversion functions to specific JID subtypes
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).
2024-05-14 17:53:53 +02:00
Emmanuel Gil Peyrot
48f77acb69 jid: Make the crate no_std
Only std::error::Error is missing in this mode, but that’s only waiting
for its stabilisation, see this issue:
https://github.com/rust-lang/rust/issues/103765
2024-05-04 10:28:25 +00:00
Jonas Schäfer
1293e9a3eb jid: fix incorrect type on Jid::Full
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.
2024-04-16 18:19:47 +02:00
Jonas Schäfer
054447d147 jid: add more testcases
Because why not!
2024-04-15 19:54:59 +02:00
Jonas Schäfer
c08946aa7c jid: skip at and slash in comparison operators
They only contain cached information and thus don't need to be included
in comparison and identity operators.

Fixes #123.
2024-04-15 19:35:02 +02:00
Jonas Schäfer
c895cb1009 jid: implement Borrow<Jid> on FullJid and BareJid
This allows to use them interchangably when looking up keys in hash sets
and dicts.
2024-04-15 18:21:24 +02:00
Jonas Schäfer
2e9c9411a3 jid: rewrite public types
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.
2024-04-15 18:21:24 +02:00
Jonas Schäfer
2c701038cd Implement as_str on all Jid types
This is useful for printing with quotes without copying any data.
2024-03-10 10:51:53 +01:00
Jonas Schäfer
9608b59f60 Add more conversion/construction paths between Jid and part types 2024-03-10 10:51:53 +01:00
Jonas Schäfer
7fce1146e0 Offer {Resource,Node,Domain}Ref on Jid API
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.
2024-03-10 10:51:01 +01:00
Jonas Schäfer
45f1567ff2 Use debug_tuple instead of string formatting
This provides standard-library-like output.
2024-03-09 09:00:22 +01:00
Jonas Schäfer
8238e81c66 Unify declaration of {Node,Domain,Resource}Part
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.
2024-03-09 09:00:22 +01:00
xmppftw
141a40bc79 Derive PartialOrd/Ord for Jid types 2023-12-31 16:59:21 +00:00
xmppftw
ac4ffd2268 Use relative cargo paths when using local copy 2023-12-18 13:06:22 +01:00
xmppftw
119c04801c Fix cargo doc warnings in jid crate 2023-12-16 17:19:11 +01:00
4089891f6c Update edition to 2021
- Remove TryFrom/Into and FromIterator imports
- Prevent impl_validator_using_provider macro in sasl crate from
  constructing trait object

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-12-15 19:40:09 +00:00
Aurabindo Pillai
12d102b39c Fix some clippy warnings 2023-12-04 01:01:19 +00:00
e20bd9b1d2
jid: Update Changelog
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-11-11 13:24:26 +01:00
ec969a78fc
jid: Add optional quote support
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-10-30 14:18:13 +01:00
d0a8ea3178 jid: bump to 0.10
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-08-20 21:34:04 +02:00
63b2e6d176 jid: Update changelog
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-08-20 21:34:04 +02:00
8de14336f5
jid: Add test for Jid::Full ser/de
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-08-14 21:59:27 +02:00
e9066c353d
jid: Replace serde_json with serde_test in tests
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-08-14 21:59:09 +02:00
mb
2f808f161f chore: Rename User struct to JidContainer 2023-08-14 12:17:51 +00:00
mb
fc23f987cd style: Run cargo fmt 2023-08-14 12:17:51 +00:00
xmppftw
b09c540080 Add tests for serde features of jid crate 2023-08-14 12:17:51 +00:00
mb
997303900b fix(jid): Fix JID serialization with serde; address oversight in commit cdf4486e 2023-08-14 12:17:51 +00:00
Emmanuel Gil Peyrot
2ad0dd66dd Replace format!("{}", jid) with jid.to_string()
This is more readable I think, and expresses better our intent.
2023-08-10 19:35:53 +00:00
Emmanuel Gil Peyrot
6fc3a46bd2 jid: Fix tests 2023-08-10 19:31:10 +00:00
Emmanuel Gil Peyrot
e6595762f6 Use the parts/str split in FullJid and BareJid too
Since 199b3ae7ae we allow typed parts to
be reused without stringprep being reapplied.  This extends it from just
Jid to FullJid and BareJid too.
2023-08-10 19:31:10 +00:00
Emmanuel Gil Peyrot
6ccee76621 Add a test for an invalid resource
This one uses unassigned codepoints in Unicode 3.2.
2023-08-05 16:53:22 +02:00
Emmanuel Gil Peyrot
11087d64f7 Add *Jid::into_inner() returning the inner String
Thanks pep. for the suggestion!
2023-07-30 15:23:02 +02:00
Emmanuel Gil Peyrot
6f304d197d jid: Optimise for no-transform JIDs
stringprep can make transformations to a JID, the most well-known one is
making the nodepart and domainpart lowercase but it does much more than
that.

It is extremely common to have to validate already-normalised JIDs
though, and since https://github.com/sfackler/rust-stringprep/pull/4
this is exactly what the stringprep crate does, by returning
Cow::Borrowed() for common ASCII-only cases.

This commit further reduces time spent by an additional -15%..-58% when
already using this stringprep improvement, in addition to the
89.5%..98.5% change brought by this improvement (and +1.3% total when
the JID isn’t normalised yet).

For instance, my own full JID parses in 1.83 µs before these changes,
132 ns with just the stringprep optimisation, and 46 ns with also this
commit, on an i7-8700K.
2023-07-16 19:50:12 +02:00
xmppftw
76b68e932a Update CHANGELOG for jid crate 2023-06-21 18:41:32 +02:00
xmppftw
4266368a98 JIDs now have typed and stringy methods for node/domain/resource access
Jid now has typed with_resource and stringy with_resource_str
Jid now has is_full, is_bare
2023-06-21 18:30:25 +02:00
xmppftw
199b3ae7ae Introduce typed Parts for the JID to enable unfallible JID construction 2023-06-21 14:15:03 +02:00
xmppftw
c86f0118b7 jid: Better docs for those types 2023-06-20 21:21:06 +02:00
Emmanuel Gil Peyrot
cdf4486e53 jid: Remove From<*Jid> for String
Use fmt::Display instead if you want this feature.
2023-06-20 18:59:26 +02:00
Emmanuel Gil Peyrot
ccf41fc1e8 jid: Rename errors to make them more consistent 2023-06-20 18:59:26 +02:00
Emmanuel Gil Peyrot
1904f0af6c jid: Rename error into Error
JidParseError is an ok name when imported elsewhere, but inside of this
crate it makes much more sense to name it Error.
2023-06-20 18:59:26 +02:00