haproxy_config/section/
owned.rs

1use crate::config::Address;
2use crate::line::owned;
3
4/// Represents a section in a config file.
5#[derive(Debug)]
6pub enum Section {
7    BlankLine,
8    /// Comment on a separate line not in a section
9    Comment(String),
10    /// The global section of a config.
11    Global {
12        /// Comment on the same line as the section header
13        comment: Option<String>,
14        /// [`Lines`](owned::Line) in this section.
15        lines: Vec<owned::Line>,
16    },
17    /// The lines in the default section of a config.
18    Default {
19        /// Comment on the same line as the section header
20        comment: Option<String>,
21        /// The default proxy stated after the section header
22        proxy: Option<String>,
23        /// [`Lines`](owned::Line) in this section.
24        lines: Vec<owned::Line>,
25    },
26    Frontend {
27        /// Comment on the same line as the section header
28        comment: Option<String>,
29        /// The proxy stated after the section header
30        proxy: String,
31        /// [`Lines`](owned::Line) in this section.
32        lines: Vec<owned::Line>,
33        /// Optional address to which the frontend binds can be stated
34        /// in the header, for example `frontend webserver *:80` instead
35        /// of a bind line, any optional config for the bind follows
36        header_addr: Option<(Address, Option<String>)>,
37    },
38    Listen {
39        /// Comment on the same line as the section header
40        comment: Option<String>,
41        /// The proxy stated after the section header
42        proxy: String,
43        /// [`Lines`](owned::Line) in this section.
44        lines: Vec<owned::Line>,
45        /// Optional address to which the listen binds can be stated
46        /// in the header, for example `frontend webserver *:80` instead
47        /// of a bind line, any optional config for the bind follows
48        header_addr: Option<(Address, Option<String>)>,
49    },
50    Backend {
51        /// Comment on the same line as the section header
52        comment: Option<String>,
53        /// The proxy stated after the section header
54        proxy: String,
55        /// [`Lines`](owned::Line) in this section.
56        lines: Vec<owned::Line>,
57    },
58    Userlist {
59        /// Comment on the same line as the section header
60        comment: Option<String>,
61        /// Name of this userlist
62        name: String,
63        /// [`Lines`](owned::Line) in this section.
64        lines: Vec<owned::Line>,
65    },
66    UnknownLine {
67        /// A line that could not be parsed.
68        line: String,
69    },
70}