-module(automata@fsevent@watch).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/automata/fsevent/watch.gleam").
-export([watch_all_ops/0, watch/0, watch_no_ops/0, with_ops/2, watch_op/2, unwatch_op/2, watch_op_mask/1, watch_observes/2, watch_is_silent/1]).
-export_type([watch/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-opaque watch() :: {watch, gleam@set:set(automata@fsevent@ast:op())}.
-file("src/automata/fsevent/watch.gleam", 24).
?DOC(" Watch every op.\n").
-spec watch_all_ops() -> watch().
watch_all_ops() ->
{watch, automata@fsevent@op:all_ops()}.
-file("src/automata/fsevent/watch.gleam", 19).
?DOC(
" Default watch: subscribed to every op (`Create`, `Write`, `Remove`,\n"
" `Rename`, `Chmod`).\n"
).
-spec watch() -> watch().
watch() ->
watch_all_ops().
-file("src/automata/fsevent/watch.gleam", 29).
?DOC(" Watch no op. The differ will return an empty list for any input.\n").
-spec watch_no_ops() -> watch().
watch_no_ops() ->
{watch, automata@fsevent@op:empty_ops()}.
-file("src/automata/fsevent/watch.gleam", 34).
?DOC(" Replace the op mask with the given set.\n").
-spec with_ops(watch(), gleam@set:set(automata@fsevent@ast:op())) -> watch().
with_ops(_, Ops) ->
{watch, Ops}.
-file("src/automata/fsevent/watch.gleam", 39).
?DOC(" Add a single op to `watch`'s mask. Idempotent.\n").
-spec watch_op(watch(), automata@fsevent@ast:op()) -> watch().
watch_op(Watch, Op) ->
{watch, gleam@set:insert(erlang:element(2, Watch), Op)}.
-file("src/automata/fsevent/watch.gleam", 44).
?DOC(" Remove a single op from `watch`'s mask. Idempotent.\n").
-spec unwatch_op(watch(), automata@fsevent@ast:op()) -> watch().
unwatch_op(Watch, Op) ->
{watch, gleam@set:delete(erlang:element(2, Watch), Op)}.
-file("src/automata/fsevent/watch.gleam", 49).
?DOC(" Recover the watch's op mask.\n").
-spec watch_op_mask(watch()) -> gleam@set:set(automata@fsevent@ast:op()).
watch_op_mask(Watch) ->
erlang:element(2, Watch).
-file("src/automata/fsevent/watch.gleam", 54).
?DOC(" `True` when `watch` is interested in `op`.\n").
-spec watch_observes(watch(), automata@fsevent@ast:op()) -> boolean().
watch_observes(Watch, Op) ->
gleam@set:contains(erlang:element(2, Watch), Op).
-file("src/automata/fsevent/watch.gleam", 59).
?DOC(" `True` when `watch`'s op mask is empty.\n").
-spec watch_is_silent(watch()) -> boolean().
watch_is_silent(Watch) ->
gleam@set:size(erlang:element(2, Watch)) =:= 0.