Skip to main content

butterflow_models/
strategy.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4use ts_rs::TS;
5/// Type of strategy
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema, TS)]
7#[serde(rename_all = "lowercase")]
8pub enum StrategyType {
9    /// Matrix strategy (run multiple instances with different inputs)
10    Matrix,
11}
12
13/// Represents a strategy configuration
14#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, TS)]
15pub struct Strategy {
16    /// Type of strategy
17    pub r#type: StrategyType,
18
19    /// Matrix values (for matrix strategy)
20    #[serde(default)]
21    #[ts(optional, as = "Option<Vec<HashMap<String, serde_json::Value>>>")]
22    pub values: Option<Vec<HashMap<String, serde_json::Value>>>,
23
24    /// State key to get matrix values from (for matrix strategy)
25    #[serde(default)]
26    #[ts(optional=nullable)]
27    pub from_state: Option<String>,
28}