pub trait Instance<B>:
Sized
+ Any
+ Send
+ Syncwhere
B: Backend,{
// Required methods
fn create(name: &str, version: u32) -> Result<Self, UnsupportedBackend>;
fn enumerate_adapters(&self) -> Vec<Adapter<B>>;
unsafe fn create_surface(
&self,
_: &impl HasRawWindowHandle,
) -> Result<<B as Backend>::Surface, InitError>;
unsafe fn destroy_surface(&self, surface: <B as Backend>::Surface);
}
Expand description
An instantiated backend.
Any startup the backend needs to perform will be done when creating the type that implements
Instance
.
§Examples
use gfx_backend_empty as backend;
use gfx_hal as hal;
// Create a concrete instance of our backend (this is backend-dependent and may be more
// complicated for some backends).
let instance = backend::Instance;
// We can get a list of the available adapters, which are either physical graphics
// devices, or virtual adapters. Because we are using the dummy `empty` backend,
// there will be nothing in this list.
for (idx, adapter) in hal::Instance::enumerate_adapters(&instance).iter().enumerate() {
println!("Adapter {}: {:?}", idx, adapter.info);
}
Required Methods§
Sourcefn enumerate_adapters(&self) -> Vec<Adapter<B>>
fn enumerate_adapters(&self) -> Vec<Adapter<B>>
Return all available adapters.
Sourceunsafe fn create_surface(
&self,
_: &impl HasRawWindowHandle,
) -> Result<<B as Backend>::Surface, InitError>
unsafe fn create_surface( &self, _: &impl HasRawWindowHandle, ) -> Result<<B as Backend>::Surface, InitError>
Create a new surface.
Sourceunsafe fn destroy_surface(&self, surface: <B as Backend>::Surface)
unsafe fn destroy_surface(&self, surface: <B as Backend>::Surface)
Destroy a surface.
The surface shouldn’t be destroyed before the attached swapchain is destroyed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.