3 releases

0.0.3 Dec 19, 2021
0.0.2 Mar 7, 2017
0.0.1 Dec 20, 2016

#190 in Science

Used in fitsio


205 lines


A bindgen implementation of a low level FFI wrapper to cfitsio.

This wrapper requires the use of clang-3.9, see the upstream bindgen requirements for more information.

See the main documentation


This package was automatically generated with rust-bindgen and as such was not user-generated.

The functions contained are expected to be used with fitsio, a high level API wrapper around the low level direct C-bindings, though the bindings are complete enough to be usable.

This code will not be directly documented, and so users should refer to the fitsio C documentation for usage.

Note about function names

Unfortunately we must use fits short names throughout. The C-api exposes long names for functions which are more descriptive, for example fits_open_file instead of ffopen, but the symbols available in the library have only short names, and the long names are merely preprocessor definitions.


use std::ptr;
use std::ffi;
# use fitsio_sys_bindgen as fitsio_sys;

# fn main() -> Result<(), Box<dyn std::error::Error>> {
let filename = ffi::CString::new("!/tmp/test.fits").unwrap();
let mut fptr = ptr::null_mut();
let mut status = 0;

unsafe {
    // Create a new file, clobbering any pre-existing file
    fitsio_sys::ffinit(&mut fptr as *mut *mut _,
        &mut status);

    // Add an empty primary HDU
    fitsio_sys::ffphps(fptr, 8, 0, ptr::null_mut(), &mut status);

    // Finally close the file
    fitsio_sys::ffclos(fptr, &mut status);

assert_eq!(status, 0);
# Ok(())
# }


~31K SLoC