-module(l4u@union_term). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([keys/0, get/2, get_int/2, get_str/2, put/2, put_int/2, put_str/2, erase/1, get_map/1, get_with_default/2, nt_get_with_default/2, nt_put/2, get_map_value/3, set_map_value/3]). -spec keys() -> list(binary()). keys() -> persistent_term:keys(). -spec get(binary(), FRB) -> FRB. get(Key, Default_value) -> persistent_term:get(Key, Default_value). -spec get_int(binary(), integer()) -> integer(). get_int(Key, Default_value) -> persistent_term:get(Key, Default_value). -spec get_str(binary(), binary()) -> binary(). get_str(Key, Default_value) -> persistent_term:get(Key, Default_value). -spec put(binary(), any()) -> nil. put(Key, Value) -> persistent_term:put(Key, Value). -spec put_int(binary(), integer()) -> nil. put_int(Key, Value) -> persistent_term:put(Key, Value). -spec put_str(binary(), binary()) -> nil. put_str(Key, Value) -> persistent_term:put(Key, Value). -spec erase(binary()) -> nil. erase(Key) -> persistent_term:erase(Key). -spec get_map(binary()) -> gleam@dict:dict(binary(), any()). get_map(Key) -> _assert_subject = persistent_term:get(Key, gleam@dict:new()), Dic = case _assert_subject of _ -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"l4u/union_term"/utf8>>, function => <<"get_map"/utf8>>, line => 38}) end, Dic. -spec get_with_default(binary(), FRG) -> FRG. get_with_default(A, Default_value) -> persistent_term:get(A, Default_value). -spec nt_get_with_default(any(), FRI) -> FRI. nt_get_with_default(A, Default_value) -> persistent_term:get(A, Default_value). -spec nt_put(any(), any()) -> nil. nt_put(Key, Value) -> persistent_term:put(Key, Value). -spec get_map_value(binary(), binary(), FRL) -> FRL. get_map_value(Key, Property_key, Default_value) -> _assert_subject = persistent_term:get(Key, gleam@dict:new()), Dic = case _assert_subject of _ -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"l4u/union_term"/utf8>>, function => <<"get_map_value"/utf8>>, line => 59}) end, case gleam@dict:get(Dic, Property_key) of {ok, Value} -> Value; _ -> Default_value end. -spec set_map_value(binary(), binary(), gleam@dynamic:dynamic_()) -> nil. set_map_value(Key, Property_key, Property_value) -> Dic = persistent_term:get(Key, gleam@dict:new()), New_dict = gleam@dict:insert(Dic, Property_key, Property_value), persistent_term:put(Key, New_dict).