1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#[cfg(not(feature = "with_serde"))]
use alloc::vec::Vec;
#[cfg(not(feature = "with_serde"))]
use binary_sv2::binary_codec_sv2::{self, free_vec, free_vec_2, CVec, CVec2};
use binary_sv2::{Deserialize, Serialize};
use binary_sv2::{Error, Seq064K, Str0255, B016M, B064K};
use core::convert::TryInto;
#[derive(Serialize, Deserialize, Debug, Clone)]
#[repr(C)]
pub struct RequestTransactionData {
pub template_id: u64,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RequestTransactionDataSuccess<'decoder> {
pub template_id: u64,
#[cfg_attr(feature = "with_serde", serde(borrow))]
pub excess_data: B064K<'decoder>,
#[cfg_attr(feature = "with_serde", serde(borrow))]
pub transaction_list: Seq064K<'decoder, B016M<'decoder>>,
}
#[repr(C)]
#[cfg(not(feature = "with_serde"))]
pub struct CRequestTransactionDataSuccess {
template_id: u64,
excess_data: CVec,
transaction_list: CVec2,
}
impl<'a> CRequestTransactionDataSuccess {
#[cfg(not(feature = "with_serde"))]
pub fn to_rust_rep_mut(&'a mut self) -> Result<RequestTransactionDataSuccess<'a>, Error> {
let excess_data: B064K = self.excess_data.as_mut_slice().try_into()?;
let transaction_list_ = self.transaction_list.as_mut_slice();
let mut transaction_list: Vec<B016M> = Vec::new();
for cvec in transaction_list_ {
transaction_list.push(cvec.as_mut_slice().try_into()?);
}
let transaction_list = Seq064K::new(transaction_list)?;
Ok(RequestTransactionDataSuccess {
template_id: self.template_id,
excess_data,
transaction_list,
})
}
}
#[no_mangle]
#[cfg(not(feature = "with_serde"))]
pub extern "C" fn free_request_tx_data_success(s: CRequestTransactionDataSuccess) {
drop(s)
}
#[cfg(not(feature = "with_serde"))]
impl Drop for CRequestTransactionDataSuccess {
fn drop(&mut self) {
free_vec(&mut self.excess_data);
free_vec_2(&mut self.transaction_list);
}
}
#[cfg(not(feature = "with_serde"))]
impl<'a> From<RequestTransactionDataSuccess<'a>> for CRequestTransactionDataSuccess {
fn from(v: RequestTransactionDataSuccess<'a>) -> Self {
Self {
template_id: v.template_id,
excess_data: v.excess_data.into(),
transaction_list: v.transaction_list.into(),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RequestTransactionDataError<'decoder> {
pub template_id: u64,
#[cfg_attr(feature = "with_serde", serde(borrow))]
pub error_code: Str0255<'decoder>,
}
#[repr(C)]
#[cfg(not(feature = "with_serde"))]
pub struct CRequestTransactionDataError {
template_id: u64,
error_code: CVec,
}
impl<'a> CRequestTransactionDataError {
#[cfg(not(feature = "with_serde"))]
pub fn to_rust_rep_mut(&'a mut self) -> Result<RequestTransactionDataError<'a>, Error> {
let error_code: Str0255 = self.error_code.as_mut_slice().try_into()?;
Ok(RequestTransactionDataError {
template_id: self.template_id,
error_code,
})
}
}
#[no_mangle]
#[cfg(not(feature = "with_serde"))]
pub extern "C" fn free_request_tx_data_error(s: CRequestTransactionDataError) {
drop(s)
}
#[cfg(not(feature = "with_serde"))]
impl Drop for CRequestTransactionDataError {
fn drop(&mut self) {
free_vec(&mut self.error_code);
}
}
#[cfg(not(feature = "with_serde"))]
impl<'a> From<RequestTransactionDataError<'a>> for CRequestTransactionDataError {
fn from(v: RequestTransactionDataError<'a>) -> Self {
Self {
template_id: v.template_id,
error_code: v.error_code.into(),
}
}
}