Skip to main content

thruput_sys/
lib.rs

1//! # thruput-sys
2//!
3//! Low-level FFI bindings to the Thruput test executor, the native library
4//! that `thruput-native-exec` runs contracts on. The bindings are generated
5//! from the executor's C headers with bindgen; the build script fetches and
6//! links the library itself.
7//!
8//! This crate is an implementation detail of `thruput-native-exec`. Use that
9//! crate, or `thruput-sdk`'s `dev` feature, instead.
10
11// suppress spurious warnings from bindgen
12#![allow(non_camel_case_types)]
13#![allow(non_upper_case_globals)]
14#![allow(non_snake_case)]
15#![allow(dead_code)]
16
17// Private module containing all bindgen-generated bindings
18mod bindings {
19    include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
20}
21
22// Export all non-weird bindgen symbols (excludes __ prefixed items, _opaque_* structs, etc.)
23
24// Constants
25#[rustfmt::skip]
26pub use bindings::{
27    TEST_FFI_VERSION_MAJOR,
28    TEST_FFI_VERSION_MINOR,
29    TEST_FFI_VERSION_PATCH,
30};
31
32// Types
33#[rustfmt::skip]
34pub use bindings::{
35    ForeignInvokeResult,
36    ForeignTracedInvokeResult,
37    ForeignEntryPoint,
38    ForeignHostFnResult,
39    ForeignTryCommitResult,
40    CreateDBResult,
41    OpenRuntimeContextResult,
42    FFISerializedSignedTransaction,
43    OpenSyscallHandlerResult,
44    FFISourceAuthData,
45    FFISerializedAuthClaimData,
46    FFISerializedInvocation,
47    VerifyAuthResult,
48    VerifyAuthResultFromDBResult,
49    FFIDataBuffer,
50    GetCostModelResult,
51    GetNetworkConfigResult,
52    GetSnapshotStorageItemResult,
53    VerifyContractResult,
54    FFISerializedAddressAndKey,
55    FFIRv32StackUsage,
56    GetRv32StackUsageResult,
57};
58
59// Functions
60#[rustfmt::skip]
61pub use bindings::{
62    create_db,
63    free_db,
64    get_cost_model,
65    get_network_config,
66    get_snapshot_storage_item,
67    advance_new_block,
68    open_runtime_context,
69    close_runtime_context,
70    register_new_contract,
71    setup_create_contract,
72    setup_deploy_contract,
73    setup_grant_contract_storage_tokens,
74    open_syscall_handler,
75    open_mocked_syscall_handler,
76    open_mock_invocation_frame,
77    finish_mock_invocation_frame,
78    push_context,
79    pop_context,
80    close_syscall_handler,
81    mock_syscall_entrypoint,
82    root_invoke,
83    try_commit_transaction,
84    abort_transaction,
85    enable_syscall_logging,
86    verify_signed_transaction_auth,
87    verify_signed_transaction_auth_from_db,
88    do_verify_contract,
89    get_rv32_stack_usage,
90};
91
92mod impls;
93pub use impls::FFIErrorCode;
94pub use impls::FFILogLevel;