chemfiles_sys/
lib.rs

1// Chemfiles.rs, a modern library for chemistry file reading and writing
2// Copyright (C) Guillaume Fraux and contributors -- BSD license
3//
4// ========================================================================= //
5//                       !!!! AUTO-GENERATED FILE !!!!
6// Do not edit. See the bindgen repository for the generation code
7//                   https://github.com/chemfiles/bindgen
8// ========================================================================= //
9
10#![cfg_attr(rustfmt, rustfmt_skip)]
11
12#![allow(non_camel_case_types)]
13use std::os::raw::{c_char, c_double, c_void};
14
15// Manual definitions. Edit the bindgen code to make sure this matches the
16// chemfiles.h header
17pub type c_bool = u8;
18pub type chfl_warning_callback = extern fn(*const c_char);
19pub type chfl_vector3d = [c_double; 3];
20
21#[repr(C)]
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub struct chfl_match {
24    pub size: u64,
25    pub atoms: [u64; 4],
26}
27
28#[repr(C)]
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub struct chfl_format_metadata {
31    pub name: *const c_char,
32    pub extension: *const c_char,
33    pub description: *const c_char,
34    pub reference: *const c_char,
35    pub read: bool,
36    pub write: bool,
37    pub memory: bool,
38    pub positions: bool,
39    pub velocities: bool,
40    pub unit_cell: bool,
41    pub atoms: bool,
42    pub bonds: bool,
43    pub residues: bool,
44}
45// End manual definitions
46
47pub enum CHFL_TRAJECTORY{}
48pub enum CHFL_CELL{}
49pub enum CHFL_ATOM{}
50pub enum CHFL_FRAME{}
51pub enum CHFL_TOPOLOGY{}
52pub enum CHFL_SELECTION{}
53pub enum CHFL_RESIDUE{}
54pub enum CHFL_PROPERTY{}
55
56#[must_use]
57#[repr(C)]
58#[derive(Debug, Clone, Copy, PartialEq, Eq)]
59pub enum chfl_status {
60    CHFL_SUCCESS = 0,
61    CHFL_MEMORY_ERROR = 1,
62    CHFL_FILE_ERROR = 2,
63    CHFL_FORMAT_ERROR = 3,
64    CHFL_SELECTION_ERROR = 4,
65    CHFL_CONFIGURATION_ERROR = 5,
66    CHFL_OUT_OF_BOUNDS = 6,
67    CHFL_PROPERTY_ERROR = 7,
68    CHFL_GENERIC_ERROR = 254,
69    CHFL_CXX_ERROR = 255,
70}
71
72
73#[repr(C)]
74#[derive(Debug, Clone, Copy, PartialEq, Eq)]
75pub enum chfl_bond_order {
76    CHFL_BOND_UNKNOWN = 0,
77    CHFL_BOND_SINGLE = 1,
78    CHFL_BOND_DOUBLE = 2,
79    CHFL_BOND_TRIPLE = 3,
80    CHFL_BOND_QUADRUPLE = 4,
81    CHFL_BOND_QUINTUPLET = 5,
82    CHFL_BOND_AMIDE = 254,
83    CHFL_BOND_AROMATIC = 255,
84}
85
86
87#[repr(C)]
88#[derive(Debug, Clone, Copy, PartialEq, Eq)]
89pub enum chfl_property_kind {
90    CHFL_PROPERTY_BOOL = 0,
91    CHFL_PROPERTY_DOUBLE = 1,
92    CHFL_PROPERTY_STRING = 2,
93    CHFL_PROPERTY_VECTOR3D = 3,
94}
95
96
97#[repr(C)]
98#[derive(Debug, Clone, Copy, PartialEq, Eq)]
99pub enum chfl_cellshape {
100    CHFL_CELL_ORTHORHOMBIC = 0,
101    CHFL_CELL_TRICLINIC = 1,
102    CHFL_CELL_INFINITE = 2,
103}
104
105#[link(name="chemfiles", kind="static")]
106extern "C" {
107    pub fn chfl_version() -> *const c_char;
108    pub fn chfl_last_error() -> *const c_char;
109    pub fn chfl_clear_errors() -> chfl_status;
110    pub fn chfl_set_warning_callback(callback: chfl_warning_callback) -> chfl_status;
111    pub fn chfl_add_configuration(path: *const c_char) -> chfl_status;
112    pub fn chfl_formats_list(metadata: *mut *mut chfl_format_metadata, count: *mut u64) -> chfl_status;
113    pub fn chfl_guess_format(path: *const c_char, format: *mut c_char, buffsize: u64) -> chfl_status;
114    pub fn chfl_free(object: *const c_void) -> c_void;
115    pub fn chfl_property_bool(value: c_bool) -> *mut CHFL_PROPERTY;
116    pub fn chfl_property_double(value: c_double) -> *mut CHFL_PROPERTY;
117    pub fn chfl_property_string(value: *const c_char) -> *mut CHFL_PROPERTY;
118    pub fn chfl_property_vector3d(value: *const c_double) -> *mut CHFL_PROPERTY;
119    pub fn chfl_property_get_kind(property: *const CHFL_PROPERTY, kind: *mut chfl_property_kind) -> chfl_status;
120    pub fn chfl_property_get_bool(property: *const CHFL_PROPERTY, value: *mut c_bool) -> chfl_status;
121    pub fn chfl_property_get_double(property: *const CHFL_PROPERTY, value: *mut c_double) -> chfl_status;
122    pub fn chfl_property_get_string(property: *const CHFL_PROPERTY, buffer: *mut c_char, buffsize: u64) -> chfl_status;
123    pub fn chfl_property_get_vector3d(property: *const CHFL_PROPERTY, value: *mut c_double) -> chfl_status;
124    pub fn chfl_atom(name: *const c_char) -> *mut CHFL_ATOM;
125    pub fn chfl_atom_copy(atom: *const CHFL_ATOM) -> *mut CHFL_ATOM;
126    pub fn chfl_atom_from_frame(frame: *mut CHFL_FRAME, index: u64) -> *mut CHFL_ATOM;
127    pub fn chfl_atom_from_topology(topology: *mut CHFL_TOPOLOGY, index: u64) -> *mut CHFL_ATOM;
128    pub fn chfl_atom_mass(atom: *const CHFL_ATOM, mass: *mut c_double) -> chfl_status;
129    pub fn chfl_atom_set_mass(atom: *mut CHFL_ATOM, mass: c_double) -> chfl_status;
130    pub fn chfl_atom_charge(atom: *const CHFL_ATOM, charge: *mut c_double) -> chfl_status;
131    pub fn chfl_atom_set_charge(atom: *mut CHFL_ATOM, charge: c_double) -> chfl_status;
132    pub fn chfl_atom_type(atom: *const CHFL_ATOM, _type: *mut c_char, buffsize: u64) -> chfl_status;
133    pub fn chfl_atom_set_type(atom: *mut CHFL_ATOM, _type: *const c_char) -> chfl_status;
134    pub fn chfl_atom_name(atom: *const CHFL_ATOM, name: *mut c_char, buffsize: u64) -> chfl_status;
135    pub fn chfl_atom_set_name(atom: *mut CHFL_ATOM, name: *const c_char) -> chfl_status;
136    pub fn chfl_atom_full_name(atom: *const CHFL_ATOM, name: *mut c_char, buffsize: u64) -> chfl_status;
137    pub fn chfl_atom_vdw_radius(atom: *const CHFL_ATOM, radius: *mut c_double) -> chfl_status;
138    pub fn chfl_atom_covalent_radius(atom: *const CHFL_ATOM, radius: *mut c_double) -> chfl_status;
139    pub fn chfl_atom_atomic_number(atom: *const CHFL_ATOM, number: *mut u64) -> chfl_status;
140    pub fn chfl_atom_properties_count(atom: *const CHFL_ATOM, count: *mut u64) -> chfl_status;
141    pub fn chfl_atom_list_properties(atom: *const CHFL_ATOM, names: *mut *mut c_char, count: u64) -> chfl_status;
142    pub fn chfl_atom_set_property(atom: *mut CHFL_ATOM, name: *const c_char, property: *const CHFL_PROPERTY) -> chfl_status;
143    pub fn chfl_atom_get_property(atom: *const CHFL_ATOM, name: *const c_char) -> *mut CHFL_PROPERTY;
144    pub fn chfl_residue(name: *const c_char) -> *mut CHFL_RESIDUE;
145    pub fn chfl_residue_with_id(name: *const c_char, resid: i64) -> *mut CHFL_RESIDUE;
146    pub fn chfl_residue_from_topology(topology: *const CHFL_TOPOLOGY, i: u64) -> *const CHFL_RESIDUE;
147    pub fn chfl_residue_for_atom(topology: *const CHFL_TOPOLOGY, i: u64) -> *const CHFL_RESIDUE;
148    pub fn chfl_residue_copy(residue: *const CHFL_RESIDUE) -> *mut CHFL_RESIDUE;
149    pub fn chfl_residue_atoms_count(residue: *const CHFL_RESIDUE, count: *mut u64) -> chfl_status;
150    pub fn chfl_residue_atoms(residue: *const CHFL_RESIDUE, atoms: *mut u64, count: u64) -> chfl_status;
151    pub fn chfl_residue_id(residue: *const CHFL_RESIDUE, id: *mut i64) -> chfl_status;
152    pub fn chfl_residue_name(residue: *const CHFL_RESIDUE, name: *mut c_char, buffsize: u64) -> chfl_status;
153    pub fn chfl_residue_add_atom(residue: *mut CHFL_RESIDUE, i: u64) -> chfl_status;
154    pub fn chfl_residue_contains(residue: *const CHFL_RESIDUE, i: u64, result: *mut c_bool) -> chfl_status;
155    pub fn chfl_residue_properties_count(residue: *const CHFL_RESIDUE, count: *mut u64) -> chfl_status;
156    pub fn chfl_residue_list_properties(residue: *const CHFL_RESIDUE, names: *mut *mut c_char, count: u64) -> chfl_status;
157    pub fn chfl_residue_set_property(residue: *mut CHFL_RESIDUE, name: *const c_char, property: *const CHFL_PROPERTY) -> chfl_status;
158    pub fn chfl_residue_get_property(residue: *const CHFL_RESIDUE, name: *const c_char) -> *mut CHFL_PROPERTY;
159    pub fn chfl_topology() -> *mut CHFL_TOPOLOGY;
160    pub fn chfl_topology_from_frame(frame: *const CHFL_FRAME) -> *const CHFL_TOPOLOGY;
161    pub fn chfl_topology_copy(topology: *const CHFL_TOPOLOGY) -> *mut CHFL_TOPOLOGY;
162    pub fn chfl_topology_atoms_count(topology: *const CHFL_TOPOLOGY, count: *mut u64) -> chfl_status;
163    pub fn chfl_topology_resize(topology: *mut CHFL_TOPOLOGY, natoms: u64) -> chfl_status;
164    pub fn chfl_topology_add_atom(topology: *mut CHFL_TOPOLOGY, atom: *const CHFL_ATOM) -> chfl_status;
165    pub fn chfl_topology_remove(topology: *mut CHFL_TOPOLOGY, i: u64) -> chfl_status;
166    pub fn chfl_topology_bonds_count(topology: *const CHFL_TOPOLOGY, count: *mut u64) -> chfl_status;
167    pub fn chfl_topology_angles_count(topology: *const CHFL_TOPOLOGY, count: *mut u64) -> chfl_status;
168    pub fn chfl_topology_dihedrals_count(topology: *const CHFL_TOPOLOGY, count: *mut u64) -> chfl_status;
169    pub fn chfl_topology_impropers_count(topology: *const CHFL_TOPOLOGY, count: *mut u64) -> chfl_status;
170    pub fn chfl_topology_bonds(topology: *const CHFL_TOPOLOGY, data: *mut [u64; 2], count: u64) -> chfl_status;
171    pub fn chfl_topology_angles(topology: *const CHFL_TOPOLOGY, data: *mut [u64; 3], count: u64) -> chfl_status;
172    pub fn chfl_topology_dihedrals(topology: *const CHFL_TOPOLOGY, data: *mut [u64; 4], count: u64) -> chfl_status;
173    pub fn chfl_topology_impropers(topology: *const CHFL_TOPOLOGY, data: *mut [u64; 4], count: u64) -> chfl_status;
174    pub fn chfl_topology_add_bond(topology: *mut CHFL_TOPOLOGY, i: u64, j: u64) -> chfl_status;
175    pub fn chfl_topology_remove_bond(topology: *mut CHFL_TOPOLOGY, i: u64, j: u64) -> chfl_status;
176    pub fn chfl_topology_clear_bonds(topology: *mut CHFL_TOPOLOGY) -> chfl_status;
177    pub fn chfl_topology_residues_count(topology: *const CHFL_TOPOLOGY, count: *mut u64) -> chfl_status;
178    pub fn chfl_topology_add_residue(topology: *mut CHFL_TOPOLOGY, residue: *const CHFL_RESIDUE) -> chfl_status;
179    pub fn chfl_topology_residues_linked(topology: *const CHFL_TOPOLOGY, first: *const CHFL_RESIDUE, second: *const CHFL_RESIDUE, result: *mut c_bool) -> chfl_status;
180    pub fn chfl_topology_bond_with_order(topology: *mut CHFL_TOPOLOGY, i: u64, j: u64, bond_order: chfl_bond_order) -> chfl_status;
181    pub fn chfl_topology_bond_orders(topology: *const CHFL_TOPOLOGY, orders: *mut chfl_bond_order, nbonds: u64) -> chfl_status;
182    pub fn chfl_topology_bond_order(topology: *const CHFL_TOPOLOGY, i: u64, j: u64, order: *mut chfl_bond_order) -> chfl_status;
183    pub fn chfl_cell(lengths: *const c_double, angles: *const c_double) -> *mut CHFL_CELL;
184    pub fn chfl_cell_from_matrix(matrix: *mut [c_double; 3]) -> *mut CHFL_CELL;
185    pub fn chfl_cell_from_frame(frame: *mut CHFL_FRAME) -> *mut CHFL_CELL;
186    pub fn chfl_cell_copy(cell: *const CHFL_CELL) -> *mut CHFL_CELL;
187    pub fn chfl_cell_volume(cell: *const CHFL_CELL, volume: *mut c_double) -> chfl_status;
188    pub fn chfl_cell_lengths(cell: *const CHFL_CELL, lengths: *mut c_double) -> chfl_status;
189    pub fn chfl_cell_set_lengths(cell: *mut CHFL_CELL, lengths: *const c_double) -> chfl_status;
190    pub fn chfl_cell_angles(cell: *const CHFL_CELL, angles: *mut c_double) -> chfl_status;
191    pub fn chfl_cell_set_angles(cell: *mut CHFL_CELL, angles: *const c_double) -> chfl_status;
192    pub fn chfl_cell_matrix(cell: *const CHFL_CELL, matrix: *mut [c_double; 3]) -> chfl_status;
193    pub fn chfl_cell_shape(cell: *const CHFL_CELL, shape: *mut chfl_cellshape) -> chfl_status;
194    pub fn chfl_cell_set_shape(cell: *mut CHFL_CELL, shape: chfl_cellshape) -> chfl_status;
195    pub fn chfl_cell_wrap(cell: *const CHFL_CELL, vector: *mut c_double) -> chfl_status;
196    pub fn chfl_frame() -> *mut CHFL_FRAME;
197    pub fn chfl_frame_copy(frame: *const CHFL_FRAME) -> *mut CHFL_FRAME;
198    pub fn chfl_frame_atoms_count(frame: *const CHFL_FRAME, count: *mut u64) -> chfl_status;
199    pub fn chfl_frame_positions(frame: *mut CHFL_FRAME, positions: *mut *mut [c_double; 3], size: *mut u64) -> chfl_status;
200    pub fn chfl_frame_velocities(frame: *mut CHFL_FRAME, velocities: *mut *mut [c_double; 3], size: *mut u64) -> chfl_status;
201    pub fn chfl_frame_add_atom(frame: *mut CHFL_FRAME, atom: *const CHFL_ATOM, position: *const c_double, velocity: *const c_double) -> chfl_status;
202    pub fn chfl_frame_remove(frame: *mut CHFL_FRAME, i: u64) -> chfl_status;
203    pub fn chfl_frame_resize(frame: *mut CHFL_FRAME, size: u64) -> chfl_status;
204    pub fn chfl_frame_add_velocities(frame: *mut CHFL_FRAME) -> chfl_status;
205    pub fn chfl_frame_has_velocities(frame: *const CHFL_FRAME, has_velocities: *mut c_bool) -> chfl_status;
206    pub fn chfl_frame_set_cell(frame: *mut CHFL_FRAME, cell: *const CHFL_CELL) -> chfl_status;
207    pub fn chfl_frame_set_topology(frame: *mut CHFL_FRAME, topology: *const CHFL_TOPOLOGY) -> chfl_status;
208    pub fn chfl_frame_step(frame: *const CHFL_FRAME, step: *mut u64) -> chfl_status;
209    pub fn chfl_frame_set_step(frame: *mut CHFL_FRAME, step: u64) -> chfl_status;
210    pub fn chfl_frame_guess_bonds(frame: *mut CHFL_FRAME) -> chfl_status;
211    pub fn chfl_frame_distance(frame: *const CHFL_FRAME, i: u64, j: u64, distance: *mut c_double) -> chfl_status;
212    pub fn chfl_frame_angle(frame: *const CHFL_FRAME, i: u64, j: u64, k: u64, angle: *mut c_double) -> chfl_status;
213    pub fn chfl_frame_dihedral(frame: *const CHFL_FRAME, i: u64, j: u64, k: u64, m: u64, dihedral: *mut c_double) -> chfl_status;
214    pub fn chfl_frame_out_of_plane(frame: *const CHFL_FRAME, i: u64, j: u64, k: u64, m: u64, distance: *mut c_double) -> chfl_status;
215    pub fn chfl_frame_properties_count(frame: *const CHFL_FRAME, count: *mut u64) -> chfl_status;
216    pub fn chfl_frame_list_properties(frame: *const CHFL_FRAME, names: *mut *mut c_char, count: u64) -> chfl_status;
217    pub fn chfl_frame_set_property(frame: *mut CHFL_FRAME, name: *const c_char, property: *const CHFL_PROPERTY) -> chfl_status;
218    pub fn chfl_frame_get_property(frame: *const CHFL_FRAME, name: *const c_char) -> *mut CHFL_PROPERTY;
219    pub fn chfl_frame_add_bond(frame: *mut CHFL_FRAME, i: u64, j: u64) -> chfl_status;
220    pub fn chfl_frame_bond_with_order(frame: *mut CHFL_FRAME, i: u64, j: u64, bond_order: chfl_bond_order) -> chfl_status;
221    pub fn chfl_frame_remove_bond(frame: *mut CHFL_FRAME, i: u64, j: u64) -> chfl_status;
222    pub fn chfl_frame_clear_bonds(frame: *mut CHFL_FRAME) -> chfl_status;
223    pub fn chfl_frame_add_residue(frame: *mut CHFL_FRAME, residue: *const CHFL_RESIDUE) -> chfl_status;
224    pub fn chfl_trajectory_open(path: *const c_char, mode: c_char) -> *mut CHFL_TRAJECTORY;
225    pub fn chfl_trajectory_with_format(path: *const c_char, mode: c_char, format: *const c_char) -> *mut CHFL_TRAJECTORY;
226    pub fn chfl_trajectory_memory_reader(memory: *const c_char, size: u64, format: *const c_char) -> *mut CHFL_TRAJECTORY;
227    pub fn chfl_trajectory_memory_writer(format: *const c_char) -> *mut CHFL_TRAJECTORY;
228    pub fn chfl_trajectory_path(trajectory: *const CHFL_TRAJECTORY, path: *mut c_char, buffsize: u64) -> chfl_status;
229    pub fn chfl_trajectory_read(trajectory: *mut CHFL_TRAJECTORY, frame: *mut CHFL_FRAME) -> chfl_status;
230    pub fn chfl_trajectory_read_step(trajectory: *mut CHFL_TRAJECTORY, step: u64, frame: *mut CHFL_FRAME) -> chfl_status;
231    pub fn chfl_trajectory_write(trajectory: *mut CHFL_TRAJECTORY, frame: *const CHFL_FRAME) -> chfl_status;
232    pub fn chfl_trajectory_set_topology(trajectory: *mut CHFL_TRAJECTORY, topology: *const CHFL_TOPOLOGY) -> chfl_status;
233    pub fn chfl_trajectory_topology_file(trajectory: *mut CHFL_TRAJECTORY, path: *const c_char, format: *const c_char) -> chfl_status;
234    pub fn chfl_trajectory_set_cell(trajectory: *mut CHFL_TRAJECTORY, cell: *const CHFL_CELL) -> chfl_status;
235    pub fn chfl_trajectory_nsteps(trajectory: *mut CHFL_TRAJECTORY, nsteps: *mut u64) -> chfl_status;
236    pub fn chfl_trajectory_memory_buffer(trajectory: *const CHFL_TRAJECTORY, data: *mut *const c_char, size: *mut u64) -> chfl_status;
237    pub fn chfl_trajectory_close(trajectory: *const CHFL_TRAJECTORY) -> c_void;
238    pub fn chfl_selection(selection: *const c_char) -> *mut CHFL_SELECTION;
239    pub fn chfl_selection_copy(selection: *const CHFL_SELECTION) -> *mut CHFL_SELECTION;
240    pub fn chfl_selection_size(selection: *const CHFL_SELECTION, size: *mut u64) -> chfl_status;
241    pub fn chfl_selection_string(selection: *const CHFL_SELECTION, string: *mut c_char, buffsize: u64) -> chfl_status;
242    pub fn chfl_selection_evaluate(selection: *mut CHFL_SELECTION, frame: *const CHFL_FRAME, n_matches: *mut u64) -> chfl_status;
243    pub fn chfl_selection_matches(selection: *const CHFL_SELECTION, matches: *mut chfl_match, n_matches: u64) -> chfl_status;
244}