pub struct BareJid { /* private fields */ }
Expand description
A struct representing a bare Jabber ID, without a resource part.
A bare JID is composed of 2 components, of which only the node is optional:
- the (optional) node part is the part before the (optional)
@
. - the domain part is the mandatory part between the (optional)
@
and before the/
.
Unlike a FullJid
, it can’t contain a resource, and should only be used when you are certain
there is no case where a resource can be set. Otherwise, use a Jid
or FullJid
.
Implementations§
§impl BareJid
impl BareJid
pub fn new(s: &str) -> Result<BareJid, Error>
pub fn new(s: &str) -> Result<BareJid, Error>
Constructs a bare Jabber ID, containing two components. This is of the form
node
@domain
, where node part is optional.
If you want a non-fallible version, use BareJid::from_parts
instead.
Examples
use jid::BareJid;
let jid = BareJid::new("node@domain")?;
assert_eq!(jid.node_str(), Some("node"));
assert_eq!(jid.domain_str(), "domain");
pub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Returns the inner String of this JID.
pub fn from_parts(node: Option<&NodePart>, domain: &DomainPart) -> BareJid
pub fn from_parts(node: Option<&NodePart>, domain: &DomainPart) -> BareJid
Build a BareJid
from typed parts. This method cannot fail because it uses parts that have
already been parsed and stringprepped into [NodePart
] and [DomainPart
]. This method allocates
and does not consume the typed parts.
pub fn domain(&self) -> DomainPart
pub fn domain(&self) -> DomainPart
The domain part of the JID, as a [DomainPart
]
pub fn domain_str(&self) -> &str
pub fn domain_str(&self) -> &str
The domain part of the JID, as a stringy reference
pub fn with_resource(&self, resource: &ResourcePart) -> FullJid
pub fn with_resource(&self, resource: &ResourcePart) -> FullJid
Constructs a BareJid
from the bare JID, by specifying a [ResourcePart
].
If you’d like to specify a stringy resource, use BareJid::with_resource_str
instead.
Examples
use jid::{BareJid, ResourcePart};
let resource = ResourcePart::new("resource").unwrap();
let bare = BareJid::new("node@domain").unwrap();
let full = bare.with_resource(&resource);
assert_eq!(full.node_str(), Some("node"));
assert_eq!(full.domain_str(), "domain");
assert_eq!(full.resource_str(), "resource");
pub fn with_resource_str(&self, resource: &str) -> Result<FullJid, Error>
pub fn with_resource_str(&self, resource: &str) -> Result<FullJid, Error>
Constructs a FullJid
from the bare JID, by specifying a stringy resource
.
If your resource has already been parsed into a [ResourcePart
], use BareJid::with_resource
.
Examples
use jid::BareJid;
let bare = BareJid::new("node@domain").unwrap();
let full = bare.with_resource_str("resource").unwrap();
assert_eq!(full.node_str(), Some("node"));
assert_eq!(full.domain_str(), "domain");
assert_eq!(full.resource_str(), "resource");
Trait Implementations§
§impl IntoAttributeValue for BareJid
impl IntoAttributeValue for BareJid
§fn into_attribute_value(self) -> Option<String>
fn into_attribute_value(self) -> Option<String>
impl Eq for BareJid
impl StructuralEq for BareJid
impl StructuralPartialEq for BareJid
Auto Trait Implementations§
impl RefUnwindSafe for BareJid
impl Send for BareJid
impl Sync for BareJid
impl Unpin for BareJid
impl UnwindSafe for BareJid
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.