Crate script_meditate

Source
Expand description

This crate is intended to be used in (currently unstable) Cargo scripts. It allows you to provide structured data and configuration inside a frontmatter comment, which can be parsed and obtained using a utility macro.

§Data format support

JSON, TOML, and YAML are currently supported. The desired format(s) must be enabled through Cargo features. The type expected from parsing must implement Deserialize.

The frontmatter comment is detected using the following pattern: /*${tag}\n, where ${tag} is json, toml, or yaml (case-sensitive). The end of the frontmatter comment is detected using \n*/\n and must therefore not be found inside the data.

§Note

The script must not be placed directly inside the user’s home directory.

§Features

§Frontmatter format selection

One or more of these must be enabled.

  • json — Enables JSON parsing.
  • toml — Enables TOML parsing.
  • yaml — Enables YAML parsing.

Macros§

extract_json_frontmatterjson
Extracts, parses, and returns the JSON frontmatter.
extract_toml_frontmattertoml
Extracts, parses, and returns the TOML frontmatter.
extract_yaml_frontmatteryaml
Extracts, parses, and returns the YAML frontmatter.