Enum tokio_xmpp::Jid
pub enum Jid {
Bare(BareJid),
Full(FullJid),
}
Expand description
An enum representing a Jabber ID. It can be either a FullJid
or a BareJid
.
Variants§
Bare(BareJid)
Contains a BareJid
, without a resource part
Full(FullJid)
Contains a FullJid
, with a resource part
Implementations§
§impl Jid
impl Jid
pub fn new(s: &str) -> Result<Jid, Error>
pub fn new(s: &str) -> Result<Jid, Error>
Constructs a Jabber ID from a string. This is of the form
node
@domain
/resource
, where node and resource parts are optional.
If you want a non-fallible version, use Jid::from_parts
instead.
Examples
use jid::Jid;
let jid = Jid::new("node@domain/resource")?;
assert_eq!(jid.node_str(), Some("node"));
assert_eq!(jid.domain_str(), "domain");
assert_eq!(jid.resource_str(), Some("resource"));
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,
resource: Option<&ResourcePart>
) -> Jid
pub fn from_parts( node: Option<&NodePart>, domain: &DomainPart, resource: Option<&ResourcePart> ) -> Jid
Build a Jid
from typed parts. This method cannot fail because it uses parts that have
already been parsed and stringprepped into [NodePart
], [DomainPart
], and [ResourcePart
].
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 resource(&self) -> Option<ResourcePart>
pub fn resource(&self) -> Option<ResourcePart>
The optional resource part of the JID, as a [ResourcePart
]. It is guaranteed to be present
when the JID is a Full variant, which you can check with Jid::is_full
.
pub fn resource_str(&self) -> Option<&str>
pub fn resource_str(&self) -> Option<&str>
The optional resource of the Jabber ID. It is guaranteed to be present when the JID is
a Full variant, which you can check with Jid::is_full
.