Skip to main content
QAROS Rust API Dev (main) · versions: Dev (main) · Developer Guide

qaros_sys/
defaults.rs

1//! Ports of the header's `static inline` `qar_*_default()` initializers.
2//!
3//! These functions do not exist in the binary, so every language binding
4//! must replicate them. Each port matches the header's initializer field by
5//! field, which the `qaros-conformance` tests check by compiling the C
6//! originals. Members the C initializers zero-fill (`{ 0 }` or `{}`) are
7//! zero here too.
8
9use std::ptr;
10
11#[allow(clippy::wildcard_imports)]
12use crate::types::*;
13
14/// Plain C data for which the all-zero bit pattern is a valid value: integers,
15/// floats, `bool`, raw pointers, `Option` of function pointers and the
16/// newtype enums.
17///
18/// # Safety
19///
20/// Implement only for `#[repr(C)]` types whose every field satisfies the
21/// above.
22unsafe trait ZeroInitializable {}
23
24macro_rules! zero_initializable {
25    ($($type_name:ty),* $(,)?) => {
26        $(
27            // SAFETY: generated from the header; fields are integers, floats,
28            // bools, raw pointers or nested types listed here.
29            unsafe impl ZeroInitializable for $type_name {}
30        )*
31    };
32}
33
34zero_initializable!(
35    QarVideoFrameView,
36    QarTextureSize,
37    QarVideoTextureCpu,
38    QarRenderFrameView,
39    QarGeoAnchorFrame,
40    QarAppVolumeGestureMappingRule,
41    QarHandJointLocation,
42    QarHandJointVelocity,
43    QarVideoTextureVulkan,
44    QarLuid,
45);
46
47#[cfg(any(target_os = "windows", target_os = "macos"))]
48zero_initializable!(QarVideoTextureD3D11, QarDXGIKeyedMutexSync);
49
50fn zeroed<T: ZeroInitializable>() -> T {
51    // SAFETY: ZeroInitializable guarantees the all-zero pattern is valid.
52    unsafe { std::mem::zeroed() }
53}
54
55/// Header stamp `{ type, NULL }`.
56pub fn structure_header(structure_type: QarStructureType) -> QarStructureHeader {
57    QarStructureHeader {
58        type_: structure_type,
59        next: ptr::null_mut(),
60    }
61}
62
63const ZERO_ID: [u8; 16] = [0; 16];
64
65/// C enums are `int` under MSVC and `unsigned int` under clang outside Windows, so
66/// the newtype's inner type differs per target; the mask field is `uint32_t`.
67#[allow(clippy::unnecessary_cast, clippy::cast_sign_loss)]
68fn axis_mask(flags: QarAppVolumeAxisFlags) -> u32 {
69    flags.0 as u32
70}
71
72pub fn qar_time_point_default() -> QarTimePoint {
73    QarTimePoint { unix_ns: 0 }
74}
75
76pub fn qar_vector3_default() -> QarVector3 {
77    QarVector3 {
78        x: 0.0,
79        y: 0.0,
80        z: 0.0,
81    }
82}
83
84pub fn qar_quaternion_default() -> QarQuaternion {
85    QarQuaternion {
86        x: 0.0,
87        y: 0.0,
88        z: 0.0,
89        w: 1.0,
90    }
91}
92
93pub fn qar_pose_default() -> QarPose {
94    QarPose {
95        orientation: qar_quaternion_default(),
96        position: qar_vector3_default(),
97    }
98}
99
100/// The header's comment says "all zeros"; the initializer sets ±0.785 rad.
101/// This port follows the initializer.
102pub fn qar_fov_default() -> QarFov {
103    QarFov {
104        angle_left: -0.785,
105        angle_right: 0.785,
106        angle_up: 0.785,
107        angle_down: -0.785,
108    }
109}
110
111/// The header's comment says "zeros"; the initializer sets 0.1 and 100.
112/// This port follows the initializer.
113pub fn qar_near_far_default() -> QarNearFar {
114    QarNearFar {
115        near_plane: 0.1,
116        far_plane: 100.0,
117    }
118}
119
120pub fn qar_peer_id_default() -> QarPeerId {
121    QarPeerId { data: ZERO_ID }
122}
123
124pub fn qar_session_id_default() -> QarSessionId {
125    QarSessionId { data: ZERO_ID }
126}
127
128pub fn qar_gui_panel_id_default() -> QarGuiPanelId {
129    QarGuiPanelId { data: ZERO_ID }
130}
131
132pub fn qar_app_volume_id_default() -> QarAppVolumeId {
133    QarAppVolumeId { data: ZERO_ID }
134}
135
136pub fn qar_stream_id_default() -> QarStreamId {
137    QarStreamId { data: ZERO_ID }
138}
139
140pub fn qar_onboarding_id_default() -> QarOnboardingId {
141    QarOnboardingId { data: ZERO_ID }
142}
143
144pub fn qar_hand_joint_location_default() -> QarHandJointLocation {
145    QarHandJointLocation {
146        joint_id: 0,
147        location_flags: 0,
148        pose: qar_pose_default(),
149        radius: 0.0,
150    }
151}
152
153pub fn qar_hand_joint_velocity_default() -> QarHandJointVelocity {
154    QarHandJointVelocity {
155        joint_id: 0,
156        flags: 0,
157        linear_velocity: qar_vector3_default(),
158        angular_velocity: qar_vector3_default(),
159    }
160}
161
162pub fn qar_hand_joints_default() -> QarHandJoints {
163    QarHandJoints {
164        is_tracked: false,
165        is_active: false,
166        pose: qar_pose_default(),
167        joint_locations: [qar_hand_joint_location_default(); QAR_HAND_JOINT_COUNT as usize],
168        has_velocity: false,
169        joint_velocities: [qar_hand_joint_velocity_default(); QAR_HAND_JOINT_COUNT as usize],
170    }
171}
172
173pub fn qar_device_hand_with_joints_default() -> QarDeviceHandsWithJoints {
174    QarDeviceHandsWithJoints {
175        device_id: qar_peer_id_default(),
176        device_timestamp: qar_time_point_default(),
177        left_hand: qar_hand_joints_default(),
178        right_hand: qar_hand_joints_default(),
179    }
180}
181
182pub fn qar_render_frame_view_default() -> QarRenderFrameView {
183    QarRenderFrameView {
184        data_type: QarVideoFrameViewType::QAR_VIDEO_FRAME_VIEW_TYPE_GRAYSCALE,
185        eye: QarVideoFrameViewEye::QAR_VIDEO_FRAME_VIEW_EYE_NONE,
186        texture_index: 0,
187    }
188}
189
190pub fn qar_image_size_default() -> QarImageSize {
191    QarImageSize {
192        width: 0,
193        height: 0,
194    }
195}
196
197pub fn qar_texture_size_default() -> QarTextureSize {
198    QarTextureSize {
199        format: QarPixelFormat::QAR_PIXEL_FORMAT_B8G8R8A8,
200        width: 0,
201        height: 0,
202        array_layers: 1,
203    }
204}
205
206pub fn qar_video_frame_view_default() -> QarVideoFrameView {
207    QarVideoFrameView {
208        start_x: 0,
209        start_y: 0,
210        end_x: 0,
211        end_y: 0,
212        texture_index: 0,
213        array_layer_index: 0,
214        texture_format: QarPixelFormat::QAR_PIXEL_FORMAT_B8G8R8A8,
215        data_type: QarVideoFrameViewType::QAR_VIDEO_FRAME_VIEW_TYPE_COLOR,
216        eye: QarVideoFrameViewEye::QAR_VIDEO_FRAME_VIEW_EYE_NONE,
217    }
218}
219
220/// Views and textures are zero-filled, as in the header (not set to their
221/// own defaults).
222pub fn qar_video_frame_layout_default() -> QarVideoFrameLayout {
223    QarVideoFrameLayout {
224        views: [zeroed(); QAR_MAX_FRAME_VIEWS as usize],
225        views_count: 0,
226        textures: [zeroed(); QAR_MAX_FRAME_TEXTURES as usize],
227        textures_count: 0,
228    }
229}
230
231pub fn qar_video_texture_cpu_default() -> QarVideoTextureCpu {
232    QarVideoTextureCpu {
233        size: qar_texture_size_default(),
234        pitch: 0,
235        texture_data: ptr::null_mut(),
236        texture_data_size: 0,
237    }
238}
239
240/// Views and textures are zero-filled, as in the header.
241pub fn qar_video_frame_cpu_default() -> QarVideoFrameCpu {
242    QarVideoFrameCpu {
243        texture_views: [zeroed(); QAR_MAX_FRAME_VIEWS as usize],
244        texture_views_count: 0,
245        textures: [zeroed(); QAR_MAX_FRAME_TEXTURES as usize],
246        textures_count: 0,
247    }
248}
249
250#[cfg(any(target_os = "windows", target_os = "macos"))]
251pub fn qar_video_texture_d3d11_default() -> QarVideoTextureD3D11 {
252    QarVideoTextureD3D11 {
253        size: qar_texture_size_default(),
254        texture: ptr::null_mut(),
255    }
256}
257
258#[cfg(any(target_os = "windows", target_os = "macos"))]
259pub fn qar_dxgi_keyed_mutex_sync_default() -> QarDXGIKeyedMutexSync {
260    QarDXGIKeyedMutexSync {
261        mutex: ptr::null_mut(),
262        acquire: 0,
263        release: 0,
264    }
265}
266
267#[cfg(any(target_os = "windows", target_os = "macos"))]
268pub fn qar_sync_frame_d3d11_default() -> QarSyncFrameD3D11 {
269    QarSyncFrameD3D11 {
270        texture_sync: [zeroed(); QAR_MAX_FRAME_TEXTURES as usize],
271        texture_sync_count: 0,
272    }
273}
274
275#[cfg(any(target_os = "windows", target_os = "macos"))]
276pub fn qar_video_frame_d3d11_default() -> QarVideoFrameD3D11 {
277    QarVideoFrameD3D11 {
278        texture_views: [zeroed(); QAR_MAX_FRAME_VIEWS as usize],
279        texture_views_count: 0,
280        textures: [zeroed(); QAR_MAX_FRAME_TEXTURES as usize],
281        textures_count: 0,
282        synchronization: qar_sync_frame_d3d11_default(),
283    }
284}
285
286#[cfg(any(target_os = "windows", target_os = "macos"))]
287pub fn qar_stream_params_d3d11_default() -> QarStreamParamsD3D11 {
288    QarStreamParamsD3D11 {
289        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_STREAM_D3D11_PARAMS_EXT),
290        d3d11_context: ptr::null_mut(),
291        d3d11_device: ptr::null_mut(),
292        color_bind_flags: 0,
293        depth_bind_flags: 0,
294        acquire_keyed_mutex_sync: true,
295    }
296}
297
298pub fn qar_gui_panel_size_default() -> QarGuiPanelSize {
299    QarGuiPanelSize {
300        width_meters: 1.0,
301        height_meters: 1.0,
302        content_scale: 1.0,
303    }
304}
305
306pub fn qar_app_volume_size_default() -> QarAppVolumeSize {
307    QarAppVolumeSize {
308        width_meters: 1.0,
309        length_meters: 1.0,
310        height_meters: 1.0,
311    }
312}
313
314pub fn qar_app_volume_editing_status_default() -> QarAppVolumeEditingStatus {
315    QarAppVolumeEditingStatus {
316        is_being_edited: false,
317        editor_peer: qar_peer_id_default(),
318    }
319}
320
321pub fn qar_app_volume_gesture_mapping_rule_default() -> QarAppVolumeGestureMappingRule {
322    QarAppVolumeGestureMappingRule {
323        header: structure_header(
324            QarStructureType::QAR_STRUCTURE_TYPE_APP_VOLUME_GESTURE_MAPPING_RULE,
325        ),
326        gesture_kind: QarGestureKind::QAR_GESTURE_CLICK,
327        enabled: true,
328        precision: 1.0,
329        app_scale_sensitivity_mode: QarAppScaleSensitivityMode::QAR_APP_SCALE_SENSITIVITY_CONSTANT,
330        translation_axes: axis_mask(QarAppVolumeAxisFlags::QAR_APP_VOLUME_AXIS_ALL),
331        rotation_axes: axis_mask(QarAppVolumeAxisFlags::QAR_APP_VOLUME_AXIS_ALL),
332        enable_gestures_from_outside_of_volume: true,
333        controller_ray_style: QarAppVolumeControllerRayStyle {
334            line_style:
335                QarAppVolumeControllerRayLineStyle::QAR_APP_VOLUME_CONTROLLER_RAY_LINE_STYLE_SOLID,
336            color: QarColor {
337                r: 255,
338                g: 255,
339                b: 255,
340                a: 255,
341            },
342        },
343        app_transform_mapping:
344            QarGestureAppTransformMapping::QAR_GESTURE_APP_TRANSFORM_MAPPING_NONE,
345    }
346}
347
348pub fn qar_app_volume_gesture_configuration_default() -> QarAppVolumeGestureConfiguration {
349    const MANIPULATION_GREEN: QarColor = QarColor {
350        r: 0,
351        g: 200,
352        b: 0,
353        a: 255,
354    };
355    const CLICK_LIGHT_GREEN: QarColor = QarColor {
356        r: 144,
357        g: 238,
358        b: 144,
359        a: 255,
360    };
361
362    let mut configuration = QarAppVolumeGestureConfiguration {
363        header: structure_header(
364            QarStructureType::QAR_STRUCTURE_TYPE_APP_VOLUME_GESTURE_CONFIGURATION,
365        ),
366        mapping_rules: [zeroed(); QAR_MAX_APP_VOLUME_GESTURE_MAPPING_RULES as usize],
367        mapping_rule_count: 4,
368    };
369
370    let mut scale_rule = qar_app_volume_gesture_mapping_rule_default();
371    scale_rule.gesture_kind = QarGestureKind::QAR_GESTURE_DUAL_POINTER_TRANSLATE_DISTANCE;
372    scale_rule.precision = 1.0;
373    scale_rule.app_scale_sensitivity_mode =
374        QarAppScaleSensitivityMode::QAR_APP_SCALE_SENSITIVITY_BASED_ON_APP_SCALE;
375    scale_rule.rotation_axes = axis_mask(QarAppVolumeAxisFlags::QAR_APP_VOLUME_AXIS_NONE);
376    scale_rule.app_transform_mapping =
377        QarGestureAppTransformMapping::QAR_GESTURE_APP_TRANSFORM_MAPPING_APP_SCALE;
378    scale_rule.controller_ray_style.color = MANIPULATION_GREEN;
379    configuration.mapping_rules[0] = scale_rule;
380
381    let mut pose_rule = qar_app_volume_gesture_mapping_rule_default();
382    pose_rule.gesture_kind = QarGestureKind::QAR_GESTURE_SINGLE_POINTER_6DOF;
383    pose_rule.precision = 1.0;
384    pose_rule.rotation_axes = axis_mask(QarAppVolumeAxisFlags::QAR_APP_VOLUME_AXIS_NONE);
385    pose_rule.app_transform_mapping =
386        QarGestureAppTransformMapping::QAR_GESTURE_APP_TRANSFORM_MAPPING_APP_POSE;
387    pose_rule.controller_ray_style.color = MANIPULATION_GREEN;
388    configuration.mapping_rules[1] = pose_rule;
389
390    let mut hover_rule = qar_app_volume_gesture_mapping_rule_default();
391    hover_rule.gesture_kind = QarGestureKind::QAR_GESTURE_HOVER;
392    hover_rule.controller_ray_style.line_style =
393        QarAppVolumeControllerRayLineStyle::QAR_APP_VOLUME_CONTROLLER_RAY_LINE_STYLE_DOTTED;
394    configuration.mapping_rules[2] = hover_rule;
395
396    let mut click_rule = qar_app_volume_gesture_mapping_rule_default();
397    click_rule.gesture_kind = QarGestureKind::QAR_GESTURE_CLICK;
398    click_rule.controller_ray_style.color = CLICK_LIGHT_GREEN;
399    configuration.mapping_rules[3] = click_rule;
400
401    configuration
402}
403
404pub fn qar_library_init_default() -> QarLibraryInit {
405    QarLibraryInit {
406        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_LIBRARY_INIT),
407        enable_console_logging: true,
408        log_folder_path: ptr::null(),
409        log_severity: QarLogSeverity::QAR_LOG_SEVERITY_INFO,
410    }
411}
412
413pub fn qar_runtime_init_default() -> QarRuntimeInit {
414    QarRuntimeInit {
415        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_INIT),
416        runtime_binaries_folder_path: ptr::null(),
417        storage_folder_path: ptr::null(),
418    }
419}
420
421pub fn qar_peer_presentation_default() -> QarPeerPresentation {
422    QarPeerPresentation {
423        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_PEER_PRESENTATION),
424        display_name: ptr::null(),
425        app_version: ptr::null(),
426        app_custom_peer_info: ptr::null(),
427    }
428}
429
430pub fn qar_rejoin_init_default() -> QarRejoinInit {
431    QarRejoinInit {
432        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_REJOIN_INIT),
433        onboarding_id: qar_onboarding_id_default(),
434        presentation: qar_peer_presentation_default(),
435    }
436}
437
438pub fn qar_onboard_init_default() -> QarOnboardInit {
439    QarOnboardInit {
440        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_INIT),
441        onboarding_id: qar_onboarding_id_default(),
442        presentation: qar_peer_presentation_default(),
443    }
444}
445
446pub fn qar_onboard_code_ext_default() -> QarOnboardCodeExt {
447    QarOnboardCodeExt {
448        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_CODE_EXT),
449        code: ptr::null(),
450    }
451}
452
453pub fn qar_onboard_host_ext_default() -> QarOnboardHostExt {
454    QarOnboardHostExt {
455        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_HOST_EXT),
456        hostname: ptr::null(),
457        port: 0,
458    }
459}
460
461pub fn qar_onboard_invite_ext_default() -> QarOnboardInviteExt {
462    QarOnboardInviteExt {
463        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_INVITE_EXT),
464        invite: ptr::null(),
465    }
466}
467
468pub fn qar_onboard_local_app_ext_default() -> QarOnboardLocalAppExt {
469    QarOnboardLocalAppExt {
470        header: structure_header(
471            QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_LOCAL_APP_EXT,
472        ),
473        approval_timeout_ms: 0,
474    }
475}
476
477pub fn qar_runtime_ephemeral_storage_ext_default() -> QarRuntimeEphemeralStorageExt {
478    QarRuntimeEphemeralStorageExt {
479        header: structure_header(
480            QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_EPHEMERAL_STORAGE_EXT,
481        ),
482    }
483}
484
485/// `app_tag` is required; the caller sets it.
486pub fn qar_onboard_local_app_tag_ext_default() -> QarOnboardLocalAppTagExt {
487    QarOnboardLocalAppTagExt {
488        header: structure_header(
489            QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_LOCAL_APP_TAG_EXT,
490        ),
491        app_tag: ptr::null(),
492    }
493}
494
495/// `app_tag` is required; the caller sets it.
496pub fn qar_request_invite_init_default() -> QarRequestInviteInit {
497    QarRequestInviteInit {
498        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_SESSION_REQUEST_INVITE_INIT),
499        app_tag: ptr::null(),
500    }
501}
502
503pub fn qar_forget_init_default() -> QarForgetInit {
504    QarForgetInit {
505        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_FORGET_INIT),
506        onboarding_id: qar_onboarding_id_default(),
507    }
508}
509
510/// `peer_id` is required (the zero id is refused); the caller sets it.
511pub fn qar_onboard_peer_id_ext_default() -> QarOnboardPeerIdExt {
512    QarOnboardPeerIdExt {
513        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_PEER_ID_EXT),
514        peer_id: qar_peer_id_default(),
515    }
516}
517
518/// Category `QAR_DEVICE_CATEGORY_DESKTOP_PC`, NULL strings; `device_id` is required.
519pub fn qar_peer_device_identity_default() -> QarPeerDeviceIdentity {
520    QarPeerDeviceIdentity {
521        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_PEER_DEVICE_IDENTITY),
522        category: QarDeviceCategory::QAR_DEVICE_CATEGORY_DESKTOP_PC,
523        device_id: ptr::null(),
524        device_family: ptr::null(),
525        device_name: ptr::null(),
526    }
527}
528
529/// `connection_string` is required; the caller sets it.
530pub fn qar_session_invite_target_app_init_default() -> QarSessionInviteTargetAppInit {
531    QarSessionInviteTargetAppInit {
532        header: structure_header(
533            QarStructureType::QAR_STRUCTURE_TYPE_SESSION_INVITE_TARGET_APP_INIT,
534        ),
535        connection_string: ptr::null(),
536    }
537}
538
539/// Zero fields select the defaults: 24 h, one use, join, rejoin and bring devices.
540pub fn qar_member_hub_invitation_init_default() -> QarMemberHubInvitationInit {
541    QarMemberHubInvitationInit {
542        header: structure_header(
543            QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_CREATE_MEMBER_HUB_INVITATION_INIT,
544        ),
545        lifetime_seconds: 0,
546        max_uses: 0,
547        permissions: 0,
548        label: ptr::null(),
549    }
550}
551
552/// `app_tag` is required; the caller sets it.
553pub fn qar_member_hub_invitation_app_grant_ext_default() -> QarMemberHubInvitationAppGrantExt {
554    QarMemberHubInvitationAppGrantExt {
555        header: structure_header(
556            QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_MEMBER_HUB_INVITATION_APP_GRANT_EXT,
557        ),
558        app_tag: ptr::null(),
559    }
560}
561
562/// `invitation` is required; the caller sets it.
563pub fn qar_onboard_remote_app_grant_ext_default() -> QarOnboardRemoteAppGrantExt {
564    QarOnboardRemoteAppGrantExt {
565        header: structure_header(
566            QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_ONBOARD_REMOTE_APP_GRANT_EXT,
567        ),
568        invitation: ptr::null(),
569    }
570}
571
572/// `invitation` is required; the zero timeouts select 60 s and 120 s.
573pub fn qar_join_hub_as_member_init_default() -> QarJoinHubAsMemberInit {
574    QarJoinHubAsMemberInit {
575        header: structure_header(
576            QarStructureType::QAR_STRUCTURE_TYPE_RUNTIME_JOIN_HUB_AS_MEMBER_INIT,
577        ),
578        invitation: ptr::null(),
579        hub_start_timeout_ms: 0,
580        restart_timeout_ms: 0,
581    }
582}
583
584/// Frame views are zero-filled, as in the header.
585pub fn qar_render_sender_init_default() -> QarRenderSenderInit {
586    QarRenderSenderInit {
587        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RENDERING_STREAM_SENDER_INIT),
588        peer_id: qar_peer_id_default(),
589        enable_auto_reconnects: true,
590        texture_layout: QarFrameLayout::QAR_FRAME_LAYOUT_SIDE_BY_SIDE,
591        frame_views: [zeroed(); QAR_MAX_FRAME_VIEWS as usize],
592        frame_views_count: 0,
593        app_volume_id: ptr::null(),
594        color_format: QarPixelFormat::QAR_PIXEL_FORMAT_B8G8R8A8,
595        depth_format: QarPixelFormat::QAR_PIXEL_FORMAT_D32_FLOAT,
596        graphics_api: QarGraphicsAPI::QAR_GRAPHICS_API_CPU,
597    }
598}
599
600pub fn qar_render_sender_alpha_mode_ext_default() -> QarRenderSenderAlphaModeExt {
601    QarRenderSenderAlphaModeExt {
602        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RENDER_SENDER_ALPHA_MODE_EXT),
603        alpha_mode: QarColorAlphaMode::QAR_COLOR_ALPHA_MODE_UNSPECIFIED,
604    }
605}
606
607pub fn qar_render_sender_color_encoding_ext_default() -> QarRenderSenderColorEncodingExt {
608    QarRenderSenderColorEncodingExt {
609        header: structure_header(
610            QarStructureType::QAR_STRUCTURE_TYPE_RENDER_SENDER_COLOR_ENCODING_EXT,
611        ),
612        color_encoding: QarColorEncoding::QAR_COLOR_ENCODING_SRGB,
613    }
614}
615
616pub fn qar_render_sender_render_loop_ext_default() -> QarRenderSenderRenderLoopExt {
617    QarRenderSenderRenderLoopExt {
618        header: structure_header(
619            QarStructureType::QAR_STRUCTURE_TYPE_RENDER_SENDER_RENDER_LOOP_EXT,
620        ),
621        render_loop: QarRenderLoop::QAR_RENDER_LOOP_REQUEST_DRIVEN,
622    }
623}
624
625/// The zero stream id; the caller sets it.
626pub fn qar_gui_panel_stream_id_ext_default() -> QarGuiPanelStreamIdExt {
627    QarGuiPanelStreamIdExt {
628        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_GUI_PANEL_STREAM_ID_EXT),
629        stream_id: qar_stream_id_default(),
630    }
631}
632
633pub fn qar_gui_panel_url_ext_default() -> QarGuiPanelUrlExt {
634    QarGuiPanelUrlExt {
635        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_GUI_PANEL_URL_EXT),
636        url: ptr::null(),
637    }
638}
639
640/// No bundle and no entry: the caller sets both before chaining it.
641pub fn qar_gui_panel_served_content_ext_default() -> QarGuiPanelServedContentExt {
642    QarGuiPanelServedContentExt {
643        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_GUI_PANEL_SERVED_CONTENT_EXT),
644        bundle: QarPanelContentBundleId {
645            publisher: QarPeerId { data: [0; 16] },
646            name: [0; QAR_PANEL_CONTENT_BUNDLE_NAME_MAX as usize + 1],
647        },
648        entry: ptr::null(),
649    }
650}
651
652/// No peers: the caller sets `allowed_peers` and `allowed_peer_count`.
653pub fn qar_app_volume_gesture_allowed_peers_ext_default() -> QarAppVolumeGestureAllowedPeersExt {
654    QarAppVolumeGestureAllowedPeersExt {
655        header: structure_header(
656            QarStructureType::QAR_STRUCTURE_TYPE_APP_VOLUME_GESTURE_ALLOWED_PEERS_EXT,
657        ),
658        allowed_peers: ptr::null(),
659        allowed_peer_count: 0,
660    }
661}
662
663/// Reconnects on, 300 s reconnect timeout, CPU frames.
664pub fn qar_video_sender_init_default() -> QarVideoSenderInit {
665    QarVideoSenderInit {
666        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_VIDEO_SENDER_INIT),
667        layout: qar_video_frame_layout_default(),
668        enable_reconnects: true,
669        reconnect_timeout_ms: 300_000,
670        graphics_api: QarGraphicsAPI::QAR_GRAPHICS_API_CPU,
671    }
672}
673
674pub fn qar_gui_panel_init_default() -> QarGuiPanelInit {
675    QarGuiPanelInit {
676        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_GUI_PANEL_INIT),
677        common_name: ptr::null(),
678        display_name: ptr::null(),
679        pose: qar_pose_default(),
680        size: qar_gui_panel_size_default(),
681        visible_to_peers: ptr::null(),
682        visible_to_peer_count: 0,
683    }
684}
685
686/// The world anchor is zero-filled, as in the header.
687pub fn qar_app_volume_init_default() -> QarAppVolumeInit {
688    QarAppVolumeInit {
689        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_APP_VOLUME_INIT),
690        common_name: ptr::null(),
691        display_name: ptr::null(),
692        pose: qar_pose_default(),
693        size: qar_app_volume_size_default(),
694        initial_peers: ptr::null_mut(),
695        initial_peer_count: 0,
696        app_pose: qar_pose_default(),
697        app_scale: 1.0,
698        has_app_world_anchor: false,
699        app_world_anchor: zeroed(),
700        gesture_configuration: ptr::null(),
701    }
702}
703
704/// The header stamps this structure with `QAR_STRUCTURE_TYPE_RENDERING_END_FRAME`.
705pub fn qar_render_frame_show_default() -> QarRenderFrameShow {
706    QarRenderFrameShow {
707        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_RENDERING_END_FRAME),
708        rendered_near_far: qar_near_far_default(),
709        depth_scale: 1.0,
710    }
711}
712
713pub fn qar_session_lifecycle_info_default() -> QarSessionLifecycleInfo {
714    QarSessionLifecycleInfo {
715        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_SESSION_LIFECYCLE_INFO),
716        state: QarSessionLifecycleState::QAR_SESSION_LIFECYCLE_STATE_CONNECTED,
717        cause: QarSessionChangeCause::QAR_SESSION_CHANGE_CAUSE_NONE,
718        session_id: qar_session_id_default(),
719        previous_session_id: qar_session_id_default(),
720        has_previous_session: false,
721        reason: ptr::null(),
722    }
723}
724
725pub fn qar_open_qaros_view_info_default() -> QarOpenQarosViewInfo {
726    QarOpenQarosViewInfo {
727        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_SESSION_OPEN_QAROS_VIEW_INFO),
728        view: QarQarosView::QAR_QAROS_VIEW_PAIR_HEADSET_QR,
729        device_kind: QarQarosDeviceKind::QAR_QAROS_DEVICE_KIND_NONE,
730    }
731}
732
733/// The header leaves the id empty and picks the id type by platform: LUID on
734/// Windows, UUID elsewhere.
735pub fn qar_graphics_device_id_default() -> QarGraphicsDeviceId {
736    QarGraphicsDeviceId {
737        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_SESSION_GRAPHICS_DEVICE_ID),
738        id_type: if cfg!(target_os = "windows") {
739            QarGpuDeviceIdType::QAR_GPU_DEVICE_ID_TYPE_LUID
740        } else {
741            QarGpuDeviceIdType::QAR_GPU_DEVICE_ID_TYPE_UUID
742        },
743        luid: zeroed(),
744        uuid: ZERO_ID,
745    }
746}
747
748pub fn qar_graphics_device_disabled_ext_default() -> QarGraphicsDeviceDisabledExt {
749    QarGraphicsDeviceDisabledExt {
750        header: structure_header(
751            QarStructureType::QAR_STRUCTURE_TYPE_SESSION_GRAPHICS_DEVICE_DISABLED_EXT,
752        ),
753    }
754}
755
756/// Null `VkPhysicalDevice` and `VkDevice`.
757pub fn qar_stream_params_vulkan_default() -> QarStreamParamsVulkan {
758    QarStreamParamsVulkan {
759        header: structure_header(QarStructureType::QAR_STRUCTURE_TYPE_STREAM_VULKAN_PARAMS_EXT),
760        physical_device: ptr::null_mut(),
761        device: ptr::null_mut(),
762    }
763}
764
765/// `VK_NULL_HANDLE` semaphore and fence.
766pub fn qar_sync_frame_vulkan_default() -> QarSyncFrameVulkan {
767    QarSyncFrameVulkan {
768        semaphore: 0,
769        fence: 0,
770    }
771}
772
773pub fn qar_video_frame_vulkan_default() -> QarVideoFrameVulkan {
774    QarVideoFrameVulkan {
775        texture_views: [zeroed(); QAR_MAX_FRAME_VIEWS as usize],
776        texture_views_count: 0,
777        textures: [zeroed(); QAR_MAX_FRAME_TEXTURES as usize],
778        textures_count: 0,
779        synchronization: qar_sync_frame_vulkan_default(),
780    }
781}