crux_structs v0.2.3 Crux.Structs.BitField behaviour View Source
Custom non discord api behaviour to help with bitfields of all kind.
Link to this section Summary
Types
The name of a bit flag.
All valid types that can be directly resolved into a bitfield.
Represents a struct of a module implementing the Crux.Structs.BitField behaviour.
Callbacks
Add all set bits of to_add to base.
Get an integer representing all available bits set.
Check whether the t:resolvable/0 you have has everything set you want.
Return a t:t/0 of all bits you want but not have.
Create a new t:t/0 from a t:resolvable/0.
Remove all set bits of to_remove from base.
Resolve a t:resolvable/0 into a bitfield.
Serialize a t:resolvable/0 into a list of set bit flag names.
Serialize a t:resolvable/0 into a map representing bit flag names to whether they are set.
Link to this section Types
Specs
name() :: atom()
The name of a bit flag.
Specs
resolvable() :: t() | non_neg_integer() | name() | [resolvable()]
All valid types that can be directly resolved into a bitfield.
Specs
t() :: struct()
Represents a struct of a module implementing the Crux.Structs.BitField behaviour.
Link to this section Callbacks
Specs
add(base :: resolvable(), to_add :: resolvable()) :: t()
Add all set bits of to_add to base.
Specs
all() :: non_neg_integer()
Get an integer representing all available bits set.
Specs
flags() :: %{required(name()) => non_neg_integer()}
Get a map of t:name/0s and their corresponding bit values.
Specs
has(have :: resolvable(), want :: resolvable()) :: boolean()
Check whether the t:resolvable/0 you have has everything set you want.
Specs
missing(have :: resolvable(), want :: resolvable()) :: t()
Return a t:t/0 of all bits you want but not have.
Specs
names() :: [name()]
Get a list of all available t:name/0s.
Specs
new(resolvable()) :: t()
Create a new t:t/0 from a t:resolvable/0.
Specs
remove(base :: resolvable(), to_remove :: resolvable()) :: t()
Remove all set bits of to_remove from base.
Specs
resolve(resolvable()) :: non_neg_integer()
Resolve a t:resolvable/0 into a bitfield.
Specs
to_list(resolvable()) :: [name()]
Serialize a t:resolvable/0 into a list of set bit flag names.
Specs
to_map(resolvable()) :: %{required(name()) => boolean()}
Serialize a t:resolvable/0 into a map representing bit flag names to whether they are set.