Packages

A library to compress unsigned integers using LEB128 - Gleam bindings for the Elixir `varint` package.

Current section

Files

Jump to
gvarint src gvarint.erl
Raw

src/gvarint.erl

-module(gvarint).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/gvarint.gleam").
-export([encode/1, decode/1]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/gvarint.gleam", 3).
?DOC(" Encodes an unsigned integer using LEB128 compression.\n").
-spec encode(integer()) -> bitstring().
encode(Num) ->
'Elixir.Varint.LEB128':encode(Num).
-file("src/gvarint.gleam", 12).
?DOC(
" Decodes LEB128 encoded bytes to an unsigned integer.\n"
"\n"
" Returns a tuple where the first element is the decoded value and the second element the bytes which have not been\n"
" parsed.\n"
"\n"
" This function will raise ArgumentError if the given bytes are not a valid LEB128 integer.\n"
).
-spec decode(bitstring()) -> {integer(), bitstring()}.
decode(B) ->
'Elixir.Varint.LEB128':decode(B).