Skip to content

Commit

Permalink
add Serialize and Deserialize to UnifiedProgramABI
Browse files Browse the repository at this point in the history
  • Loading branch information
hal3e committed Jul 19, 2024
1 parent 38ae82e commit 2501051
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/abi/unified_program.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

use crate::{
Expand All @@ -16,7 +17,8 @@ use crate::{
use super::program::{self, ConcreteTypeId, MessageType, TypeId, Version};

/// 'Unified' versions of the ABI structures removes concrete types and types metadata and unifies them under a single types declarations array.
#[derive(Default, Debug, Clone, Eq, PartialEq)]
#[derive(Default, Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnifiedProgramABI {
pub program_type: String,
pub spec_version: Version,
Expand Down Expand Up @@ -127,7 +129,8 @@ impl UnifiedProgramABI {
}
}

#[derive(Default, Debug, Clone, Eq, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnifiedABIFunction {
pub name: String,
pub inputs: Vec<UnifiedTypeApplication>,
Expand Down Expand Up @@ -187,7 +190,8 @@ impl UnifiedABIFunction {
}
}

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnifiedTypeDeclaration {
pub type_id: usize,
pub type_field: String,
Expand Down Expand Up @@ -241,7 +245,8 @@ impl UnifiedTypeDeclaration {
}
}

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnifiedTypeApplication {
pub type_id: usize,
pub name: String,
Expand Down Expand Up @@ -342,7 +347,8 @@ impl UnifiedTypeApplication {
}
}

#[derive(Default, Debug, Clone, Eq, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnifiedLoggedType {
pub log_id: String,
pub application: UnifiedTypeApplication,
Expand All @@ -364,7 +370,8 @@ impl UnifiedLoggedType {
}
}

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnifiedConfigurable {
pub name: String,
pub application: UnifiedTypeApplication,
Expand All @@ -388,7 +395,8 @@ impl UnifiedConfigurable {
}
}

#[derive(Default, Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UnifiedMessageType {
pub message_id: String,
pub application: UnifiedTypeApplication,
Expand Down

0 comments on commit 2501051

Please sign in to comment.