Skip to main content

ergo_runtime/common/
effect.rs

1use serde::{Deserialize, Serialize};
2
3use super::Value;
4
5/// A single write effect: resolved key name + value.
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub struct EffectWrite {
8    pub key: String,
9    pub value: Value,
10}
11
12/// A single intent field: resolved field name + typed value.
13#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
14pub struct IntentField {
15    pub name: String,
16    pub value: Value,
17}
18
19/// An external intent record emitted by an action.
20#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
21pub struct IntentRecord {
22    pub kind: String,
23    pub intent_id: String,
24    pub fields: Vec<IntentField>,
25}
26
27/// An action effect containing a kind and write operations.
28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
29pub struct ActionEffect {
30    pub kind: String,
31    pub writes: Vec<EffectWrite>,
32    /// Optional intent records attached to this effect.
33    ///
34    /// `#[serde(default)]` is intentional: captures created before
35    /// intent support was added will not have this field.  Deserializing
36    /// those captures must produce an empty vec rather than a parse error
37    /// to maintain backward compatibility with existing capture bundles.
38    #[serde(default, skip_serializing_if = "Vec::is_empty")]
39    pub intents: Vec<IntentRecord>,
40}