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
OrtApitable — IDX_* indices, typed fn aliases, Api accessors, and the opaque handle types. zrt names; noOrt*; no bindgen. Regenerate viacargo run -p st-zrt-sys-codegen -- <header> <this file>. GENERATED byst-zrt-sys-codegenfrom 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 useGetApi(offset 0) andGetVersionString(offset 1).
Enums§
- Allocator
Type - OrtAllocatorType.
- Element
Type - ONNXTensorElementDataType.
- EpData
Layout - OrtEpDataLayout (onnxruntime_ep_c_api.h). An EP’s preferred tensor data layout.
Defaultis an alias forNchw(= 0), so only the two concrete variants are modelled. - Execution
Mode - ExecutionMode.
- Execution
Provider Device Policy - OrtExecutionProviderDevicePolicy.
- Graph
Capture Node Assignment Policy - OrtGraphCaptureNodeAssignmentPolicy (onnxruntime_ep_c_api.h). How strictly ORT validates node assignment when an EP enables CUDA-graph-style capture.
- Graph
Optimization Level - GraphOptimizationLevel.
- Logging
Level - OrtLoggingLevel (a.k.a. LogLevel).
- MemType
- OrtMemType.
- Onnx
Type - ONNXType (the top-level value kind).
- OpAttr
Type - OrtOpAttrType — the value kind of a custom-op attribute (CreateOpAttr / OpAttr_GetType).
- OrtError
Code - OrtErrorCode — the status code
GetErrorCodereturns andCreateStatusaccepts (onnxruntime_c_api.h:257-273).#[repr(i32)]makes it ABI-compatible with thec_int-typed generated status API (CreateStatusFn/GetErrorCodeFn— both map the COrtErrorCodetoc_int). - Profiling
Event Category - OrtProfilingEventCategory (onnxruntime_ep_c_api.h). The granularity of an EP profiling event,
passed to
CreateProfilingEventand read back viaProfilingEvent_GetCategory. A plain int enum — not an opaque handle — so it is modelled here, likeMemType. - Sparse
Format - OrtSparseFormat.
- Sparse
Indices Format - 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
Apifunction-pointer table forAPI_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 aSUPPORTED_RUNTIME_LINESline. - status_
to_ ⚠result - Turn a raw
OrtStatus*intoResult:Ok(())if null, else code+message. On the error path the status is consumed (released).
Type Aliases§
- LogLevel
- Logging
Function - OrtLoggingFunction — the custom-logger callback (
CreateEnvWithCustomLogger).