cudd_sys/
lib.rs

1//! This crate provides unsafe Rust bindings for the University of Colorado decision diagram
2//! package (CUDD), including the DDDMP serialisation library. It uses version `3.0.0` of CUDD
3//! available from the unofficial [Github mirror](https://github.com/ivmai/cudd) and compiles on
4//! Linux and MacOS (you should be also able to build CUDD on Windows using cygwin, but the project
5//! is not set-up to do it automatically).
6//!
7//! > On Linux and macOS, you should ideally have `autoconf`, `automake` and `libtool` installed
8//! > to build CUDD. And of course, some C/C++ compiler (`clang`, `gcc`, etc.).
9//!
10//! In the root module, you will find declarations of the C structs and types used
11//! throughout CUDD. The main API of the CUDD package is then exported in `::cudd`. However,
12//! CUDD also includes other "public" functionality (multiway-branching trees, extended
13//! double precision numbers, serialisation, ...) which can be found in the remaining modules.
14//!
15//! In some cases, there are macro and constant definitions which cannot be directly exported
16//! to Rust. These have been re-implemented and should have their own documentation.
17//! For the functions which are re-exported without change, please refer to the original
18//! [CUDD doxygen](https://add-lib.scce.info/assets/doxygen-cudd-documentation/) and
19//! [manual](https://add-lib.scce.info/assets/documents/cudd-manual.pdf). The documentation
20//! of the DDDMP library is available
21//! [here](https://www.cs.rice.edu/~lm30/RSynth/CUDD/dddmp/doc/dddmpExt.html).
22//!
23//! **Completeness:** The main CUDD API should be fully reproduced here (except for one small
24//! issue with `f128` numbers). The remaining modules may still be incomplete: if you need
25//! a function that isn't exported yet, let us know in the issues.
26//!
27//! **Correctness:** Unfortunately, CUDD cannot be processed using `bindgen`, so the API was
28//! reproduced using a semi-automated method with a manual validation step (bunch of regexes
29//! that a human makes sure didn't break anything ;)). As such, it is possible that there
30//! are some minor problems that need to be sorted out. Please file an issue if you see any
31//! unexpected behaviour or segfaults.
32//!
33
34// Allow non-idiomatic names in the whole crate.
35#![allow(non_camel_case_types)]
36#![allow(non_snake_case)]
37extern crate libc;
38
39#[cfg(test)]
40mod test;
41
42/// Contains the declarations present in `cudd.h` (main CUDD API).
43pub mod cudd;
44
45/// Contains the declarations present in `mtr.h` (multiway-branching trees).
46pub mod mtr;
47
48/// Contains the declarations present in `epd.h` (extended double precision numbers).
49pub mod epd;
50
51/// Declarations from `dddmp.h` (serialisation of decision diagrams).
52///
53/// Currently, the error checking macros are not implemented.
54pub mod dddmp;
55
56use std::marker::{PhantomData, PhantomPinned};
57
58/// An opaque C struct used to represent the decision diagram node.
59#[repr(C)]
60pub struct DdNode {
61    _data: [u8; 0],
62    _marker: PhantomData<(*mut u8, PhantomPinned)>,
63}
64
65/// An opaque C struct used to represent the CUDD manager.
66#[repr(C)]
67pub struct DdManager {
68    _data: [u8; 0],
69    _marker: PhantomData<(*mut u8, PhantomPinned)>,
70}
71
72/// An opaque C struct used to represent the CUDD generator.
73#[repr(C)]
74pub struct DdGen {
75    _data: [u8; 0],
76    _marker: PhantomData<(*mut u8, PhantomPinned)>,
77}
78
79/// The type of an arbitrary precision "digit".
80pub type DdApaDigit = u32;
81
82/// The type of an arbitrary precision integer, corresponding to an array of digits.
83pub type DdApaNumber = *mut DdApaDigit;
84
85/// A const-qualified version of `DdApaNumber`.
86pub type DdConstApaNumber = *const DdApaDigit;
87
88/// An opaque C struct used to represent the result of the computation of two-literal clauses.
89///
90/// See `Cudd_FindTwoLiteralClauses`.
91#[repr(C)]
92pub struct DdTlcInfo {
93    _data: [u8; 0],
94    _marker: PhantomData<(*mut u8, PhantomPinned)>,
95}
96
97/// An opaque C struct representing an extended double precision floating point number.
98#[repr(C)]
99pub struct EpDouble {
100    _data: [u8; 0],
101    _marker: PhantomData<(*mut u8, PhantomPinned)>,
102}
103
104/// An opaque C struct representing a multi-way branch tree node.
105#[repr(C)]
106pub struct MtrNode {
107    _data: [u8; 0],
108    _marker: PhantomData<(*mut u8, PhantomPinned)>,
109}