rust: add type aliases for certain ffi types

This commit is contained in:
Alex Beregszaszi 2019-07-03 16:34:23 +01:00
parent 48f1903d9c
commit c9ce3a10d4
2 changed files with 39 additions and 0 deletions

View File

@ -9,9 +9,11 @@
//! This crate documents how to use certain data types.
mod container;
mod types;
pub use container::EvmcContainer;
pub use evmc_sys as ffi;
pub use types::*;
pub trait EvmcVm {
fn init() -> Self;

View File

@ -0,0 +1,37 @@
use evmc_sys as ffi;
/// EVMC address
pub type Address = ffi::evmc_address;
/// EVMC 32 bytes value (used for hashes)
pub type Bytes32 = ffi::evmc_bytes32;
/// EVMC big-endian 256-bit integer
pub type Uint256 = ffi::evmc_uint256be;
#[cfg(test)]
mod tests {
use super::*;
// These tests check for Default, PartialEq and Clone traits.
#[test]
fn address_smoke_test() {
let a = ffi::evmc_address::default();
let b = Address::default();
assert_eq!(a.clone(), b.clone());
}
#[test]
fn bytes32_smoke_test() {
let a = ffi::evmc_bytes32::default();
let b = Bytes32::default();
assert_eq!(a.clone(), b.clone());
}
#[test]
fn uint26be_smoke_test() {
let a = ffi::evmc_uint256be::default();
let b = Uint256::default();
assert_eq!(a.clone(), b.clone());
}
}