use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ProbeContext {
pub baseline_url: String,
pub probe_url: String,
pub method: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub headers: Option<HeadersBundle>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct ExchangeContext {
pub baseline_status: u16,
pub probe_status: u16,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub headers: Option<HeadersBundle>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub body_samples: Option<BodySamplesBundle>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct HeadersBundle {
pub baseline: BTreeMap<String, String>,
pub probe: BTreeMap<String, String>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct BodySamplesBundle {
pub baseline: String,
pub probe: String,
}
#[cfg(test)]
pub(crate) mod test_helpers {
use super::{ExchangeContext, ProbeContext};
pub(crate) fn probe_ctx(method: &str, baseline: &str, probe: &str) -> ProbeContext {
ProbeContext {
baseline_url: baseline.to_owned(),
probe_url: probe.to_owned(),
method: method.to_owned(),
headers: None,
}
}
pub(crate) fn exchange_ctx(baseline_status: u16, probe_status: u16) -> ExchangeContext {
ExchangeContext {
baseline_status,
probe_status,
headers: None,
body_samples: None,
}
}
}