endurox-sys
Low-level Rust FFI bindings for Enduro/X middleware.
Enduro/X is a high-performance, open-source middleware platform that implements the XATMI API. This crate provides safe and unsafe Rust bindings to the Enduro/X C API, enabling you to build distributed transaction processing applications in Rust.
Features
- XATMI API - Complete bindings for
tpcall(),tpacall(),tpreturn(), etc. - UBF Buffers - Typed buffer manipulation with
Bchg(),Bget(), etc. - Server Development - Build Enduro/X servers with
atmisrvnomain() - Client Development - Create clients with
tpinit(),tpterm() - Derive Macros - Optional
#[derive(UbfStructDerive)]for automatic serialization - Type Safety - Safe wrappers around raw pointers and error handling
Installation
Add this to your Cargo.toml:
[]
= { = "0.1", = ["ubf", "server"] }
Prerequisites
- Enduro/X middleware installed and configured
- Required environment variables (see below)
- Oracle Instant Client (if using Oracle features)
Environment Variables
NDRX_HOME (Required)
Points to the Enduro/X installation directory. Used by the build script to locate Enduro/X libraries and headers.
The build script uses this to:
- Link against Enduro/X libraries (
libatmi,libubf,libnstd, etc.) - Find header files during compilation
NDRX_APPHOME (Optional)
Points to your application's home directory. Used by the build script to locate UBF field table definitions (ubftab/ directory) for generating Rust constants.
When set, the build script looks for *.fd.h files in $NDRX_APPHOME/ubftab/ and generates Rust constants for UBF field IDs. This allows you to use field constants like T_NAME_FLD directly in your code.
Build-time behavior:
- If
NDRX_APPHOMEis set: looks for$NDRX_APPHOME/ubftab/*.fd.h - If not set: looks for
../ubftab/*.fd.h(relative to crate directory, for local development) - If no UBF tables found: generates empty constants file (build still succeeds)
Example:
use *;
unsafe
Usage
Basic Client Example
use *;
Server Example with Derive
use *;
pub extern "C"
Features
ubf
Enables UBF buffer API bindings:
Bchg(),Bget(),Badd(),Bdel()- Field ID and type management
- Buffer allocation and manipulation
server
Enables server-side bindings:
atmisrvnomain()- Main server entry pointtpsvrinit(),tpsvrdone()- Server lifecycle hookstpadvertise(),tpunadvertise()- Service advertisement
client
Enables client-side bindings:
tpinit(),tpterm()- Connection managementtpcall(),tpacall(),tpgetrply()- Service calls
derive
Enables #[derive(UbfStructDerive)] macro for automatic UBF serialization.
Requires the endurox-derive crate.
Safety
Most functions in this crate are marked unsafe as they interact with C FFI and raw pointers. Safe wrappers can be found in higher-level crates built on top of endurox-sys.
Always ensure:
- Buffers are properly allocated before use
tpinit()is called before any XATMI operations- Resources are freed with
tpfree()andtpterm() - Error codes are checked after each operation
Error Handling
Use tperrno() and tpstrerror() to get error information:
use *;
unsafe
Documentation
For complete API documentation, see docs.rs/endurox-sys.
For Enduro/X documentation, visit www.endurox.org/dokuwiki.
License
Licensed under the MIT license. See LICENSE for details.
Related Crates
endurox-derive- Derive macros for UBF serializationendurox- High-level safe API (coming soon)