Skip to main content

Crate cadlib

Crate cadlib 

Source
Expand description

Package cadlib provides Rust bindings for the SimScale cadlib native library.

This crate links against the prebuilt cadlib native library over the stable C ABI (libcadlib.so). Install the native library first (see https://github.com/SimScaleGmbH/simscale-rust-cadlib#install); the crate’s build.rs links it by name (-lcadlib).

Cad::load takes the CAD data map entry of a workflow method’s run request: Cad::load(&request.data_map.cad)?.

use cadlib::{Cad, VolumeParameters};

let cad = Cad::load(&cad_model)?;
let params = VolumeParameters { entity_ids: vec!["B1_TE5".to_string()] };
let result = cad.volume(Some(&params))?;
println!("{result:?}");

All query methods are blocking. From an async (e.g. tokio) context, run them on the blocking pool so they don’t stall the runtime:

ⓘ
let result = tokio::task::spawn_blocking(move || cad.volume(Some(&params))).await??;

Re-exports§

pub use models::*;

Modules§

models
Model types generated from the cadlib JSON schemas.

Structs§

Cad
A handle to a loaded CAD model.

Enums§

CadLibError
An error returned by the cadlib native library, or by the bindings layer.

Functions§

version
The version string of the loaded native library (e.g. "3.4.0").