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