@std/toml.ms#
Import each required symbol with import Name from "@std/toml.ms".
TomlError Alternative#
Errors returned for invalid limits, malformed TOML, or exceeded resource bounds.
type TomlError:
case InvalidInput
case InvalidData(line: Int, column: Int, reason: String)
case LimitExceededimpl Error for TomlError:
fn message() -> String:TomlError.InvalidData#
Invalid syntax, duplicate/conflicting keys, unsupported value forms or numeric range failures.
case InvalidData(line: Int, column: Int, reason: String)TomlError.InvalidInput#
A supplied limit is negative, or stringify received a value that is not a table.
case InvalidInputTomlError.LimitExceeded#
Input, nesting or parsed/returned value counts exceed a supplied budget.
case LimitExceededTomlError.InvalidData.column#
One-based Unicode scalar column after CRLF normalization.
column: IntTomlError.InvalidData.line#
One-based line of the invalid token or conflicting construct.
line: IntTomlError.InvalidData.reason#
Parser diagnostic describing the rejected TOML construct.
reason: StringTomlError.Error.message#
Formats the source line, scalar column and parser reason for a malformed document.
fn message() -> String:TomlLimits Record#
Optional input-byte, nesting-depth, and parsed-value limits for TOML parsing.
type TomlLimits:
max_bytes: Optional[Int] = none
max_depth: Optional[Int] = none
max_values: Optional[Int] = noneTomlLimits.max_bytes#
Maximum UTF-8 input bytes before CRLF normalization; none adds no budget.
max_bytes: Optional[Int] = noneTomlLimits.max_depth#
Maximum value depth, including scalar leaves and implicit tables, with the root at one.
max_depth: Optional[Int] = noneTomlLimits.max_values#
Maximum containers and leaves, excluding keys; checked during parsing and materialization.
max_values: Optional[Int] = noneTomlValue Alternative#
A TOML value. Date and time values retain their original TOML text.
type TomlValue:
case StringValue(value: String)
case IntValue(value: Int)
case FloatValue(value: Float)
case BoolValue(value: Bool)
case DateTimeValue(text: String)
case ArrayValue(values: List[TomlValue])
case TableValue(values: Map[String, TomlValue])TomlValue.ArrayValue#
An ordered array; elements can have different TOML value kinds.
case ArrayValue(values: List[TomlValue])TomlValue.BoolValue#
A TOML true or false value; other capitalizations are invalid.
case BoolValue(value: Bool)TomlValue.DateTimeValue#
A validated local/offset date or time token, retained as text.
case DateTimeValue(text: String)TomlValue.FloatValue#
A parsed floating-point number, including TOML infinity and NaN spellings.
case FloatValue(value: Float)TomlValue.IntValue#
A parsed whole number; out-of-range input is rejected rather than truncated.
case IntValue(value: Int)TomlValue.StringValue#
Text decoded from TOML basic or literal string syntax.
case StringValue(value: String)TomlValue.TableValue#
An insertion-ordered table; parse returns this case even for an empty document.
case TableValue(values: Map[String, TomlValue])TomlValue.ArrayValue.values#
Element values in document order, with ordinary mutable list storage.
values: List[TomlValue]TomlValue.BoolValue.value#
The decoded boolean from the lowercase TOML token.
value: BoolTomlValue.DateTimeValue.text#
Original accepted TOML date/time spelling, without a timezone conversion.
text: StringTomlValue.FloatValue.value#
Numeric value of the accepted floating token, preserving signed zero.
value: FloatTomlValue.IntValue.value#
Exact signed integer value of the accepted TOML numeric token.
value: IntTomlValue.StringValue.value#
Unicode contents after the applicable escapes and multiline rules.
value: StringTomlValue.TableValue.values#
String-keyed entries produced by assignments, dotted keys and table headers.
values: Map[String, TomlValue]parse Function#
Parses a TOML document into a table value and reports source line and column on invalid input.
fn parse(text: String, limits: Optional[TomlLimits] = none) -> Result[TomlValue, TomlError]:stringify Function#
Serializes a table value as a TOML document. Tables and arrays of tables use headers; other values are written inline.
fn stringify(value: TomlValue, max_bytes: Optional[Int] = none) -> Result[String, TomlError]: