message: * Added implementation of list handler for inmem wallet
diff: @@ -3,7 +3,7 @@ extern crate time;
  use api::ErrorCode;
  use utils::cstring::CStringUtils;
  -use utils::json::JsonDecodable;
  +use utils::json::{JsonDecodable, JsonEncodable};
  use utils::sequence::SequenceUtils;
  use self::libc::c_char;
  @@ -40,6 +40,19 @@ struct InmemWalletRecord {
  time_created: Timespec
  }
  +#[derive(Debug, Serialize)]
  +pub struct InmemWalletJSONValue {
  + pub key: String,
  + pub value: String
  +}
  +
  +#[derive(Debug, Serialize)]
  +pub struct InmemWalletJSONValues {
  + pub values: Vec<InmemWalletJSONValue>
  +}
  +
  +impl JsonEncodable for InmemWalletJSONValues {}
  +
  lazy_static! {
  static ref INMEM_WALLETS: Mutex<HashMap<String, HashMap<String, InmemWalletRecord>>> = Default::default();
  }
  @@ -73,7 +86,6 @@ impl InmemWallet {
  runtime_config: *const c_char,
  credentials: *const c_char,
  handle: *mut i32) -> ErrorCode {
  -
  check_useful_c_str!(name, ErrorCode::CommonInvalidStructure);
  check_useful_opt_c_str!(config, ErrorCode::CommonInvalidStructure);
  check_useful_opt_c_str!(runtime_config, ErrorCode::CommonInvalidStructure);
  @@ -199,7 +211,40 @@ impl InmemWallet {
  pub extern "C" fn list(xhandle: i32,
  key_prefix: *const c_char,
  values_json_ptr: *mut *const c_char) -> ErrorCode {
  - unimplemented!()
  + check_useful_c_str!(key_prefix, ErrorCode::CommonInvalidStructure);
  +
  + let handles = INMEM_WALLET_HANDLES.lock().unwrap();
  +
  + if !handles.contains_key(&xhandle) {
  + return ErrorCode::CommonInvalidState;
  + }
  +
  + let wallet_context = handles.get(&xhandle).unwrap();
  +
  + let wallets = INMEM_WALLETS.lock().unwrap();
  +
  + if !wallets.contains_key(&wallet_context.name) {
  + return ErrorCode::CommonInvalidState;
  + }
  +
  + let wallet = wallets.get(&wallet_context.name).unwrap();
  +
  +
  + let values = InmemWalletJSONValues {
  + values: wallet
  + .keys()
  + .filter(|&ref key| key.starts_with(&key_prefix))
  + .map(|&ref key| InmemWalletJSONValue {
  + key: key.clone(),
  + value: wallet.get(key).unwrap().value.clone()
  + })
  + .collect()
  + }
  + .to_json()
  + .unwrap();
  +
  + unsafe { *values_json_ptr = CString::new(values.as_str()).unwrap().into_raw(); }
  + ErrorCode::Success
  }
  pub extern "C" fn close(xhandle: i32) -> ErrorCode {
  