FedecksServer.BinaryCodec (fedecks_server v0.1.0)
Provides:-
- A thin wrapper over
:erlang.binary_to_term/1
and:erlang.term_to_binary/1
. The latter to add some error handling and ensure only safe decoding; the former is included for symmetry. - Additional support for encoding / decoding binary terms to base 64
Link to this section Summary
Functions
Wrapper for :erlang.binary_to_term/2
. Will not decode and unsafe binary (ie on which
will create a new atom). Instead of raising an argument error, invalid or unsafe binaries
will return :error
, otherwise an :ok
tuple is returned
Decodes the base64 encoded binary term. Returns an ok tuple, or a different error depending on whether the issue is with base64 or the binary term part.
Wrapper for :erlang.term_to_binary/1
Encodes the term as a binary, then further encodes in base 64 for transmission where pure binary would not work, eg in HTTP headers
Link to this section Functions
decode(bin)
Wrapper for :erlang.binary_to_term/2
. Will not decode and unsafe binary (ie on which
will create a new atom). Instead of raising an argument error, invalid or unsafe binaries
will return :error
, otherwise an :ok
tuple is returned
decode_base64(encoded)
Decodes the base64 encoded binary term. Returns an ok tuple, or a different error depending on whether the issue is with base64 or the binary term part.
encode(term)
Wrapper for :erlang.term_to_binary/1
encode_base64(term)
Encodes the term as a binary, then further encodes in base 64 for transmission where pure binary would not work, eg in HTTP headers