khive_fold/objective/
context.rs1use chrono::{DateTime, Utc};
4#[cfg(feature = "serde")]
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Default)]
9#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
10pub struct ObjectiveContext {
11 pub as_of: DateTime<Utc>,
13 pub max_candidates: Option<usize>,
15 pub min_score: Option<f64>,
17 #[cfg_attr(feature = "serde", serde(default))]
19 pub extra: serde_json::Value,
20}
21
22impl ObjectiveContext {
23 pub fn new() -> Self {
25 Self::default()
26 }
27
28 pub fn at(time: DateTime<Utc>) -> Self {
30 Self {
31 as_of: time,
32 ..Default::default()
33 }
34 }
35
36 pub fn with_max_candidates(mut self, n: usize) -> Self {
38 self.max_candidates = Some(n);
39 self
40 }
41
42 pub fn with_min_score(mut self, score: f64) -> Self {
44 self.min_score = Some(score);
45 self
46 }
47
48 pub fn with_extra(mut self, extra: serde_json::Value) -> Self {
50 self.extra = extra;
51 self
52 }
53}