ValidatedTimeLogline

Type Alias ValidatedTimeLogline 

Source
pub type ValidatedTimeLogline<'a> = Logline<'a, Validated>;
Available on crate feature time only.
Expand description

The validated typed log line, using time crate for date and time

Most fields are parsed into more meaningful types.

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

Construction can panic if the input is not a valid log line!

§Examples

Use .try_from() or .try_into() to construct an instance, since action can fail.

use cloudfront_logs::{borrowed::typed::time::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, time::macros::date!(2019 - 12 - 04));
assert_eq!(item.sc_bytes, 392u64);
assert_eq!(item.cs_protocol, CsProtocol::Https);

Aliased Type§

pub struct ValidatedTimeLogline<'a> {
Show 34 fields pub date: Date, pub time: Time, pub datetime: OffsetDateTime, pub x_edge_location: &'a str, pub sc_bytes: u64, pub c_ip: IpAddr, pub cs_method: &'a str, pub cs_host: &'a str, pub cs_uri_stem: &'a str, pub sc_status: u16, pub cs_referer: Option<&'a str>, pub cs_user_agent: &'a str, pub cs_uri_query: Option<&'a str>, pub cs_cookie: Option<&'a str>, pub x_edge_result_type: EdgeResultType, pub x_edge_request_id: &'a str, pub x_host_header: &'a str, pub cs_protocol: CsProtocol, pub cs_bytes: u64, pub time_taken: Duration, pub x_forwarded_for: Option<ForwardedForAddrs>, pub ssl_protocol: Option<SslProtocol>, pub ssl_cipher: Option<&'a str>, pub x_edge_response_result_type: EdgeResultType, pub cs_protocol_version: CsProtocolVersion, pub fle_status: Option<&'a str>, pub fle_encrypted_fields: Option<u64>, pub c_port: u16, pub time_to_first_byte: Duration, pub x_edge_detailed_result_type: DetailedEdgeResultType, pub sc_content_type: Option<&'a str>, pub sc_content_len: Option<u64>, pub sc_range_start: Option<i64>, pub sc_range_end: Option<i64>, /* private fields */
}

Fields§

§date: Date§time: Time§datetime: OffsetDateTime§x_edge_location: &'a str§sc_bytes: u64§c_ip: IpAddr§cs_method: &'a str§cs_host: &'a str§cs_uri_stem: &'a str§sc_status: u16§cs_referer: Option<&'a str>§cs_user_agent: &'a str§cs_uri_query: Option<&'a str>§cs_cookie: Option<&'a str>§x_edge_result_type: EdgeResultType§x_edge_request_id: &'a str§x_host_header: &'a str§cs_protocol: CsProtocol§cs_bytes: u64§time_taken: Duration§x_forwarded_for: Option<ForwardedForAddrs>§ssl_protocol: Option<SslProtocol>§ssl_cipher: Option<&'a str>§x_edge_response_result_type: EdgeResultType§cs_protocol_version: CsProtocolVersion§fle_status: Option<&'a str>§fle_encrypted_fields: Option<u64>§c_port: u16§time_to_first_byte: Duration§x_edge_detailed_result_type: DetailedEdgeResultType§sc_content_type: Option<&'a str>§sc_content_len: Option<u64>§sc_range_start: Option<i64>§sc_range_end: Option<i64>