std/data/toml

Standard Library documentation

TOML encoding and decoding for ZuzuScript.

Module

Name
std/data/toml
Area
Standard Library
Source
modules/std/data/toml.zzm

NAME

std/data/toml - TOML encoding and decoding for ZuzuScript.

SYNOPSIS

  from std/data/toml import TOML;

  let codec := new TOML( pretty: true, canonical: true );
  let text := codec.encode({ answer: 42, name: "Zuzu" });
  let data := codec.decode(text);

IMPLEMENTATION SUPPORT

This module is supported by zuzu.pl, zuzu-rust, and zuzu-js on Node and Electron. It is partially supported by zuzu-js in the browser: in-memory TOML encode/decode coverage passes, but file-backed load/dump coverage is unsupported because browser filesystem capability is unavailable.

DESCRIPTION

This module provides a pure-Zuzu implementation of TOML parsing and serialization, with a user-facing API modelled on std/data/json.

EXPORTS

Classes

  • TOML({ utf8?: Bool, pretty?: Bool, canonical?: Bool })

    Constructs a TOML codec. Returns: TOML.

  • codec.encode(value)

    Parameters: value is a Dict or compatible mapping. Returns: String. Encodes value as TOML text.

  • codec.encode_binarystring(value)

    Parameters: value is a Dict or compatible mapping. Returns: BinaryString. Encodes value as UTF-8 TOML bytes.

  • codec.decode(String text)

    Parameters: text is TOML text. Returns: Dict. Decodes TOML text into a dictionary.

  • codec.decode_binarystring(BinaryString bytes)

    Parameters: bytes is UTF-8 TOML bytes. Returns: Dict. Decodes TOML bytes into a dictionary.

  • codec.load(Path path)

    Parameters: path is a std/io Path. Returns: Dict. Reads TOML text from path and decodes it.

  • codec.dump(Path path, value)

    Parameters: path is a std/io Path and value is a Dict or compatible mapping. Returns: null. Encodes value and writes TOML text to path.

COPYRIGHT AND LICENCE

std/data/toml is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.