jid: Add a failible DomainRef::with_node_str()
This matches BareJid::with_resource_str() in that it allows the user to parse a &str into a NodePart and construct the BareJid in one call.
This commit is contained in:
parent
e72394c658
commit
393feb8d5e
2 changed files with 13 additions and 0 deletions
|
|
@ -1,3 +1,8 @@
|
|||
Version NEXT, release XXXX-XX-XX:
|
||||
* Changes:
|
||||
- Add a `DomainRef::with_node_str()` method, matching `with_resource_str()`
|
||||
but for `with_node()`.
|
||||
|
||||
Version 0.12.2, release 2025-02-26:
|
||||
* Changes:
|
||||
- Add a `NodeRef::unescape()` method, to implement XEP-0106 escaping.
|
||||
|
|
|
|||
|
|
@ -288,6 +288,14 @@ impl DomainRef {
|
|||
pub fn with_node(&self, node: &NodeRef) -> BareJid {
|
||||
BareJid::from_parts(Some(node), self)
|
||||
}
|
||||
|
||||
/// Construct a bare JID (a JID without a resource) from this domain and
|
||||
/// the given node (local part), by specifying a stringy `node`.
|
||||
/// If your node has already been parsed into a [`NodePart`], use [`DomainRef::with_node`].
|
||||
pub fn with_node_str(&self, node: &str) -> Result<BareJid, Error> {
|
||||
let node = NodePart::new(node)?;
|
||||
Ok(self.with_node(&node))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DomainPart> for BareJid {
|
||||
|
|
|
|||
Loading…
Reference in a new issue