jid v0.1.4 JID

Jabber Identifiers (JIDs) uniquely identify individual entities in an XMPP network.

A JID often resembles an email address with a user@host form, but there's a bit more to it. JIDs consist of three main parts:

A JID can be composed of a local part, a server part, and a resource part. The server part is mandatory for all JIDs, and can even stand alone (e.g., as the address for a server).

The combination of a local (user) part and a server is called a "bare JID", and it is used to identitfy a particular account on a server.

A JID that includes a resource is called a "full JID", and it is used to identify a particular client connection (i.e., a specific connection for the associated "bare JID" account).

This module implements the to_string/1 for the String.Chars protocol for returning a binary string from the JID struct.

Returns a string representation from a JID struct.

Examples

iex> to_string(%JID{user: "romeo", server: "montague.lit", resource: "chamber"})
"romeo@montague.lit/chamber"

iex> to_string(%JID{user: "romeo", server: "montague.lit"})
"romeo@montague.lit"

iex> to_string(%JID{server: "montague.lit"})
"montague.lit"

Link to this section Summary

Functions

Returns a binary JID without a resource

Parses a binary string JID into a JID struct

Link to this section Types

Link to this type

t()
t() :: %JID{full: term(), resource: term(), server: term(), user: term()}

Link to this section Functions

Link to this function

bare(jid)
bare(jid :: binary() | JID.t()) :: binary()

Returns a binary JID without a resource.

Examples

iex> JID.bare(%JID{user: "romeo", server: "montague.lit", resource: "chamber"})
"romeo@montague.lit"

iex> JID.bare("romeo@montague.lit/chamber")
"romeo@montague.lit"
Link to this function

parse(string)
parse(jid :: nil) :: JID.JIDParsingError
parse(jid :: binary()) :: JID.t()

Parses a binary string JID into a JID struct.

Examples

iex> JID.parse("romeo@montague.lit/chamber")
%JID{user: "romeo", server: "montague.lit", resource: "chamber", full: "romeo@montague.lit/chamber"}

iex> JID.parse("romeo@montague.lit")
%JID{user: "romeo", server: "montague.lit", resource: "", full: "romeo@montague.lit"}
Link to this function

resource(jid)
resource(jid :: binary() | JID.t()) :: binary()

Link to this function

server(jid)
server(jid :: binary() | JID.t()) :: binary()

Link to this function

user(jid)
user(jid :: binary() | JID.t()) :: binary()