jid (jid v2.2.3)

View Source

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

jid/0

-type jid() :: #jid{luser :: jid:luser(), lserver :: jid:lserver(), lresource :: jid:lresource()}.

JID data structure.

literal_jid/0

-type literal_jid() :: binary().

literal binary containing a bare or full JID, not ensured to be string-prepped.

ljid/0

-type ljid() :: {luser(), lserver(), lresource()}.

3-tuple containing the string-prepped binaries.

lresource/0

-type lresource() :: binary().

lserver/0

-type lserver() :: binary().

luser/0

-type luser() :: binary().

resource/0

-type resource() :: binary().

server/0

-type server() :: binary().

simple_bare_jid/0

-type simple_bare_jid() :: {luser(), lserver()}.

2-tuple containing string-prepped user and server parts.

simple_jid/0

-type simple_jid() :: {user(), server(), resource()}.

3-tuple containing not-yet string-prepped binaries.

user/0

-type user() :: binary().

Functions

are_bare_equal(Jid, _)

-spec are_bare_equal(jid() | ljid(), jid() | ljid()) -> boolean().

Returns true if are_equal(to_bare(A), to_bare(B))

are_equal(Jid, _)

-spec are_equal(jid(), jid()) -> boolean().

Compares jid structures according to the RFC, i.e., only after normalisation

binary_to_bare(JID)

-spec binary_to_bare(binary()) -> jid() | error.

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

from_binary(J)

-spec from_binary(binary()) -> jid() | error.

Parses a binary and returns a jid record or an error

from_binary_noprep(J)

-spec from_binary_noprep(binary()) -> jid() | error.

Parses a binary and returns a jid record or an error, but without normalisation of the parts

is_nodename(J)

-spec is_nodename(<<>> | binary()) -> boolean().

Returns true if the input is a valid user part

lresource(Jid)

-spec lresource(jid() | ljid() | simple_bare_jid()) -> lresource().

Extract the string-prepped resource part of the jid

lserver(Jid)

-spec lserver(jid() | ljid() | simple_bare_jid()) -> lserver().

Extract the string-prepped server part of the jid

luser(Jid)

-spec luser(jid() | ljid() | simple_bare_jid()) -> luser().

Extract the string-prepped user part of the jid

make(_)

-spec make(simple_jid()) -> jid() | error.

Equivalent to make(User, Server, Resource).

make(User, Server, Resource)

-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.

make_bare(User, Server)

-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.

make_noprep(_)

-spec make_noprep(simple_jid()) -> jid().

Equivalent to make_noprep(User, Server, Resource).

make_noprep(User, Server, Resource)

-spec make_noprep(User :: luser(), Server :: lserver(), Resource :: lresource()) -> jid().

Creates a jid record without validating the input. Useful when input is already trusted.

nameprep(S)

-spec nameprep(server()) -> lserver() | error.

Prepares the server part of a jid

nodeprep(S)

-spec nodeprep(user()) -> luser() | error.

Prepares the user part of a jid

replace_resource(Jid, Resource)

-spec replace_resource(jid(), resource()) -> jid() | error.

Replaces the resource part of a jid with a new resource

replace_resource_noprep(Jid, LResource)

-spec replace_resource_noprep(jid(), resource()) -> jid().

Replaces the resource part of a jid with a new resource, but without normalisation

resourceprep(S)

-spec resourceprep(resource()) -> lresource() | error.

Prepares the resource part of a jid

str_tolower(Val)

-spec str_tolower(iodata()) -> binary() | error.

Lowercases a string using the stringprep algorithm

to_bare(Jid)

-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

to_bare_binary(Jid)

-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.

to_binary(Jid)

-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.

to_lower(Jid)

-spec to_lower(simple_jid() | jid()) -> error | ljid().

Returns a jid that contains only prepared strings

to_lus(Jid)

-spec to_lus(jid() | ljid() | simple_bare_jid()) -> simple_bare_jid();
            (error) -> error.

Takes a jid and returns a prepared bare jid