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

The node part of the Jabber ID, if it exists, else None.

The domain of the Jabber ID.

The resource of the Jabber ID, if it exists, else None.

Methods

impl Jid
[src]

[src]

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()));

[src]

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);

[src]

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);

[src]

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);

[src]

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);

[src]

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()));

[src]

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()));

[src]

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");

[src]

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]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for Jid
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for Jid
[src]

impl Hash for Jid
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for Jid
[src]

[src]

Formats the value using the given formatter.

impl Display for Jid
[src]

[src]

Formats the value using the given formatter. Read more

impl FromStr for Jid
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more