24 releases

0.9.1 Mar 26, 2024
0.9.0 Nov 24, 2023
0.8.8 Feb 4, 2020
0.8.6 Nov 25, 2019
0.2.0 Nov 2, 2015

#144 in Parser implementations

Download history 1117/week @ 2024-01-25 1852/week @ 2024-02-01 1636/week @ 2024-02-08 2094/week @ 2024-02-15 2175/week @ 2024-02-22 1166/week @ 2024-02-29 2107/week @ 2024-03-07 1886/week @ 2024-03-14 1366/week @ 2024-03-21 1009/week @ 2024-03-28 1477/week @ 2024-04-04 1720/week @ 2024-04-11 1595/week @ 2024-04-18 1603/week @ 2024-04-25 1523/week @ 2024-05-02 1457/week @ 2024-05-09

6,423 downloads per month

MIT license

74KB
2K SLoC

ion   crates-badge docs-badge

MIT License Test Status

ion: Advanced Ion File Parser

Overview

ion is a sophisticated parser for *.ion files, crafted in Rust to handle a versatile data format. This format is ideal for configurations and structured data, supporting a diverse range of types like String, Integer (i64), Float (f64), Boolean, Arrays, and Dictionary.

Features

  • Diverse Data Type Support: Capable of parsing Strings, Integers, Floats, Booleans, Arrays, and Dictionaries.
  • Section-based Organization: Facilitates data organization in distinct sections with varied structures.
  • Efficient Parsing: Optimized for performance and reliability in parsing complex Ion documents.

Example Usage

The following examples demonstrate the flexibility and structure of *.ion files:

Basic Section

[CONTRACT]
id = "HOTEL001"
name = "Hotel001"
currency = "EUR"
active = true
markets = ["DE", "PL"]

Table Format

[DEF.MEAL]
| code | description |
|------|-------------|
| RO   | Room Only   |

[DEF.ROOM]
| code | description |      occ       |
|------|-------------|----------------|
| SGL  | Single      | P1:2 A1:1 C0:1 |
| DBL  | Double      | P2:3 A2:2 C0:1 |

Basic section with possible field types

[CONTRACT]
country = "Poland"                  // String
markets = ["PL", "DE", "UK"]        // Array
75042 = {                           // Dictionary
    view = "SV"                     // String
    loc  = ["M", "B"]               // Array
    dist = { beach_km = 4.1 }       // Dictionary
}

Complex document built from few sections

[CONTRACT]
country = "Poland"
markets = ["PL", "DE", "UK"]
75042 = {
    view = "SV"
    loc  = ["M", "B"]
    dist = { beach_km = 4.1 }
}

[RATE.PLAN]
|       dates       | code |  description   |    rooms    | rules |
|-------------------|------|----------------|-------------|-------|
| 20200512:20200514 | BAR  | Best available | SGL,DBL,APP |       |
| 20200601:20200614 | BBV  | Best Bar View  | DBL,APP     |       |

# A `key-value` and `table` section
[RATE.BASE]
enable = true
legend = {
    UN = "unit night"
    RO = "room only"
}
|       dates       | charge | room | occ | meal |  amt   |
|-------------------|--------|------|-----|------|--------|
| 20161122:20170131 | UN     | APP  | A2  | RO   | 250.00 |
| 20161122:20170131 | UN     | APP  | A4  | RO   | 450.00 |
| 20161122:20170131 | UN     | APP  | A6  | RO   | 650.00 |

License

Licensed under the MIT license.

No runtime deps