@@ -39,7 +39,7 @@ unsafe impl<const OPCODE: Opcode> Ioctl for NoArg<OPCODE> {
39
39
40
40
const IS_MUTATING : bool = false ;
41
41
42
- fn opcode ( & self ) -> self :: Opcode {
42
+ fn opcode ( & self ) -> Opcode {
43
43
OPCODE
44
44
}
45
45
@@ -52,7 +52,7 @@ unsafe impl<const OPCODE: Opcode> Ioctl for NoArg<OPCODE> {
52
52
}
53
53
}
54
54
55
- /// Implements an `ioctl` with no real arguments.
55
+ /// Implements an `ioctl` with no real arguments that returns an integer .
56
56
///
57
57
/// To compute a value for the `OPCODE` argument, see the functions in the
58
58
/// [`opcode`] module.
@@ -80,18 +80,65 @@ unsafe impl<const OPCODE: Opcode> Ioctl for NoArgGetter<OPCODE> {
80
80
81
81
const IS_MUTATING : bool = false ;
82
82
83
- fn opcode ( & self ) -> self :: Opcode {
83
+ fn opcode ( & self ) -> Opcode {
84
84
OPCODE
85
85
}
86
86
87
- fn as_ptr ( & mut self ) -> * mut core :: ffi :: c_void {
87
+ fn as_ptr ( & mut self ) -> * mut c :: c_void {
88
88
core:: ptr:: null_mut ( )
89
89
}
90
90
91
- unsafe fn output_from_ptr (
92
- output : IoctlOutput ,
93
- _: * mut core:: ffi:: c_void ,
94
- ) -> Result < Self :: Output > {
91
+ unsafe fn output_from_ptr ( output : IoctlOutput , _: * mut c:: c_void ) -> Result < Self :: Output > {
92
+ Ok ( output)
93
+ }
94
+ }
95
+
96
+ /// Implements an `ioctl` with one real argument that returns an integer.
97
+ ///
98
+ /// To compute a value for the `OPCODE` argument, see the functions in the
99
+ /// [`opcode`] module.
100
+ ///
101
+ /// [`opcode`]: crate::ioctl::opcode
102
+ pub struct ParameterizedReturnGetter < const OPCODE : Opcode > {
103
+ value : * const c:: c_void ,
104
+ }
105
+
106
+ impl < const OPCODE : Opcode > fmt:: Debug for ParameterizedReturnGetter < OPCODE > {
107
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
108
+ f. debug_tuple ( "ParameterizedReturnGetter" )
109
+ . field ( & OPCODE )
110
+ . field ( & self . value )
111
+ . finish ( )
112
+ }
113
+ }
114
+
115
+ impl < const OPCODE : Opcode > ParameterizedReturnGetter < OPCODE > {
116
+ /// Create a new `ioctl` object.
117
+ ///
118
+ /// # Safety
119
+ ///
120
+ /// - `OPCODE` must provide a valid opcode.
121
+ #[ inline]
122
+ pub const unsafe fn new ( value : usize ) -> Self {
123
+ Self {
124
+ value : core:: ptr:: without_provenance ( value) ,
125
+ }
126
+ }
127
+ }
128
+ unsafe impl < const OPCODE : Opcode > Ioctl for ParameterizedReturnGetter < OPCODE > {
129
+ type Output = IoctlOutput ;
130
+
131
+ const IS_MUTATING : bool = false ;
132
+
133
+ fn opcode ( & self ) -> Opcode {
134
+ OPCODE
135
+ }
136
+
137
+ fn as_ptr ( & mut self ) -> * mut c:: c_void {
138
+ self . value . cast_mut ( )
139
+ }
140
+
141
+ unsafe fn output_from_ptr ( output : IoctlOutput , _: * mut c:: c_void ) -> Result < Self :: Output > {
95
142
Ok ( output)
96
143
}
97
144
}
@@ -137,7 +184,7 @@ unsafe impl<const OPCODE: Opcode, Output> Ioctl for Getter<OPCODE, Output> {
137
184
138
185
const IS_MUTATING : bool = true ;
139
186
140
- fn opcode ( & self ) -> self :: Opcode {
187
+ fn opcode ( & self ) -> Opcode {
141
188
OPCODE
142
189
}
143
190
@@ -192,7 +239,7 @@ unsafe impl<const OPCODE: Opcode, Input> Ioctl for Setter<OPCODE, Input> {
192
239
193
240
const IS_MUTATING : bool = false ;
194
241
195
- fn opcode ( & self ) -> self :: Opcode {
242
+ fn opcode ( & self ) -> Opcode {
196
243
OPCODE
197
244
}
198
245
@@ -219,6 +266,15 @@ pub struct Updater<'a, const OPCODE: Opcode, Value> {
219
266
value : & ' a mut Value ,
220
267
}
221
268
269
+ impl < ' a , const OPCODE : Opcode , Value : fmt:: Debug > fmt:: Debug for Updater < ' a , OPCODE , Value > {
270
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
271
+ f. debug_tuple ( "Setter" )
272
+ . field ( & OPCODE )
273
+ . field ( & self . value )
274
+ . finish ( )
275
+ }
276
+ }
277
+
222
278
impl < ' a , const OPCODE : Opcode , Value > Updater < ' a , OPCODE , Value > {
223
279
/// Create a new pointer updater-style `ioctl` object.
224
280
///
@@ -238,7 +294,7 @@ unsafe impl<'a, const OPCODE: Opcode, T> Ioctl for Updater<'a, OPCODE, T> {
238
294
239
295
const IS_MUTATING : bool = true ;
240
296
241
- fn opcode ( & self ) -> self :: Opcode {
297
+ fn opcode ( & self ) -> Opcode {
242
298
OPCODE
243
299
}
244
300
@@ -264,6 +320,15 @@ pub struct IntegerSetter<const OPCODE: Opcode> {
264
320
value : * mut c:: c_void ,
265
321
}
266
322
323
+ impl < const OPCODE : Opcode > fmt:: Debug for IntegerSetter < OPCODE > {
324
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
325
+ f. debug_tuple ( "IntegerSetter" )
326
+ . field ( & OPCODE )
327
+ . field ( & self . value )
328
+ . finish ( )
329
+ }
330
+ }
331
+
267
332
impl < const OPCODE : Opcode > IntegerSetter < OPCODE > {
268
333
/// Create a new integer `Ioctl` helper containing a `usize`.
269
334
///
@@ -295,7 +360,7 @@ unsafe impl<const OPCODE: Opcode> Ioctl for IntegerSetter<OPCODE> {
295
360
296
361
const IS_MUTATING : bool = false ;
297
362
298
- fn opcode ( & self ) -> self :: Opcode {
363
+ fn opcode ( & self ) -> Opcode {
299
364
OPCODE
300
365
}
301
366
0 commit comments