A generated resource whose step function is native/examples/box_user.mojo.
open/0 returns an opaque reference. The native object holds one signed
integer, starting at 0. That field is not visible to Elixir.
Summary
Functions
Adds delta to the box and returns the new total.
Loads priv/native/libdsl_box.so.
Opens a box whose total is 0.
Types
@type box() :: reference()
Opaque box handle. Inspects as a reference. The running total is native state.
Functions
Adds delta to the box and returns the new total.
box is a handle from open/0. delta is a signed integer. There is no
optional argument. The native step is value + delta.
Raises
ArgumentErrorwhenboxis not a box from this module, ordeltais not an integer
Examples
iex> box = Mojoler.Dsl.Box.open()
iex> Mojoler.Dsl.Box.bump(box, 20)
20
iex> Mojoler.Dsl.Box.bump(box, 22)
42
iex> Mojoler.Dsl.Box.bump(:nope, 1)
** (ArgumentError) argument error
@spec load_nif() :: :ok | {:error, term()}
Loads priv/native/libdsl_box.so.
A second call returns {:error, {:reload, charlist}}.
Examples
iex> Mojoler.Dsl.Box.load_nif()
{:error, {:reload, ~c"NIF library already loaded (reload disallowed since OTP 20)."}}
@spec open() :: box()
Opens a box whose total is 0.
Returns
A box/0.
Examples
iex> box = Mojoler.Dsl.Box.open()
iex> is_reference(box)
true