# `TomlElixir`
[🔗](https://github.com/nikolauska/toml_elixir/blob/v3.1.0/lib/toml_elixir.ex#L1)

# TomlElixir

[TOML](https://github.com/toml-lang/toml) parser for elixir.

## Installation

The package can be installed by adding `toml_elixir` to your list of
dependencies in `mix.exs`:

```elixir
def deps do
  [{:toml_elixir, "~> 3.0.0"}]
end
```

## Usage
TomlElixir is used by calling decode functions

* `TomlElixir.decode/2`
* `TomlElixir.decode!/2`
* `TomlElixir.encode/2`
* `TomlElixir.encode!/2`

# `options`

```elixir
@type options() :: map() | keyword()
```

# `decode`

```elixir
@spec decode(binary(), options()) :: {:ok, map()} | {:error, Exception.t()}
```

Decode toml string to map.

## Options
  * `:spec` - The TOML specification version to follow. Can be `:"1.1.0"` (default) or `:"1.0.0"`.

## Example
```
TomlElixir.decode("toml = true", spec: :"1.1.0")
```

# `decode!`

```elixir
@spec decode!(binary(), options()) :: map()
```

Same as `decode/2`, but raises error on failure.

## Example
```
TomlElixir.decode!("toml = true")
```

# `encode`

```elixir
@spec encode(map(), options()) :: {:ok, binary()} | {:error, any()}
```

Encode map to toml string.

## Example
```
TomlElixir.encode(%{a: 1})
```

# `encode!`

```elixir
@spec encode!(map(), options()) :: binary()
```

Same as `encode/2`, but raises error on failure.

## Example
```
TomlElixir.encode!(%{a: 1})
```

---

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