Module source

Module source 

Source
Expand description

Source-level document representation with layout metadata.

Used for programmatic construction of Eure documents with preserved formatting information (comments, section ordering, etc.). Source-level document representation for programmatic construction and formatting.

This module provides types for representing Eure source structure with layout metadata, while actual values are referenced via [NodeId] into an [EureDocument].

§Design

┌─────────────────────────────────────────────┐
│              SourceDocument                  │
│  ┌─────────────────┐  ┌──────────────────┐  │
│  │  EureDocument   │  │     Layout       │  │
│  │  ┌───────────┐  │  │                  │  │
│  │  │ NodeId(0) │◄─┼──┼─ Binding.node    │  │
│  │  │ NodeId(1) │◄─┼──┼─ Binding.node    │  │
│  │  │ NodeId(2) │◄─┼──┼─ Binding.node    │  │
│  │  └───────────┘  │  │                  │  │
│  └─────────────────┘  └──────────────────┘  │
└─────────────────────────────────────────────┘
  • EureDocument: Holds semantic data (values)
  • Layout: Holds presentation metadata (comments, ordering, section structure)

§Example

// Convert from TOML, preserving comments and section ordering
let source = eure_toml::to_source_document(&toml_doc);

// Modify values (layout is preserved)
let node = source.find_binding(&["server", "port"]).unwrap();
source.document.node_mut(node).set_primitive(8080.into());

// Format to Eure string
let output = eure_fmt::format_source(&source, &config);

Structs§

ArrayElementLayout
Layout information for an array element.
Layout
Layout information describing how to render the document.
SourceDocument
A document with layout/presentation metadata.
SourcePathSegment
A segment in a source path.

Enums§

Comment
A comment in the source.
LayoutItem
An item in the layout.
SectionBody
The body of a section.
SourceKey
A key in source representation.

Type Aliases§

SourcePath
A path in source representation.