Skip to main content

Crate ion

Crate ion 

Source
Expand description

Parser and data model for .ion documents.

An Ion document is represented as Ion, which contains named Section values. Each section can hold:

  • a Dictionary of scalar, array, or nested dictionary fields
  • tabular Row data

The crate provides two entry points:

  • Ion for the high-level parsed document model
  • Parser for lower-level iteration and error inspection

§Feature flags

  • default: section and dictionary storage use BTreeMap, so iteration and serialization are sorted by key
  • dictionary-indexmap: section and dictionary storage use IndexMap, so iteration and serialization preserve insertion order

§Examples

use ion::{Ion, Value};

let mut ion: Ion = r#"
    [APP]
    name = "demo"
    retries = 3
"#.parse()?;

let app = ion.get_mut("APP").unwrap();
app.dictionary
    .insert("enabled".to_owned(), Value::Boolean(true));

assert_eq!(Some("demo"), app.get("name").and_then(Value::as_str));

§Ordering backend

The selected backend affects both Dictionary and Sections, which means it changes:

Macros§

ion
Parses a string literal into Ion.
ion_filtered
Parses a string literal into Ion while keeping only selected sections.

Structs§

IntoIter
Owning iterator over section rows.
Ion
Parsed Ion document.
Parser
Stateful parser for Ion text.
ParserError
Structured parser error with location and source context.
Section
A named Ion section.

Enums§

Element
Low-level parser output item.
IonError
Errors returned by high-level Ion parsing and access APIs.
ParserErrorKind
Machine-readable parser error category.
Value
A typed Ion value.

Traits§

FromIon
Converts Ion values or sections into typed Rust values.
FromRow
Converts a row of Value cells into a typed Rust value.
ParseRow
Extension trait for parsing a Row into a typed value.

Type Aliases§

Dictionary
Dictionary storage used by Section::dictionary.
Row
A single table row stored inside a Section.
Sections
Top-level section storage used by Ion.