#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub struct ResponseMeta<'a> {
pub sent_us: u64,
pub received_us: u64,
pub date: Option<&'a str>,
pub etag: Option<&'a str>,
pub last_modified: Option<&'a str>,
pub final_url: Option<&'a str>,
}
impl<'a> ResponseMeta<'a> {
#[must_use]
pub fn new(sent_us: u64, received_us: u64) -> Self {
Self {
sent_us,
received_us,
date: None,
etag: None,
last_modified: None,
final_url: None,
}
}
#[must_use]
pub fn at(now_us: u64) -> Self {
Self::new(now_us, now_us)
}
#[must_use]
pub fn with_date(mut self, date: &'a str) -> Self {
self.date = Some(date);
self
}
#[must_use]
pub fn with_etag(mut self, etag: &'a str) -> Self {
self.etag = Some(etag);
self
}
#[must_use]
pub fn with_last_modified(mut self, last_modified: &'a str) -> Self {
self.last_modified = Some(last_modified);
self
}
#[must_use]
pub fn with_final_url(mut self, final_url: &'a str) -> Self {
self.final_url = Some(final_url);
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub struct UtcResponse<'a> {
pub sent_us: u64,
pub received_us: u64,
pub date: Option<&'a str>,
pub body: &'a [u8],
}
impl<'a> UtcResponse<'a> {
#[must_use]
pub fn new(sent_us: u64, received_us: u64, body: &'a [u8]) -> Self {
Self {
sent_us,
received_us,
date: None,
body,
}
}
#[must_use]
pub fn with_date(mut self, date: &'a str) -> Self {
self.date = Some(date);
self
}
}