Expand description
Implements the XMPP Address Format as defined in RFC 7622.
For historical reasons, XMPP addresses are called “Jabber Identifiers”, or JIDs. JIDs are comprised of three parts: an optional localpart (a username or account), the domainpart (the server), and an optional resourcepart (a specific client) and look more or less like an email where the first two parts are demarcated by the ‘@’ character but with the resourcepart added to the end and demarcated by the ‘/’ character, eg:
localpart@domainpart/resourcepart
Like email, JIDs allow routing across networks based on the domainpart, and local routing based on the localpart. Unlike emails however, JIDs also allow for last-mile-delivery to specific clients (or “resources”) using the resourcepart. Also unlike email, JIDs support internationalization.
Note well that this package currently isn’t fully compliant with RFC 7622; it does not perform the PRECIS (RFC 8264) enforcement step.
§Features
The following feature flag can be used when compiling the crate:
try_from
— build with experimentalTryFrom
impls on nightly
No features are enabled by default.
§Examples
§From parts (stable)
let j = Jid::new("feste", "example.net", None)?;
assert_eq!(j, "feste@example.net");
§From parts (nightly)
#![feature(try_from)]
let j: Jid = ("feste", "example.net").try_into()?;
assert_eq!(j, "feste@example.net");
let j = Jid::try_from(("feste", "example.net", "avsgasje"))?;
assert_eq!(j, "feste@example.net/avsgasje");
§Parsing (stable)
let j = Jid::from_str("juliet@example.net/balcony")?;
assert_eq!(j.localpart(), Some("juliet"));
assert_eq!(j.domainpart(), "example.net");
assert_eq!(j.resourcepart(), Some("balcony"));
§Parsing (nightly)
#![feature(try_from)]
let j: Jid = "orsino@example.net/ilyria".try_into()?;
assert_eq!(j, "orsino@example.net/ilyria");
let j = Jid::try_from("juliet@example.net/balcony")?;
assert_eq!(j, "juliet@example.net/balcony");
Structs§
- A parsed JID.
Enums§
- Possible error values that can occur when parsing JIDs.
Type Aliases§
- A custom result type for JIDs that elides the error type.