rayforce-sys 1.1.0

Raw FFI bindings to the RayforceDB v2 core (librayforce)
Documentation
//! Raw FFI bindings to the RayforceDB v2 core (`librayforce`).
//!
//! Generated by `bindgen` from the core's own headers: the public
//! `rayforce.h`, plus the private ones declaring the handful of internal
//! symbols the safe crate needs (`INTERNAL_FNS` in `build.rs` is the full
//! list). This crate is `unsafe` and 1:1 with the C ABI; use the safe
//! `rayforce` crate instead.
//!
//! The header's function-like macros (`ray_type`, `ray_len`, `ray_data`,
//! `RAY_IS_ERR`, `RAY_IS_NULL`, …) are not emitted by bindgen — the safe crate
//! reimplements them in Rust against the generated [`ray_t`] layout.
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(clippy::all)]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

// Q IPC wire-format client from the shared `rayforce-q` repo (q.c/q.h). Not
// part of the engine bindings; hand-declared here to match `q.h`.
extern "C" {
    /// Open a TCP connection to a Q server and perform the login handshake.
    /// Returns a connection fd (>= 0), or a negative `Q_ERR_*` code.
    pub fn q_connect(
        host: *const ::std::os::raw::c_char,
        port: ::std::os::raw::c_int,
        user: *const ::std::os::raw::c_char,
        password: *const ::std::os::raw::c_char,
        timeout_ms: ::std::os::raw::c_int,
    ) -> ::std::os::raw::c_int;
    /// Close a connection fd. Returns 0 on success, -1 on an invalid fd.
    pub fn q_close(fd: ::std::os::raw::c_int) -> ::std::os::raw::c_int;
    /// Encode + exchange + decode: send `msg` and return the decoded response
    /// (possibly a `RAY_ERROR`), or null on a transport/serialization failure
    /// with a short reason written to `err`.
    pub fn q_send(
        fd: ::std::os::raw::c_int,
        msg: *mut ray_t,
        err: *mut ::std::os::raw::c_char,
        errlen: usize,
    ) -> *mut ray_t;
    /// Decompress (if needed) and deserialize a response *body* (wire header
    /// already stripped) into a freshly-owned object — possibly a `RAY_ERROR`
    /// carrying a Q server-side error. Touches the symbol table: engine thread
    /// only. Returns null on a decode failure with a short reason in `err`.
    pub fn q_decode(
        resp: *mut u8,
        resp_len: i64,
        compressed: ::std::os::raw::c_int,
        err: *mut ::std::os::raw::c_char,
        errlen: usize,
    ) -> *mut ray_t;
}

/// `q_connect` failure codes (mirrors `q.h`).
pub const Q_ERR_SOCKET: ::std::os::raw::c_int = -1;
pub const Q_ERR_HANDSHAKE: ::std::os::raw::c_int = -2;
pub const Q_ERR_TIMEOUT: ::std::os::raw::c_int = -3;

/// `ray_ipc_connect` failure codes.
///
/// The public header declares the function with no contract at all
/// (`include/rayforce.h`); this mirrors the comment on the private
/// `src/core/ipc.h` declaration and, for [`RAY_IPC_ERR_OS`], the
/// `connect_fail_code()` classifier in `src/core/ipc.c` that the header's
/// comment predates. Hand-maintained against a core bump, like `Q_ERR_*`.
///
/// [`RAY_IPC_ERR_REFUSED`] is the documented name for -1, but the core also
/// returns it for a missing poll, a credential buffer overflow and a failed
/// poll registration — treat it as the catch-all it is.
pub const RAY_IPC_ERR_REFUSED: i64 = -1;
/// The server demands credentials and the caller supplied no password.
pub const RAY_IPC_ERR_AUTH_REQUIRED: i64 = -2;
/// The server rejected the credentials.
pub const RAY_IPC_ERR_AUTH_FAILED: i64 = -3;
/// The peer speaks a different serialization wire version.
pub const RAY_IPC_ERR_WIRE_VERSION: i64 = -4;
/// No answer within the connect/handshake budget. The core folds `EAGAIN` and
/// `EWOULDBLOCK` in here too, so this also covers a live server that is busy
/// inside a long evaluation.
pub const RAY_IPC_ERR_TIMEOUT: i64 = -5;
/// Some other OS error; the core leaves `errno` holding it.
pub const RAY_IPC_ERR_OS: i64 = -6;