Trait raw_window_handle::HasDisplayHandle
source · pub trait HasDisplayHandle {
// Required method
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>;
}
Expand description
A display that acts as a wrapper around a display handle.
Objects that implement this trait should be able to return a DisplayHandle
for the display
that they are associated with. This handle should last for the lifetime of the object, and should
return an error if the application is inactive.
Implementors of this trait will be windowing systems, like winit
and sdl2
. These windowing
systems should implement this trait on types that already implement HasRawDisplayHandle
. It
should be implemented by tying the lifetime of the DisplayHandle
to the lifetime of the
display object.
Users of this trait will include graphics libraries, like wgpu
and glutin
. These APIs
should be generic over a type that implements HasDisplayHandle
, and should use the
DisplayHandle
type to access the display handle.
Safety
The safety requirements of HasRawDisplayHandle
apply here as well. To reiterate, the
DisplayHandle
must contain a valid window handle for its lifetime.
It is not possible to invalidate a DisplayHandle
on any platform without additional unsafe code.
Note that these requirements are not enforced on HasDisplayHandle
, rather, they are enforced on the
constructors of DisplayHandle
. This is because the HasDisplayHandle
trait is safe to implement.
Required Methods§
sourcefn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>
Get a handle to the display controller of the windowing system.