Skip to main content

DeviceContext

Trait DeviceContext 

Source
pub trait DeviceContext:
    Sealed
    + Send
    + Sync { }
Expand description

A trait implemented by all possible contexts a Device can be used in.

Setting up a new Device is a multi-stage process. Each step of the process that a user interacts with in Rust has a respective DeviceContext typestate. For example, Device<T, Registered> would be a Device that reached the Registered DeviceContext.

Each stage of this process is described below:

       1                     2                         3
+--------------+   +------------------+   +-----------------------+
|Device created| → |Device initialized| → |Registered w/ userspace|
+--------------+   +------------------+   +-----------------------+
   (Uninit)                                      (Registered)
  1. The Device is in the Uninit context and is not guaranteed to be initialized or registered with userspace. Only a limited subset of DRM core functionality is available.
  2. The Device is guaranteed to be fully initialized, but is not guaranteed to be registered with userspace. All DRM core functionality which doesn’t interact with userspace is available. We currently don’t have a context for representing this.
  3. The Device is guaranteed to be fully initialized, and is guaranteed to have been registered with userspace at some point - thus putting it in the Registered context.

An important caveat of DeviceContext which must be kept in mind: when used as a typestate for a reference type, it can only guarantee that a Device reached a particular stage in the initialization process at the time the reference was taken. No guarantee is made in regards to what stage of the process the Device is currently in. This means for instance that a &Device<T, Uninit> may actually be registered with userspace, it just wasn’t known to be registered at the time the reference was taken.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§