Skip to content

Commit

Permalink
Add is_account_empty as experimental method
Browse files Browse the repository at this point in the history
Mv isAccountEmpty to experimental namespace

Add experimental as a cargo feature

Make experimental native methods private
  • Loading branch information
s1na committed May 28, 2019
1 parent 9cc0d51 commit 3fbd67e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ wee_alloc = "0.4.4"
default = [ "std" ]
std = []
debug = []
experimental = []
18 changes: 18 additions & 0 deletions src/experimental.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! Experimental methods.

use super::*;

mod native {
extern "C" {
pub fn experimental_isAccountEmpty(addressOffset: *const u32) -> u32;
}
}

pub fn is_account_empty(address: &Address) -> bool {
let ret = unsafe { native::experimental_isAccountEmpty(address.bytes.as_ptr() as *const u32) };
if ret != 0 && ret != 1 {
panic!();
}

ret == 1
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub mod debug;
#[cfg(not(feature = "std"))]
pub mod convert;

#[cfg(feature = "experimental")]
pub mod experimental;

#[cfg(feature = "std")]
use std::vec::Vec;

Expand Down

0 comments on commit 3fbd67e

Please sign in to comment.