use crate::intent_graph::Meta;
#[derive(Debug, Default)]
pub struct MetaBuilder {
confidence: Option<f64>,
source: Option<String>,
timestamp: Option<String>,
agent_id: Option<String>,
}
impl MetaBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn confidence(mut self, c: f64) -> Self {
self.confidence = Some(c);
self
}
pub fn source(mut self, s: impl Into<String>) -> Self {
self.source = Some(s.into());
self
}
pub fn timestamp(mut self, t: impl Into<String>) -> Self {
self.timestamp = Some(t.into());
self
}
pub fn now(mut self) -> Self {
self.timestamp = Some(chrono::Utc::now().to_rfc3339());
self
}
pub fn agent_id(mut self, a: impl Into<String>) -> Self {
self.agent_id = Some(a.into());
self
}
pub fn build(self) -> Result<Meta, String> {
Ok(Meta {
confidence: self.confidence,
source: self.source.ok_or("source is required")?,
timestamp: self.timestamp.ok_or("timestamp is required")?,
agent_id: self.agent_id,
})
}
}