air_interpreter_interface/
call_request_parameters.rs1use air_interpreter_sede::define_simple_representation;
18use air_interpreter_sede::derive_serialized_type;
19use air_interpreter_sede::Format;
20use air_interpreter_sede::FromSerialized;
21use air_interpreter_sede::MsgPackFormat;
22use air_interpreter_sede::MsgPackMultiformat;
23use air_interpreter_sede::Representation;
24use air_interpreter_value::JValue;
25
26use marine_call_parameters::SecurityTetraplet;
27#[cfg(feature = "marine")]
28use marine_rs_sdk::marine;
29use serde::Deserialize;
30use serde::Serialize;
31
32use std::collections::HashMap;
33use std::rc::Rc;
34
35pub type CallRequests = HashMap<u32, CallRequestParams>;
36
37derive_serialized_type!(SerializedCallArguments);
38derive_serialized_type!(SerializedTetraplets);
39derive_serialized_type!(SerializedCallRequests);
40
41pub type CallArgumentsFormat = MsgPackFormat;
42pub type TetrapletsFormat = MsgPackFormat;
43pub type CallRequestsFormat = MsgPackMultiformat;
44
45define_simple_representation! {
46 CallArgumentsRepr,
47 Vec<JValue>,
48 CallArgumentsFormat,
49 SerializedCallArguments
50}
51
52pub type CallArgumentsDeserializeError = <CallArgumentsRepr as Representation>::DeserializeError;
53
54impl FromSerialized<Vec<serde_json::Value>> for CallArgumentsRepr {
55 fn deserialize(&self, repr: &[u8]) -> Result<Vec<serde_json::Value>, Self::DeserializeError> {
56 Self.get_format().from_slice(repr)
57 }
58}
59
60define_simple_representation! {
61 TetrapletsRepr,
62 Vec<Vec<Rc<SecurityTetraplet>>>,
65 TetrapletsFormat,
66 SerializedTetraplets
67}
68
69pub type TetrapletDeserializeError = <TetrapletsRepr as Representation>::DeserializeError;
70
71define_simple_representation! {
72 CallRequestsRepr,
73 CallRequests,
74 CallRequestsFormat,
75 SerializedCallRequests
76}
77
78pub type CallRequestsDeserializeError = <CallRequestsRepr as Representation>::DeserializeError;
79
80impl FromSerialized<Vec<Vec<SecurityTetraplet>>> for TetrapletsRepr {
81 fn deserialize(
82 &self,
83 repr: &[u8],
84 ) -> Result<Vec<Vec<SecurityTetraplet>>, Self::DeserializeError> {
85 Self.get_format().from_slice(repr)
86 }
87}
88
89#[cfg_attr(feature = "marine", marine)]
92#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
93pub struct CallRequestParams {
94 pub service_id: String,
96
97 pub function_name: String,
99
100 pub arguments: SerializedCallArguments,
102
103 pub tetraplets: SerializedTetraplets,
105}
106
107impl CallRequestParams {
108 pub fn new(
109 service_id: String,
110 function_name: String,
111 arguments: SerializedCallArguments,
112 tetraplets: SerializedTetraplets,
113 ) -> Self {
114 Self {
115 service_id,
116 function_name,
117 arguments,
118 tetraplets,
119 }
120 }
121}