1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::ffi::CString;
use bitflags::bitflags;
use leap_sys::*;
bitflags! {
pub struct ConnectionConfigFlags: _eLeapConnectionConfig {
#[doc = " The client is aware of how to handle multiple devices through the API."]
#[doc = " @since 4.1.0"]
const MULTI_DEVICE_AWARE = _eLeapConnectionConfig_eLeapConnectionConfig_MultiDeviceAware;
}
}
#[doc = " Specifies the configuration for a connection."]
#[doc = " @since 3.0.0"]
pub struct ConnectionConfig {
pub(crate) handle: LEAP_CONNECTION_CONFIG,
server_namespace: Option<CString>,
}
impl Default for ConnectionConfig {
fn default() -> Self {
Self::new(ConnectionConfigFlags::empty(), None)
}
}
impl ConnectionConfig {
pub fn new(flags: ConnectionConfigFlags, namespace: Option<CString>) -> Self {
let mut config = ConnectionConfig {
handle: LEAP_CONNECTION_CONFIG {
size: std::mem::size_of::<LEAP_CONNECTION_CONFIG>() as u32,
flags: flags.bits() as u32,
server_namespace: std::ptr::null(),
},
server_namespace: namespace,
};
if let Some(namespace) = &config.server_namespace {
config.handle.server_namespace = namespace.as_ptr()
}
config
}
}