pub struct Device<Ctx: DeviceContext = Normal>(/* private fields */);Expand description
The auxiliary device representation.
This structure represents the Rust abstraction for a C struct auxiliary_device. The
implementation abstracts the usage of an already existing C struct auxiliary_device within
Rust code that we get passed from the C side.
§Invariants
A Device instance represents a valid struct auxiliary_device created by the C portion of
the kernel.
Implementations§
Source§impl<Ctx: DeviceContext> Device<Ctx>
impl<Ctx: DeviceContext> Device<Ctx>
Source§impl Device<Bound>
impl Device<Bound>
Sourcepub fn parent(&self) -> &Device<Bound>
pub fn parent(&self) -> &Device<Bound>
Returns a bound reference to the parent device::Device.
Sourcepub fn registration_data_with<F: ForLt + 'static, R>(
&self,
f: impl for<'a> FnOnce(Pin<&'a F::Of<'a>>) -> R,
) -> Result<R>
pub fn registration_data_with<F: ForLt + 'static, R>( &self, f: impl for<'a> FnOnce(Pin<&'a F::Of<'a>>) -> R, ) -> Result<R>
Access the registration data set by the registering (parent) driver through a closure.
F is the ForLt encoding of the data type. The closure receives a pinned
reference to the registration data.
For covariant types that implement CovariantForLt, prefer
registration_data which returns a direct reference.
Returns EINVAL if F does not match the type used by the parent driver when calling
Registration::new().
Returns ENOENT if no registration data has been set, e.g. when the device was
registered by a C driver.
Sourcepub fn registration_data<F: CovariantForLt + 'static>(
&self,
) -> Result<Pin<&F::Of<'_>>>
pub fn registration_data<F: CovariantForLt + 'static>( &self, ) -> Result<Pin<&F::Of<'_>>>
Returns a pinned reference to the registration data set by the registering (parent) driver.
This method is only available when F implements CovariantForLt, which guarantees
that the lifetime shortening is sound.
For non-covariant types, use the closure-based Self::registration_data_with.
Returns EINVAL if F does not match the type used by the parent driver when calling
Registration::new().
Returns ENOENT if no registration data has been set, e.g. when the device was
registered by a C driver.