View Source Antikythera.Session (antikythera v0.5.1)
Definition of data structure to work with session.
Gear implementations usually don't use the functions defined in this module; instead use
Antikythera.Plug.Session
- interfaces in
Antikythera.Conn
(e.g.Antikythera.Conn.get_session/2
).
Summary
Functions
Type-aware getter for data.
Type-aware setter for data.
Type-aware getter for id.
Type-aware setter for id.
Creates a new instance of Antikythera.Session by using the given dict
.
A variant of new/1
which returns t
or raise if validation fails.
Type-aware getter for state.
Type-aware setter for state.
Updates an existing instance of Antikythera.Session with the given dict
.
The values in the dict
are validated by each field's valid?/1
function.
Returns {:ok, valid_struct}
or {:error, reason}
.
A variant of update/2
which returns t
or raise if validation fails.
In other words, update/2
followed by Croma.Result.get!/1
.
Checks if the given value belongs to t/0
or not.
Types
@type t() :: %Antikythera.Session{ data: Croma.Map.t(), id: Croma.TypeGen.Nilable.Croma.String.t(), state: Antikythera.Session.State.t() }
Functions
@spec data(t()) :: Croma.Map.t()
Type-aware getter for data.
@spec data(t(), Croma.Map.t()) :: t()
Type-aware setter for data.
@spec id(t()) :: Croma.TypeGen.Nilable.Croma.String.t()
Type-aware getter for id.
Type-aware setter for id.
@spec new(term()) :: Croma.Result.t(t())
Creates a new instance of Antikythera.Session by using the given dict
.
Returns {:ok, valid_struct}
or {:error, reason}
.
The values in the dict
are validated by each field's valid?/1
function.
If the value was invalid, it will be passed to new/1
of the field
For missing fields, followings will be tried:
default/0
of each field typenew/1
of each field type, with empty map as input
A variant of new/1
which returns t
or raise if validation fails.
In other words, new/1
followed by Croma.Result.get!/1
.
@spec state(t()) :: Antikythera.Session.State.t()
Type-aware getter for state.
@spec state(t(), Antikythera.Session.State.t()) :: t()
Type-aware setter for state.
@spec update(t(), Dict.t()) :: Croma.Result.t(t())
Updates an existing instance of Antikythera.Session with the given dict
.
The values in the dict
are validated by each field's valid?/1
function.
Returns {:ok, valid_struct}
or {:error, reason}
.
A variant of update/2
which returns t
or raise if validation fails.
In other words, update/2
followed by Croma.Result.get!/1
.
Checks if the given value belongs to t/0
or not.