Raw C Header

Author:

Rohit Goswami, Ruhila Goswami

Below is the full, auto-generated C FFI header rsx.h produced by cbindgen.

radsex-core/include/rsx.h
// GPL-3.0-or-later
// Copyright 2024--present rsx-rs developers
//
// Auto-generated by cbindgen -- do not edit manually.


#ifndef RSX_H
#define RSX_H

/* Generated with cbindgen:0.28.0 */

/* Warning: this file is auto-generated by cbindgen. Do not modify this manually. */

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>


#define RSX_VERSION "0.2.3"
#define RSX_VERSION_MAJOR 0
#define RSX_VERSION_MINOR 2
#define RSX_VERSION_PATCH 3

/**
 * Bytes per depth cell. We always store u16 in the marker buffer
 * regardless of the inbound Arrow type, so this is a fixed 2 bytes.
 */
#define BYTES_PER_CELL 2

/**
 * Default overhead multiplier capturing arrow validity buffers, group
 * masks, per-marker accumulators, intermediate Vecs. 6x is conservative
 * for the largest commands (signif FDR, triage Bayesian, depth exact).
 */
#define DEFAULT_OVERHEAD 6.0

/**
 * Default fraction of available RAM we are willing to use before
 * switching to the spill path.
 */
#define DEFAULT_SPILL_FRACTION 0.55

/**
 * Status codes returned by all C API functions.
 */
typedef enum rsx_status_t {
  /**
   * Operation completed successfully.
   */
  RSX_SUCCESS = 0,
  /**
   * An invalid parameter was passed (null pointer, wrong size, etc.).
   */
  RSX_INVALID_PARAMETER = 1,
  /**
   * An internal error occurred (e.g. a Rust panic was caught).
   */
  RSX_INTERNAL_ERROR = 2,
  /**
   * An I/O error occurred (file not found, permission denied, etc.).
   */
  RSX_IO_ERROR = 3,
  /**
   * An alignment error occurred (index missing, alignment failed, etc.).
   */
  RSX_ALIGNMENT_ERROR = 4,
} rsx_status_t;

/**
 * Opaque handle to a loaded popmap.
 */
typedef struct rsx_popmap_t rsx_popmap_t;

/**
 * Run the `process` command.
 *
 * # Safety
 * All string pointers must be valid null-terminated C strings.
 */
enum rsx_status_t rsx_process(const char *input_dir,
                              const char *output_path,
                              uint32_t n_threads,
                              uint32_t min_depth);

/**
 * Run the `freq` command.
 *
 * # Safety
 * All string pointers must be valid null-terminated C strings.
 */
enum rsx_status_t rsx_freq(const char *table_path, const char *output_path, uint32_t min_depth);

/**
 * Load a popmap from a file path.
 *
 * # Safety
 * `path` must be a valid null-terminated C string.
 */
enum rsx_status_t rsx_popmap_load(const char *path, struct rsx_popmap_t **out);

/**
 * Free a popmap handle.
 *
 * # Safety
 * `popmap` must have been created by `rsx_popmap_load`.
 */
void rsx_popmap_free(struct rsx_popmap_t *popmap);

/**
 * Get the number of individuals in a popmap.
 *
 * # Safety
 * `popmap` must be a valid handle from `rsx_popmap_load`.
 */
uint16_t rsx_popmap_n_individuals(const struct rsx_popmap_t *popmap);

/**
 * Retrieve a pointer to the last error message for the current thread.
 *
 * The pointer is valid until the next call to any `radsex_*` function
 * on the same thread.
 *
 * # Safety
 * This is intended to be called from C. The returned pointer must not
 * be freed by the caller.
 */
const char *rsx_last_error(void);

#endif  /* RSX_H */