penumbra_sdk_transaction/plan/
detection_data.rs1use crate::DetectionData;
2
3use super::CluePlan;
4use penumbra_sdk_proto::{core::transaction::v1 as pb, DomainType};
5use serde::{Deserialize, Serialize};
6
7#[derive(Clone, Debug, Default, Serialize, Deserialize)]
8#[serde(try_from = "pb::DetectionDataPlan", into = "pb::DetectionDataPlan")]
9pub struct DetectionDataPlan {
10 pub clue_plans: Vec<CluePlan>,
11}
12
13impl DetectionDataPlan {
14 pub fn detection_data(&self) -> DetectionData {
15 DetectionData {
16 fmd_clues: self.clue_plans.iter().map(|x| x.clue()).collect::<Vec<_>>(),
17 }
18 }
19}
20
21impl TryFrom<pb::DetectionDataPlan> for DetectionDataPlan {
22 type Error = anyhow::Error;
23 fn try_from(value: pb::DetectionDataPlan) -> Result<Self, Self::Error> {
24 Ok(Self {
25 clue_plans: value
26 .clue_plans
27 .into_iter()
28 .map(TryInto::try_into)
29 .collect::<Result<_, _>>()?,
30 })
31 }
32}
33
34impl From<DetectionDataPlan> for pb::DetectionDataPlan {
35 fn from(msg: DetectionDataPlan) -> Self {
36 Self {
37 clue_plans: msg.clue_plans.into_iter().map(Into::into).collect(),
38 }
39 }
40}
41
42impl DomainType for DetectionDataPlan {
43 type Proto = pb::DetectionDataPlan;
44}