Skip to main content

cadlib/
lib.rs

1//! Package cadlib provides Rust bindings for the `SimScale` cadlib native library.
2//!
3//! This crate links against the **prebuilt** cadlib native library over the
4//! stable C ABI (`libcadlib.so`). Install the native library first
5//! (see <https://github.com/SimScaleGmbH/simscale-rust-cadlib#install>);
6//! the crate's `build.rs` links it by name (`-lcadlib`).
7//!
8//! [`Cad::load`] takes the CAD data map entry of a workflow method's run request:
9//! `Cad::load(&request.data_map.cad)?`.
10//!
11//! ```no_run
12//! use cadlib::{Cad, VolumeParameters};
13//!
14//! # let cad_model = serde_json::json!({});
15//! let cad = Cad::load(&cad_model)?;
16//! let params = VolumeParameters { entity_ids: vec!["B1_TE5".to_string()] };
17//! let result = cad.volume(Some(&params))?;
18//! println!("{result:?}");
19//! # Ok::<(), cadlib::CadLibError>(())
20//! ```
21//!
22//! All query methods are **blocking**. From an async (e.g. tokio) context, run
23//! them on the blocking pool so they don't stall the runtime:
24//!
25//! ```ignore
26//! let result = tokio::task::spawn_blocking(move || cad.volume(Some(&params))).await??;
27//! ```
28
29mod cad;
30mod error;
31mod ffi;
32mod lib_version;
33pub mod models;
34mod version_check;
35
36pub use cad::Cad;
37pub use error::CadLibError;
38pub use models::*;
39pub use version_check::version;