wgpu/api/
mod.rs

1//! Types and functions which define our public api and their
2//! helper functionality.
3//!
4//! # Conventions
5//!
6//! Each major type gets its own module. The module is laid out as follows:
7//!
8//! - The type itself
9//! - `impl` block for the type
10//! - `Drop` implementation for the type (if needed)
11//! - Descriptor types and their subtypes.
12//! - Any non-public helper types or functions.
13//!
14//! # Imports
15//!
16//! Because our public api is "flat" (i.e. all types are directly under the `wgpu` module),
17//! we use a single `crate::*` import at the top of each module to bring in all the types in
18//! the public api. This is done to:
19//! - Avoid having to write out a long list of imports for each module.
20//! - Allow docs to be written naturally, without needing to worry about needing dedicated doc imports.
21//! - Treat wgpu-types types and wgpu-core types as a single set.
22
23mod adapter;
24mod bind_group;
25mod bind_group_layout;
26mod blas;
27mod buffer;
28mod command_buffer;
29mod command_encoder;
30// Not a root type, but common descriptor types for pipelines.
31mod common_pipeline;
32mod compute_pass;
33mod compute_pipeline;
34mod device;
35mod external_texture;
36mod instance;
37mod pipeline_cache;
38mod pipeline_layout;
39mod query_set;
40mod queue;
41mod render_bundle;
42mod render_bundle_encoder;
43mod render_pass;
44mod render_pipeline;
45mod sampler;
46mod shader_module;
47mod surface;
48mod surface_texture;
49mod texture;
50mod texture_view;
51mod tlas;
52
53pub use adapter::*;
54pub use bind_group::*;
55pub use bind_group_layout::*;
56pub use blas::*;
57pub use buffer::*;
58pub use command_buffer::*;
59pub use command_encoder::*;
60pub use common_pipeline::*;
61pub use compute_pass::*;
62pub use compute_pipeline::*;
63pub use device::*;
64pub use external_texture::*;
65pub use instance::*;
66pub use pipeline_cache::*;
67pub use pipeline_layout::*;
68pub use query_set::*;
69pub use queue::*;
70pub use render_bundle::*;
71pub use render_bundle_encoder::*;
72pub use render_pass::*;
73pub use render_pipeline::*;
74pub use sampler::*;
75pub use shader_module::*;
76pub use surface::*;
77pub use surface_texture::*;
78pub use texture::*;
79pub use texture_view::*;
80pub use tlas::*;
81
82/// Object debugging label.
83pub type Label<'a> = Option<&'a str>;
84
85/// A cute utility type that works just like `PhantomData`, but also
86/// implements `Drop`. This forces any lifetimes that are associated
87/// with the type to be used until the `Drop` impl is ran. This prevents
88/// lifetimes from being shortened.
89#[derive(Debug)]
90pub(crate) struct PhantomDrop<T>(core::marker::PhantomData<T>);
91
92impl<T> Default for PhantomDrop<T> {
93    fn default() -> Self {
94        Self(core::marker::PhantomData)
95    }
96}
97
98impl<T> Drop for PhantomDrop<T> {
99    fn drop(&mut self) {}
100}