inf_rs/
types.rs

1use std::collections::HashMap;
2
3/// A value in a Windows INF file
4/// 
5/// Values can be either raw strings or lists of strings.
6/// Raw strings are used for simple values, while lists are used for
7/// multi-line values or arrays.
8#[derive(Debug, Clone, PartialEq)]
9pub enum InfValue {
10    // INF values can be complex, like comma-separated lists or numbers.
11    // For simplicity, we'll treat most as strings initially.
12    // You could extend this to handle specific value types if needed.
13    CommaSeparated(Vec<String>),
14    /// A raw string value
15    /// 
16    /// This variant is used for simple string values in the INF file.
17    Raw(String),
18    /// A list of string values
19    /// 
20    /// This variant is used for multi-line values or arrays in the INF file.
21    List(Vec<String>),
22}
23
24/// An entry in a Windows INF file section
25/// 
26/// Entries can be either key-value pairs or standalone values.
27/// Key-value pairs are used for configuration settings, while standalone values
28/// are often used for lists or simple values.
29#[derive(Debug, Clone, PartialEq)]
30pub enum InfEntry {
31    /// A key-value pair entry
32    /// 
33    /// The first field is the key, and the second field is an optional value.
34    /// The value is optional because some INF files may have keys without values.
35    KeyValue(String, Option<InfValue>),
36    /// A standalone value entry
37    /// 
38    /// This variant is used for entries that don't have a key, such as
39    /// list items or simple values.
40    OnlyValue(InfValue),
41}
42
43/// A section in a Windows INF file
44/// 
45/// Each section in an INF file has a name and contains a list of entries.
46/// Entries can be either key-value pairs or standalone values.
47#[derive(Debug, Clone, PartialEq)]
48pub struct InfSection {
49    /// The name of the section
50    pub name: String,
51    /// The entries contained in this section
52    pub entries: Vec<InfEntry>,
53}
54
55#[derive(Debug, PartialEq)]
56pub struct InfFile {
57    pub sections: HashMap<String, InfSection>,
58    pub strings: HashMap<String, String>,
59}