P11ex.Flags (p11ex v0.1.1)
Handles conversion between PKCS#11 flags (CK_FLAGS) and MapSets of atoms.
Summary
Functions
Returns all possible flags for the given type.
Converts a MapSet of atoms to a flags integer for the given flag type.
Converts a flags integer to a MapSet of atoms for the given flag type.
Types
@type flag_name() :: atom()
@type flag_type() :: :slot | :token | :mechanism
@type flag_value() :: non_neg_integer()
Functions
Returns all possible flags for the given type.
Examples
iex> P11ex.Flags.available_flags(:slot)
[:hw_slot, :removable_device, :token_present]
@spec from_atoms(flag_type(), MapSet.t(flag_name())) :: flag_value()
Converts a MapSet of atoms to a flags integer for the given flag type.
Examples
iex> P11ex.Flags.from_atoms(:slot, MapSet.new([:hw_slot, :removable_device]))
0x0003
@spec to_atoms(flag_type(), flag_value()) :: MapSet.t(flag_name())
Converts a flags integer to a MapSet of atoms for the given flag type.
Examples
iex> P11ex.Flags.to_atoms(:slot, 0x0003)
#MapSet<[:hw_slot, :removable_device]>