mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
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.
This commit is contained in:
parent
6ccee76621
commit
e6595762f6
1 changed files with 35 additions and 9 deletions
|
@ -435,18 +435,34 @@ impl FullJid {
|
||||||
FullJid { inner }
|
FullJid { inner }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The optional node part of the JID.
|
/// The optional node part of the JID, as a [`NodePart`]
|
||||||
pub fn node(&self) -> Option<&str> {
|
pub fn node(&self) -> Option<NodePart> {
|
||||||
|
self.node_str().map(|s| NodePart::new_unchecked(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The optional node part of the JID, as a stringy reference
|
||||||
|
pub fn node_str(&self) -> Option<&str> {
|
||||||
self.inner.node()
|
self.inner.node()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The domain part of the JID.
|
/// The domain part of the JID, as a [`DomainPart`]
|
||||||
pub fn domain(&self) -> &str {
|
pub fn domain(&self) -> DomainPart {
|
||||||
|
DomainPart::new_unchecked(self.domain_str())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The domain part of the JID, as a stringy reference
|
||||||
|
pub fn domain_str(&self) -> &str {
|
||||||
self.inner.domain()
|
self.inner.domain()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The optional resource part of the JID, as a [`ResourcePart`]. Since this is a full JID it
|
||||||
|
/// is always present.
|
||||||
|
pub fn resource(&self) -> ResourcePart {
|
||||||
|
ResourcePart::new_unchecked(self.resource_str())
|
||||||
|
}
|
||||||
|
|
||||||
/// The optional resource of the Jabber ID. Since this is a full JID it is always present.
|
/// The optional resource of the Jabber ID. Since this is a full JID it is always present.
|
||||||
pub fn resource(&self) -> &str {
|
pub fn resource_str(&self) -> &str {
|
||||||
self.inner.resource().unwrap()
|
self.inner.resource().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,13 +552,23 @@ impl BareJid {
|
||||||
BareJid { inner }
|
BareJid { inner }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The optional node part of the JID.
|
/// The optional node part of the JID, as a [`NodePart`]
|
||||||
pub fn node(&self) -> Option<&str> {
|
pub fn node(&self) -> Option<NodePart> {
|
||||||
|
self.node_str().map(|s| NodePart::new_unchecked(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The optional node part of the JID, as a stringy reference
|
||||||
|
pub fn node_str(&self) -> Option<&str> {
|
||||||
self.inner.node()
|
self.inner.node()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The domain part of the JID.
|
/// The domain part of the JID, as a [`DomainPart`]
|
||||||
pub fn domain(&self) -> &str {
|
pub fn domain(&self) -> DomainPart {
|
||||||
|
DomainPart::new_unchecked(self.domain_str())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The domain part of the JID, as a stringy reference
|
||||||
|
pub fn domain_str(&self) -> &str {
|
||||||
self.inner.domain()
|
self.inner.domain()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue