pub struct Dftd4Structure(pub dftd4_structure);Expand description
Safe wrapper for dftd4_structure handle that automatically frees on drop
Tuple Fields§
§0: dftd4_structureImplementations§
Source§impl Dftd4Structure
impl Dftd4Structure
Sourcepub unsafe fn try_new(
error: dftd4_error,
natoms: c_int,
numbers: *const c_int,
positions: *const c_double,
charge: *const c_double,
lattice: *const c_double,
periodic: *const bool,
) -> Result<Self, Dftd4StructureError>
pub unsafe fn try_new( error: dftd4_error, natoms: c_int, numbers: *const c_int, positions: *const c_double, charge: *const c_double, lattice: *const c_double, periodic: *const bool, ) -> Result<Self, Dftd4StructureError>
Checked creation of molecular structure data (quantities in Bohr).
Behaves exactly like dftd4_new_structure, except that the degenerate
inputs the pinned upstream cannot report through the error handle are
rejected before the FFI call and returned as a catchable Rust error:
natoms <= 0→Dftd4StructureError::EmptyAtomCount(the raw call would return a handle with an empty error handle, and a later calculation would terminate the host process viaerror stop)numbers[i]outside1..=MAX_SUPPORTED_ATOMIC_NUMBER→Dftd4StructureError::AtomicNumberOutOfRange(the raw call would silently produce zero-valued results)- null
numbersorpositions→Dftd4StructureError::MissingRequiredArray - null
errorhandle →Dftd4StructureError::MissingErrorHandle(upstream does not merely omit the reporting through a null handle: it skips the entire call and returns a null structure handle, so reporting that asOkwould hand out a dead wrapper)
Conditions upstream does report (e.g. “unsupported element” for
atomic numbers 104..=111, too close interatomic distances) still come
through error exactly as with the raw call — consult the handle after
an Ok result as usual. A rejected input leaves error untouched.
§Safety
Same requirements as dftd4_new_structure, except that error must
not be null here: error must be a valid error handle created by
dftd4_new_error, numbers must point to an array of at least
natoms atomic numbers, positions to an array of at least
3 * natoms Cartesian coordinates in Bohr, and charge (one value),
lattice (3 * 3 values) and periodic (3 values) must each be
either null or point to valid storage. (A null error is rejected
with Dftd4StructureError::MissingErrorHandle instead of silently
producing a null handle wrapped in Ok, as the raw call does — see
the note above and on dftd4_new_structure.)