-module(priv@toml). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). -export([do_toml_get/2, parse/1, get_string/2, get_bool/2]). -export_type([toml/0]). -type toml() :: any(). -spec do_toml_get(toml(), list(binary())) -> {ok, gleam@dynamic:dynamic_()} | {error, nil}. do_toml_get(Toml, Keys) -> adglent_ffi:toml_get(Toml, Keys). -spec decode( toml(), list(binary()), fun((gleam@dynamic:dynamic_()) -> {ok, MIP} | {error, list(gleam@dynamic:decode_error())}) ) -> {ok, MIP} | {error, nil}. decode(Toml, Key_path, Decoder) -> gleam@result:'try'( adglent_ffi:toml_get(Toml, Key_path), fun(Item) -> _pipe = Item, _pipe@1 = Decoder(_pipe), gleam@result:map_error(_pipe@1, fun(_) -> nil end) end ). -spec parse(binary()) -> {ok, toml()} | {error, nil}. parse(Content) -> adglent_ffi:toml_parse(Content). -spec get_string(binary(), list(binary())) -> {ok, binary()} | {error, nil}. get_string(Toml_content, Key_path) -> gleam@result:'try'( adglent_ffi:toml_parse(Toml_content), fun(Toml) -> _pipe = Toml, decode(_pipe, Key_path, fun gleam@dynamic:string/1) end ). -spec get_bool(binary(), list(binary())) -> {ok, boolean()} | {error, nil}. get_bool(Toml_content, Key_path) -> gleam@result:'try'( adglent_ffi:toml_parse(Toml_content), fun(Toml) -> _pipe = Toml, _pipe@1 = decode(_pipe, Key_path, fun gleam@dynamic:string/1), gleam@result:map(_pipe@1, fun(Bool_str) -> case Bool_str of <<"True"/utf8>> -> true; <<"true"/utf8>> -> true; _ -> false end end) end ).