Add split_jid/1

This is a convenience reverse of make_jid/1. It allows extracting the jid parts
without relying on using the jid record structure, to abstract details.
This commit is contained in:
Mickael Remond 2015-08-04 09:48:59 +02:00
parent f377992232
commit e3b7d43b76
1 changed files with 8 additions and 1 deletions

View File

@ -39,7 +39,7 @@
make_error_reply/2, make_error_element/2,
make_correct_from_to_attrs/3, replace_from_to_attrs/3,
replace_from_to/3, replace_from_attrs/2, replace_from/2,
remove_attr/2, make_jid/3, make_jid/1, string_to_jid/1,
remove_attr/2, make_jid/3, make_jid/1, split_jid/1, string_to_jid/1,
jid_to_string/1, is_nodename/1, tolower/1, nodeprep/1,
nameprep/1, resourceprep/1, jid_tolower/1,
jid_remove_resource/1, jid_replace_resource/2,
@ -214,6 +214,13 @@ make_jid(User, Server, Resource) ->
make_jid({User, Server, Resource}) ->
make_jid(User, Server, Resource).
%% This is the reverse of make_jid/1
-spec split_jid(jid()) -> {binary(), binary(), binary()} | error.
split_jid(#jid{user = U, server = S, resource = R}) ->
{U, S, R};
split_jid(_) ->
error.
-spec string_to_jid(binary()) -> jid() | error.
string_to_jid(S) ->