Skip to main content

oak_ini/ast/
mod.rs

1#![doc = include_str!("readme.md")]
2use core::range::Range;
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6/// Root of the INI AST.
7#[derive(Clone, Debug, PartialEq, Eq, Hash)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9pub struct IniRoot {
10    /// Sections in the INI file.
11    pub sections: Vec<Section>,
12    /// Global properties in the INI file.
13    pub properties: Vec<Property>,
14}
15
16/// A section in the INI file.
17#[derive(Clone, Debug, PartialEq, Eq, Hash)]
18#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
19pub struct Section {
20    /// Name of the section.
21    pub name: String,
22    /// Properties in the section.
23    pub properties: Vec<Property>,
24    /// Span of the section in the source text.
25    #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
26    pub span: Range<usize>,
27}
28
29/// A key-value property in the INI file.
30#[derive(Clone, Debug, PartialEq, Eq, Hash)]
31#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
32pub struct Property {
33    /// Key of the property.
34    pub key: String,
35    /// Value of the property.
36    pub value: String,
37    /// Span of the property in the source text.
38    #[cfg_attr(feature = "serde", serde(with = "oak_core::serde_range"))]
39    pub span: Range<usize>,
40}