Skip to main content

Crate st_zrt_sys

Crate st_zrt_sys 

Source
Expand description

st-zrt-sys — hand-written FFI to libonnxruntime, in the zrt namespace.

NO bindgen: OrtApi’s function-pointer table is macro-defined (bindgen can’t parse it and drags in legacy Ort* names). Instead, the st-zrt-sys-codegen tool preprocesses onnxruntime_c_api.h (gcc -E -P), parses the fully-expanded struct OrtApi, and emits [mod generated] — the exhaustive IDX_*/typed-alias/ accessor table with zrt names. This file keeps only the hand-written core: opaque handles, the stable enums, ApiBase, the Api table primitive, the entry point, and status_to_result.

The only C symbol linked by name is OrtGetApiBase (#[link_name]); everything else is reached through Api by positional index.

Re-exports§

pub use generated::*;

Modules§

generated
GENERATED: the exhaustive OrtApi table — IDX_* indices, typed fn aliases, Api accessors, and the opaque handle types. zrt names; no Ort*; no bindgen. Regenerate via cargo run -p st-zrt-sys-codegen -- <header> <this file>. GENERATED by st-zrt-sys-codegen from onnxruntime_c_api.h — DO NOT EDIT. The full OrtApi function-pointer table: IDX_* indices, typed fn aliases, and Api accessors, plus the opaque handle types. zrt names; no Ort*; no bindgen.

Structs§

Api
OrtApi — a table of function pointers, indexed positionally. The struct is effectively [*const c_void; N] (all slots pointer-sized, no padding). The generated table (in [mod generated]) adds the typed accessors.
ApiBase
OrtApiBase. We only use GetApi (offset 0) and GetVersionString (offset 1).

Enums§

AllocatorType
OrtAllocatorType.
ElementType
ONNXTensorElementDataType.
EpDataLayout
OrtEpDataLayout (onnxruntime_ep_c_api.h). An EP’s preferred tensor data layout. Default is an alias for Nchw (= 0), so only the two concrete variants are modelled.
ExecutionMode
ExecutionMode.
ExecutionProviderDevicePolicy
OrtExecutionProviderDevicePolicy.
GraphCaptureNodeAssignmentPolicy
OrtGraphCaptureNodeAssignmentPolicy (onnxruntime_ep_c_api.h). How strictly ORT validates node assignment when an EP enables CUDA-graph-style capture.
GraphOptimizationLevel
GraphOptimizationLevel.
LoggingLevel
OrtLoggingLevel (a.k.a. LogLevel).
MemType
OrtMemType.
OnnxType
ONNXType (the top-level value kind).
OpAttrType
OrtOpAttrType — the value kind of a custom-op attribute (CreateOpAttr / OpAttr_GetType).
OrtErrorCode
OrtErrorCode — the status code GetErrorCode returns and CreateStatus accepts (onnxruntime_c_api.h:257-273). #[repr(i32)] makes it ABI-compatible with the c_int-typed generated status API (CreateStatusFn / GetErrorCodeFn — both map the C OrtErrorCode to c_int).
ProfilingEventCategory
OrtProfilingEventCategory (onnxruntime_ep_c_api.h). The granularity of an EP profiling event, passed to CreateProfilingEvent and read back via ProfilingEvent_GetCategory. A plain int enum — not an opaque handle — so it is modelled here, like MemType.
SparseFormat
OrtSparseFormat.
SparseIndicesFormat
OrtSparseIndicesFormat.

Constants§

API_VERSION
libonnxruntime API version we bind (1.27.0 → API version 27).
ORT_VERSION
The exact libonnxruntime version this crate acquires and links by default.
SUPPORTED_RUNTIME_LINES
libonnxruntime release lines whose runtime these API-{API_VERSION} bindings support.

Functions§

api
The Api function-pointer table for API_VERSION.
api_base
The global OrtApiBase.
runtime_version_string
GetVersionString() of the loaded libonnxruntime, if the entry point is callable.
runtime_version_supported
Whether a GetVersionString() result belongs to a SUPPORTED_RUNTIME_LINES line.
status_to_result⚠
Turn a raw OrtStatus* into Result: Ok(()) if null, else code+message. On the error path the status is consumed (released).

Type Aliases§

LogLevel
LoggingFunction
OrtLoggingFunction — the custom-logger callback (CreateEnvWithCustomLogger).