cloudfront_logs/raw/view/
checked.rs1use crate::shared::*;
2
3#[derive(Debug)]
12pub struct LogLineView<'a> {
13 line: &'a str,
14}
15
16impl<'a> LogLineView<'a> {
17 pub fn new(line: &'a str) -> Result<Self, &'static str> {
23 validate_line(line)?;
24
25 Ok(LogLineView { line })
26 }
27
28 #[inline]
29 fn field(&self, index: usize) -> &'a str {
30 split(self.line).nth(index).unwrap()
31 }
32
33 pub fn date(&self) -> &'a str {
39 self.field(0)
40 }
41
42 pub fn time(&self) -> &'a str {
43 self.field(1)
44 }
45
46 pub fn x_edge_location(&self) -> &'a str {
47 self.field(2)
48 }
49
50 pub fn sc_bytes(&self) -> &'a str {
51 self.field(3)
52 }
53
54 pub fn c_ip(&self) -> &'a str {
55 self.field(4)
56 }
57
58 pub fn cs_method(&self) -> &'a str {
59 self.field(5)
60 }
61
62 pub fn cs_host(&self) -> &'a str {
63 self.field(6)
64 }
65
66 pub fn cs_uri_stem(&self) -> &'a str {
67 self.field(7)
68 }
69
70 pub fn sc_status(&self) -> &'a str {
71 self.field(8)
72 }
73
74 pub fn cs_referer(&self) -> &'a str {
75 self.field(9)
76 }
77
78 pub fn cs_user_agent(&self) -> &'a str {
79 self.field(10)
80 }
81
82 pub fn cs_uri_query(&self) -> &'a str {
83 self.field(11)
84 }
85
86 pub fn cs_cookie(&self) -> &'a str {
87 self.field(12)
88 }
89
90 pub fn x_edge_result_type(&self) -> &'a str {
91 self.field(13)
92 }
93
94 pub fn x_edge_request_id(&self) -> &'a str {
95 self.field(14)
96 }
97
98 pub fn x_host_header(&self) -> &'a str {
99 self.field(15)
100 }
101
102 pub fn cs_protocol(&self) -> &'a str {
103 self.field(16)
104 }
105
106 pub fn cs_bytes(&self) -> &'a str {
107 self.field(17)
108 }
109
110 pub fn time_taken(&self) -> &'a str {
111 self.field(18)
112 }
113
114 pub fn x_forwarded_for(&self) -> &'a str {
115 self.field(19)
116 }
117
118 pub fn ssl_protocol(&self) -> &'a str {
119 self.field(20)
120 }
121
122 pub fn ssl_cipher(&self) -> &'a str {
123 self.field(21)
124 }
125
126 pub fn x_edge_response_result_type(&self) -> &'a str {
127 self.field(22)
128 }
129
130 pub fn cs_protocol_version(&self) -> &'a str {
131 self.field(23)
132 }
133
134 pub fn fle_status(&self) -> &'a str {
135 self.field(24)
136 }
137
138 pub fn fle_encrypted_fields(&self) -> &'a str {
139 self.field(25)
140 }
141
142 pub fn c_port(&self) -> &'a str {
143 self.field(26)
144 }
145
146 pub fn time_to_first_byte(&self) -> &'a str {
147 self.field(27)
148 }
149
150 pub fn x_edge_detailed_result_type(&self) -> &'a str {
151 self.field(28)
152 }
153
154 pub fn sc_content_type(&self) -> &'a str {
155 self.field(29)
156 }
157
158 pub fn sc_content_len(&self) -> &'a str {
159 self.field(30)
160 }
161
162 pub fn sc_range_start(&self) -> &'a str {
163 self.field(31)
164 }
165
166 pub fn sc_range_end(&self) -> &'a str {
167 self.field(32)
168 }
169}