pub type ValidatedLogline<'a> = Logline<'a, Validated>;Expand description
The validated raw log line
All fields are &str slices into the original log line.
On construction it checks if the line can be parsed. This is useful if you cannot skip the comment lines or have reason to not trust the input for format correctness. The latter should be only an issue if you do not use this crate on CloudFront logs directly.
§Panics
Technically the construction should never panic, because the input is validated before the line is sliced into fields. The fields are only view into the original full log line, no parsing errors can occur.
§Examples
Use .try_from() or .try_into() to construct an instance, since action can fail.
use cloudfront_logs::{borrowed::raw::ValidatedLogline, types::*};
let line = "2019-12-04 21:02:31 LAX1 392 192.0.2.100 GET d111111abcdef8.cloudfront.net /index.html 200 - Mozilla/5.0%20(Windows%20NT%2010.0;%20Win64;%20x64)%20AppleWebKit/537.36%20(KHTML,%20like%20Gecko)%20Chrome/78.0.3904.108%20Safari/537.36 - - Hit SOX4xwn4XV6Q4rgb7XiVGOHms_BGlTAC4KyHmureZmBNrjGdRLiNIQ== d111111abcdef8.cloudfront.net https 23 0.001 - TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 Hit HTTP/2.0 - - 11040 0.001 Hit text/html 78 - -";
let item = ValidatedLogline::try_from(line).unwrap();
// alternative:
let item: ValidatedLogline<'_> = line.try_into().unwrap();
assert_eq!(item.date, "2019-12-04");
assert_eq!(item.sc_bytes, "392");
assert_eq!(item.c_ip, "192.0.2.100");Aliased Type§
pub struct ValidatedLogline<'a> {Show 33 fields
pub date: &'a str,
pub time: &'a str,
pub x_edge_location: &'a str,
pub sc_bytes: &'a str,
pub c_ip: &'a str,
pub cs_method: &'a str,
pub cs_host: &'a str,
pub cs_uri_stem: &'a str,
pub sc_status: &'a str,
pub cs_referer: &'a str,
pub cs_user_agent: &'a str,
pub cs_uri_query: &'a str,
pub cs_cookie: &'a str,
pub x_edge_result_type: &'a str,
pub x_edge_request_id: &'a str,
pub x_host_header: &'a str,
pub cs_protocol: &'a str,
pub cs_bytes: &'a str,
pub time_taken: &'a str,
pub x_forwarded_for: &'a str,
pub ssl_protocol: &'a str,
pub ssl_cipher: &'a str,
pub x_edge_response_result_type: &'a str,
pub cs_protocol_version: &'a str,
pub fle_status: &'a str,
pub fle_encrypted_fields: &'a str,
pub c_port: &'a str,
pub time_to_first_byte: &'a str,
pub x_edge_detailed_result_type: &'a str,
pub sc_content_type: &'a str,
pub sc_content_len: &'a str,
pub sc_range_start: &'a str,
pub sc_range_end: &'a str,
/* private fields */
}Fields§
§date: &'a str§time: &'a str§x_edge_location: &'a str§sc_bytes: &'a str§c_ip: &'a str§cs_method: &'a str§cs_host: &'a str§cs_uri_stem: &'a str§sc_status: &'a str§cs_referer: &'a str§cs_user_agent: &'a str§cs_uri_query: &'a str§x_edge_result_type: &'a str§x_edge_request_id: &'a str§x_host_header: &'a str§cs_protocol: &'a str§cs_bytes: &'a str§time_taken: &'a str§x_forwarded_for: &'a str§ssl_protocol: &'a str§ssl_cipher: &'a str§x_edge_response_result_type: &'a str§cs_protocol_version: &'a str§fle_status: &'a str§fle_encrypted_fields: &'a str§c_port: &'a str§time_to_first_byte: &'a str§x_edge_detailed_result_type: &'a str§sc_content_type: &'a str§sc_content_len: &'a str§sc_range_start: &'a str§sc_range_end: &'a str