View Source ehashids (ehashids v0.1.4)
Link to this section Summary
Functions
hashids_ref()
data in to a tuple to be cached.This data needs to be treated as opaque changing the values can be dangerous!
Note that decode here is not safe the Id can contain additional invalid data. If this is a problem use the equivalent decode_safe/2
function.
This function decodes and also checks if the result is commutative with encode/2
.
Numbers
here are 64 bit unsigned integers internally larger integers will cause an error. For larger values multiple numbers can be used instead.
Number
here is a 64 bit unsigned integer internally larger values will cause an error. For larger values multiple numbers can be used instead using the encode/2
function.
hashids_ref()
from cached data avoiding shuffling.The compiled data needs to be treated as opaque changing the values can be dangerous! Only use an input produced by the compile/1
function.
IMPORTANT do not share these references between processes. This can cause stability issues. Avoiding the shuffle overhead at initialization can be accomplished by caching the compiled output of the reference using the compile/1
function and then recreating the reference in each process.
IMPORTANT do not share these references between processes. This can cause stability issues. Avoiding the shuffle overhead at initialization can be accomplished by caching the compiled output of the reference using the compile/1
function and then recreating the reference in each process.
IMPORTANT do not share these references between processes. This can cause stability issues. Avoiding the shuffle overhead at initialization can be accomplished by caching the compiled output of the reference using the compile/1
function and then recreating the reference in each process.
Keep in mind that the alphabet only supports the ASCII character set. If this a problem consider adding UTF-8 support to the underlying library.
Link to this section Types
-opaque compiled_hashids_ref()
-opaque hashids_ref()
Link to this section Functions
-spec compile(Ref :: hashids_ref()) -> {ok, compiled_hashids_ref()} | {error, atom()}.
hashids_ref()
data in to a tuple to be cached.This data needs to be treated as opaque changing the values can be dangerous!
-spec decode(Ref :: hashids_ref(), Id :: binary()) -> {ok, Numbers :: [non_neg_integer()]} | {error, atom()}.
Note that decode here is not safe the Id can contain additional invalid data. If this is a problem use the equivalent decode_safe/2
function.
-spec decode_safe(Ref :: hashids_ref(), Id :: binary()) -> {ok, Numbers :: [non_neg_integer()]} | {error, unsafe} | {error, atom()}.
This function decodes and also checks if the result is commutative with encode/2
.
-spec default_alphabet() -> binary().
-spec default_salt() -> binary().
-spec default_separators() -> binary().
-spec encode(Ref :: hashids_ref(), Numbers :: [non_neg_integer()]) -> {ok, Id :: binary()} | {error, atom()}.
Numbers
here are 64 bit unsigned integers internally larger integers will cause an error. For larger values multiple numbers can be used instead.
-spec encode_one(Ref :: hashids_ref(), Number :: non_neg_integer()) -> {ok, Id :: binary()} | {error, atom()}.
Number
here is a 64 bit unsigned integer internally larger values will cause an error. For larger values multiple numbers can be used instead using the encode/2
function.
-spec estimate_encoded_size(Ref :: hashids_ref(), [non_neg_integer()]) -> {ok, Size :: non_neg_integer()} | {error, atom()}.
-spec from_compiled(CompiledData :: compiled_hashids_ref()) -> hashids_ref() | {error, atom()}.
hashids_ref()
from cached data avoiding shuffling.The compiled data needs to be treated as opaque changing the values can be dangerous! Only use an input produced by the compile/1
function.
-spec min_alphabet_length() -> pos_integer().
-spec min_hash_length() -> non_neg_integer().
-spec new() -> hashids_ref().
IMPORTANT do not share these references between processes. This can cause stability issues. Avoiding the shuffle overhead at initialization can be accomplished by caching the compiled output of the reference using the compile/1
function and then recreating the reference in each process.
-spec new(Salt :: binary()) -> hashids_ref() | {error, Reason :: atom()}.
IMPORTANT do not share these references between processes. This can cause stability issues. Avoiding the shuffle overhead at initialization can be accomplished by caching the compiled output of the reference using the compile/1
function and then recreating the reference in each process.
-spec new(Salt :: binary(), MinHashLen :: non_neg_integer()) -> hashids_ref() | {error, Reason :: atom()}.
IMPORTANT do not share these references between processes. This can cause stability issues. Avoiding the shuffle overhead at initialization can be accomplished by caching the compiled output of the reference using the compile/1
function and then recreating the reference in each process.
-spec new(Salt :: binary(), MinHashLen :: non_neg_integer(), Alphabet :: binary()) -> hashids_ref() | {error, Reason :: atom()}.
Keep in mind that the alphabet only supports the ASCII character set. If this a problem consider adding UTF-8 support to the underlying library.
IMPORTANT do not share these references between processes. This can cause stability issues. Avoiding the shuffle overhead at initialization can be accomplished by caching the compiled output of the reference using the compile/1
function and then recreating the reference in each process.