# `Mojoler.Nif`
[🔗](https://github.com/thanos/mojoler/blob/v0.1.0/lib/mojoler/nif.ex#L1)

Shared path and load bookkeeping.

`:erlang.load_nif/2` must run inside the module named by the NIF entry.
This module builds that path and records a successful load. It does not
call `:erlang.load_nif/2`.

# `library`

```elixir
@type library() :: String.t()
```

File name of a built library, including the `.so` suffix OTP appends.

## Examples

    "libpoc.so"

# `loaded?`

```elixir
@spec loaded?(library()) :: boolean()
```

Returns whether `basename` was marked loaded in this VM.

`basename` includes the `.so` suffix. An unknown name is `false`.
There is no optional argument.

## Examples

    iex> Mojoler.Nif.loaded?("not-a-library.so")
    false

# `mark!`

```elixir
@spec mark!(String.t()) :: :ok
```

Records that `stem <> ".so"` has been loaded in this VM.

`stem` is the file name without `.so`. The compiler reads this mark and
will not replace a library this VM has already mapped.

## Returns

`:ok`.

## Examples

    iex> Mojoler.Nif.mark!("doctest-mark")
    :ok
    iex> Mojoler.Nif.loaded?("doctest-mark.so")
    true

# `path`

```elixir
@spec path(String.t()) :: charlist()
```

Returns the load path for `priv/native/<stem>`.

`stem` is the file name without `.so`. OTP appends `.so` on Darwin and Linux.
There is no optional argument.

## Returns

A charlist. `:erlang.load_nif/2` accepts that form.

## Examples

    iex> path = Mojoler.Nif.path("libpoc")
    iex> List.ends_with?(path, ~c"libpoc")
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
