Trait Ioctl
unsafe trait Ioctl
A trait defining the properties of an ioctl command.
Objects implementing this trait can be passed to ioctl to make an
ioctl call. The contents of the object represent the inputs to the
ioctl call. The inputs must be convertible to a pointer through the
as_ptr method. In most cases, this involves either casting a number to a
pointer, or creating a pointer to the actual data. The latter case is
necessary for ioctl calls that modify userspace data.
Safety
This trait is unsafe to implement because it is impossible to guarantee
that the ioctl call is safe. The ioctl call may be proprietary, or it
may be unsafe to call in certain circumstances.
By implementing this trait, you guarantee that:
- The
ioctlcall expects the input provided byas_ptrand produces the output as indicated byoutput. - That
output_from_ptrcan safely take the pointer fromas_ptrand cast it to the correct type, only after theioctlcall. - That the return value of
opcodeuniquely identifies theioctlcall. - That, for whatever platforms you are targeting, the
ioctlcall is safe to make. - If
IS_MUTATINGis false, that no userspace data will be modified by theioctlcall.
Associated Types
type OutputThe type of the output data.
Given a pointer, one should be able to construct an instance of this type.
Required Methods
fn opcode(self: &Self) -> OpcodeGet the opcode used by this
ioctlcommand.There are different types of opcode depending on the operation. See documentation for
opcodefor more information.fn as_ptr(self: &mut Self) -> *mut c_voidGet a pointer to the data to be passed to the
ioctlcommand.See trait-level documentation for more information.
unsafe fn output_from_ptr(out: IoctlOutput, extract_output: *mut c_void) -> Result<<Self as >::Output>Cast the output data to the correct type.
Safety
The
extract_outputvalue must be the resulting value after a successfulioctlcall, andoutis the direct return value of anioctlcall that did not fail. In this caseextract_outputis the pointer that was passed to theioctlcall.
Implementors
impl<OPCODE: super::Opcode> Ioctl for IntegerSetter<OPCODE>impl<OPCODE: super::Opcode, Input> Ioctl for Setter<OPCODE, Input>impl<OPCODE: super::Opcode, Output> Ioctl for Getter<OPCODE, Output>impl<OPCODE: super::Opcode> Ioctl for NoArg<OPCODE>impl<'a, OPCODE: super::Opcode, T> Ioctl for Updater<'a, OPCODE, T>