use chrono::{DateTime, Utc};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ObjectiveContext {
pub as_of: DateTime<Utc>,
pub max_candidates: Option<usize>,
pub min_score: Option<f64>,
#[cfg_attr(feature = "serde", serde(default))]
pub extra: serde_json::Value,
}
impl ObjectiveContext {
pub fn new() -> Self {
Self::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
}
}