@@ -39,7 +39,7 @@ unsafe impl<const OPCODE: Opcode> Ioctl for NoArg<OPCODE> {
3939
4040 const IS_MUTATING : bool = false ;
4141
42- fn opcode ( & self ) -> self :: Opcode {
42+ fn opcode ( & self ) -> Opcode {
4343 OPCODE
4444 }
4545
@@ -52,7 +52,7 @@ unsafe impl<const OPCODE: Opcode> Ioctl for NoArg<OPCODE> {
5252 }
5353}
5454
55- /// Implements an `ioctl` with no real arguments.
55+ /// Implements an `ioctl` with no real arguments that returns an integer .
5656///
5757/// To compute a value for the `OPCODE` argument, see the functions in the
5858/// [`opcode`] module.
@@ -80,18 +80,65 @@ unsafe impl<const OPCODE: Opcode> Ioctl for NoArgGetter<OPCODE> {
8080
8181 const IS_MUTATING : bool = false ;
8282
83- fn opcode ( & self ) -> self :: Opcode {
83+ fn opcode ( & self ) -> Opcode {
8484 OPCODE
8585 }
8686
87- fn as_ptr ( & mut self ) -> * mut core :: ffi :: c_void {
87+ fn as_ptr ( & mut self ) -> * mut c :: c_void {
8888 core:: ptr:: null_mut ( )
8989 }
9090
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 > {
95142 Ok ( output)
96143 }
97144}
@@ -137,7 +184,7 @@ unsafe impl<const OPCODE: Opcode, Output> Ioctl for Getter<OPCODE, Output> {
137184
138185 const IS_MUTATING : bool = true ;
139186
140- fn opcode ( & self ) -> self :: Opcode {
187+ fn opcode ( & self ) -> Opcode {
141188 OPCODE
142189 }
143190
@@ -192,7 +239,7 @@ unsafe impl<const OPCODE: Opcode, Input> Ioctl for Setter<OPCODE, Input> {
192239
193240 const IS_MUTATING : bool = false ;
194241
195- fn opcode ( & self ) -> self :: Opcode {
242+ fn opcode ( & self ) -> Opcode {
196243 OPCODE
197244 }
198245
@@ -219,6 +266,15 @@ pub struct Updater<'a, const OPCODE: Opcode, Value> {
219266 value : & ' a mut Value ,
220267}
221268
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+
222278impl < ' a , const OPCODE : Opcode , Value > Updater < ' a , OPCODE , Value > {
223279 /// Create a new pointer updater-style `ioctl` object.
224280 ///
@@ -238,7 +294,7 @@ unsafe impl<'a, const OPCODE: Opcode, T> Ioctl for Updater<'a, OPCODE, T> {
238294
239295 const IS_MUTATING : bool = true ;
240296
241- fn opcode ( & self ) -> self :: Opcode {
297+ fn opcode ( & self ) -> Opcode {
242298 OPCODE
243299 }
244300
@@ -264,6 +320,15 @@ pub struct IntegerSetter<const OPCODE: Opcode> {
264320 value : * mut c:: c_void ,
265321}
266322
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+
267332impl < const OPCODE : Opcode > IntegerSetter < OPCODE > {
268333 /// Create a new integer `Ioctl` helper containing a `usize`.
269334 ///
@@ -295,7 +360,7 @@ unsafe impl<const OPCODE: Opcode> Ioctl for IntegerSetter<OPCODE> {
295360
296361 const IS_MUTATING : bool = false ;
297362
298- fn opcode ( & self ) -> self :: Opcode {
363+ fn opcode ( & self ) -> Opcode {
299364 OPCODE
300365 }
301366
0 commit comments