@@ -9,6 +9,7 @@ use core::{ops::Deref, pin::Pin};
9
9
use alloc:: { boxed:: Box , sync:: Arc } ;
10
10
11
11
use crate :: bindings;
12
+ use crate :: c_types;
12
13
use crate :: sync:: { Ref , RefCounted } ;
13
14
14
15
/// Permissions.
@@ -82,56 +83,56 @@ macro_rules! cstr {
82
83
/// file::private_data`.
83
84
pub trait PointerWrapper {
84
85
/// Returns the raw pointer.
85
- fn into_pointer ( self ) -> * const T ;
86
+ fn into_pointer ( self ) -> * const c_types :: c_void ;
86
87
87
88
/// Returns the instance back from the raw pointer.
88
89
///
89
90
/// # Safety
90
91
///
91
92
/// The passed pointer must come from a previous call to [`PointerWrapper::into_pointer()`].
92
- unsafe fn from_pointer ( ptr : * const T ) -> Self ;
93
+ unsafe fn from_pointer ( ptr : * const c_types :: c_void ) -> Self ;
93
94
}
94
95
95
96
impl < T > PointerWrapper for Box < T > {
96
- fn into_pointer ( self ) -> * const T {
97
- Box :: into_raw ( self )
97
+ fn into_pointer ( self ) -> * const c_types :: c_void {
98
+ Box :: into_raw ( self ) as _
98
99
}
99
100
100
- unsafe fn from_pointer ( ptr : * const T ) -> Self {
101
+ unsafe fn from_pointer ( ptr : * const c_types :: c_void ) -> Self {
101
102
Box :: from_raw ( ptr as _ )
102
103
}
103
104
}
104
105
105
106
impl < T : RefCounted > PointerWrapper for Ref < T > {
106
- fn into_pointer ( self ) -> * const T {
107
- Ref :: into_raw ( self )
107
+ fn into_pointer ( self ) -> * const c_types :: c_void {
108
+ Ref :: into_raw ( self ) as _
108
109
}
109
110
110
- unsafe fn from_pointer ( ptr : * const T ) -> Self {
111
+ unsafe fn from_pointer ( ptr : * const c_types :: c_void ) -> Self {
111
112
Ref :: from_raw ( ptr as _ )
112
113
}
113
114
}
114
115
115
116
impl < T > PointerWrapper for Arc < T > {
116
- fn into_pointer ( self ) -> * const T {
117
- Arc :: into_raw ( self )
117
+ fn into_pointer ( self ) -> * const c_types :: c_void {
118
+ Arc :: into_raw ( self ) as _
118
119
}
119
120
120
- unsafe fn from_pointer ( ptr : * const T ) -> Self {
121
- Arc :: from_raw ( ptr)
121
+ unsafe fn from_pointer ( ptr : * const c_types :: c_void ) -> Self {
122
+ Arc :: from_raw ( ptr as _ )
122
123
}
123
124
}
124
125
125
- impl < T , W : PointerWrapper + Deref > PointerWrapper for Pin < W > {
126
- fn into_pointer ( self ) -> * const T {
126
+ impl < T : PointerWrapper + Deref > PointerWrapper for Pin < T > {
127
+ fn into_pointer ( self ) -> * const c_types :: c_void {
127
128
// SAFETY: We continue to treat the pointer as pinned by returning just a pointer to it to
128
129
// the caller.
129
130
let inner = unsafe { Pin :: into_inner_unchecked ( self ) } ;
130
131
inner. into_pointer ( )
131
132
}
132
133
133
- unsafe fn from_pointer ( p : * const T ) -> Self {
134
+ unsafe fn from_pointer ( p : * const c_types :: c_void ) -> Self {
134
135
// SAFETY: The object was originally pinned.
135
- Pin :: new_unchecked ( W :: from_pointer ( p) )
136
+ Pin :: new_unchecked ( T :: from_pointer ( p) )
136
137
}
137
138
}
0 commit comments