Skip to main content

oak_ini/ast/
mod.rs

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