mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
Merge branch 'get__functions' into 'master'
Add get_ functions that return new truncated structs from the current one See merge request !4
This commit is contained in:
commit
ce664554d6
1 changed files with 46 additions and 0 deletions
46
src/lib.rs
46
src/lib.rs
|
@ -190,6 +190,29 @@ impl Jid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a new Jabber ID from the current one with only node and domain.
|
||||||
|
///
|
||||||
|
/// This is of the form `node`@`domain`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use jid::Jid;
|
||||||
|
///
|
||||||
|
/// let jid = Jid::full("node", "domain", "resource").into_bare_jid();
|
||||||
|
///
|
||||||
|
/// assert_eq!(jid.node, Some("node".to_owned()));
|
||||||
|
/// assert_eq!(jid.domain, "domain".to_owned());
|
||||||
|
/// assert_eq!(jid.resource, None);
|
||||||
|
/// ```
|
||||||
|
pub fn into_bare_jid(self) -> Jid {
|
||||||
|
Jid {
|
||||||
|
node: self.node,
|
||||||
|
domain: self.domain,
|
||||||
|
resource: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Constructs a Jabber ID containing only a `domain`.
|
/// Constructs a Jabber ID containing only a `domain`.
|
||||||
///
|
///
|
||||||
/// This is of the form `domain`.
|
/// This is of the form `domain`.
|
||||||
|
@ -214,6 +237,29 @@ impl Jid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a new Jabber ID from the current one with only domain.
|
||||||
|
///
|
||||||
|
/// This is of the form `domain`.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use jid::Jid;
|
||||||
|
///
|
||||||
|
/// let jid = Jid::full("node", "domain", "resource").into_domain_jid();
|
||||||
|
///
|
||||||
|
/// assert_eq!(jid.node, None);
|
||||||
|
/// assert_eq!(jid.domain, "domain".to_owned());
|
||||||
|
/// assert_eq!(jid.resource, None);
|
||||||
|
/// ```
|
||||||
|
pub fn into_domain_jid(self) -> Jid {
|
||||||
|
Jid {
|
||||||
|
node: None,
|
||||||
|
domain: self.domain,
|
||||||
|
resource: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Constructs a Jabber ID containing the `domain` and `resource` components.
|
/// Constructs a Jabber ID containing the `domain` and `resource` components.
|
||||||
///
|
///
|
||||||
/// This is of the form `domain`/`resource`.
|
/// This is of the form `domain`/`resource`.
|
||||||
|
|
Loading…
Reference in a new issue