UnvalidatedLogline

Type Alias UnvalidatedLogline 

Source
pub type UnvalidatedLogline<'a> = Logline<'a, Unvalidated>;
Expand description

The unvalidated simple log line

Most fields are parsed into more meaningful types. It only uses types available in the standard library.

If you need more specific types, use the typed module.

Unlike ValidatedLogline, this variant does not check if the line can be parsed. Use this if you already did a check before creating this struct. A common scenario is that you 1) trust the input data and 2) skipped the comment lines.

Note: This is the only variant which can use the From trait instead of TryFrom, because validation is skipped and the input data does not need to be parsed into other types.

§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::simple::UnvalidatedLogline, 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 = UnvalidatedLogline::try_from(line).unwrap();
// alternative:
let item: UnvalidatedLogline<'_> = line.try_into().unwrap();

assert_eq!(item.date, "2019-12-04");
assert_eq!(item.sc_bytes, 392u64);
assert_eq!(item.cs_protocol, CsProtocol::Https);

Aliased Type§

pub struct UnvalidatedLogline<'a> {
Show 33 fields pub date: &'a str, pub time: &'a str, 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: &'a str§time: &'a str§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>