Rapier C — 2D / f64 0.36.0+c.0
Loading...
Searching...
No Matches
ABI and errors

Build identity, layout checks, status codes, and thread-local diagnostics. More...

Data Structures

struct  R2ErrorHandler
 An optional thread-local error handler. More...
struct  R2BuildInfo
 Runtime ABI identity and fundamental type sizes. More...
struct  R2BuildFeatures
 Features available through the loaded C library, independent of consumer defines. More...

Macros

#define R2_ABI_VERSION   1
 C binary ABI revision expected by this header.
#define R2_ABI_FEATURE_FEM   1
 ABI feature bit: RAPIER_FEM, which changes the layout of R2IntegrationParameters.
#define R2_ABI_FEATURE_ROBOTICS   2
 ABI feature bit: RAPIER_ROBOTICS (3D, f32 only), which declares the URDF/MJCF API.
#define R2_ABI_FEATURES   1
 R2_ABI_FEATURE_* bits selected by the defines of this header; pass it to CheckAbi.
#define R2_OK   0
 Operation succeeded.
#define R2_NULL_POINTER   1
 A required pointer was NULL.
#define R2_INVALID_ARGUMENT   2
 An argument failed validation.
#define R2_INVALID_HANDLE   3
 The entity handle is stale, invalid, or belongs to another world.
#define R2_BUFFER_TOO_SMALL   4
 Output capacity is insufficient; the returned count is the required capacity.
#define R2_UNSUPPORTED   5
 This build or object does not support the operation.
#define R2_PANIC   6
 Rust panicked; discard objects mutated by the call.
#define R2_NOT_FOUND   7
 No matching query result or object was found.
#define R2_WORLD_BUSY   8
 Conflicting or reentrant access to simulation state.

Typedefs

typedef uint32_t R2Status
 Status-returning operations use these integer codes.
typedef void(*) R2ErrorCallback(R2Status, const char *, void *)
 Called synchronously on the calling thread when an operation reports an error.
typedef struct R2ErrorHandler R2ErrorHandler
 An optional thread-local error handler.
typedef struct R2BuildInfo R2BuildInfo
 Runtime ABI identity and fundamental type sizes.
typedef struct R2BuildFeatures R2BuildFeatures
 Features available through the loaded C library, independent of consumer defines.

Functions

struct R2PodLayout r2PodLayout (void)
 Return POD structure sizes for checking foreign-language layouts against this library.
struct R2ErrorHandler r2SetErrorHandler (struct R2ErrorHandler handler)
 Replace this thread's error handler and return the previous handler so it can be restored at the end of a scope.
R2Status r2LastStatus (void)
 Status of the most recent fallible operation on this thread.
const char * r2LastError (void)
 Thread-local UTF-8 diagnostic, valid until the next fallible call on this thread.
struct R2BuildInfo r2BuildInfo (void)
 Return ABI version, dimension, scalar size, and pointer size of the linked library.
const char * r2Version (void)
 Release version of the loaded C bindings, e.g.
const char * r2BuildProfile (void)
 Cargo profile of the loaded physics library: "debug" or "release".
struct R2BuildFeatures r2BuildFeatures (void)
 Return profiling, SIMD width, parallelism, and determinism of the linked library.
R2Status r2CheckAbi (uint32_t version, uint32_t dimension, size_t real_size, size_t vector_size, size_t pose_size, uint32_t features)
 Check that the header matches the linked library before passing any structure across the ABI.

Detailed Description

Build identity, layout checks, status codes, and thread-local diagnostics.

See Errors and returned values for the return-value convention.

Macro Definition Documentation

◆ R2_ABI_FEATURE_FEM

#define R2_ABI_FEATURE_FEM   1

ABI feature bit: RAPIER_FEM, which changes the layout of R2IntegrationParameters.

◆ R2_ABI_FEATURE_ROBOTICS

#define R2_ABI_FEATURE_ROBOTICS   2

ABI feature bit: RAPIER_ROBOTICS (3D, f32 only), which declares the URDF/MJCF API.

◆ R2_ABI_FEATURES

#define R2_ABI_FEATURES   1

R2_ABI_FEATURE_* bits selected by the defines of this header; pass it to CheckAbi.

◆ R2_ABI_VERSION

#define R2_ABI_VERSION   1

C binary ABI revision expected by this header.

◆ R2_BUFFER_TOO_SMALL

#define R2_BUFFER_TOO_SMALL   4

Output capacity is insufficient; the returned count is the required capacity.

◆ R2_INVALID_ARGUMENT

#define R2_INVALID_ARGUMENT   2

An argument failed validation.

◆ R2_INVALID_HANDLE

#define R2_INVALID_HANDLE   3

The entity handle is stale, invalid, or belongs to another world.

◆ R2_NOT_FOUND

#define R2_NOT_FOUND   7

No matching query result or object was found.

◆ R2_NULL_POINTER

#define R2_NULL_POINTER   1

A required pointer was NULL.

◆ R2_OK

#define R2_OK   0

Operation succeeded.

◆ R2_PANIC

#define R2_PANIC   6

Rust panicked; discard objects mutated by the call.

◆ R2_UNSUPPORTED

#define R2_UNSUPPORTED   5

This build or object does not support the operation.

◆ R2_WORLD_BUSY

#define R2_WORLD_BUSY   8

Conflicting or reentrant access to simulation state.

No mutation was performed.

Typedef Documentation

◆ R2BuildFeatures

typedef struct R2BuildFeatures R2BuildFeatures

Features available through the loaded C library, independent of consumer defines.

◆ R2BuildInfo

typedef struct R2BuildInfo R2BuildInfo

Runtime ABI identity and fundamental type sizes.

◆ R2ErrorCallback

typedef void(*) R2ErrorCallback(R2Status, const char *, void *)

Called synchronously on the calling thread when an operation reports an error.

The diagnostic is borrowed for the duration of the callback. The callback must return normally or terminate the process: never throw or longjmp across the Rust/C boundary. Nested failing calls do not invoke the handler recursively.

◆ R2ErrorHandler

typedef struct R2ErrorHandler R2ErrorHandler

An optional thread-local error handler.

A null callback disables reporting. Keep the callback and user_data alive until the handler is replaced.

◆ R2Status

typedef uint32_t R2Status

Status-returning operations use these integer codes.

Function Documentation

◆ r2BuildFeatures()

struct R2BuildFeatures r2BuildFeatures ( void )

Return profiling, SIMD width, parallelism, and determinism of the linked library.

◆ r2BuildInfo()

struct R2BuildInfo r2BuildInfo ( void )

Return ABI version, dimension, scalar size, and pointer size of the linked library.

◆ r2BuildProfile()

const char * r2BuildProfile ( void )

Cargo profile of the loaded physics library: "debug" or "release".

Custom profiles report the corresponding inherited Cargo profile category. The UTF-8, NUL-terminated string is borrowed for the library's lifetime; do not free it. This is independent of the consumer's build mode and of per-package optimization overrides.

◆ r2CheckAbi()

R2Status r2CheckAbi ( uint32_t version,
uint32_t dimension,
size_t real_size,
size_t vector_size,
size_t pose_size,
uint32_t features )

Check that the header matches the linked library before passing any structure across the ABI.

Pass R2_ABI_VERSION, R2_DIMENSION, the sizes of R2Real, R2Vector and R2Pose, and R2_ABI_FEATURES. Fails with R2_INVALID_ARGUMENT when the version, dimension, precision, or the RAPIER_FEM/RAPIER_ROBOTICS defines differ from the library, since they change structure layouts.

◆ r2LastError()

const char * r2LastError ( void )

Thread-local UTF-8 diagnostic, valid until the next fallible call on this thread.

◆ r2LastStatus()

R2Status r2LastStatus ( void )

Status of the most recent fallible operation on this thread.

Reading this or LastError does not clear it. Infallible value constructors do not change it. Check immediately after a fallible value-returning operation when recovering from errors instead of using a fail-fast error callback.

◆ r2PodLayout()

struct R2PodLayout r2PodLayout ( void )

Return POD structure sizes for checking foreign-language layouts against this library.

◆ r2SetErrorHandler()

struct R2ErrorHandler r2SetErrorHandler ( struct R2ErrorHandler handler)

Replace this thread's error handler and return the previous handler so it can be restored at the end of a scope.

Status returns are unchanged. A handler that returns lets the caller recover by checking the status; a fail-fast handler may terminate the process. Includes R2_NOT_FOUND query misses.

◆ r2Version()

const char * r2Version ( void )

Release version of the loaded C bindings, e.g.

"0.35.3+c.2". The suffix identifies the C bindings revision for the Rust crate version. The UTF-8, NUL-terminated string is borrowed for the library's lifetime; do not free it. This release identifier is independent of the ABI compatibility version.