leaprs 0.2.2

Safe wrapper for the LeapC Ultraleap (Leap Motion) hand tracking device API.
Documentation
use derive_deref::Deref;
use leap_sys::LEAP_CONNECTION_INFO;

use crate::ConnectionStatus;

#[doc = " \\ingroup Structs"]
#[doc = " Information about a connection."]
#[doc = ""]
#[doc = " Call LeapCreateConnection() to generate the handle for the connection;"]
#[doc = " call LeapOpenConnection() to establish the connection; then call"]
#[doc = " LeapGetConnectionInfo(), which creates this struct, to check the connection status."]
#[doc = " @since 3.0.0"]
/// # Fields
/// Available via dereference: [LEAP_CONNECTION_INFO].
#[derive(Deref, Clone, Copy)]
pub struct ConnectionInfo(pub(crate) LEAP_CONNECTION_INFO);

impl ConnectionInfo {
    pub fn status(&self) -> ConnectionStatus {
        self.status.into()
    }
}

#[cfg(test)]
mod tests {
    use crate::tests::*;
    use crate::*;

    #[test]
    fn connection_info_test() {
        let mut connection = initialize_connection();
        let info = connection.info().expect("Failed to get connection info");
        assert_eq!(info.status(), ConnectionStatus::Connected);
    }
}