TomlElixir.Encoder protocol (Toml Elixir v3.1.0)

Copy Markdown View Source

Protocol for encoding Elixir terms to TOML.

You can derive this protocol for structs:

@derive TomlElixir.Encoder
defstruct [:name, :age]

@derive {TomlElixir.Encoder, only: [:name]}
defstruct [:name, :age, :password]

@derive {TomlElixir.Encoder, except: [:password]}
defstruct [:name, :age, :password]

If you don't own the struct, you can derive externally:

Protocol.derive(TomlElixir.Encoder, NameOfTheStruct, only: [:field])
Protocol.derive(TomlElixir.Encoder, NameOfTheStruct, except: [:field])
Protocol.derive(TomlElixir.Encoder, NameOfTheStruct)

Summary

Types

t()

All the types that implement this protocol.

Functions

Encodes a value to TOML value format (inline).

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

encode(value)

Encodes a value to TOML value format (inline).