haproxy_config/section/borrowed.rs
1use super::AddressRef;
2
3use crate::line::borrowed;
4
5/// Parsed haproxy config preserving the order and comments.
6/// Does not support conditional blocks,
7/// these and other unsupported lines will be stored in the [`UnknownLine`](Section::UnknownLine) variant.
8/// Information outside the header is containd in the correct order in the lines member. See the [`Line`](borrowed::Line) documentation.
9#[derive(Debug)]
10pub enum Section<'input> {
11 BlankLine,
12 /// Comment on a seperate line not in a section
13 Comment(&'input str),
14 /// The global section of a config.
15 Global {
16 /// Comment on the same line as the section header
17 comment: Option<&'input str>,
18 /// [`Lines`](borrowed::Line) in this section.
19 lines: Vec<borrowed::Line<'input>>,
20 },
21 /// The lines in the default section of a config.
22 Default {
23 /// Comment on the same line as the section header
24 comment: Option<&'input str>,
25 /// The default proxy stated after the section header
26 proxy: Option<&'input str>,
27 /// [`Lines`](borrowed::Line) in this section.
28 lines: Vec<borrowed::Line<'input>>,
29 },
30 Frontend {
31 /// Comment on the same line as the section header
32 comment: Option<&'input str>,
33 /// The proxy stated after the section header
34 proxy: &'input str,
35 /// [`Lines`](borrowed::Line) in this section.
36 lines: Vec<borrowed::Line<'input>>,
37 /// Optional address to which the frontend binds can be stated
38 /// in the header, for example `frontend webserver *:80` instead
39 /// of a bind line, any optional config for the bind follows
40 header_addr: Option<(AddressRef<'input>, Option<&'input str>)>,
41 },
42 Listen {
43 /// Comment on the same line as the section header
44 comment: Option<&'input str>,
45 /// The proxy stated after the section header
46 proxy: &'input str,
47 /// [`Lines`](borrowed::Line) in this section.
48 lines: Vec<borrowed::Line<'input>>,
49 /// Optional address to which the listen binds can be stated
50 /// in the header, for example `frontend webserver *:80` instead
51 /// of a bind line, any optional config for the bind follows
52 header_addr: Option<(AddressRef<'input>, Option<&'input str>)>,
53 },
54 Backend {
55 /// Comment on the same line as the section header
56 comment: Option<&'input str>,
57 /// The proxy stated after the section header
58 proxy: &'input str,
59 /// [`Lines`](borrowed::Line) in this section.
60 lines: Vec<borrowed::Line<'input>>,
61 },
62 Userlist {
63 /// Comment on the same line as the section header
64 comment: Option<&'input str>,
65 /// Name of this userlist
66 name: &'input str,
67 /// [`Lines`](borrowed::Line) in this section.
68 lines: Vec<borrowed::Line<'input>>,
69 },
70 UnknownLine {
71 /// A line that could not be parsed.
72 line: &'input str,
73 },
74}