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
impl Library
Sourcepub unsafe fn load_default(config: &LibraryConfig) -> Result<Self>
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.
Sourcepub unsafe fn load(
path: impl AsRef<Path>,
config: &LibraryConfig,
) -> Result<Self>
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.
Sourcepub fn create_runtime(&self, config: &RuntimeConfig) -> Result<Runtime>
pub fn create_runtime(&self, config: &RuntimeConfig) -> Result<Runtime>
qar_runtime_create.
Sourcepub fn create_cancel_token(
&self,
timeout: Option<Duration>,
) -> Result<CancelToken>
pub fn create_cancel_token( &self, timeout: Option<Duration>, ) -> Result<CancelToken>
Creates a cancellation token, optionally cancelling itself after
timeout.
Sourcepub fn target_app_connection_string(
&self,
device: TargetDevice,
host: &str,
) -> Result<String>
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.
Sourcepub fn deserialize_invite(&self, wire_bytes: &[u8]) -> Result<OnboardingInvite>
pub fn deserialize_invite(&self, wire_bytes: &[u8]) -> Result<OnboardingInvite>
Parses an invite serialized by OnboardingInvite::serialize.
Sourcepub fn runtime_info(&self) -> Result<RuntimeInfo>
pub fn runtime_info(&self) -> Result<RuntimeInfo>
Version, flavor and C API generation of the loaded runtime
(qar_runtime_info), for diagnostics.
Sourcepub fn uuid_to_string(&self, bytes: &[u8; 16]) -> Result<String>
pub fn uuid_to_string(&self, bytes: &[u8; 16]) -> Result<String>
The library’s UUID text form, for persisting ids.
Sourcepub fn uuid_from_string(&self, text: &str) -> Result<[u8; 16]>
pub fn uuid_from_string(&self, text: &str) -> Result<[u8; 16]>
Parses the library’s UUID text form.
Sourcepub fn library_path(&self) -> Option<&Path>
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.
Sourcepub fn lookup_step(&self) -> Option<LookupStep>
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.
Sourcepub fn raw_api(&self) -> &QarApi
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
impl Library
Sourcepub fn deserialize_member_hub_invitation(
&self,
wire_bytes: &[u8],
) -> Result<MemberHubInvitation>
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.