mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
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).
This commit is contained in:
parent
002c2803d4
commit
9b2663a28b
1 changed files with 23 additions and 0 deletions
|
@ -720,6 +720,24 @@ impl FullJid {
|
||||||
pub fn resource(&self) -> &ResourceRef {
|
pub fn resource(&self) -> &ResourceRef {
|
||||||
self.inner.resource().unwrap()
|
self.inner.resource().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the inner String of this full JID.
|
||||||
|
pub fn into_inner(self) -> String {
|
||||||
|
self.inner.into_inner()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Transforms this full JID into a [`BareJid`], throwing away the
|
||||||
|
/// resource.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// # use jid::{BareJid, FullJid};
|
||||||
|
/// let jid: FullJid = "foo@bar/baz".parse().unwrap();
|
||||||
|
/// let bare = jid.into_bare();
|
||||||
|
/// assert_eq!(bare.to_string(), "foo@bar");
|
||||||
|
/// ```
|
||||||
|
pub fn into_bare(self) -> BareJid {
|
||||||
|
self.inner.into_bare()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for BareJid {
|
impl FromStr for BareJid {
|
||||||
|
@ -826,6 +844,11 @@ impl BareJid {
|
||||||
let resource = ResourcePart::new(resource)?;
|
let resource = ResourcePart::new(resource)?;
|
||||||
Ok(self.with_resource(&resource))
|
Ok(self.with_resource(&resource))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the inner String of this bare JID.
|
||||||
|
pub fn into_inner(self) -> String {
|
||||||
|
self.inner.into_inner()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "minidom")]
|
#[cfg(feature = "minidom")]
|
||||||
|
|
Loading…
Reference in a new issue