Skip to content

Commit e84bca3

Browse files
committed
rust: add type aliases for enums
1 parent 2f7a083 commit e84bca3

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

bindings/rust/evmc-vm/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//! Have a look at evmc-declare to declare an EVMC compatible VM.
99
//! This crate documents how to use certain data types.
1010
11+
#![feature(type_alias_enum_variants)]
12+
1113
mod container;
1214
mod types;
1315

bindings/rust/evmc-vm/src/types.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ pub type Bytes32 = ffi::evmc_bytes32;
99
/// EVMC big-endian 256-bit integer
1010
pub type Uint256 = ffi::evmc_uint256be;
1111

12+
/// EVMC message (call) kind.
13+
pub type MessageKind = ffi::evmc_call_kind;
14+
15+
/// EVMC message (call) flags.
16+
pub type MessageFlags = ffi::evmc_flags;
17+
18+
/// EVMC status code.
19+
pub type StatusCode = ffi::evmc_status_code;
20+
21+
/// EVMC storage status.
22+
pub type StorageStatus = ffi::evmc_storage_status;
23+
24+
/// EVMC VM revision.
25+
pub type Revision = ffi::evmc_revision;
26+
1227
#[cfg(test)]
1328
mod tests {
1429
use super::*;
@@ -34,4 +49,35 @@ mod tests {
3449
let b = Uint256::default();
3550
assert_eq!(a.clone(), b.clone());
3651
}
52+
53+
#[test]
54+
fn message_kind() {
55+
assert_eq!(MessageKind::EVMC_CALL, ffi::evmc_call_kind::EVMC_CALL);
56+
assert_eq!(
57+
MessageKind::EVMC_CALLCODE,
58+
ffi::evmc_call_kind::EVMC_CALLCODE
59+
);
60+
assert_eq!(
61+
MessageKind::EVMC_DELEGATECALL,
62+
ffi::evmc_call_kind::EVMC_DELEGATECALL
63+
);
64+
assert_eq!(MessageKind::EVMC_CREATE, ffi::evmc_call_kind::EVMC_CREATE);
65+
}
66+
67+
#[test]
68+
fn message_flags() {
69+
assert_eq!(MessageFlags::EVMC_STATIC, ffi::evmc_flags::EVMC_STATIC);
70+
}
71+
72+
#[test]
73+
fn status_code() {}
74+
75+
#[test]
76+
fn storage_status() {}
77+
78+
#[test]
79+
fn revision() {
80+
assert_eq!(Revision::EVMC_FRONTIER, ffi::evmc_revision::EVMC_FRONTIER);
81+
assert_eq!(Revision::EVMC_ISTANBUL, ffi::evmc_revision::EVMC_ISTANBUL);
82+
}
3783
}

0 commit comments

Comments
 (0)