use serde::Serialize;
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AgentOptions {
#[serde(skip_serializing_if = "Option::is_none")]
pub key: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub disabled: Option<bool>,
}
impl AgentOptions {
pub fn with_key(key: impl Into<String>) -> Self {
Self {
key: Some(key.into()),
disabled: None,
}
}
pub fn disabled() -> Self {
Self {
key: None,
disabled: Some(true),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Source {
pub url: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub agent: Option<AgentOptions>,
}
impl Source {
pub fn new(url: impl Into<String>) -> Self {
Self {
url: url.into(),
agent: None,
}
}
pub fn with_agent(mut self, agent: AgentOptions) -> Self {
self.agent = Some(agent);
self
}
}