Struct jid::Jid
[−]
[src]
pub struct Jid { pub node: Option<String>, pub domain: String, pub resource: Option<String>, }
A struct representing a Jabber ID.
A Jabber ID is composed of 3 components, of which 2 are optional:
- A node/name,
node
, which is the optional part before the @. - A domain,
domain
, which is the mandatory part after the @ but before the /. - A resource,
resource
, which is the optional part after the /.
Fields
node: Option<String>
The node part of the Jabber ID, if it exists, else None.
domain: String
The domain of the Jabber ID.
resource: Option<String>
The resource of the Jabber ID, if it exists, else None.
Methods
impl Jid
[src]
fn full<NS, DS, RS>(node: NS, domain: DS, resource: RS) -> Jid where
NS: Into<String>,
DS: Into<String>,
RS: Into<String>,
NS: Into<String>,
DS: Into<String>,
RS: Into<String>,
Constructs a Jabber ID containing all three components.
This is of the form node
@domain
/resource
.
Examples
use jid::Jid; let jid = Jid::full("node", "domain", "resource"); assert_eq!(jid.node, Some("node".to_owned())); assert_eq!(jid.domain, "domain".to_owned()); assert_eq!(jid.resource, Some("resource".to_owned()));
fn bare<NS, DS>(node: NS, domain: DS) -> Jid where
NS: Into<String>,
DS: Into<String>,
NS: Into<String>,
DS: Into<String>,
Constructs a Jabber ID containing only the node
and domain
components.
This is of the form node
@domain
.
Examples
use jid::Jid; let jid = Jid::bare("node", "domain"); assert_eq!(jid.node, Some("node".to_owned())); assert_eq!(jid.domain, "domain".to_owned()); assert_eq!(jid.resource, None);
fn domain<DS>(domain: DS) -> Jid where
DS: Into<String>,
DS: Into<String>,
Constructs a Jabber ID containing only a domain
.
This is of the form domain
.
Examples
use jid::Jid; let jid = Jid::domain("domain"); assert_eq!(jid.node, None); assert_eq!(jid.domain, "domain".to_owned()); assert_eq!(jid.resource, None);
fn domain_with_resource<DS, RS>(domain: DS, resource: RS) -> Jid where
DS: Into<String>,
RS: Into<String>,
DS: Into<String>,
RS: Into<String>,
Constructs a Jabber ID containing the domain
and resource
components.
This is of the form domain
/resource
.
Examples
use jid::Jid; let jid = Jid::domain_with_resource("domain", "resource"); assert_eq!(jid.node, None); assert_eq!(jid.domain, "domain".to_owned()); assert_eq!(jid.resource, Some("resource".to_owned()));
fn with_node<S>(&self, node: S) -> Jid where
S: Into<String>,
S: Into<String>,
Constructs a new Jabber ID from an existing one, with the node swapped out with a new one.
Examples
use jid::Jid; let jid = Jid::domain("domain"); assert_eq!(jid.node, None); let new_jid = jid.with_node("node"); assert_eq!(new_jid.node, Some("node".to_owned()));
fn with_domain<S>(&self, domain: S) -> Jid where
S: Into<String>,
S: Into<String>,
Constructs a new Jabber ID from an existing one, with the domain swapped out with a new one.
Examples
use jid::Jid; let jid = Jid::domain("domain"); assert_eq!(jid.domain, "domain"); let new_jid = jid.with_domain("new_domain"); assert_eq!(new_jid.domain, "new_domain");
fn with_resource<S>(&self, resource: S) -> Jid where
S: Into<String>,
S: Into<String>,
Constructs a new Jabber ID from an existing one, with the resource swapped out with a new one.
Examples
use jid::Jid; let jid = Jid::domain("domain"); assert_eq!(jid.resource, None); let new_jid = jid.with_resource("resource"); assert_eq!(new_jid.resource, Some("resource".to_owned()));
Trait Implementations
impl Clone for Jid
[src]
fn clone(&self) -> Jid
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Jid
[src]
fn eq(&self, __arg_0: &Jid) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Jid) -> bool
This method tests for !=
.
impl Eq for Jid
[src]
impl Hash for Jid
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Debug for Jid
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.
impl Display for Jid
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl FromStr for Jid
[src]
type Err = JidParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Jid, JidParseError>
Parses a string s
to return a value of this type. Read more