1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
-module(priv@toml).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).
-export([get_string/2, get_bool/2, get_int/2]).
-export_type([tom_error/0]).
-type tom_error() :: {tom_parse_error, tom:parse_error()} |
{tom_get_error, tom:get_error()}.
-spec get_string(binary(), list(binary())) -> {ok, binary()} |
{error, tom_error()}.
get_string(Toml_content, Key_path) ->
gleam@result:'try'(
begin
_pipe = tom:parse(<<Toml_content/binary, "\n"/utf8>>),
gleam@result:map_error(
_pipe,
fun(Field@0) -> {tom_parse_error, Field@0} end
)
end,
fun(Toml) ->
gleam@result:'try'(
begin
_pipe@1 = tom:get_string(Toml, Key_path),
gleam@result:map_error(
_pipe@1,
fun(Field@0) -> {tom_get_error, Field@0} end
)
end,
fun(Value) -> {ok, Value} end
)
end
).
-spec get_bool(binary(), list(binary())) -> {ok, boolean()} |
{error, tom_error()}.
get_bool(Toml_content, Key_path) ->
gleam@result:'try'(
begin
_pipe = tom:parse(<<Toml_content/binary, "\n"/utf8>>),
gleam@result:map_error(
_pipe,
fun(Field@0) -> {tom_parse_error, Field@0} end
)
end,
fun(Toml) ->
gleam@result:'try'(
begin
_pipe@1 = tom:get_bool(Toml, Key_path),
gleam@result:map_error(
_pipe@1,
fun(Field@0) -> {tom_get_error, Field@0} end
)
end,
fun(Value) -> {ok, Value} end
)
end
).
-spec get_int(binary(), list(binary())) -> {ok, integer()} |
{error, tom_error()}.
get_int(Toml_content, Key_path) ->
gleam@result:'try'(
begin
_pipe = tom:parse(<<Toml_content/binary, "\n"/utf8>>),
gleam@result:map_error(
_pipe,
fun(Field@0) -> {tom_parse_error, Field@0} end
)
end,
fun(Toml) ->
gleam@result:'try'(
begin
_pipe@1 = tom:get_int(Toml, Key_path),
gleam@result:map_error(
_pipe@1,
fun(Field@0) -> {tom_get_error, Field@0} end
)
end,
fun(Value) -> {ok, Value} end
)
end
).
|