Crate rgpot_core¶
- crate rgpot_core¶
rgpot-core
Rust core library for rgpot: RPC-based distributed potential energy surface calculations. This crate follows the metatensor architecture pattern: a Rust core that defines fundamental types, exposed via a stable C ABI (auto-generated by cbindgen), with hand-written C++ RAII wrappers on top.
Module Overview
Module
Purpose
types#[repr(C)]data structures for force/energy I/OtensorDLPack tensor helpers: create, free, validate
statusStatus codes, thread-local error message, panic safety
potentialCallback-based potential dispatch (opaque handle)
c_apiextern "C"entry points collected by cbindgenrpcCap’n Proto RPC client and server (feature-gated)
Design Principles
C ABI is the contract. Every public type is
#[repr(C)]and every public function isextern "C". The generatedrgpot.hheader is the single source of truth for all language bindings.Panic safety at every boundary. All
extern "C"functions wrap their body instatus::catch_unwind, converting panics tostatus::rgpot_status_t::RGPOT_INTERNAL_ERRORand storing a human-readable message retrievable viastatus::rgpot_last_error.Callback-based dispatch. C++ potentials register themselves as function pointer callbacks. The Rust core never depends on concrete C++ types — only on the callback signature.
Feature-gated optional layers. RPC (
rpcfeature) and caching (cachefeature) are opt-in, keeping the core dependency-free.
Quick Example (Rust-side)
The core types use DLPack tensors for device-agnostic data exchange. See
tensorfor helpers to create DLPack tensors from raw pointers.Modules