VDF.Reader (vdf v0.1.0)

This module is responsible for parsing VDF files into Elixir maps.

The public API consists of two functions: parse_string/1 and parse_enum/1. Both functions have identical parsing logic and differ based on the input type. parse_string/1 accepts a binary string which will be split on new lines for parsing. parse_enum/1 accepts an enumerable of strings which will be parsed line by line. The intent is to use parse_enum/1 when parsing large files, alongside File.stream!/1, to avoid loading the entire file into memory.

Summary

Functions

Parses an Enumerable of Strings representing a VDF into an Elixir map.

Parses a VDF string into an Elixir map.

Types

@type stack() :: [{String.t(), map()} | {nil, map()}]

Functions

Link to this function

parse_enum(enum)

@spec parse_enum(Enum.t()) :: {:ok, map()} | {:error, VDF.ParseError.t()}

Parses an Enumerable of Strings representing a VDF into an Elixir map.

This function will treat each string as a new line in the VDF file. This function is intended to be used with File.stream!/1 to avoid loading the entire file into memory.

Link to this function

parse_string(vdf)

@spec parse_string(binary()) :: {:ok, map()} | {:error, VDF.ParseError.t()}

Parses a VDF string into an Elixir map.

This function will split the input string on new lines and parse each line individually.