View Source jid (jid v2.0.0)

Link to this section Summary

Functions

Returns true if are_equal(to_bare(A), to_bare(B))
Compares jid structures according to the RFC, i.e., only after normalisation
Parses a binary and returns a jid record or an error
Parses a binary and returns a jid record or an error, but without normalisation of the parts
Returns true if the input is a valid user part
Takes the user, server, and resource parts, and returns a jid record or an error.
Takes the user and server parts, and returns a jid record with an empty resource, or an error.
Creates a jid record without validating the input. Useful when input is already trusted.
Prepares the server part of a jid
Prepares the user part of a jid
Replaces the resource part of a jid with a new resource
Replaces the resource part of a jid with a new resource, but without normalisation
Prepares the resource part of a jid
Lowercases a string using the stringprep algorithm
Takes a jid and returns the same jid without its resourcepart
Takes a representation of a jid, and outputs such jid as a literal binary
Returns a jid that contains only prepared strings
Takes a jid and returns a prepared bare jid

Link to this section Types

-type jid() :: #jid{}.
-type literal_jid() :: binary().
-type ljid() :: {luser(), lserver(), lresource()}.
-type lresource() :: binary().
-type lserver() :: binary().
-type luser() :: binary().
-type resource() :: binary().
-type server() :: binary().
-type simple_bare_jid() :: {luser(), lserver()}.
-type simple_jid() :: {user(), server(), resource()}.
-type user() :: binary().

Link to this section Functions

-spec are_bare_equal(jid() | ljid(), jid() | ljid()) -> boolean().
Returns true if are_equal(to_bare(A), to_bare(B))
-spec are_equal(jid(), jid()) -> boolean().
Compares jid structures according to the RFC, i.e., only after normalisation
-spec binary_to_bare(binary()) -> jid() | error.

Equivalent to jid:to_bare(jid:from_binary(BinaryJid)).

-spec from_binary(binary()) -> jid() | error.
Parses a binary and returns a jid record or an error
-spec from_binary_noprep(binary()) -> jid() | error.
Parses a binary and returns a jid record or an error, but without normalisation of the parts
-spec is_nodename(<<>> | binary()) -> boolean().
Returns true if the input is a valid user part
-spec make(simple_jid()) -> jid() | error.

Equivalent to make(User, Server, Resource).

-spec make(User :: user(), Server :: server(), Res :: resource()) -> jid() | error.
Takes the user, server, and resource parts, and returns a jid record or an error.
-spec make_bare(User :: user(), Server :: server()) -> jid() | error.
Takes the user and server parts, and returns a jid record with an empty resource, or an error.
-spec make_noprep(simple_jid()) -> jid().

Equivalent to make_noprep(User, Server, Resource).

Link to this function

make_noprep(User, Server, Resource)

View Source
-spec make_noprep(User :: luser(), Server :: lserver(), Resource :: lresource()) -> jid().
Creates a jid record without validating the input. Useful when input is already trusted.
-spec nameprep(server()) -> lserver() | error.
Prepares the server part of a jid
-spec nodeprep(user()) -> luser() | error.
Prepares the user part of a jid
Link to this function

replace_resource(Jid, Resource)

View Source
-spec replace_resource(jid(), resource()) -> jid() | error.
Replaces the resource part of a jid with a new resource
Link to this function

replace_resource_noprep(Jid, LResource)

View Source
-spec replace_resource_noprep(jid(), resource()) -> jid().
Replaces the resource part of a jid with a new resource, but without normalisation
-spec resourceprep(resource()) -> lresource() | error.
Prepares the resource part of a jid
-spec str_tolower(iodata()) -> binary() | error.
Lowercases a string using the stringprep algorithm
-spec to_bare(simple_jid()) -> simple_jid();
       (jid()) -> jid();
       (error) -> error.
Takes a jid and returns the same jid without its resourcepart
-spec to_bare_binary(simple_jid() | simple_bare_jid() | jid() | literal_jid()) -> binary() | error.
-spec to_binary(simple_jid() | simple_bare_jid() | jid() | literal_jid()) -> binary().
Takes a representation of a jid, and outputs such jid as a literal binary
-spec to_lower(simple_jid() | jid()) -> error | simple_jid().
Returns a jid that contains only prepared strings
-spec to_lus(jid() | ljid()) -> simple_bare_jid();
      (error) -> error.
Takes a jid and returns a prepared bare jid