Skip to content

Commit c6c925b

Browse files
committed
[DOCS] Document the cprover_api module.
Also, add a warning for any missing documentation from functions.
1 parent 63a8374 commit c6c925b

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/libcprover-rust/src/lib.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,51 @@
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).
19
#[cxx::bridge]
210
pub mod cprover_api {
311

412
unsafe extern "C++" {
513
include!("libcprover-cpp/api.h");
614
include!("include/c_api.h");
715

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].
818
type api_sessiont;
919

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.
1123
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.
1228
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.
1332
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.
1435
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`.
1538
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`
1641
fn drop_unused_functions(&self) -> Result<()>;
1742

1843
// WARNING: Please don't use this function - use its public interface in [ffi_util::translate_rust_vector_to_cpp].
1944
// The reason this is here is that it's implemented on the C++ shim, and to link this function against
2045
// its implementation it needs to be declared within the `unsafe extern "C++"` block of the FFI bridge.
2146
#[doc(hidden)]
2247
fn _translate_vector_of_string(elements: Vec<String>) -> &'static CxxVector<CxxString>;
48+
/// Print messages accumulated into the message buffer from CProver's end.
2349
fn get_messages() -> &'static CxxVector<CxxString>;
2450
}
2551
}

0 commit comments

Comments
 (0)