use std::time::Duration;
use crate::response::Version;
#[derive(Clone, Debug, Default, Eq, PartialEq)]
pub struct Metrics {
dns_duration: Option<Duration>,
connect_duration: Option<Duration>,
tls_duration: Option<Duration>,
request_write_duration: Option<Duration>,
ttfb: Option<Duration>,
download_duration: Option<Duration>,
reused_connection: bool,
protocol: Option<Version>,
}
impl Metrics {
pub fn dns_duration(&self) -> Option<Duration> {
self.dns_duration
}
pub fn connect_duration(&self) -> Option<Duration> {
self.connect_duration
}
pub fn tls_duration(&self) -> Option<Duration> {
self.tls_duration
}
pub fn request_write_duration(&self) -> Option<Duration> {
self.request_write_duration
}
pub fn ttfb(&self) -> Option<Duration> {
self.ttfb
}
pub fn download_duration(&self) -> Option<Duration> {
self.download_duration
}
pub fn reused_connection(&self) -> bool {
self.reused_connection
}
pub fn protocol(&self) -> Option<Version> {
self.protocol
}
pub(crate) fn with_dns_duration(mut self, value: Option<Duration>) -> Self {
self.dns_duration = value;
self
}
pub(crate) fn with_connect_duration(mut self, value: Option<Duration>) -> Self {
self.connect_duration = value;
self
}
pub(crate) fn with_tls_duration(mut self, value: Option<Duration>) -> Self {
self.tls_duration = value;
self
}
pub(crate) fn with_request_write_duration(mut self, value: Option<Duration>) -> Self {
self.request_write_duration = value;
self
}
pub(crate) fn with_ttfb(mut self, value: Option<Duration>) -> Self {
self.ttfb = value;
self
}
pub(crate) fn with_download_duration(mut self, value: Option<Duration>) -> Self {
self.download_duration = value;
self
}
pub(crate) fn with_reused_connection(mut self, value: bool) -> Self {
self.reused_connection = value;
self
}
pub(crate) fn with_protocol(mut self, value: Version) -> Self {
self.protocol = Some(value);
self
}
}