# codixor/rs-toml architecture

> Architecture diagram of the GitHub repository codixor/rs-toml, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codixor/rs-toml
- Repository: https://github.com/codixor/rs-toml

## Overview

rs-toml is a Rust TOML parsing, document/value, typed-conversion, and emission library, with additive derive and serde features. The principal workflow is TOML input through parsing into an arena-backed document, optional typed conversion or document traversal, then emission. The README documents bounded parsing and span-aware diagnostics as well. Relationships are limited to README statements and the supplied source-index references; unsampled implementation details and optional integrations are not inferred.

Main entry points: [`src/parser.rs`](https://github.com/codixor/rs-toml/blob/main/src/parser.rs) (TOML parser), [`src/lib.rs`](https://github.com/codixor/rs-toml/blob/main/src/lib.rs) (Public API), [`src/emit/reprojection.rs`](https://github.com/codixor/rs-toml/blob/main/src/emit/reprojection.rs) (Format reprojection), [`src/item.rs`](https://github.com/codixor/rs-toml/blob/main/src/item.rs) (Item values)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Parse and document"]
  node_api["Public API<br/>[lib.rs]"]
  node_parser["TOML parser<br/>[parser.rs]"]
  node_document["Document and traversal<br/>[parser.rs]"]
  node_item["Item values<br/>[item.rs]"]
  node_table["Table access<br/>[table.rs]"]
  node_array["Array access<br/>[array.rs]"]
end

subgraph group_conversion["Typed conversion"]
  node_from_toml["FromToml conversion<br/>[de.rs]"]
  node_to_toml["ToToml conversion<br/>[ser.rs]"]
end

subgraph group_output["Emission"]
  node_emitter["TOML emitter<br/>[emit.rs]"]
  node_normalization["Output normalization<br/>[normalization.rs]"]
  node_reprojection["Format reprojection<br/>[reprojection.rs]"]
end

subgraph group_integrations["Additive features"]
  node_serde_de["Serde deserialization<br/>[serde.rs]"]
  node_serde_ser["Serde serialization<br/>[impl_serde.rs]"]
  node_derive["Toml derive macro<br/>[lib.rs]"]
  node_derive_ast["Derive AST<br/>[ast.rs]"]
  node_derive_cases["Case conversion<br/>[case.rs]"]
  node_derive_codegen["Code generation<br/>[codegen.rs]"]
  node_derive_writer["Token writer<br/>[writer.rs]"]
end

subgraph group_internals["Storage and diagnostics"]
  node_arena["Arena allocation<br/>[arena.rs]"]
  node_raw_item["Packed value storage<br/>[item.rs]"]
  node_diagnostics["Parse diagnostics<br/>[error.rs]"]
  node_spans["Source spans<br/>[span.rs]"]
end

node_caller(("Library user"))
node_toml_input["TOML input"]

node_caller -->|"uses"| node_api
node_toml_input -->|"provides input"| node_api
node_api -->|"parses via"| node_parser
node_parser -->|"builds"| node_document
node_parser -->|"constructs"| node_raw_item
node_parser -->|"uses"| node_table
node_parser -->|"uses"| node_array
node_parser -->|"reports"| node_diagnostics
node_parser -->|"tracks"| node_spans
node_parser -.->|"allocates in"| node_arena
node_document -->|"exposes"| node_item
node_item -->|"uses representation"| node_raw_item
node_item -->|"delegates to"| node_table
node_item -->|"delegates to"| node_array
node_api -->|"converts via"| node_from_toml
node_from_toml -->|"records errors"| node_diagnostics
node_from_toml -->|"retains spans"| node_spans
node_api -->|"converts via"| node_to_toml
node_api -->|"offers feature"| node_serde_de
node_serde_de -.->|"parses input"| node_parser
node_api -->|"offers feature"| node_serde_ser
node_api -->|"emits via"| node_emitter
node_emitter -->|"uses"| node_normalization
node_emitter -->|"uses"| node_reprojection
node_reprojection -->|"reads source"| node_document
node_reprojection -->|"matches values"| node_item
node_reprojection -->|"walks tables"| node_table
node_reprojection -->|"compares spans"| node_spans
node_caller -->|"uses derive"| node_derive
node_derive -.->|"generates with"| node_derive_codegen
node_derive_codegen -->|"reads"| node_derive_ast
node_derive_codegen -->|"uses"| node_derive_cases
node_derive_codegen -->|"writes through"| node_derive_writer
node_derive_ast -->|"uses"| node_derive_cases

click node_api "https://github.com/codixor/rs-toml/blob/main/src/lib.rs"
click node_parser "https://github.com/codixor/rs-toml/blob/main/src/parser.rs"
click node_document "https://github.com/codixor/rs-toml/blob/main/src/parser.rs"
click node_item "https://github.com/codixor/rs-toml/blob/main/src/item.rs"
click node_table "https://github.com/codixor/rs-toml/blob/main/src/item/table.rs"
click node_array "https://github.com/codixor/rs-toml/blob/main/src/item/array.rs"
click node_arena "https://github.com/codixor/rs-toml/blob/main/src/raw/arena.rs"
click node_raw_item "https://github.com/codixor/rs-toml/blob/main/src/raw/item.rs"
click node_diagnostics "https://github.com/codixor/rs-toml/blob/main/src/error.rs"
click node_spans "https://github.com/codixor/rs-toml/blob/main/src/span.rs"
click node_from_toml "https://github.com/codixor/rs-toml/blob/main/src/de.rs"
click node_to_toml "https://github.com/codixor/rs-toml/blob/main/src/ser.rs"
click node_serde_de "https://github.com/codixor/rs-toml/blob/main/src/serde.rs"
click node_serde_ser "https://github.com/codixor/rs-toml/blob/main/src/impl_serde.rs"
click node_emitter "https://github.com/codixor/rs-toml/blob/main/src/emit.rs"
click node_normalization "https://github.com/codixor/rs-toml/blob/main/src/emit/normalization.rs"
click node_reprojection "https://github.com/codixor/rs-toml/blob/main/src/emit/reprojection.rs"
click node_derive "https://github.com/codixor/rs-toml/blob/main/macros/src/lib.rs"
click node_derive_ast "https://github.com/codixor/rs-toml/blob/main/macros/src/ast.rs"
click node_derive_cases "https://github.com/codixor/rs-toml/blob/main/macros/src/case.rs"
click node_derive_codegen "https://github.com/codixor/rs-toml/blob/main/macros/src/codegen.rs"
click node_derive_writer "https://github.com/codixor/rs-toml/blob/main/macros/src/writer.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_parser,node_document,node_item,node_table,node_array,node_caller toneBlue
class node_from_toml,node_to_toml toneAmber
class node_emitter,node_normalization,node_reprojection toneMint
class node_serde_de,node_serde_ser,node_derive,node_derive_ast,node_derive_cases,node_derive_codegen,node_derive_writer toneRose
class node_arena,node_raw_item,node_diagnostics,node_spans,node_toml_input toneIndigo
```

## Components

### Parse and document

- [Public API](https://github.com/codixor/rs-toml/blob/main/src/lib.rs): `src/lib.rs`
- [TOML parser](https://github.com/codixor/rs-toml/blob/main/src/parser.rs): `src/parser.rs`
- [Document and traversal](https://github.com/codixor/rs-toml/blob/main/src/parser.rs): `src/parser.rs`
- [Item values](https://github.com/codixor/rs-toml/blob/main/src/item.rs): `src/item.rs`
- [Table access](https://github.com/codixor/rs-toml/blob/main/src/item/table.rs): `src/item/table.rs`
- [Array access](https://github.com/codixor/rs-toml/blob/main/src/item/array.rs): `src/item/array.rs`

### Typed conversion

- [FromToml conversion](https://github.com/codixor/rs-toml/blob/main/src/de.rs): `src/de.rs`
- [ToToml conversion](https://github.com/codixor/rs-toml/blob/main/src/ser.rs): `src/ser.rs`

### Emission

- [TOML emitter](https://github.com/codixor/rs-toml/blob/main/src/emit.rs): `src/emit.rs`
- [Output normalization](https://github.com/codixor/rs-toml/blob/main/src/emit/normalization.rs): `src/emit/normalization.rs`
- [Format reprojection](https://github.com/codixor/rs-toml/blob/main/src/emit/reprojection.rs): `src/emit/reprojection.rs`

### Additive features

- [Serde deserialization](https://github.com/codixor/rs-toml/blob/main/src/serde.rs): `src/serde.rs`
- [Serde serialization](https://github.com/codixor/rs-toml/blob/main/src/impl_serde.rs): `src/impl_serde.rs`
- [Toml derive macro](https://github.com/codixor/rs-toml/blob/main/macros/src/lib.rs): `macros/src/lib.rs`
- [Derive AST](https://github.com/codixor/rs-toml/blob/main/macros/src/ast.rs): `macros/src/ast.rs`
- [Case conversion](https://github.com/codixor/rs-toml/blob/main/macros/src/case.rs): `macros/src/case.rs`
- [Code generation](https://github.com/codixor/rs-toml/blob/main/macros/src/codegen.rs): `macros/src/codegen.rs`
- [Token writer](https://github.com/codixor/rs-toml/blob/main/macros/src/writer.rs): `macros/src/writer.rs`

### Storage and diagnostics

- [Arena allocation](https://github.com/codixor/rs-toml/blob/main/src/raw/arena.rs): `src/raw/arena.rs`
- [Packed value storage](https://github.com/codixor/rs-toml/blob/main/src/raw/item.rs): `src/raw/item.rs`
- [Parse diagnostics](https://github.com/codixor/rs-toml/blob/main/src/error.rs): `src/error.rs`
- [Source spans](https://github.com/codixor/rs-toml/blob/main/src/span.rs): `src/span.rs`

### Other components

- **Library user**
- **TOML input**

## Connections

- Library user → Public API: uses (evidence: `README.md`)
- TOML input → Public API: provides input (evidence: `README.md`)
- Public API → TOML parser: parses via (evidence: `src/lib.rs`)
- TOML parser → Document and traversal: builds (evidence: `README.md`)
- TOML parser → Packed value storage: constructs (evidence: `src/parser.rs`)
- TOML parser → Table access: uses (evidence: `src/parser.rs`)
- TOML parser → Array access: uses (evidence: `src/parser.rs`)
- TOML parser → Parse diagnostics: reports (evidence: `src/parser.rs`)
- TOML parser → Source spans: tracks (evidence: `src/parser.rs`)
- TOML parser → Arena allocation: allocates in
- Document and traversal → Item values: exposes (evidence: `README.md`)
- Item values → Packed value storage: uses representation (evidence: `src/item.rs`)
- Item values → Table access: delegates to (evidence: `src/item.rs`)
- Item values → Array access: delegates to (evidence: `src/item.rs`)
- Public API → FromToml conversion: converts via (evidence: `README.md`)
- FromToml conversion → Parse diagnostics: records errors (evidence: `src/de.rs`)
- FromToml conversion → Source spans: retains spans (evidence: `README.md`)
- Public API → ToToml conversion: converts via (evidence: `README.md`)
- Public API → Serde deserialization: offers feature (evidence: `README.md`)
- Serde deserialization → TOML parser: parses input
- Public API → Serde serialization: offers feature (evidence: `README.md`)
- Public API → TOML emitter: emits via (evidence: `README.md`)
- TOML emitter → Output normalization: uses (evidence: `src/emit.rs`)
- TOML emitter → Format reprojection: uses (evidence: `src/emit.rs`)
- Format reprojection → Document and traversal: reads source (evidence: `src/emit/reprojection.rs`)
- Format reprojection → Item values: matches values (evidence: `src/emit/reprojection.rs`)
- Format reprojection → Table access: walks tables (evidence: `src/emit/reprojection.rs`)
- Format reprojection → Source spans: compares spans (evidence: `src/emit/reprojection.rs`)
- Library user → Toml derive macro: uses derive (evidence: `README.md`)
- Toml derive macro → Code generation: generates with (evidence: `macros/src/lib.rs`)
- Code generation → Derive AST: reads (evidence: `macros/src/codegen.rs`)
- Code generation → Case conversion: uses (evidence: `macros/src/codegen.rs`)
- Code generation → Token writer: writes through (evidence: `macros/src/codegen.rs`)
- Derive AST → Case conversion: uses (evidence: `macros/src/ast.rs`)
