[][src]Struct iocuddle::Ioctl

#[repr(transparent)]pub struct Ioctl<D, T>(_, _);

A defined ioctl along with its associated direction and type

Implementations

impl<D, T> Ioctl<D, T>[src]

pub const unsafe fn classic(request: c_ulong) -> Self[src]

Define a new ioctl with an associated direction and type

The request argument is the allocated integer which uniquely identifies this ioctl.

Safety

This function is unsafe because defining an ioctl with an incorrect request, direction or argument type can later result in memory corruption. You are responsible to ensure these values are correct.

Further, you are responsible to ensure that the argument type itself provides appropriate safe wrappers around its raw contents. For some types none are required. For others, particularly types that pass pointers to the kernel as u64, you need to ensure that things like lifetimes are correct.

pub const unsafe fn lie<E, U>(self) -> Ioctl<E, U>[src]

Lie about the ioctl direction or type

This function should be avoided unless necessary.

Sometimes kernel developers make mistakes and use the wrong macros or types during their ioctl definitions. However, once merged these form part of the userspace API and won't be broken. Therefore, we need a way to use the request number with the incorrect type. This function allows this.

Whenever using this function, it would be wise to include a comment with a link to the kernel's ioctl definition and explaining why the definition is incorrect.

Safety

For safety details, see Ioctl::classic.

Additionally, one should note that this function discards your normal protections. So you need to make sure that you have it correct.

impl Ioctl<Read, c_void>[src]

pub fn ioctl(self, fd: &impl AsRawFd) -> Result<c_uint>[src]

Issue an ioctl to read a file descriptor's metadata as c_uint.

No argument is supplied to the internal ioctl() call. The raw (positive) return value from the internal ioctl() call is returned on success.

impl<T, '_> Ioctl<Read, &'_ T>[src]

pub fn ioctl(self, fd: &impl AsRawFd) -> Result<(c_uint, T)>[src]

Issue an ioctl to read a file descriptor's metadata as type T.

A zeroed instance of type T is passed as the first argument to the internal ioctl() call. Upon success, returns the raw (positive) return value and the instance of T.

impl Ioctl<Write, c_void>[src]

pub fn ioctl(self, fd: &mut impl AsRawFd) -> Result<c_uint>[src]

Issue an ioctl to modify a file descriptor

No argument is provided.

On success, returns the (positive) return value.

impl Ioctl<Write, c_int>[src]

pub fn ioctl(self, fd: &mut impl AsRawFd, data: c_int) -> Result<c_uint>[src]

Issue an ioctl to modify a file descriptor

A C-integer argument is provided.

On success, returns the (positive) return value.

impl<T, '_> Ioctl<Write, &'_ T>[src]

pub fn ioctl(self, fd: &mut impl AsRawFd, data: &T) -> Result<c_uint>[src]

Issue an ioctl to modify a file descriptor

A reference to an immutable instance of T is provided as the argument.

On success, returns the (positive) return value.

impl<T, '_> Ioctl<WriteRead, &'_ T>[src]

pub fn ioctl(self, fd: &mut impl AsRawFd, data: &mut T) -> Result<c_uint>[src]

Issue an ioctl to modify a file descriptor and read its metadata

A reference to a mutable instance of T is provided as the argument.

On success, returns the (positive) return value.

Trait Implementations

impl<D: Clone, T: Clone> Clone for Ioctl<D, T>[src]

impl<D: Copy, T: Copy> Copy for Ioctl<D, T>[src]

impl<D: Eq, T: Eq> Eq for Ioctl<D, T>[src]

impl<D: PartialEq, T: PartialEq> PartialEq<Ioctl<D, T>> for Ioctl<D, T>[src]

impl<D, T> StructuralEq for Ioctl<D, T>[src]

impl<D, T> StructuralPartialEq for Ioctl<D, T>[src]

Auto Trait Implementations

impl<D, T> RefUnwindSafe for Ioctl<D, T> where
    D: RefUnwindSafe,
    T: RefUnwindSafe

impl<D, T> Send for Ioctl<D, T> where
    D: Send,
    T: Send

impl<D, T> Sync for Ioctl<D, T> where
    D: Sync,
    T: Sync

impl<D, T> Unpin for Ioctl<D, T> where
    D: Unpin,
    T: Unpin

impl<D, T> UnwindSafe for Ioctl<D, T> where
    D: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.