zino_http/timing/
server_timing.rsuse super::TimingMetric;
use smallvec::SmallVec;
use std::fmt;
#[derive(Debug, Clone)]
pub struct ServerTiming {
metrics: SmallVec<[TimingMetric; 4]>,
}
impl ServerTiming {
#[inline]
pub fn new() -> Self {
Self {
metrics: SmallVec::new(),
}
}
#[inline]
pub fn push(&mut self, metric: TimingMetric) {
self.metrics.push(metric);
}
}
impl Default for ServerTiming {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for ServerTiming {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let output = self
.metrics
.iter()
.map(|metric| metric.to_string())
.collect::<Vec<_>>()
.join(", ");
write!(f, "{output}")
}
}