View Source Bento.Decoder (bento v1.0.0)
Useful wrapper for Bento.Parser
.
Link to this section Summary
Functions
Decode a bencoded value.
Decode a bencoded value, but raise an error if it fails.
Transform a parsed value into a struct.
Link to this section Types
Link to this section Functions
@spec decode(iodata(), opts()) :: {:ok, t()} | {:error, decode_err()}
Decode a bencoded value.
Decode a bencoded value, but raise an error if it fails.
@spec transform(Bento.Parser.t(), opts()) :: t()
Transform a parsed value into a struct.
defmodule User do
defstruct name: "John", age: 27
end
Bento.Decoder.transform(%{"name" => "Bob"}, as: %User{})
# %User{name: "Bob", age: 27}