use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ObjectiveContext {
pub as_of: DateTime<Utc>,
pub max_candidates: Option<usize>,
pub min_score: Option<f64>,
#[serde(default)]
pub extra: serde_json::Value,
}
impl ObjectiveContext {
pub fn new() -> Self {
Self {
as_of: Utc::now(),
..Default::default()
}
}
pub fn at(time: DateTime<Utc>) -> Self {
Self {
as_of: time,
..Default::default()
}
}
pub fn with_max_candidates(mut self, n: usize) -> Self {
self.max_candidates = Some(n);
self
}
pub fn with_min_score(mut self, score: f64) -> Self {
self.min_score = Some(score);
self
}
pub fn with_extra(mut self, extra: serde_json::Value) -> Self {
self.extra = extra;
self
}
}