1
0
mirror of https://gitlab.com/xmpp-rs/xmpp-rs.git synced 2024-06-09 09:44:03 +02:00
Commit Graph

40 Commits

Author SHA1 Message Date
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
Maxime “pep” Buquet
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
Maxime “pep” Buquet
ec969a78fc
jid: Add optional quote support
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-10-30 14:18:13 +01:00
Maxime “pep” Buquet
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
Maxime “pep” Buquet
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
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
Emmanuel Gil Peyrot
cf25bd3fee jid: Refactor all three JID types
The main reason for this refactor was to make common operations simpler,
for instance formatting a JID is now a simple clone of a String.

Instead of having three different String for each of node, domain and
resource, we now have a single String with offsets pointing to where the
at and slash are (if they are present).

This also reduces the size of a FullJid from 72 bytes to 32 bytes on
64-bit platforms (less so on 32-bit), and BareJid from 48 bytes to
32 bytes.  Jid is still 40 bytes instead of 32, but that can be improved
in a future version where InnerJid has been inlined into each struct.
2023-06-20 18:59:26 +02:00
Emmanuel Gil Peyrot
187e156b0b jid: Move JidParseError into its own module 2023-06-20 18:59:26 +02:00
Emmanuel Gil Peyrot
d867d8d7a1 jid: Replace icu with stringprep
This dependency is unmaintained, but it is written in pure Rust unlike
ICU, and doesn’t require a roundtrip through UTF-16, improving both
performances (perhaps?) and ease of compilation.
2023-06-20 18:59:26 +02:00
Emmanuel Gil Peyrot
a7dee0bef4 jid: Test for the size of our structs
This shows how big JIDs are represented on the stack and in other
structs.
2023-06-20 18:59:26 +02:00
Maxime “pep” Buquet
4701f6bb69 jid: Rename Error::IcuError into Error::Stringprep
Avoir the "Error Error" pattern, and also use Stringprep instead of ICU

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2023-06-07 17:29:05 +02:00
xmppftw
2cafecb004 JID stringprep errors return a JidParseError instead of panic (#84) 2023-06-07 17:29:00 +02:00
xmppftw
8d9288ffd7 Implement From<&Jid> for String (close #69) 2023-05-28 22:27:40 +02:00
xmppftw
ce255d9602 Jid (de)serialization now uses untagged representation (close #66) 2023-05-28 19:54:51 +02:00
Emmanuel Gil Peyrot
6eb25755a3 WIP: Add ICU bindings for stringprep, idna2008 and spoof checker. 2022-09-16 11:10:52 +02:00
Emmanuel Gil Peyrot
9891cc48ac jid: Fix the issues reported by clippy 2021-10-11 16:17:09 +02:00
Emmanuel Gil Peyrot
3df447de97 jid: Implement PartialEq between Jid and BareJid/FullJid.
This can be useful at times.
2020-12-10 20:45:01 +01:00
Emmanuel Gil Peyrot
714d850e69 Remove the -rs suffix of jid, minidom and xmpp
We know those are Rust libraries, no need to add it to the path.  This
synchronises their directory with the crate name, hopefully reducing
confusion.
2020-06-22 02:17:32 +02:00