licence_audit/toml
Shared TOML access layer for licence_audit, built on the tomlet
dependency: comment-preserving edits (set_string_array) plus the read
accessors used by manifest/config parsing. These are thin wrappers over
tomlet’s value-level accessors and table-key enumeration.
Types
pub type ArrayError {
ArrayMissing
ArrayNotArray
}
Constructors
-
ArrayMissing -
ArrayNotArray
Re-export of tomlet’s parsed-document type so callers depend only on this
wrapper rather than importing tomlet directly.
pub type Document =
tomlet.Document
A table’s entries as tomlet exposes them: an ordered assoc list of
#(dotted_key_path, value).
pub type Entry =
List(#(List(String), tomlet.Value))
pub type TableLookupError {
TableLookupMissing
TableLookupNotTable
}
Constructors
-
TableLookupMissing -
TableLookupNotTable
pub type Value =
tomlet.Value
Values
pub fn as_array(
value: tomlet.Value,
) -> Result(List(tomlet.Value), Nil)
Value -> array item list.
pub fn as_table(
value: tomlet.Value,
) -> Result(List(#(List(String), tomlet.Value)), Nil)
Value -> table entries (standard or inline table).
pub fn error_message(error: Error) -> String
pub fn field(
entry: List(#(List(String), tomlet.Value)),
name: String,
) -> Result(tomlet.Value, Nil)
Look up a simple (single-segment) field within a table’s entries.
pub fn get(
doc: tomlet.Document,
path: List(String),
) -> Result(tomlet.Value, Nil)
Read a value at a document path, including tables.
pub fn get_array(
doc: tomlet.Document,
path: List(String),
) -> Result(List(tomlet.Value), ArrayError)
Read the array at path as its item values.
pub fn get_string(
doc: tomlet.Document,
path: List(String),
) -> Result(String, Nil)
Read a top-level (or path-addressed) string scalar.
pub fn get_table(
doc: tomlet.Document,
path: List(String),
) -> Result(List(#(List(String), tomlet.Value)), TableLookupError)
Read the table at path as its entry assoc list.
pub fn parse(input: String) -> Result(tomlet.Document, Nil)
Parse TOML source, collapsing tomlet’s rich parse error to Error(Nil).
pub fn set_string_array(
existing_toml: String,
path: List(String),
key: String,
values: List(String),
) -> Result(String, Error)
Replace (or create) a string array at the table named by path (a list of
segments forming nested tables) and key key in the provided TOML source,
preserving comments, formatting, and unrelated sections.
pub fn table_headers(
doc: tomlet.Document,
) -> Result(List(List(String)), Nil)
Enumerate explicit table paths, including empty descendants hidden by get.
pub fn table_keys(
doc: tomlet.Document,
path: List(String),
) -> Result(List(String), Nil)
Top-level keys of the table at path, in source order. Error(Nil) when
the path is absent or is not a table.