[][src]Struct jid::Jid

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]

pub fn full<NS, DS, RS>(node: NS, domain: DS, resource: RS) -> Jid where
    NS: Into<String>,
    DS: Into<String>,
    RS: Into<String>, 
[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()));

pub fn bare<NS, DS>(node: NS, domain: DS) -> Jid where
    NS: Into<String>,
    DS: Into<String>, 
[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);

pub fn into_bare_jid(self) -> Jid
[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);

pub fn domain<DS>(domain: DS) -> Jid where
    DS: Into<String>, 
[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);

pub fn into_domain_jid(self) -> Jid
[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);

pub fn domain_with_resource<DS, RS>(domain: DS, resource: RS) -> Jid where
    DS: Into<String>,
    RS: Into<String>, 
[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()));

pub fn with_node<S>(&self, node: S) -> Jid where
    S: Into<String>, 
[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()));

pub fn with_domain<S>(&self, domain: S) -> Jid where
    S: Into<String>, 
[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");

pub fn with_resource<S>(&self, resource: S) -> Jid where
    S: Into<String>, 
[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 From<Jid> for String
[src]

impl Eq for Jid
[src]

impl PartialEq<Jid> for Jid
[src]

impl Clone for Jid
[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Debug for Jid
[src]

impl Display for Jid
[src]

impl Hash for Jid
[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

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

impl FromStr for Jid
[src]

type Err = JidParseError

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for Jid

impl Sync for Jid

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]