ssvm_evmc_sys/
lib.rs

1/* EVMC: Ethereum Client-VM Connector API.
2 * Copyright 2019 The EVMC Authors.
3 * Licensed under the Apache License, Version 2.0.
4 */
5
6#![allow(non_upper_case_globals)]
7#![allow(non_camel_case_types)]
8#![allow(non_snake_case)]
9
10include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
11
12// Defining evmc_host_context here, because bindgen cannot create a useful declaration yet.
13
14pub type evmc_host_context = ::std::os::raw::c_void;
15
16//pub struct evmc_host_context { }
17
18// TODO: add `.derive_default(true)` to bindgen instead?
19
20impl Default for evmc_address {
21    fn default() -> Self {
22        evmc_address { bytes: [0u8; 20] }
23    }
24}
25
26impl Default for evmc_bytes32 {
27    fn default() -> Self {
28        evmc_bytes32 { bytes: [0u8; 32] }
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use std::mem::size_of;
35
36    use super::*;
37
38    #[test]
39    fn container_new() {
40        // TODO: add other checks from test/unittests/test_helpers.cpp
41        assert_eq!(size_of::<evmc_bytes32>(), 32);
42        assert_eq!(size_of::<evmc_address>(), 20);
43        assert!(size_of::<evmc_result>() <= 64);
44        assert!(size_of::<evmc_vm>() <= 64);
45    }
46}