Packages
gleam_bson
0.27.0
0.27.0
retired
0.26.0
retired
0.25.0
retired
0.24.0
retired
0.23.0
retired
0.22.0
retired
0.21.0
retired
0.20.0
retired
0.19.0
retired
0.18.0
retired
0.17.0
retired
0.16.0
retired
0.15.0
retired
0.14.0
retired
0.13.0
retired
0.12.0
retired
0.11.0
retired
0.10.1
retired
0.10.0
retired
0.9.0
retired
0.8.0
retired
0.7.0
retired
0.6.0
retired
0.5.0
retired
0.4.0
retired
0.3.0
retired
0.2.0
retired
0.1.0
retired
bson encoder and decoder for gleam
Retired package: Renamed - Republished as bison
Current section
Files
Jump to
Current section
Files
src/bson@custom.erl
-module(bson@custom).
-compile([no_auto_import, nowarn_unused_vars]).
-export([to_bit_string_with_code/1, from_bit_string_with_code/2]).
-export_type([custom/0]).
-opaque custom() :: {custom, bitstring(), bitstring()}.
-spec to_bit_string_with_code(custom()) -> {integer(), bitstring()}.
to_bit_string_with_code(Custom) ->
case Custom of
{custom, <<Code>>, Value} ->
{Code, Value}
end.
-spec from_bit_string_with_code(integer(), bitstring()) -> {ok, custom()} |
{error, nil}.
from_bit_string_with_code(Code, Value) ->
case (Code =< 16#ff) andalso (Code >= 16#80) of
true ->
{ok, {custom, <<Code>>, Value}};
false ->
{error, nil}
end.