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

Library

Struct Library 

Source
pub struct Library { /* private fields */ }
Expand description

The loaded and initialized C API library.

Process-wide: at most one may be alive at a time. Cloning shares the same library. Runtimes, sessions and every other handle keep it alive, so it is destroyed (qar_library_destroy) only after them, whatever order the Rust values are dropped in.

The DLL is never unloaded: it stays mapped for the rest of the process. Freeing it after qar_library_destroy runs its detach code and unmaps code that its threads may still reach, which has crashed processes at exit. After a drop whose qar_library_destroy succeeded, a second Library::load re-initializes the mapped library. After one whose qar_library_destroy failed, the process slot stays reserved and every later load returns Error::LibraryAlreadyLoaded.

Not Send: the SDK is designed for single-threaded use per runtime.

Implementations§

Source§

impl Library

Source

pub unsafe fn load_default(config: &LibraryConfig) -> Result<Self>

Finds qar-streaming-c with the default lookup every QAROS binding follows and runs qar_library_init. This is the normal way to load the runtime: a distributed application runs against the QAROS installed on the PC and ships no copy of the runtime.

The first match wins: a runtime already loaded in the process; one beside the executable (or library) this binding is compiled into; on Windows, when QAR_INSTANCE names a QAROS instance, that instance’s runtime folder (default is the installed QAROS, any other name the RuntimeFolder its hub records under HKCU\SOFTWARE\Quaternar\QAROS\Instances); the installed QAROS (<InstallFolder>\bin from HKLM\SOFTWARE\Quaternar\QAROS); each folder on PATH. A set QAR_INSTANCE naming an invalid or unknown instance, and an instance or installed QAROS whose runtime is missing or fails to load, is an error, never a reason to load another runtime. Nothing found is Error::Load with qaros_sys::LoadError::NotFound, naming every place looked at. See QarApi::load_default for the details; Library::library_path tells which file was loaded.

§Safety

The runtime found must be a qar-streaming-c build matching these bindings; see QarApi::load.

Source

pub unsafe fn load( path: impl AsRef<Path>, config: &LibraryConfig, ) -> Result<Self>

Loads qar-streaming-c from the library file at path and runs qar_library_init. Only that file is tried. Explicit paths are for development builds of QAROS; a distributed application uses Library::load_default, and QAR_INSTANCE points a run at another QAROS instance’s runtime without code.

§Safety

path must name a qar-streaming-c build matching these bindings; see QarApi::load.

Source

pub fn create_runtime(&self, config: &RuntimeConfig) -> Result<Runtime>

qar_runtime_create.

Source

pub fn create_cancel_token( &self, timeout: Option<Duration>, ) -> Result<CancelToken>

Creates a cancellation token, optionally cancelling itself after timeout.

Source

pub fn target_app_connection_string( &self, device: TargetDevice, host: &str, ) -> Result<String>

The connection string for a target app on host, a hostname or IP address (qar_target_app_connection_string_hololens, _quest, _android), for crate::Session::invite_target_app (HoloLens only) or crate::Session::find_render_target. An empty host fails in the library.

Source

pub fn deserialize_invite(&self, wire_bytes: &[u8]) -> Result<OnboardingInvite>

Parses an invite serialized by OnboardingInvite::serialize.

Source

pub fn runtime_info(&self) -> Result<RuntimeInfo>

Version, flavor and C API generation of the loaded runtime (qar_runtime_info), for diagnostics.

Source

pub fn uuid_to_string(&self, bytes: &[u8; 16]) -> Result<String>

The library’s UUID text form, for persisting ids.

Source

pub fn uuid_from_string(&self, text: &str) -> Result<[u8; 16]>

Parses the library’s UUID text form.

Source

pub fn library_path(&self) -> Option<&Path>

The file qar-streaming-c was loaded from, for diagnostics. None for the import-linked library or when the operating system does not name the module.

Source

pub fn lookup_step(&self) -> Option<LookupStep>

The step of the default lookup that found the runtime, for diagnostics; None after Library::load or for the import-linked library.

Source

pub fn raw_api(&self) -> &QarApi

The raw function table, for the parts this crate leaves to qaros-sys: hands, gestures, world anchors, video senders, target apps, the peer presence, role, category and device identity, and the other areas the README’s coverage table lists as raw only. Call them with the as_raw() handle of a safe value (crate::Session::as_raw and the others). Valid while this Library (or any handle derived from it) is alive.

Source§

impl Library

Source

pub fn deserialize_member_hub_invitation( &self, wire_bytes: &[u8], ) -> Result<MemberHubInvitation>

Reads an invitation from the bytes MemberHubInvitation::serialize wrote (qar_member_hub_invitation_deserialize). Strict: an invitation with an unknown or missing field, of another kind or version, out of its bounds, or over 16 KiB fails with StatusCode::MEMBER_INVITATION_INVALID. Its signature is checked by Runtime::join_hub_as_member, not here.

Trait Implementations§

Source§

impl Clone for Library

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Library

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.