use futures::Future;
use {ErrorCode, IndyError};
use std::ffi::CString;
use utils::callbacks::{ClosureHandler, ResultHandler};
use ffi::cache;
use ffi::{ResponseEmptyCB, ResponseStringCB};
use {WalletHandle, CommandHandle, PoolHandle};
pub fn get_schema(pool_handle: PoolHandle,
wallet_handle: WalletHandle,
submitter_did: &str,
id: &str,
options_json: &str) -> Box<Future<Item=String, Error=IndyError>> {
let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
let err = _get_schema(command_handle, pool_handle, wallet_handle, submitter_did, id, options_json, cb);
ResultHandler::str(command_handle, err, receiver)
}
pub fn _get_schema(command_handle: CommandHandle,
pool_handle: PoolHandle,
wallet_handle: WalletHandle,
submitter_did: &str,
id: &str,
options_json: &str,
cb: Option<ResponseStringCB>) -> ErrorCode {
let submitter_did = c_str!(submitter_did);
let id = c_str!(id);
let options_json = c_str!(options_json);
ErrorCode::from(
unsafe {
cache::indy_get_schema(command_handle, pool_handle, wallet_handle, submitter_did.as_ptr(), id.as_ptr(), options_json.as_ptr(), cb)
}
)
}
pub fn get_cred_def(pool_handle: PoolHandle,
wallet_handle: WalletHandle,
submitter_did: &str,
id: &str,
options_json: &str) -> Box<Future<Item=String, Error=IndyError>> {
let (receiver, command_handle, cb) = ClosureHandler::cb_ec_string();
let err = _get_cred_def(command_handle, pool_handle, wallet_handle, submitter_did, id, options_json, cb);
ResultHandler::str(command_handle, err, receiver)
}
pub fn _get_cred_def(command_handle: CommandHandle,
pool_handle: PoolHandle,
wallet_handle: WalletHandle,
submitter_did: &str,
id: &str,
options_json: &str,
cb: Option<ResponseStringCB>) -> ErrorCode {
let submitter_did = c_str!(submitter_did);
let id = c_str!(id);
let options_json = c_str!(options_json);
ErrorCode::from(
unsafe {
cache::indy_get_cred_def(command_handle, pool_handle, wallet_handle, submitter_did.as_ptr(), id.as_ptr(), options_json.as_ptr(), cb)
}
)
}
pub fn purge_schema_cache(wallet_handle: WalletHandle, options_json: &str) -> Box<Future<Item=(), Error=IndyError>> {
let (receiver, command_handle, cb) = ClosureHandler::cb_ec();
let err = _purge_schema_cache(command_handle, wallet_handle, options_json, cb);
ResultHandler::empty(command_handle, err, receiver)
}
fn _purge_schema_cache(command_handle: CommandHandle, wallet_handle: WalletHandle, options_json: &str, cb: Option<ResponseEmptyCB>) -> ErrorCode {
let options_json = c_str!(options_json);
ErrorCode::from(unsafe { cache::indy_purge_schema_cache(command_handle, wallet_handle, options_json.as_ptr(), cb) })
}
pub fn purge_cred_def_cache(wallet_handle: WalletHandle, options_json: &str) -> Box<Future<Item=(), Error=IndyError>> {
let (receiver, command_handle, cb) = ClosureHandler::cb_ec();
let err = _purge_cred_def_cache(command_handle, wallet_handle, options_json, cb);
ResultHandler::empty(command_handle, err, receiver)
}
fn _purge_cred_def_cache(command_handle: CommandHandle, wallet_handle: WalletHandle, options_json: &str, cb: Option<ResponseEmptyCB>) -> ErrorCode {
let options_json = c_str!(options_json);
ErrorCode::from(unsafe { cache::indy_purge_cred_def_cache(command_handle, wallet_handle, options_json.as_ptr(), cb) })
}