esp_idf_svc/handle.rs
1//! Wrapper around ESP-IDF raw handles
2pub trait RawHandle {
3 type Handle;
4
5 /// Care should be taken to use the returned ESP-IDF driver raw handle only while
6 /// the driver is still alive, so as to avoid use-after-free errors.
7 fn handle(&self) -> Self::Handle;
8}
9
10impl<R> RawHandle for &R
11where
12 R: RawHandle,
13{
14 type Handle = R::Handle;
15
16 fn handle(&self) -> Self::Handle {
17 (*self).handle()
18 }
19}
20
21impl<R> RawHandle for &mut R
22where
23 R: RawHandle,
24{
25 type Handle = R::Handle;
26
27 fn handle(&self) -> Self::Handle {
28 (**self).handle()
29 }
30}