View Source jid (jid v2.2.0)

Summary

Types

JID data structure.
literal binary containing a bare or full JID, not ensured to be string-prepped.
3-tuple containing the string-prepped binaries.
2-tuple containing string-prepped user and server parts.
3-tuple containing not-yet string-prepped binaries.

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
Extract the string-prepped resource part of the jid
Extract the string-prepped server part of the jid
Extract the string-prepped user part of the jid
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 in bare form.
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

Types

-type jid() :: #jid{luser :: jid:luser(), lserver :: jid:lserver(), lresource :: jid:lresource()}.
JID data structure.
-type literal_jid() :: binary().
literal binary containing a bare or full JID, not ensured to be string-prepped.
-type ljid() :: {luser(), lserver(), lresource()}.
3-tuple containing the string-prepped binaries.
-type lresource() :: binary().
-type lserver() :: binary().
-type luser() :: binary().
-type resource() :: binary().
-type server() :: binary().
-type simple_bare_jid() :: {luser(), lserver()}.
2-tuple containing string-prepped user and server parts.
-type simple_jid() :: {user(), server(), resource()}.
3-tuple containing not-yet string-prepped binaries.
-type user() :: binary().

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 lresource(jid() | ljid() | simple_bare_jid()) -> lresource().
Extract the string-prepped resource part of the jid
-spec lserver(jid() | ljid() | simple_bare_jid()) -> lserver().
Extract the string-prepped server part of the jid
-spec luser(jid() | ljid() | simple_bare_jid()) -> luser().
Extract the string-prepped user part of the jid
-spec make(simple_jid()) -> jid() | error.

Equivalent to make(User, Server, Resource).

Link to this function

make(User, Server, Resource)

View Source
-spec make(User :: user(), Server :: server(), Resource :: 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(jid()) -> jid();
             (ljid()) -> ljid();
             (simple_bare_jid()) -> simple_bare_jid();
             (error) -> error.
Takes a jid and returns the same jid without its resourcepart
-spec to_bare_binary(ljid() | simple_bare_jid() | jid() | literal_jid()) -> binary() | error.
Takes a representation of a jid, and outputs such jid as a literal binary in bare form.
-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 | ljid().
Returns a jid that contains only prepared strings
-spec to_lus(jid() | ljid() | simple_bare_jid()) -> simple_bare_jid();
            (error) -> error.
Takes a jid and returns a prepared bare jid