leaprs/events/
interpolation_tracking_event.rs1use std::ops::Deref;
2
3use crate::{sized_with_trailing_data::SizedWithTrailingData, FrameHeaderRef, HandRef};
4use leap_sys::LEAP_TRACKING_EVENT;
5
6pub struct InterpolationTrackingEvent(pub(crate) Box<SizedWithTrailingData<LEAP_TRACKING_EVENT>>);
9
10impl InterpolationTrackingEvent {
11 pub(crate) unsafe fn new_uninitialized(requested_frame_size: u64) -> Self {
14 let trailing_size =
15 requested_frame_size as usize - std::mem::size_of::<LEAP_TRACKING_EVENT>();
16 Self(SizedWithTrailingData::allocate(
17 std::mem::zeroed(),
18 trailing_size,
19 ))
20 }
21
22 #[doc = " A universal frame identification header. @since 3.0.0"]
23 pub fn info(&self) -> FrameHeaderRef {
24 FrameHeaderRef(&self.info)
25 }
26
27 #[doc = " A pointer to the array of hands tracked in this frame."]
28 #[doc = " @since 3.0.0"]
29 pub fn hands(&self) -> Vec<HandRef> {
30 let n_hand = self.nHands as isize;
31 unsafe {
32 (0..n_hand)
33 .map(|hand_index| &*self.pHands.offset(hand_index))
34 .map(HandRef)
35 .collect()
36 }
37 }
38}
39
40impl Deref for InterpolationTrackingEvent {
41 type Target = LEAP_TRACKING_EVENT;
42
43 fn deref(&self) -> &Self::Target {
44 &self.0.sized
45 }
46}