From 2800bd687ea1615d706caf4e0752f2bce92800a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Attab?= Date: Tue, 12 Mar 2024 14:37:50 -0400 Subject: [PATCH] Add encode_list and encode_tinyint to marina_types --- src/marina_types.erl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/marina_types.erl b/src/marina_types.erl index 2415718..8dcdfeb 100644 --- a/src/marina_types.erl +++ b/src/marina_types.erl @@ -16,10 +16,12 @@ decode_string_list/1, decode_string_map/1, decode_string_multimap/1, + decode_tinyint/1, decode_uuid/1, encode_boolean/1, encode_bytes/1, encode_int/1, + encode_list/1, encode_long/1, encode_long_string/1, encode_short/1, @@ -27,7 +29,8 @@ encode_string/1, encode_string_list/1, encode_string_map/1, - encode_string_multimap/1 + encode_string_multimap/1, + encode_tinyint/1 ]). %% public @@ -90,6 +93,11 @@ decode_string_map(<>) -> decode_string_multimap(<>) -> decode_string_multimap(Rest, Length, []). +-spec decode_tinyint(binary()) -> {integer(), binary()}. + +decode_tinyint(<>) -> + {Value, Rest}. + -spec decode_uuid(binary()) -> {binary(), binary()}. decode_uuid(<>) -> @@ -112,6 +120,11 @@ encode_bytes(Value) -> encode_int(Value) -> <>. +-spec encode_list([binary()]) -> binary(). + +encode_list(Values) -> + iolist_to_binary([encode_short(length(Values)), Values]). + -spec encode_long(integer()) -> binary(). encode_long(Value) -> @@ -154,6 +167,9 @@ encode_string_map(KeyValues) -> encode_string_multimap(KeyValues) -> encode_string_multimap(KeyValues, []). +encode_tinyint(Value) -> + <>. + %% private decode_long_string_set(Bin, 0, Acc) -> {lists:reverse(Acc), Bin};