Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

* Added basic Wallet API stubs #8

Merged
merged 1 commit into from
Mar 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod anoncreds;
pub mod sovrin;
pub mod sovrin;
pub mod wallet;
73 changes: 73 additions & 0 deletions src/api/wallet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use commands::{Command, CommandExecutor};
use errors::wallet::WalletError;

use std::sync::Arc;

pub struct WalletAPI {
command_executor: Arc<CommandExecutor>,
}

impl WalletAPI {
/// Constructs a new `WalletAPI`.
///
/// #Params
/// command_executor: Reference to `CommandExecutor` instance.
///
pub fn new(command_executor: Arc<CommandExecutor>) -> WalletAPI {
WalletAPI { command_executor: command_executor }
}

/// Set or update Wallet record identified by keys list.
///
/// #Params
/// keys: List of keys that identify Wallet record.
/// value: Wallet record value to set or update.
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// No result
///
/// #Errors
/// No method specific errors.
/// See `WallerError` docs for common errors description.
pub fn set(keys: &[&str], value: &str, cb: Box<Fn(Result<(), WalletError>) + Send>) {
unimplemented!();
}

/// Get Wallet record identified by keys list.
///
/// #Params
/// keys: List of keys that identify Wallet record.
/// cb: Callback that takes command result as parameter.
///
/// #Returns
/// Value of corresponded Wallet record.
///
/// #Errors
/// WalletError::NotFound - If no corresponded Wallet record found.
/// See `WallerError` docs for common errors description.
pub fn get(keys: &[&str], cb: Box<Fn(Result<String, WalletError>) + Send>) {
unimplemented!();
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn wallet_api_can_be_created() {
let sovrin_api = WalletAPI::new(Arc::new(CommandExecutor::new()));
assert! (true, "No crashes on WalletAPI::new");
}

#[test]
fn wallet_api_can_be_dropped() {
fn drop_test() {
let sovrin_api = WalletAPI::new(Arc::new(CommandExecutor::new()));
}

drop_test();
assert! (true, "No crashes on WalletAPI::drop");
}
}