Manuscript Documentation
v0.1.0

@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.

Manuscript
type TomlError:
    case InvalidInput
    case InvalidData(line: Int, column: Int, reason: String)
    case LimitExceeded
Manuscript
impl Error for TomlError:
    fn message() -> String:

TomlError.InvalidData#

Invalid syntax, duplicate/conflicting keys, unsupported value forms or numeric range failures.

Manuscript
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.

Manuscript
case InvalidInput

TomlError.LimitExceeded#

Input, nesting or parsed/returned value counts exceed a supplied budget.

Manuscript
case LimitExceeded

TomlError.InvalidData.column#

One-based Unicode scalar column after CRLF normalization.

Manuscript
column: Int

TomlError.InvalidData.line#

One-based line of the invalid token or conflicting construct.

Manuscript
line: Int

TomlError.InvalidData.reason#

Parser diagnostic describing the rejected TOML construct.

Manuscript
reason: String

TomlError.Error.message#

Formats the source line, scalar column and parser reason for a malformed document.

Manuscript
fn message() -> String:

TomlLimits Record#

Optional input-byte, nesting-depth, and parsed-value limits for TOML parsing.

Manuscript
type TomlLimits:
    max_bytes: Optional[Int] = none
    max_depth: Optional[Int] = none
    max_values: Optional[Int] = none

TomlLimits.max_bytes#

Maximum UTF-8 input bytes before CRLF normalization; none adds no budget.

Manuscript
max_bytes: Optional[Int] = none

TomlLimits.max_depth#

Maximum value depth, including scalar leaves and implicit tables, with the root at one.

Manuscript
max_depth: Optional[Int] = none

TomlLimits.max_values#

Maximum containers and leaves, excluding keys; checked during parsing and materialization.

Manuscript
max_values: Optional[Int] = none

TomlValue Alternative#

A TOML value. Date and time values retain their original TOML text.

Manuscript
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.

Manuscript
case ArrayValue(values: List[TomlValue])

TomlValue.BoolValue#

A TOML true or false value; other capitalizations are invalid.

Manuscript
case BoolValue(value: Bool)

TomlValue.DateTimeValue#

A validated local/offset date or time token, retained as text.

Manuscript
case DateTimeValue(text: String)

TomlValue.FloatValue#

A parsed floating-point number, including TOML infinity and NaN spellings.

Manuscript
case FloatValue(value: Float)

TomlValue.IntValue#

A parsed whole number; out-of-range input is rejected rather than truncated.

Manuscript
case IntValue(value: Int)

TomlValue.StringValue#

Text decoded from TOML basic or literal string syntax.

Manuscript
case StringValue(value: String)

TomlValue.TableValue#

An insertion-ordered table; parse returns this case even for an empty document.

Manuscript
case TableValue(values: Map[String, TomlValue])

TomlValue.ArrayValue.values#

Element values in document order, with ordinary mutable list storage.

Manuscript
values: List[TomlValue]

TomlValue.BoolValue.value#

The decoded boolean from the lowercase TOML token.

Manuscript
value: Bool

TomlValue.DateTimeValue.text#

Original accepted TOML date/time spelling, without a timezone conversion.

Manuscript
text: String

TomlValue.FloatValue.value#

Numeric value of the accepted floating token, preserving signed zero.

Manuscript
value: Float

TomlValue.IntValue.value#

Exact signed integer value of the accepted TOML numeric token.

Manuscript
value: Int

TomlValue.StringValue.value#

Unicode contents after the applicable escapes and multiline rules.

Manuscript
value: String

TomlValue.TableValue.values#

String-keyed entries produced by assignments, dotted keys and table headers.

Manuscript
values: Map[String, TomlValue]

parse Function#

Parses a TOML document into a table value and reports source line and column on invalid input.

Manuscript
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.

Manuscript
fn stringify(value: TomlValue, max_bytes: Optional[Int] = none) -> Result[String, TomlError]: