Expand description
Safe Rust API over the QAROS streaming C API.
Covers what a streaming application needs: loading and initializing the
library, the loaded runtime’s version, runtimes, onboarding and rejoin,
blocking or async (pairing code, remote hub, co-process invites, local app
approved in the hub, app tags, remote-app grants, a declared device, adapter
choice, planned peer id, re-enrollment), member hubs, peers, the CPU render sender, the
Vulkan render sender (feature vulkan, module vulkan), the D3D11 render
sender (feature d3d11, module d3d11: Windows; on macOS only for the
tests against qaros-stub), app volumes and GUI panels. Hands, gestures and world anchors
stay in qaros_sys; reach them, and every other raw call, through
Library::raw_api.
§Design
- Every fallible call returns
Result; C errors carry theStatusCodeand the message fromqar_result_message. - Init structures are built from the ported
qar_*_default()initializers, so everyQarStructureHeaderis stamped. - Handles release themselves on drop, and each keeps its parent alive, so the C teardown order is always render sender, session, runtime, library, whatever order Rust drops them in.
- None of the handle types is
Send: the SDK is designed for single-threaded use per runtime, and callbacks are its only cross-thread surface. - Subscription callbacks run on library threads. They receive owned
snapshots read from the borrowed C handle during the callback; use
channelto forward them into astd::sync::mpscreceiver. Their state lives until the session is destroyed; aSubscriptionguard only cancels.
use qaros::{BlockingOptions, Library, LibraryConfig, OnboardMethod, PeerPresentation, RuntimeConfig};
// SAFETY: the runtime found (the installed QAROS, or that of the instance QAR_INSTANCE
// names) matches these bindings.
let library = unsafe { Library::load_default(&LibraryConfig::default())? };
let runtime = library.create_runtime(&RuntimeConfig::default())?;
// An app on the hub's PC joins as a local app: the first start waits for Allow in QAROS.
let onboarded = runtime.onboard(
&OnboardMethod::LocalApp { approval_timeout: None, app_tag: None },
&PeerPresentation::default(),
&BlockingOptions::default(),
)?;
let peers = onboarded.session.peers()?;Re-exports§
pub use qaros_sys;
Modules§
- d3d11
- The D3D11 render sender path (feature
d3d11). - vulkan
- The Vulkan render sender path (feature
vulkan).
Structs§
- AppVolume
Config - Options for
qar_app_volumes_get_or_create. - AppVolume
Id - Formats as colon-separated hex bytes, like the C examples’
print_hex_id. Persist onboarding ids withcrate::Library::uuid_to_stringinstead, which uses the library’s own UUID text form. - AppVolume
Info - Snapshot of a
QarAppVolume. - AppVolume
Size - Box extents in meters.
- AppVolumes
- App volume operations of a session (
session.app_volumes()). - Blocking
Options - Optional progress channel and cancellation for the blocking calls.
- Cancel
Handle - Cancels a
CancelTokenfrom any thread (qar_cancel_token_cancel). It does not keep the token alive: once the token’s last owner is gone,CancelHandle::canceldoes nothing and returnsOk(false). - Cancel
Token - A
QarCancelToken. - CpuFrame
- The frame’s CPU textures and the views mapping eyes and color/depth onto
them (
qar_render_sender_frame_cpu). - CpuTexture
- A CPU texture of the current frame, writable until the frame is shown.
- Device
Identity - The device an application describes itself as (
QarPeerDeviceIdentity). Without one it joins as a desktop PC with the fixed id of the host OS (DesktopWindows/DesktopLinux). - Fov
- Field of view as four angles in radians, OpenXR style:
leftanddownare normally negative. - Frame
- A frame between
begin_frameandshow_frame, borrowing its sender. Dropping it withoutFrame::showreleases the frame info without presenting. - Frame
View Spec - One view inside the video frame, as declared at sender creation.
- GuiPanel
Config - Options for
qar_gui_panels_get_or_create. - GuiPanel
Id - Formats as colon-separated hex bytes, like the C examples’
print_hex_id. Persist onboarding ids withcrate::Library::uuid_to_stringinstead, which uses the library’s own UUID text form. - GuiPanel
Info - Snapshot of a
QarGuiPanel. - GuiPanel
Served Content - What a served GUI panel shows: one entry page of a content bundle.
- GuiPanel
Size - Physical size in meters and the scale mapping web content onto it.
- GuiPanels
- GUI panel operations of a session (
session.gui_panels()). - HubAddress
Deprecated - Where the hub runs, for onboarding with a code against a remote hub (
QarOnboardHostExt). - Join
HubAs Member Config - Options for
Runtime::join_hub_as_member(QarJoinHubAsMemberInit).Noneselects the C API’s default; under 1 ms, or overu32::MAXmilliseconds, iscrate::Error::InvalidArgumentbefore the call, since the C API reads zero as the default. - Library
- The loaded and initialized C API library.
- Library
Config - Options for
qar_library_init; the default matchesqar_library_init_default(). - Member
HubInvitation - A member-hub invitation (
QarMemberHubInvitation), destroyed on drop (qar_member_hub_invitation_handle_destroy). A secret bearer credential: send its bytes only over a trusted channel and never log them. The primary hub’s operator sees it in the visualizer and can revoke it. - Member
HubInvitation Config - Options for
Runtime::create_member_hub_invitation(QarMemberHubInvitationInit).Noneselects the C API’s default. - Member
HubPermissions - The permissions a member-hub invitation grants at the primary hub
(
QarMemberHubInvitationPermissionFlagBits). Combine them with|. - Onboard
Extensions - The optional extensions of
Runtime::onboard_withandRuntime::start_onboard, chained after the mode extension in this order: the remote-app grant, the adapter or no graphics device, the planned peer id (deprecated). The re-enrolled onboarding id (deprecated) goes into the init itself. - Onboarded
- The result of a successful onboarding or rejoin.
- Onboarding
Id - Key of a persisted identity slot, the ticket for the deprecated
crate::Runtime::rejoinandcrate::Runtime::forget. Local apps, companions and member hubs’ apps have none to persist. - Onboarding
Invite - A
QarOnboardingInvite: a full invite blob, onboarded withcrate::OnboardMethod::Invite. A co-process invite (crate::Session::request_onboarding_invite) or the launch invite QAROS hands an app it starts. A secret: hand it over a private channel (stdin, a pipe), never on a command line. A co-process invite names the requesting app on this PC and works for every start of the co-process while the app’s session lives; onboarding with it fetches a fresh hub invite from the app on each attempt and retries until it joins. - Owned
Frame - A frame between
begin_frameandshow_framethat owns a reference to its sender, fromRenderSender::begin_owned_frame. Dropping it withoutOwnedFrame::showreleases the frame info without presenting. - Panel
Content - Panel content operations of a session (
session.panel_content()). - Panel
Content Bundle Id - Names one content bundle (
QarPanelContentBundleId): the session that published it and serves its files, and its name, unique per publisher. - Panel
Content File - One file of
PanelContent::publish_files(QarPanelContentFile). - Panel
Content Message - A message a served panel sent to its content owner, stamped by the mixer showing it
(
QarPanelContentMessage). - PeerId
- A participant in the session: a device or an application.
- Peer
Identity - A peer’s presence, role and device identity (
qar_peer_spec_get_presence,_get_role,_get_category,_get_device_id,_get_device_family,_get_device_name), read with the rest ofcrate::PeerInfo. The device id and name can change while the peer runs (a serving app refines them once the device reports its model): re-read them in a peer update. - Peer
Info - Snapshot of a
QarPeerSpec. - Peer
Presentation - How this peer presents itself to others (
QarPeerPresentation).Nonekeeps the persisted value (or a generated default on first onboard). - Pending
Call - An async call in flight: a render sender creation (
crate::Session::start_render_sender), an onboard or rejoin (crate::Runtime::start_onboard,crate::Runtime::start_rejoin), a co-process invite (crate::Session::start_onboarding_invite), a target-app invite or kill (crate::Session::start_invite_target_app,crate::Session::start_kill_target_app), or a begin-frame (crate::RenderSender::start_owned_frame). It keeps its owner alive. - Pose
- Orientation and position; the default is the identity pose, as
qar_pose_default(). - Progress
- A progress report from a blocking onboarding call.
- Quat
- Rotation quaternion, scalar last.
- Render
Request - A render stream request from a peer that wants this application’s frames, read inside the callback.
- Render
Sender - A CPU render stream sender. Keeps its session alive; destroyed with
qar_render_stream_handle_destroyafter the last open frame. - Render
Sender Config - Options for
qar_render_sender_createon the CPU path. - Runtime
- A
QarRuntime. Sessions keep it alive; it is released after the last of them (qar_runtime_handle_destroy), which ends its pending async onboards and rejoins and waits for their callbacks. - Runtime
Config - Options for
qar_runtime_create;Nonekeeps the library default. - Runtime
Info - What the loaded
qar-streaming-creports about itself (qar_runtime_info). - Session
- A
QarSession, obtained bycrate::Runtime::rejoinorcrate::Runtime::onboard. - Session
Id - Formats as colon-separated hex bytes, like the C examples’
print_hex_id. Persist onboarding ids withcrate::Library::uuid_to_stringinstead, which uses the library’s own UUID text form. - Session
Lifecycle - One state of a session’s lifecycle (
QarSessionLifecycleInfo), copied out of the library. - Show
Params - What
show_framereports about the frame just rendered. The default isqar_render_frame_show_default(): near 0.1, far 100, depth scale 1. - Status
Code - A
QarStatusCodeas returned by the C API. - Stream
Id - Correlates render stream requests.
- Subscription
- Guard for one subscription. Dropping it cancels delivery (through the
subscription’s cancel token); the callback itself stays allocated until
the session is destroyed. A receiver from
crate::channeltherefore does not disconnect when the guard drops, only when the session does. - Texture
Size - Format and size of one texture of the frame layout (
QarTextureSize). - Vec3
- Position in meters. Room space is right-handed, Y up, minus Z forward (OpenXR conventions).
- Video
Frame Layout - The negotiated layout (
qar_render_sender_layout). - Video
Frame View - A view rectangle inside one of the frame’s textures. End coordinates are exclusive and may be smaller than the start (flips).
- View
Pose - Per-view pose and field of view to render with, from
begin_frame.
Enums§
- Action
Severity - Severity of a progress callback message (
QarActionSeverity). - AppState
- Lifecycle state of a peer’s application (
QarAppState), deprecated in the public header for the peer presence and computed from it there; seecrate::PeerInfo::app_state. - AppVolume
Lifetime - Whether an app volume is active or closed (
QarAppVolumeLifetimeStatus). - Color
Alpha Mode - What a render sender’s colour alpha means (
QarColorAlphaMode), declared throughQarRenderSenderAlphaModeExt. The stream publishes it and a receiver composites by it. - Color
Encoding - What the numbers in a render sender’s colour texture mean
(
QarColorEncoding), declared throughQarRenderSenderColorEncodingExt. Whatever is declared, the stream carries sRGB-encoded colour. - Device
Category - What kind of device a peer is (
QarDeviceCategory): the fallback when a viewer does not know the peer’s device id or family. A value the header does not name reads asDeviceCategory::Unknown, as the header says to treat it. - Error
- Every failure the safe API reports.
- Eye
- The eye a frame view is for (
QarVideoFrameViewEye). - Frame
Layout - How views pack into the frame’s textures.
- Graphics
Adapter - A graphics adapter, by the id bytes Vulkan and DXGI report for it.
- GuiPanel
Content Type - What a GUI panel shows (
QarGuiPanelContentType), fixed at creation. - GuiPanel
State - Visibility of a GUI panel (
QarGuiPanelState). - LogSeverity
- Severity of a library log message (
QarLogSeverity). - Onboard
Method - The onboarding path, chained as exactly one mode extension. An app joins in one of three ways:
as a local app (
OnboardMethod::LocalApp), as a companion of a local app (OnboardMethod::Invitewith the app’scrate::Session::request_onboarding_invite), or through a member hub (OnboardMethod::LocalAppwithOnboardExtensions::remote_app_grant). - Peer
Presence - Where a peer is (
QarPeerPresence). Render forPeerPresence::Onlinepeers andPeerPresence::Unknownones; stop at the others. A value the header does not name reads asPeerPresence::Unknown, as the header says to treat it. - Peer
Role - What a peer is in the streaming graph (
QarPeerRole). A source renders for thePeerRole::Targetpeers. A value the header does not name isPeerRole::Other. - Pixel
Format - Pixel format of a frame texture (
QarPixelFormat). - Qaros
Device Kind - The device type whose setup a
QarosView::DeviceSetupview shows (QarQarosDeviceKind). - Qaros
View - A predefined view of the QAROS Visualizer (
QarQarosView), opened withcrate::Session::open_qaros_view: each is the dialog theqaros://visualizerlink of the same name opens. The device kind sits in the setup variant, so no other view can carry one. - Render
Loop - When a render sender’s application renders its frames (
QarRenderLoop), declared throughQarRenderSenderRenderLoopExt. - Session
Change Cause - Why the session moved into another session id (
QarSessionChangeCause). Informational only; treatSelf::OtherasSelf::Rotated. - Session
Lifecycle State - Where a session stands in its hub’s session lifecycle (
QarSessionLifecycleState). TreatSelf::OtherasSelf::HubUnreachable: the session keeps trying. - Source
Device Category - The device categories an application may declare (
QarDeviceCategory). An application always joins as a source; the C API refuses every other category withQAR_STATUS_PEER_DEVICE_CATEGORY_NOT_ALLOWED, so this enum has none of them. - Target
Device - The device kind a target-app connection string names
(
Library::target_app_connection_string). - View
Kind - What a frame view holds: color, grayscale or depth (
QarVideoFrameViewType).
Constants§
- PANEL_
CONTENT_ BUNDLE_ NAME_ MAX - Longest bundle name, in bytes (
QAR_PANEL_CONTENT_BUNDLE_NAME_MAX).
Functions§
- channel
- A callback that forwards events into a channel, and the receiving end.
- installed_
bin_ folder <InstallFolder>\binof the QAROS installed on this PC, read fromHKLM\SOFTWARE\Quaternar\QAROS.Nonewhen QAROS is not installed, and always outside Windows.- instance_
runtime_ folder - The folder holding the runtime of QAROS instance
instance, as step 2 of the default lookup picks it: fordefaultthe installed QAROS’s<InstallFolder>\bin(installed_bin_folder); for any other name the fully qualified valueRuntimeFolderofHKCU\SOFTWARE\Quaternar\QAROS\Instances\<name>, which a QAROS development hub writes for the apps it starts, else that record’s fully qualified<InstallFolder>\bin.Nonewhen the name is not valid (crate::is_valid_instance_name), no folder is recorded, or outside Windows, which has no instance records. - requested_
instance - The value of
QAR_INSTANCE, exactly as set, when it is set and not empty (read lossily when it is not Unicode, which no instance name is). The default lookup reads it on Windows only.
Type Aliases§
- Pending
Frame - A begin-frame in flight from
RenderSender::start_owned_frame, delivering anOwnedFrame. - Pending
Onboard - An async onboard or rejoin, delivering an
Onboarded. - Pending
Render Sender - A render sender being created by
crate::Session::start_render_sender,Session::start_vulkan_render_sender(featurevulkan) orSession::start_d3d11_render_sender(featured3d11). Keeps its session alive, as a sender does, so dropping thecrate::Sessionmeanwhile is safe. A D3D11 creation also keeps the device references of its parameters. - Result
- The result type of every fallible call in this crate.