rust_libindy_wrapper/
anoncreds.rs

1use {ErrorCode, IndyHandle};
2
3use std::ffi::CString;
4use std::time::Duration;
5use std::ptr::null;
6
7use utils::callbacks::ClosureHandler;
8use utils::results::ResultHandler;
9
10use native::anoncreds;
11use native::{ResponseStringStringCB,
12          ResponseI32UsizeCB,
13          ResponseStringStringStringCB,
14          ResponseStringCB,
15          ResponseI32CB,
16          ResponseEmptyCB,
17          ResponseBoolCB};
18
19pub struct Issuer {}
20
21impl Issuer {
22    pub fn create_schema(issuer_did: &str, name: &str, version: &str, attrs: &str) -> Result<(String, String), ErrorCode> {
23        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string();
24
25        let err = Issuer::_create_schema(command_handle, issuer_did, name, version, attrs, cb);
26
27        ResultHandler::two(err, receiver)
28    }
29
30    /// * `timeout` - the maximum time this function waits for a response
31    pub fn create_schema_timeout(issuer_did: &str, name: &str, version: &str, attrs: &str, timeout: Duration) -> Result<(String, String), ErrorCode> {
32        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string();
33
34        let err = Issuer::_create_schema(command_handle, issuer_did, name, version, attrs, cb);
35
36        ResultHandler::two_timeout(err, receiver, timeout)
37    }
38
39    /// * `closure` - the closure that is called when finished
40    ///
41    /// # Returns
42    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
43    pub fn create_schema_async<F: 'static>(issuer_did: &str, name: &str, version: &str, attrs: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String, String) + Send {
44        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string_string(Box::new(closure));
45
46        Issuer::_create_schema(command_handle, issuer_did, name, version, attrs, cb)
47    }
48
49    fn _create_schema(command_handle: IndyHandle, issuer_did: &str, name: &str, version: &str, attrs: &str, cb: Option<ResponseStringStringCB>) -> ErrorCode {
50        let issuer_did = c_str!(issuer_did);
51        let name = c_str!(name);
52        let version = c_str!(version);
53        let attrs = c_str!(attrs);
54
55        ErrorCode::from(unsafe {
56          anoncreds::indy_issuer_create_schema(command_handle, issuer_did.as_ptr(), name.as_ptr(), version.as_ptr(), attrs.as_ptr(), cb)
57        })
58    }
59
60    pub fn create_and_store_credential_def(wallet_handle: IndyHandle, issuer_did: &str, schema_json: &str, tag: &str, signature_type: Option<&str>, config_json: &str) -> Result<(String, String), ErrorCode> {
61        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string();
62
63        let err = Issuer::_create_and_store_credential_def(command_handle, wallet_handle, issuer_did, schema_json, tag, signature_type, config_json, cb);
64
65        ResultHandler::two(err, receiver)
66    }
67
68    /// * `timeout` - the maximum time this function waits for a response
69    pub fn create_and_store_credential_def_timeout(wallet_handle: IndyHandle, issuer_did: &str, schema_json: &str, tag: &str, signature_type: Option<&str>, config_json: &str, timeout: Duration) -> Result<(String, String), ErrorCode> {
70        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string();
71
72        let err = Issuer::_create_and_store_credential_def(command_handle, wallet_handle, issuer_did, schema_json, tag, signature_type, config_json, cb);
73
74        ResultHandler::two_timeout(err, receiver, timeout)
75    }
76
77    /// * `closure` - the closure that is called when finished
78    ///
79    /// # Returns
80    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
81    pub fn create_and_store_credential_def_async<F: 'static>(wallet_handle: IndyHandle, issuer_did: &str, schema_json: &str, tag: &str, signature_type: Option<&str>, config_json: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String, String) + Send {
82        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string_string(Box::new(closure));
83
84        Issuer::_create_and_store_credential_def(command_handle, wallet_handle, issuer_did, schema_json, tag, signature_type, config_json, cb)
85    }
86
87    fn _create_and_store_credential_def(command_handle: IndyHandle, wallet_handle: IndyHandle, issuer_did: &str, schema_json: &str, tag: &str, signature_type: Option<&str>, config_json: &str, cb: Option<ResponseStringStringCB>) -> ErrorCode {
88        let issuer_did = c_str!(issuer_did);
89        let schema_json = c_str!(schema_json);
90        let tag = c_str!(tag);
91        let signature_type_str = opt_c_str!(signature_type);
92        let config_json = c_str!(config_json);
93
94        ErrorCode::from(unsafe {
95          anoncreds::indy_issuer_create_and_store_credential_def(command_handle, wallet_handle, issuer_did.as_ptr(), schema_json.as_ptr(), tag.as_ptr(), opt_c_ptr!(signature_type, signature_type_str), config_json.as_ptr(), cb)
96        })
97    }
98
99    pub fn create_and_store_revoc_reg(wallet_handle: IndyHandle, issuer_did: &str, revoc_def_type: Option<&str>, tag: &str, cred_def_id: &str, config_json: &str, tails_writer_handle: IndyHandle) -> Result<(String, String, String), ErrorCode> {
100        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string_string();
101
102        let err = Issuer::_create_and_store_revoc_reg(command_handle, wallet_handle, issuer_did, revoc_def_type, tag, cred_def_id, config_json, tails_writer_handle, cb);
103
104        ResultHandler::three(err, receiver)
105    }
106
107    /// * `timeout` - the maximum time this function waits for a response
108    pub fn create_and_store_revoc_reg_timeout(wallet_handle: IndyHandle, issuer_did: &str, revoc_def_type: Option<&str>, tag: &str, cred_def_id: &str, config_json: &str, tails_writer_handle: IndyHandle, timeout: Duration) -> Result<(String, String, String), ErrorCode> {
109        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string_string();
110
111        let err = Issuer::_create_and_store_revoc_reg(command_handle, wallet_handle, issuer_did, revoc_def_type, tag, cred_def_id, config_json, tails_writer_handle, cb);
112
113        ResultHandler::three_timeout(err, receiver, timeout)
114    }
115
116    /// * `closure` - the closure that is called when finished
117    ///
118    /// # Returns
119    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
120    pub fn create_and_store_revoc_reg_async<F: 'static>(wallet_handle: IndyHandle, issuer_did: &str, revoc_def_type: Option<&str>, tag: &str, cred_def_id: &str, config_json: &str, tails_writer_handle: IndyHandle, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String, String, String) + Send {
121        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string_string_string(Box::new(closure));
122
123        Issuer::_create_and_store_revoc_reg(command_handle, wallet_handle, issuer_did, revoc_def_type, tag, cred_def_id, config_json, tails_writer_handle, cb)
124    }
125
126    fn _create_and_store_revoc_reg(command_handle: IndyHandle, wallet_handle: IndyHandle, issuer_did: &str, revoc_def_type: Option<&str>, tag: &str, cred_def_id: &str, config_json: &str, tails_writer_handle: IndyHandle, cb: Option<ResponseStringStringStringCB>) -> ErrorCode {
127        let issuer_did = c_str!(issuer_did);
128        let revoc_def_type_str = opt_c_str!(revoc_def_type);
129        let tag = c_str!(tag);
130        let cred_def_id = c_str!(cred_def_id);
131        let config_json = c_str!(config_json);
132
133        ErrorCode::from(unsafe {
134          anoncreds::indy_issuer_create_and_store_revoc_reg(command_handle, wallet_handle, issuer_did.as_ptr(), opt_c_ptr!(revoc_def_type, revoc_def_type_str), tag.as_ptr(), cred_def_id.as_ptr(), config_json.as_ptr(), tails_writer_handle, cb)
135        })
136    }
137
138    pub fn create_credential_offer(wallet_handle: IndyHandle, cred_def_id: &str) -> Result<String, ErrorCode> {
139        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
140
141        let err = Issuer::_create_credential_offer(command_handle, wallet_handle, cred_def_id, cb);
142
143        ResultHandler::one(err, receiver)
144    }
145
146    /// * `timeout` - the maximum time this function waits for a response
147    pub fn create_credential_offer_timeout(wallet_handle: IndyHandle, cred_def_id: &str, timeout: Duration) -> Result<String, ErrorCode> {
148        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
149
150        let err = Issuer::_create_credential_offer(command_handle, wallet_handle, cred_def_id, cb);
151
152        ResultHandler::one_timeout(err, receiver, timeout)
153    }
154
155    /// * `closure` - the closure that is called when finished
156    ///
157    /// # Returns
158    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
159    pub fn create_credential_offer_async<F: 'static>(wallet_handle: IndyHandle, cred_def_id: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
160        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
161
162        Issuer::_create_credential_offer(command_handle, wallet_handle, cred_def_id, cb)
163    }
164
165    fn _create_credential_offer(command_handle: IndyHandle, wallet_handle: IndyHandle, cred_def_id: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
166        let cred_def_id = c_str!(cred_def_id);
167
168        ErrorCode::from(unsafe {
169          anoncreds::indy_issuer_create_credential_offer(command_handle, wallet_handle, cred_def_id.as_ptr(), cb)
170        })
171    }
172
173    pub fn create_credential(wallet_handle: IndyHandle, cred_offer_json: &str, cred_req_json: &str, cred_values_json: &str, rev_reg_id: Option<&str>, blob_storage_reader_handle: IndyHandle) -> Result<(String, Option<String>, Option<String>), ErrorCode> {
174        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_opt_string_opt_string();
175
176        let err = Issuer::_create_credential(command_handle, wallet_handle, cred_offer_json, cred_req_json, cred_values_json, rev_reg_id, blob_storage_reader_handle, cb);
177
178        ResultHandler::three(err, receiver)
179    }
180
181    /// * `timeout` - the maximum time this function waits for a response
182    pub fn create_credential_timeout(wallet_handle: IndyHandle, cred_offer_json: &str, cred_req_json: &str, cred_values_json: &str, rev_reg_id: Option<&str>, blob_storage_reader_handle: IndyHandle, timeout: Duration) -> Result<(String, Option<String>, Option<String>), ErrorCode> {
183        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_opt_string_opt_string();
184
185        let err = Issuer::_create_credential(command_handle, wallet_handle, cred_offer_json, cred_req_json, cred_values_json, rev_reg_id, blob_storage_reader_handle, cb);
186
187        ResultHandler::three_timeout(err, receiver, timeout)
188    }
189
190    /// * `closure` - the closure that is called when finished
191    ///
192    /// # Returns
193    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
194    pub fn create_credential_async<F: 'static>(wallet_handle: IndyHandle, cred_offer_json: &str, cred_req_json: &str, cred_values_json: &str, rev_reg_id: Option<&str>, blob_storage_reader_handle: IndyHandle, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String, Option<String>, Option<String>) + Send {
195        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string_opt_string_opt_string(Box::new(closure));
196
197        Issuer::_create_credential(command_handle, wallet_handle, cred_offer_json, cred_req_json, cred_values_json, rev_reg_id, blob_storage_reader_handle, cb)
198    }
199
200    fn _create_credential(command_handle: IndyHandle, wallet_handle: IndyHandle, cred_offer_json: &str, cred_req_json: &str, cred_values_json: &str, rev_reg_id: Option<&str>, blob_storage_reader_handle: IndyHandle, cb: Option<ResponseStringStringStringCB>) -> ErrorCode {
201        let cred_offer_json = c_str!(cred_offer_json);
202        let cred_req_json = c_str!(cred_req_json);
203        let cred_values_json = c_str!(cred_values_json);
204        let rev_reg_id_str = opt_c_str!(rev_reg_id);
205
206        ErrorCode::from(unsafe {
207          anoncreds::indy_issuer_create_credential(command_handle, wallet_handle, cred_offer_json.as_ptr(), cred_req_json.as_ptr(), cred_values_json.as_ptr(), opt_c_ptr!(rev_reg_id, rev_reg_id_str), blob_storage_reader_handle, cb)
208        })
209    }
210
211    pub fn revoke_credential(wallet_handle: IndyHandle, blob_storage_reader_cfg_handle: IndyHandle, rev_reg_id: &str, cred_revoc_id: &str) -> Result<String, ErrorCode> {
212        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
213
214        let err = Issuer::_revoke_credential(command_handle, wallet_handle, blob_storage_reader_cfg_handle, rev_reg_id, cred_revoc_id, cb);
215
216        ResultHandler::one(err, receiver)
217    }
218
219    /// * `timeout` - the maximum time this function waits for a response
220    pub fn revoke_credential_timeout(wallet_handle: IndyHandle, blob_storage_reader_cfg_handle: IndyHandle, rev_reg_id: &str, cred_revoc_id: &str, timeout: Duration) -> Result<String, ErrorCode> {
221        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
222
223        let err = Issuer::_revoke_credential(command_handle, wallet_handle, blob_storage_reader_cfg_handle, rev_reg_id, cred_revoc_id, cb);
224
225        ResultHandler::one_timeout(err, receiver, timeout)
226    }
227
228    /// * `closure` - the closure that is called when finished
229    ///
230    /// # Returns
231    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
232    pub fn revoke_credential_async<F: 'static>(wallet_handle: IndyHandle, blob_storage_reader_cfg_handle: IndyHandle, rev_reg_id: &str, cred_revoc_id: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
233        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
234
235        Issuer::_revoke_credential(command_handle, wallet_handle, blob_storage_reader_cfg_handle, rev_reg_id, cred_revoc_id, cb)
236    }
237
238    fn _revoke_credential(command_handle: IndyHandle, wallet_handle: IndyHandle, blob_storage_reader_cfg_handle: IndyHandle, rev_reg_id: &str, cred_revoc_id: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
239        let rev_reg_id = c_str!(rev_reg_id);
240        let cred_revoc_id = c_str!(cred_revoc_id);
241
242        ErrorCode::from(unsafe {
243          anoncreds::indy_issuer_revoke_credential(command_handle, wallet_handle, blob_storage_reader_cfg_handle, rev_reg_id.as_ptr(), cred_revoc_id.as_ptr(), cb)
244        })
245    }
246
247    pub fn merge_revocation_registry_deltas(rev_reg_delta_json: &str, other_rev_reg_delta_json: &str) -> Result<String, ErrorCode> {
248        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
249
250        let err = Issuer::_merge_revocation_registry_deltas(command_handle, rev_reg_delta_json, other_rev_reg_delta_json, cb);
251
252        ResultHandler::one(err, receiver)
253    }
254
255    /// * `timeout` - the maximum time this function waits for a response
256    pub fn merge_revocation_registry_deltas_timeout(rev_reg_delta_json: &str, other_rev_reg_delta_json: &str, timeout: Duration) -> Result<String, ErrorCode> {
257        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
258
259        let err = Issuer::_merge_revocation_registry_deltas(command_handle, rev_reg_delta_json, other_rev_reg_delta_json, cb);
260
261        ResultHandler::one_timeout(err, receiver, timeout)
262    }
263
264    /// * `closure` - the closure that is called when finished
265    ///
266    /// # Returns
267    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
268    pub fn merge_revocation_registry_deltas_async<F: 'static>(rev_reg_delta_json: &str, other_rev_reg_delta_json: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
269        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
270
271        Issuer::_merge_revocation_registry_deltas(command_handle, rev_reg_delta_json, other_rev_reg_delta_json, cb)
272    }
273
274    fn _merge_revocation_registry_deltas(command_handle: IndyHandle, rev_reg_delta_json: &str, other_rev_reg_delta_json: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
275        let rev_reg_delta_json = c_str!(rev_reg_delta_json);
276        let other_rev_reg_delta_json = c_str!(other_rev_reg_delta_json);
277
278        ErrorCode::from(unsafe {
279          anoncreds::indy_issuer_merge_revocation_registry_deltas(command_handle, rev_reg_delta_json.as_ptr(), other_rev_reg_delta_json.as_ptr(), cb)
280        })
281    }
282}
283
284pub struct Prover {}
285
286impl Prover {
287    pub fn create_master_secret(wallet_handle: IndyHandle, master_secret_id: Option<&str>) -> Result<String, ErrorCode> {
288        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
289
290        let err = Prover::_create_master_secret(command_handle, wallet_handle, master_secret_id, cb);
291
292        ResultHandler::one(err, receiver)
293    }
294
295    /// * `timeout` - the maximum time this function waits for a response
296    pub fn create_master_secret_timeout(wallet_handle: IndyHandle, master_secret_id: Option<&str>, timeout: Duration) -> Result<String, ErrorCode> {
297        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
298
299        let err = Prover::_create_master_secret(command_handle, wallet_handle, master_secret_id, cb);
300
301        ResultHandler::one_timeout(err, receiver, timeout)
302    }
303
304    /// * `closure` - the closure that is called when finished
305    ///
306    /// # Returns
307    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
308    pub fn create_master_secret_async<F: 'static>(wallet_handle: IndyHandle, master_secret_id: Option<&str>, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
309        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
310
311        Prover::_create_master_secret(command_handle, wallet_handle, master_secret_id, cb)
312    }
313
314    fn _create_master_secret(command_handle: IndyHandle, wallet_handle: IndyHandle, master_secret_id: Option<&str>, cb: Option<ResponseStringCB>) -> ErrorCode {
315        let master_secret_id_str = opt_c_str!(master_secret_id);
316
317        ErrorCode::from(unsafe {
318          anoncreds::indy_prover_create_master_secret(command_handle, wallet_handle, opt_c_ptr!(master_secret_id, master_secret_id_str), cb)
319        })
320    }
321
322    pub fn get_credential(wallet_handle: IndyHandle, cred_id: &str) -> Result<String, ErrorCode> {
323        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
324
325        let err = Prover::_get_credential(command_handle, wallet_handle, cred_id, cb);
326
327        ResultHandler::one(err, receiver)
328    }
329
330    /// * `timeout` - the maximum time this function waits for a response
331    pub fn get_credential_timeout(wallet_handle: IndyHandle, cred_id: &str, timeout: Duration) -> Result<String, ErrorCode> {
332        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
333
334        let err = Prover::_get_credential(command_handle, wallet_handle, cred_id, cb);
335
336        ResultHandler::one_timeout(err, receiver, timeout)
337    }
338
339    /// * `closure` - the closure that is called when finished
340    ///
341    /// # Returns
342    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
343    pub fn get_credential_async<F: 'static>(wallet_handle: IndyHandle, cred_id: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
344        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
345
346        Prover::_get_credential(command_handle, wallet_handle, cred_id, cb)
347    }
348
349    fn _get_credential(command_handle: IndyHandle, wallet_handle: IndyHandle, cred_id: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
350        let cred_id = c_str!(cred_id);
351
352        ErrorCode::from(unsafe {
353          anoncreds::indy_prover_get_credential(command_handle, wallet_handle, cred_id.as_ptr(), cb)
354        })
355    }
356
357    pub fn create_credential_req(wallet_handle: IndyHandle, prover_did: &str, cred_offer_json: &str, cred_def_json: &str, master_secret_id: &str) -> Result<(String, String), ErrorCode> {
358        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string();
359
360        let err = Prover::_create_credential_req(command_handle, wallet_handle, prover_did, cred_offer_json, cred_def_json, master_secret_id, cb);
361
362        ResultHandler::two(err, receiver)
363    }
364
365    /// * `timeout` - the maximum time this function waits for a response
366    pub fn create_credential_req_timeout(wallet_handle: IndyHandle, prover_did: &str, cred_offer_json: &str, cred_def_json: &str, master_secret_id: &str, timeout: Duration) -> Result<(String, String), ErrorCode> {
367        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string_string();
368
369        let err = Prover::_create_credential_req(command_handle, wallet_handle, prover_did, cred_offer_json, cred_def_json, master_secret_id, cb);
370
371        ResultHandler::two_timeout(err, receiver, timeout)
372    }
373
374    /// * `closure` - the closure that is called when finished
375    ///
376    /// # Returns
377    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
378    pub fn create_credential_req_async<F: 'static>(wallet_handle: IndyHandle, prover_did: &str, cred_offer_json: &str, cred_def_json: &str, master_secret_id: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String, String) + Send {
379        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string_string(Box::new(closure));
380
381        Prover::_create_credential_req(command_handle, wallet_handle, prover_did, cred_offer_json, cred_def_json, master_secret_id, cb)
382    }
383
384    fn _create_credential_req(command_handle: IndyHandle, wallet_handle: IndyHandle, prover_did: &str, cred_offer_json: &str, cred_def_json: &str, master_secret_id: &str, cb: Option<ResponseStringStringCB>) -> ErrorCode {
385        let prover_did = c_str!(prover_did);
386        let cred_offer_json = c_str!(cred_offer_json);
387        let cred_def_json = c_str!(cred_def_json);
388        let master_secret_id = c_str!(master_secret_id);
389
390        ErrorCode::from(unsafe {
391          anoncreds::indy_prover_create_credential_req(command_handle, wallet_handle, prover_did.as_ptr(), cred_offer_json.as_ptr(), cred_def_json.as_ptr(), master_secret_id.as_ptr(), cb)
392        })
393    }
394
395    pub fn store_credential(wallet_handle: IndyHandle, cred_id: Option<&str>, cred_req_metadata_json: &str, cred_json: &str, cred_def_json: &str, rev_reg_def_json: Option<&str>) -> Result<String, ErrorCode> {
396        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
397
398        let err = Prover::_store_credential(command_handle, wallet_handle, cred_id, cred_req_metadata_json, cred_json, cred_def_json, rev_reg_def_json, cb);
399
400        ResultHandler::one(err, receiver)
401    }
402
403    /// * `timeout` - the maximum time this function waits for a response
404    pub fn store_credential_timeout(wallet_handle: IndyHandle, cred_id: Option<&str>, cred_req_metadata_json: &str, cred_json: &str, cred_def_json: &str, rev_reg_def_json: Option<&str>, timeout: Duration) -> Result<String, ErrorCode> {
405        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
406
407        let err = Prover::_store_credential(command_handle, wallet_handle, cred_id, cred_req_metadata_json, cred_json, cred_def_json, rev_reg_def_json, cb);
408
409        ResultHandler::one_timeout(err, receiver, timeout)
410    }
411
412    /// * `closure` - the closure that is called when finished
413    ///
414    /// # Returns
415    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
416    pub fn store_credential_async<F: 'static>(wallet_handle: IndyHandle, cred_id: Option<&str>, cred_req_metadata_json: &str, cred_json: &str, cred_def_json: &str, rev_reg_def_json: Option<&str>, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
417        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
418
419        Prover::_store_credential(command_handle, wallet_handle, cred_id, cred_req_metadata_json, cred_json, cred_def_json, rev_reg_def_json, cb)
420    }
421
422    fn _store_credential(command_handle: IndyHandle, wallet_handle: IndyHandle, cred_id: Option<&str>, cred_req_metadata_json: &str, cred_json: &str, cred_def_json: &str, rev_reg_def_json: Option<&str>, cb: Option<ResponseStringCB>) -> ErrorCode {
423        let cred_id_str = opt_c_str!(cred_id);
424        let cred_req_metadata_json = c_str!(cred_req_metadata_json);
425        let cred_json = c_str!(cred_json);
426        let cred_def_json = c_str!(cred_def_json);
427        let rev_reg_def_json_str = opt_c_str!(rev_reg_def_json);
428
429        ErrorCode::from(unsafe {
430          anoncreds::indy_prover_store_credential(command_handle, wallet_handle, opt_c_ptr!(cred_id, cred_id_str), cred_req_metadata_json.as_ptr(), cred_json.as_ptr(), cred_def_json.as_ptr(), opt_c_ptr!(rev_reg_def_json, rev_reg_def_json_str), cb)
431        })
432    }
433
434    pub fn get_credentials(wallet_handle: IndyHandle, filter_json: Option<&str>) -> Result<String, ErrorCode> {
435        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
436
437        let err = Prover::_get_credentials(command_handle, wallet_handle, filter_json, cb);
438
439        ResultHandler::one(err, receiver)
440    }
441
442    /// * `timeout` - the maximum time this function waits for a response
443    pub fn get_credentials_timeout(wallet_handle: IndyHandle, filter_json: Option<&str>, timeout: Duration) -> Result<String, ErrorCode> {
444        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
445
446        let err = Prover::_get_credentials(command_handle, wallet_handle, filter_json, cb);
447
448        ResultHandler::one_timeout(err, receiver, timeout)
449    }
450
451    /// * `closure` - the closure that is called when finished
452    ///
453    /// # Returns
454    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
455    pub fn get_credentials_async<F: 'static>(wallet_handle: IndyHandle, filter_json: Option<&str>, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
456        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
457
458        Prover::_get_credentials(command_handle, wallet_handle, filter_json, cb)
459    }
460
461    fn _get_credentials(command_handle: IndyHandle, wallet_handle: IndyHandle, filter_json: Option<&str>, cb: Option<ResponseStringCB>) -> ErrorCode {
462        let filter_json_str = opt_c_str!(filter_json);
463
464        ErrorCode::from(unsafe {
465          anoncreds::indy_prover_get_credentials(command_handle, wallet_handle, opt_c_ptr!(filter_json, filter_json_str), cb)
466        })
467    }
468
469    pub fn search_credentials(wallet_handle: IndyHandle, query_json: Option<&str>) -> Result<(i32, usize), ErrorCode> {
470        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_i32_usize();
471
472        let err = Prover::_search_credentials(command_handle, wallet_handle, query_json, cb);
473
474        ResultHandler::two(err, receiver)
475    }
476
477    /// * `timeout` - the maximum time this function waits for a response
478    pub fn search_credentials_timeout(wallet_handle: IndyHandle, query_json: Option<&str>, timeout: Duration) -> Result<(i32, usize), ErrorCode> {
479        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_i32_usize();
480
481        let err = Prover::_search_credentials(command_handle, wallet_handle, query_json, cb);
482
483        ResultHandler::two_timeout(err, receiver, timeout)
484    }
485
486    /// * `closure` - the closure that is called when finished
487    ///
488    /// # Returns
489    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
490    pub fn search_credentials_async<F: 'static>(wallet_handle: IndyHandle, query_json: Option<&str>, closure: F) -> ErrorCode where F: FnMut(ErrorCode, i32, usize) + Send {
491        let (command_handle, cb) = ClosureHandler::convert_cb_ec_i32_usize(Box::new(closure));
492
493        Prover::_search_credentials(command_handle, wallet_handle, query_json, cb)
494    }
495
496    fn _search_credentials(command_handle: IndyHandle, wallet_handle: IndyHandle, query_json: Option<&str>, cb: Option<ResponseI32UsizeCB>) -> ErrorCode {
497        let query_json_str = opt_c_str!(query_json);
498
499        ErrorCode::from(unsafe {
500          anoncreds::indy_prover_search_credentials(command_handle, wallet_handle, opt_c_ptr!(query_json, query_json_str), cb)
501        })
502    }
503
504    pub fn fetch_credentials(search_handle: IndyHandle, count: usize) -> Result<String, ErrorCode> {
505        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
506
507        let err = Prover::_fetch_credentials(command_handle, search_handle, count, cb);
508
509        ResultHandler::one(err, receiver)
510    }
511
512    /// * `timeout` - the maximum time this function waits for a response
513    pub fn fetch_credentials_timeout(search_handle: IndyHandle, count: usize, timeout: Duration) -> Result<String, ErrorCode> {
514        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
515
516        let err = Prover::_fetch_credentials(command_handle, search_handle, count, cb);
517
518        ResultHandler::one_timeout(err, receiver, timeout)
519    }
520
521    /// * `closure` - the closure that is called when finished
522    ///
523    /// # Returns
524    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
525    pub fn fetch_credentials_async<F: 'static>(search_handle: IndyHandle, count: usize, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
526        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
527
528        Prover::_fetch_credentials(command_handle, search_handle, count, cb)
529    }
530
531    fn _fetch_credentials(command_handle: IndyHandle, search_handle: IndyHandle, count: usize, cb: Option<ResponseStringCB>) -> ErrorCode {
532
533        ErrorCode::from(unsafe {
534          anoncreds::indy_prover_fetch_credentials(command_handle, search_handle, count, cb)
535        })
536    }
537
538    pub fn close_credentials_search(search_handle: IndyHandle) -> Result<(), ErrorCode> {
539        let (receiver, command_handle, cb) = ClosureHandler::cb_ec();
540
541        let err = Prover::_close_credentials_search(command_handle, search_handle, cb);
542
543        ResultHandler::empty(err, receiver)
544    }
545
546    /// * `timeout` - the maximum time this function waits for a response
547    pub fn close_credentials_search_timeout(search_handle: IndyHandle, timeout: Duration) -> Result<(), ErrorCode> {
548        let (receiver, command_handle, cb) = ClosureHandler::cb_ec();
549
550        let err = Prover::_close_credentials_search(command_handle, search_handle, cb);
551
552        ResultHandler::empty_timeout(err, receiver, timeout)
553    }
554
555    /// * `closure` - the closure that is called when finished
556    ///
557    /// # Returns
558    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
559    pub fn close_credentials_search_async<F: 'static>(search_handle: IndyHandle, closure: F) -> ErrorCode where F: FnMut(ErrorCode) + Send {
560        let (command_handle, cb) = ClosureHandler::convert_cb_ec(Box::new(closure));
561
562        Prover::_close_credentials_search(command_handle, search_handle, cb)
563    }
564
565    fn _close_credentials_search(command_handle: IndyHandle, search_handle: IndyHandle, cb: Option<ResponseEmptyCB>) -> ErrorCode {
566
567        ErrorCode::from(unsafe {
568          anoncreds::indy_prover_close_credentials_search(command_handle, search_handle, cb)
569        })
570    }
571
572    pub fn get_credentials_for_proof_req(wallet_handle: IndyHandle, proof_request_json: &str) -> Result<String, ErrorCode> {
573        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
574
575        let err = Prover::_get_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json, cb);
576
577        ResultHandler::one(err, receiver)
578    }
579
580    /// * `timeout` - the maximum time this function waits for a response
581    pub fn get_credentials_for_proof_req_timeout(wallet_handle: IndyHandle, proof_request_json: &str, timeout: Duration) -> Result<String, ErrorCode> {
582        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
583
584        let err = Prover::_get_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json, cb);
585
586        ResultHandler::one_timeout(err, receiver, timeout)
587    }
588
589    /// * `closure` - the closure that is called when finished
590    ///
591    /// # Returns
592    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
593    pub fn get_credentials_for_proof_req_async<F: 'static>(wallet_handle: IndyHandle, proof_request_json: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
594        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
595
596        Prover::_get_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json, cb)
597    }
598
599    fn _get_credentials_for_proof_req(command_handle: IndyHandle, wallet_handle: IndyHandle, proof_request_json: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
600        let proof_request_json = c_str!(proof_request_json);
601
602        ErrorCode::from(unsafe {
603          anoncreds::indy_prover_get_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json.as_ptr(), cb)
604        })
605    }
606
607    pub fn search_credentials_for_proof_req(wallet_handle: IndyHandle, proof_request_json: &str, extra_query_json: Option<&str>) -> Result<i32, ErrorCode> {
608        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_i32();
609
610        let err = Prover::_search_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json, extra_query_json, cb);
611
612        ResultHandler::one(err, receiver)
613    }
614
615    /// * `timeout` - the maximum time this function waits for a response
616    pub fn search_credentials_for_proof_req_timeout(wallet_handle: IndyHandle, proof_request_json: &str, extra_query_json: Option<&str>, timeout: Duration) -> Result<i32, ErrorCode> {
617        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_i32();
618
619        let err = Prover::_search_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json, extra_query_json, cb);
620
621        ResultHandler::one_timeout(err, receiver, timeout)
622    }
623
624    /// * `closure` - the closure that is called when finished
625    ///
626    /// # Returns
627    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
628    pub fn search_credentials_for_proof_req_async<F: 'static>(wallet_handle: IndyHandle, proof_request_json: &str, extra_query_json: Option<&str>, closure: F) -> ErrorCode where F: FnMut(ErrorCode, i32) + Send {
629        let (command_handle, cb) = ClosureHandler::convert_cb_ec_i32(Box::new(closure));
630
631        Prover::_search_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json, extra_query_json, cb)
632    }
633
634    fn _search_credentials_for_proof_req(command_handle: IndyHandle, wallet_handle: IndyHandle, proof_request_json: &str, extra_query_json: Option<&str>, cb: Option<ResponseI32CB>) -> ErrorCode {
635        let proof_request_json = c_str!(proof_request_json);
636        let extra_query_json_str = opt_c_str!(extra_query_json);
637
638        ErrorCode::from(unsafe {
639          anoncreds::indy_prover_search_credentials_for_proof_req(command_handle, wallet_handle, proof_request_json.as_ptr(), opt_c_ptr!(extra_query_json, extra_query_json_str), cb)
640        })
641    }
642
643    pub fn _fetch_credentials_for_proof_req(search_handle: IndyHandle, item_referent: &str, count: usize) -> Result<String, ErrorCode> {
644        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
645
646        let err = Prover::__fetch_credentials_for_proof_req(command_handle, search_handle, item_referent, count, cb);
647
648        ResultHandler::one(err, receiver)
649    }
650
651    /// * `timeout` - the maximum time this function waits for a response
652    pub fn _fetch_credentials_for_proof_req_timeout(search_handle: IndyHandle, item_referent: &str, count: usize, timeout: Duration) -> Result<String, ErrorCode> {
653        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
654
655        let err = Prover::__fetch_credentials_for_proof_req(command_handle, search_handle, item_referent, count, cb);
656
657        ResultHandler::one_timeout(err, receiver, timeout)
658    }
659
660    /// * `closure` - the closure that is called when finished
661    ///
662    /// # Returns
663    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
664    pub fn _fetch_credentials_for_proof_req_async<F: 'static>(search_handle: IndyHandle, item_referent: &str, count: usize, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
665        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
666
667        Prover::__fetch_credentials_for_proof_req(command_handle, search_handle, item_referent, count, cb)
668    }
669
670    fn __fetch_credentials_for_proof_req(command_handle: IndyHandle, search_handle: IndyHandle, item_referent: &str, count: usize, cb: Option<ResponseStringCB>) -> ErrorCode {
671        let item_referent = c_str!(item_referent);
672
673        ErrorCode::from(unsafe {
674          anoncreds::indy_prover_fetch_credentials_for_proof_req(command_handle, search_handle, item_referent.as_ptr(), count, cb)
675        })
676    }
677
678    pub fn _close_credentials_search_for_proof_req(search_handle: IndyHandle) -> Result<(), ErrorCode> {
679        let (receiver, command_handle, cb) = ClosureHandler::cb_ec();
680
681        let err = Prover::__close_credentials_search_for_proof_req(command_handle, search_handle, cb);
682
683        ResultHandler::empty(err, receiver)
684    }
685
686    /// * `timeout` - the maximum time this function waits for a response
687    pub fn _close_credentials_search_for_proof_req_timeout(search_handle: IndyHandle, timeout: Duration) -> Result<(), ErrorCode> {
688        let (receiver, command_handle, cb) = ClosureHandler::cb_ec();
689
690        let err = Prover::__close_credentials_search_for_proof_req(command_handle, search_handle, cb);
691
692        ResultHandler::empty_timeout(err, receiver, timeout)
693    }
694
695    /// * `closure` - the closure that is called when finished
696    ///
697    /// # Returns
698    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
699    pub fn _close_credentials_search_for_proof_req_async<F: 'static>(search_handle: IndyHandle, closure: F) -> ErrorCode where F: FnMut(ErrorCode) + Send {
700        let (command_handle, cb) = ClosureHandler::convert_cb_ec(Box::new(closure));
701
702        Prover::__close_credentials_search_for_proof_req(command_handle, search_handle, cb)
703    }
704
705    fn __close_credentials_search_for_proof_req(command_handle: IndyHandle, search_handle: IndyHandle, cb: Option<ResponseEmptyCB>) -> ErrorCode {
706
707        ErrorCode::from(unsafe {
708          anoncreds::indy_prover_close_credentials_search_for_proof_req(command_handle, search_handle, cb)
709        })
710    }
711
712    pub fn create_proof(wallet_handle: IndyHandle, proof_req_json: &str, requested_credentials_json: &str, master_secret_id: &str, schemas_json: &str, credential_defs_json: &str, rev_states_json: &str) -> Result<String, ErrorCode> {
713        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
714
715        let err = Prover::_create_proof(command_handle, wallet_handle, proof_req_json, requested_credentials_json, master_secret_id, schemas_json, credential_defs_json, rev_states_json, cb);
716
717        ResultHandler::one(err, receiver)
718    }
719
720    /// * `timeout` - the maximum time this function waits for a response
721    pub fn create_proof_timeout(wallet_handle: IndyHandle, proof_req_json: &str, requested_credentials_json: &str, master_secret_id: &str, schemas_json: &str, credential_defs_json: &str, rev_states_json: &str, timeout: Duration) -> Result<String, ErrorCode> {
722        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
723
724        let err = Prover::_create_proof(command_handle, wallet_handle, proof_req_json, requested_credentials_json, master_secret_id, schemas_json, credential_defs_json, rev_states_json, cb);
725
726        ResultHandler::one_timeout(err, receiver, timeout)
727    }
728
729    /// * `closure` - the closure that is called when finished
730    ///
731    /// # Returns
732    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
733    pub fn create_proof_async<F: 'static>(wallet_handle: IndyHandle, proof_req_json: &str, requested_credentials_json: &str, master_secret_id: &str, schemas_json: &str, credential_defs_json: &str, rev_states_json: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
734        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
735
736        Prover::_create_proof(command_handle, wallet_handle, proof_req_json, requested_credentials_json, master_secret_id, schemas_json, credential_defs_json, rev_states_json, cb)
737    }
738
739    fn _create_proof(command_handle: IndyHandle, wallet_handle: IndyHandle, proof_req_json: &str, requested_credentials_json: &str, master_secret_id: &str, schemas_json: &str, credential_defs_json: &str, rev_states_json: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
740        let proof_req_json = c_str!(proof_req_json);
741        let requested_credentials_json = c_str!(requested_credentials_json);
742        let master_secret_id = c_str!(master_secret_id);
743        let schemas_json = c_str!(schemas_json);
744        let credential_defs_json = c_str!(credential_defs_json);
745        let rev_states_json = c_str!(rev_states_json);
746
747        ErrorCode::from(unsafe {
748          anoncreds::indy_prover_create_proof(command_handle, wallet_handle, proof_req_json.as_ptr(), requested_credentials_json.as_ptr(), master_secret_id.as_ptr(), schemas_json.as_ptr(), credential_defs_json.as_ptr(), rev_states_json.as_ptr(), cb)
749        })
750    }
751}
752
753pub struct Verifier {}
754
755impl Verifier {
756    pub fn verify_proof(proof_request_json: &str, proof_json: &str, schemas_json: &str, credential_defs_json: &str, rev_reg_defs_json: &str, rev_regs_json: &str) -> Result<bool, ErrorCode> {
757        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_bool();
758
759        let err = Verifier::_verify_proof(command_handle, proof_request_json, proof_json, schemas_json, credential_defs_json, rev_reg_defs_json, rev_regs_json, cb);
760
761        ResultHandler::one(err, receiver)
762    }
763
764    /// * `timeout` - the maximum time this function waits for a response
765    pub fn verify_proof_timeout(proof_request_json: &str, proof_json: &str, schemas_json: &str, credential_defs_json: &str, rev_reg_defs_json: &str, rev_regs_json: &str, timeout: Duration) -> Result<bool, ErrorCode> {
766        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_bool();
767
768        let err = Verifier::_verify_proof(command_handle, proof_request_json, proof_json, schemas_json, credential_defs_json, rev_reg_defs_json, rev_regs_json, cb);
769
770        ResultHandler::one_timeout(err, receiver, timeout)
771    }
772
773    /// * `closure` - the closure that is called when finished
774    ///
775    /// # Returns
776    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
777    pub fn verify_proof_async<F: 'static>(proof_request_json: &str, proof_json: &str, schemas_json: &str, credential_defs_json: &str, rev_reg_defs_json: &str, rev_regs_json: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, bool) + Send {
778        let (command_handle, cb) = ClosureHandler::convert_cb_ec_bool(Box::new(closure));
779
780        Verifier::_verify_proof(command_handle, proof_request_json, proof_json, schemas_json, credential_defs_json, rev_reg_defs_json, rev_regs_json, cb)
781    }
782
783    fn _verify_proof(command_handle: IndyHandle, proof_request_json: &str, proof_json: &str, schemas_json: &str, credential_defs_json: &str, rev_reg_defs_json: &str, rev_regs_json: &str, cb: Option<ResponseBoolCB>) -> ErrorCode {
784        let proof_request_json = c_str!(proof_request_json);
785        let proof_json = c_str!(proof_json);
786        let schemas_json = c_str!(schemas_json);
787        let credential_defs_json = c_str!(credential_defs_json);
788        let rev_reg_defs_json = c_str!(rev_reg_defs_json);
789        let rev_regs_json = c_str!(rev_regs_json);
790
791        ErrorCode::from(unsafe {
792            anoncreds::indy_verifier_verify_proof(command_handle, proof_request_json.as_ptr(), proof_json.as_ptr(), schemas_json.as_ptr(), credential_defs_json.as_ptr(), rev_reg_defs_json.as_ptr(), rev_regs_json.as_ptr(), cb)
793        })
794    }
795}
796
797pub struct AnonCreds {}
798
799impl AnonCreds {
800    pub fn create_revocation_state(blob_storage_reader_handle: IndyHandle, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str) -> Result<String, ErrorCode> {
801        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
802
803        let err = AnonCreds::_create_revocation_state(command_handle, blob_storage_reader_handle, rev_reg_def_json, rev_reg_delta_json, timestamp, cred_rev_id, cb);
804
805        ResultHandler::one(err, receiver)
806    }
807
808    /// * `timeout` - the maximum time this function waits for a response
809    pub fn create_revocation_state_timeout(blob_storage_reader_handle: IndyHandle, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str, timeout: Duration) -> Result<String, ErrorCode> {
810        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
811
812        let err = AnonCreds::_create_revocation_state(command_handle, blob_storage_reader_handle, rev_reg_def_json, rev_reg_delta_json, timestamp, cred_rev_id, cb);
813
814        ResultHandler::one_timeout(err, receiver, timeout)
815    }
816
817    /// * `closure` - the closure that is called when finished
818    ///
819    /// # Returns
820    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
821    pub fn create_revocation_state_async<F: 'static>(blob_storage_reader_handle: IndyHandle, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
822        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
823
824        AnonCreds::_create_revocation_state(command_handle, blob_storage_reader_handle, rev_reg_def_json, rev_reg_delta_json, timestamp, cred_rev_id, cb)
825    }
826
827    fn _create_revocation_state(command_handle: IndyHandle, blob_storage_reader_handle: IndyHandle, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
828        let rev_reg_def_json = c_str!(rev_reg_def_json);
829        let rev_reg_delta_json = c_str!(rev_reg_delta_json);
830        let cred_rev_id = c_str!(cred_rev_id);
831
832        ErrorCode::from(unsafe {
833          anoncreds::indy_create_revocation_state(command_handle, blob_storage_reader_handle, rev_reg_def_json.as_ptr(), rev_reg_delta_json.as_ptr(), timestamp, cred_rev_id.as_ptr(), cb)
834        })
835    }
836
837    pub fn update_revocation_state(blob_storage_reader_handle: IndyHandle, rev_state_json: &str, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str) -> Result<String, ErrorCode> {
838        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
839
840        let err = AnonCreds::_update_revocation_state(command_handle, blob_storage_reader_handle, rev_state_json, rev_reg_def_json, rev_reg_delta_json, timestamp, cred_rev_id, cb);
841
842        ResultHandler::one(err, receiver)
843    }
844
845    /// * `timeout` - the maximum time this function waits for a response
846    pub fn update_revocation_state_timeout(blob_storage_reader_handle: IndyHandle, rev_state_json: &str, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str, timeout: Duration) -> Result<String, ErrorCode> {
847        let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
848
849        let err = AnonCreds::_update_revocation_state(command_handle, blob_storage_reader_handle, rev_state_json, rev_reg_def_json, rev_reg_delta_json, timestamp, cred_rev_id, cb);
850
851        ResultHandler::one_timeout(err, receiver, timeout)
852    }
853
854    /// * `closure` - the closure that is called when finished
855    ///
856    /// # Returns
857    /// * `errorcode` - errorcode from calling ffi function. The closure receives the return result
858    pub fn update_revocation_state_async<F: 'static>(blob_storage_reader_handle: IndyHandle, rev_state_json: &str, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str, closure: F) -> ErrorCode where F: FnMut(ErrorCode, String) + Send {
859        let (command_handle, cb) = ClosureHandler::convert_cb_ec_string(Box::new(closure));
860
861        AnonCreds::_update_revocation_state(command_handle, blob_storage_reader_handle, rev_state_json, rev_reg_def_json, rev_reg_delta_json, timestamp, cred_rev_id, cb)
862    }
863
864    fn _update_revocation_state(command_handle: IndyHandle, blob_storage_reader_handle: IndyHandle, rev_state_json: &str, rev_reg_def_json: &str, rev_reg_delta_json: &str, timestamp: u64, cred_rev_id: &str, cb: Option<ResponseStringCB>) -> ErrorCode {
865        let rev_state_json = c_str!(rev_state_json);
866        let rev_reg_def_json = c_str!(rev_reg_def_json);
867        let rev_reg_delta_json = c_str!(rev_reg_delta_json);
868        let cred_rev_id = c_str!(cred_rev_id);
869
870        ErrorCode::from(unsafe {
871          anoncreds::indy_update_revocation_state(command_handle, blob_storage_reader_handle, rev_state_json.as_ptr(), rev_reg_def_json.as_ptr(), rev_reg_delta_json.as_ptr(), timestamp, cred_rev_id.as_ptr(), cb)
872        })
873    }
874}