|
| 1 | +#![warn(missing_docs)] |
| 2 | + |
| 3 | +//! # Libcprover_rust |
| 4 | +//! |
| 5 | +//! A Rust interface for convenient interaction with the CProver tools. |
| 6 | +
|
| 7 | +/// The main API module for interfacing with CProver tools (`cbmc`, |
| 8 | +/// `goto-analyzer`, etc). |
1 | 9 | #[cxx::bridge]
|
2 | 10 | pub mod cprover_api {
|
3 | 11 |
|
4 | 12 | unsafe extern "C++" {
|
5 | 13 | include!("libcprover-cpp/api.h");
|
6 | 14 | include!("include/c_api.h");
|
7 | 15 |
|
| 16 | + /// Central organisational handle of the API. This directly corresponds to the |
| 17 | + /// C++-API type `api_sessiont`. To initiate a session interaction, call [new_api_session]. |
8 | 18 | type api_sessiont;
|
9 | 19 |
|
10 |
| - // API Functions |
| 20 | + /// Provide a unique pointer to the API handle. This will be required to interact |
| 21 | + /// with the API calls, and thus, is expected to be the first call before any other |
| 22 | + /// interaction with the API. |
11 | 23 | fn new_api_session() -> UniquePtr<api_sessiont>;
|
| 24 | + |
| 25 | + /// Return the API version - note that this is coming from the C++ API, which |
| 26 | + /// returns the API version of CBMC (which should map to the version of `libcprover.a`) |
| 27 | + /// the Rust API has mapped against. |
12 | 28 | fn get_api_version(&self) -> UniquePtr<CxxString>;
|
| 29 | + /// Provided a C++ Vector of Strings (use [translate_vector_of_string] to translate |
| 30 | + /// a Rust `Vec<String` into a `CxxVector<CxxString>` before passing it to the function), |
| 31 | + /// load the models from the files in the vector and link them together. |
13 | 32 | fn load_model_from_files(&self, files: &CxxVector<CxxString>) -> Result<()>;
|
| 33 | + /// Execute a verification engine run against the loaded model. |
| 34 | + /// *ATTENTION*: A model must be loaded before this function is run. |
14 | 35 | fn verify_model(&self) -> Result<()>;
|
| 36 | + /// Run a validation check on the goto-model that has been loaded. |
| 37 | + /// Corresponds to the CProver CLI option `--validate-goto-model`. |
15 | 38 | fn validate_goto_model(&self) -> Result<()>;
|
| 39 | + /// Drop functions that aren't used from the model. Corresponds to |
| 40 | + /// the CProver CLI option `--drop-unused-functions` |
16 | 41 | fn drop_unused_functions(&self) -> Result<()>;
|
17 | 42 |
|
18 | 43 | // WARNING: Please don't use this function - use its public interface in [ffi_util::translate_rust_vector_to_cpp].
|
19 | 44 | // The reason this is here is that it's implemented on the C++ shim, and to link this function against
|
20 | 45 | // its implementation it needs to be declared within the `unsafe extern "C++"` block of the FFI bridge.
|
21 | 46 | #[doc(hidden)]
|
22 | 47 | fn _translate_vector_of_string(elements: Vec<String>) -> &'static CxxVector<CxxString>;
|
| 48 | + /// Print messages accumulated into the message buffer from CProver's end. |
23 | 49 | fn get_messages() -> &'static CxxVector<CxxString>;
|
24 | 50 | }
|
25 | 51 | }
|
|
0 commit comments