Skip to main content
Version: Dev (main)

Language Bindings

QAROS ships a single stable C ABI (qar_streaming.h). Every other binding is a thin layer over it, so all languages share the same concepts — runtime, session, peers, panels, app volumes, render senders — described in Concepts. Because the DLL exports plain named functions and structs only ever grow through the extension-chain mechanism, bindings stay compatible across runtime updates. The Rust binding needs a runtime at least as new as its header (see Rust below).

Pick your language's setup path in Getting Started. Every binding finds and loads the runtime the same way; writing a new one is described in Authoring a Language Binding.

C — the native ABI​

The C API is the source of truth: one generated header, one shared library (qar-streaming-c). Results are returned by value (QarResult), init structs carry a {type, next} header that must be stamped via the qar_*_default() helpers, and callbacks fire on library threads. Any language with a C FFI (Python cffi, …) can consume it directly by replicating those three conventions, as the Rust binding does with bindgen.

C# / .NET and Unity​

The managed binding lives in the Quaternar.Qaros namespace: types drop the Qar prefix, handles become IDisposable / SafeHandle-backed classes, and QarResult maps to a Result<T> type (.IsSuccess, .Value, .ValueOrThrow(), .Info). Enumerations return ready-made arrays (Result<PeerSpec[]>), continuous updates surface as C# events and disposable SubscribeUpdates(...) subscriptions, and ...Async variants return Task<Result<T>>.

It targets netstandard2.0, netstandard2.1, and net8.0, and loads the same native qar-streaming-c DLL. Unity uses this same C# binding, so the API is identical there; it comes with the Unity packages. See the per-language snippets throughout this guide — Peers, GUI Panels, App Volumes, and Rendering Streams — for idiomatic usage.

Rust​

The Rust binding lives in qar-streaming-rust/, a Cargo workspace:

  • qaros-sys: the raw bindings to every exported qar_impl_* function, generated from qar_streaming.h per target and committed, the runtime lookup and loading, and ports of the qar_*_default() initializers.
  • qaros: the safe API: library and runtime, onboarding and rejoin, peers, app volumes, GUI panels, and the CPU, Vulkan and D3D11 render senders (Vulkan behind the vulkan feature, D3D11 behind the d3d11 feature: Windows; on macOS only for the tests against qaros-stub).
  • qaros-stub, qaros-conformance and tests/qar-streaming-rust-ext are test-only: an in-memory stand-in for the runtime, a check of the ported initializers against the header, and the integration tests against qar-streaming-c-ext. examples/ ports the C examples.

Library::load_default finds the runtime with the default lookup every binding follows (Authoring a Language Binding); Library::load loads one library file and nothing else. Either loads every function of the header the bindings were generated from, or none. The binding therefore needs a QAROS runtime that exports every function of that header (this repository's qar-streaming-c/include/qar_streaming.h), and that is the runtime of the Hub you join. An older runtime fails to load, and the error names the functions it lacks. Pin the git dependency with rev or tag, so the header stays the one your runtime exports in full.

The binding keeps the C conventions behind safe wrappers. Init structs come from the ported initializers, so every header is stamped. A QarResult becomes a qaros::Result whose error keeps the function name, status code and message. Handles release themselves on drop, each keeping its parent alive, so the C teardown order holds. Callbacks run on library threads and receive owned snapshots. Hands, gestures, world anchors, video senders, target apps, member hubs and the peer role, category, presence and device identity stay raw: call them through library.raw_api() with the C handle of a safe value, which as_raw() returns on Session, Runtime, RenderSender, CancelToken and OnboardingInvite. The handle stays owned by the safe value, which destroys it. The coverage table in the binding's README lists each area of the C API as safe in Rust, raw only, and whether the C# binding has it. The guide's code samples have a Rust tab, taken from code the binding compiles; the Rust tutorials walk through the binding's examples, and building and testing are in the binding's README.

C++​

The C header compiles cleanly as C++, so you can consume it directly and add your own RAII wrappers. The repository also carries qar-streaming-cpp, a header-only C++17 wrapper over the C header (CMake target qar-streaming-cpp): owning handles, result types, builders and optional asio completion tokens. It has no binding of its own to keep in step; it only calls the qar_* functions of the header. MSVC compiles it in C++17 and C++20 with or without /permissive-, warning-free at /W4.

A C++-only project adds it with CMake and needs no C language:

project(MyApp LANGUAGES CXX)
add_subdirectory(qaros/qar-streaming-c)
add_subdirectory(qaros/qar-streaming-cpp)
target_link_libraries(my_app PRIVATE qar-streaming-cpp)
  • The target qar-streaming-c-headers (linked by qar-streaming-cpp) adds QAR_ENABLE_DYNAMIC_LOADING to every target that links it: put QAR_IMPLEMENT_DYNAMIC_LOADING() in exactly one source file and call qar_library_load first, as Getting Started shows.
  • The C examples build only when qaros is the top-level project; QAROS_BUILD_EXAMPLES turns them on or off (BUILD_CORE_EXAMPLES still works).

Join as a local app with OnboardBuilder::WithLocalApp() (and WithAppTag to tell instances of one app apart), or as a co-process with WithInvite. The wrapper no longer has Runtime::Rejoin, Runtime::RejoinAsync, RejoinBuilder or Runtime::Forget: they wrapped the deprecated qar_runtime_rejoin and qar_runtime_forget, which only the deprecated code onboarding needs. A local app onboards again on every start and stores nothing, so there is nothing to rejoin or forget; the user revokes its approval in the Visualizer. PeerSpec::AppState is replaced by PeerSpec::Presence. The wrapper's README has the full migration.

The recommended idioms for your own wrappers:

  • wrap each handle in a small RAII type that calls the matching qar_*_handle_destroy,
  • wrap QarResult in a checker that throws or logs via qar_result_log_if_error,
  • keep all calls on one thread and marshal callback data through your own queue.

If you work with Ogre, Qt or RViz2, three C++ libraries build on QAROS (the Qt one through the header-only C++ SDK): see Ogre, Qt and RViz2 on QAROS. To stream an Ogre scene, see Streaming an Ogre Scene to QAROS.