_site/cover/msmp_gtid_set.COVER.html

1 %% Copyright (c) 2023 Peter Morgan <peter.james.morgan@gmail.com>
2 %%
3 %% Licensed under the Apache License, Version 2.0 (the "License");
4 %% you may not use this file except in compliance with the License.
5 %% You may obtain a copy of the License at
6 %%
7 %% http://www.apache.org/licenses/LICENSE-2.0
8 %%
9 %% Unless required by applicable law or agreed to in writing, software
10 %% distributed under the License is distributed on an "AS IS" BASIS,
11 %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 %% See the License for the specific language governing permissions and
13 %% limitations under the License.
14
15
16 -module(msmp_gtid_set).
17
18
19 -export([decode/0]).
20 -export([encode/0]).
21
22
23 decode() ->
24 7 fun
25 (Encoded) ->
26 7 (scran_multi:count(
27 msmp_integer_fixed:decode(8),
28 scran_result:into_map(
29 scran_sequence:sequence(
30 [scran_result:kv(
31 sid,
32 scran_bytes:take(16)),
33 scran_result:kv(
34 intervals,
35 scran_multi:count(
36 msmp_integer_fixed:decode(8),
37 scran_result:into_map(
38 scran_sequence:sequence(
39 [scran_result:kv(
40 start,
41 msmp_integer_fixed:decode(8)),
42 scran_result:kv(
43 finish,
44 msmp_integer_fixed:decode(8))]))))]))))(Encoded)
45 end.
46
47
48 encode() ->
49 5 fun
50 (Decoded) ->
51 5 (narcs_multi:count(
52 msmp_integer_fixed:encode(8),
53 narcs_sequence:sequence(
54 [narcs_combinator:v(sid, narcs_bytes:take(16)),
55 narcs_combinator:v(
56 intervals,
57 narcs_multi:count(
58 msmp_integer_fixed:encode(8),
59 narcs_sequence:sequence(
60 [narcs_combinator:v(
61 start,
62 msmp_integer_fixed:encode(8)),
63
64 narcs_combinator:v(
65 finish,
66 msmp_integer_fixed:encode(8))])))])))(Decoded)
67 end.
Line Hits Source