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
//! Wrapper around ESP-IDF raw handles
pub trait RawHandle {
    type Handle;

    /// Care should be taken to use the returned ESP-IDF driver raw handle only while
    /// the driver is still alive, so as to avoid use-after-free errors.
    fn handle(&self) -> Self::Handle;
}

impl<R> RawHandle for &R
where
    R: RawHandle,
{
    type Handle = R::Handle;

    fn handle(&self) -> Self::Handle {
        (*self).handle()
    }
}

impl<R> RawHandle for &mut R
where
    R: RawHandle,
{
    type Handle = R::Handle;

    fn handle(&self) -> Self::Handle {
        (**self).handle()
    }
}