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