Move markers to types

we keep them undocumented because they are impl detail

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev authored and Teodor Tanasoaia committed 2026-08-17 12:01:39 +02:00
1 parent b6b1e761f2
commit df4947cf47
3 files changed
+67 -66

No files matched your search

+1 -66
View File
@@ -1,4 +1,4 @@
use wgt::WasmNotSendSync;
pub use wgt::markers::*;
/// Identify an object by the pointer returned by `Arc::as_ptr`.
///
@@ -69,68 +69,3 @@ impl<T: crate::storage::StorageItem> From<&alloc::sync::Arc<T>> for PointerId<T:
)
}
}
/// Marker trait used to determine which types uniquely identify a resource.
///
/// For example, `Device<A>` will have the same type of identifier as
/// `Device<B>` because `Device<T>` for any `T` defines the same maker type.
pub trait Marker: 'static + WasmNotSendSync {
const TYPE: &'static str;
}
// This allows `()` to be used as a marker type for tests.
//
// We don't want these in production code, since they essentially remove type
// safety, like how identifiers across different types can be compared.
#[cfg(test)]
impl Marker for () {
const TYPE: &'static str = "Untyped";
}
/// Define markers for each resource.
macro_rules! ids {
($(
$(#[$($meta:meta)*])*
pub type $marker:ident;
)*) => {
/// Marker types for each resource.
pub mod markers {
$(
#[derive(Debug)]
pub enum $marker {}
impl super::Marker for $marker {
const TYPE: &'static str = stringify!($marker);
}
)*
}
}
}
ids! {
pub type Adapter;
pub type Surface;
pub type Device;
pub type Queue;
pub type Buffer;
pub type StagingBuffer;
pub type TextureView;
pub type Texture;
pub type ExternalTexture;
pub type Sampler;
pub type BindGroupLayout;
pub type PipelineLayout;
pub type BindGroup;
pub type ShaderModule;
pub type RenderPipeline;
pub type ComputePipeline;
pub type PipelineCache;
pub type CommandEncoder;
pub type CommandBuffer;
pub type RenderPassEncoder;
pub type ComputePassEncoder;
pub type RenderBundleEncoder;
pub type RenderBundle;
pub type QuerySet;
pub type Blas;
pub type Tlas;
}
+2
View File
@@ -40,6 +40,8 @@ mod features;
pub mod instance;
mod limits;
mod macros;
#[doc(hidden)] // for use in wgpu-core,wgpu-core-remote-types
pub mod markers;
pub mod math;
mod origin_extent;
mod ray_tracing;
+64
View File
@@ -0,0 +1,64 @@
/// Marker trait used to determine which types uniquely identify a resource.
///
/// For example, `Device<A>` will have the same type of identifier as
/// `Device<B>` because `Device<T>` for any `T` defines the same maker type.
pub trait Marker: 'static + crate::WasmNotSendSync {
const TYPE: &'static str;
}
// This allows `()` to be used as a marker type for tests.
//
// We don't want these in production code, since they essentially remove type
// safety, like how identifiers across different types can be compared.
#[cfg(test)]
impl Marker for () {
const TYPE: &'static str = "Untyped";
}
/// Define markers for each resource.
macro_rules! ids {
($(
$(#[$($meta:meta)*])*
pub type $marker:ident;
)*) => {
/// Marker types for each resource.
pub mod markers {
$(
#[derive(Debug)]
pub enum $marker {}
impl super::Marker for $marker {
const TYPE: &'static str = stringify!($marker);
}
)*
}
}
}
ids! {
pub type Adapter;
pub type Surface;
pub type Device;
pub type Queue;
pub type Buffer;
pub type StagingBuffer;
pub type TextureView;
pub type Texture;
pub type ExternalTexture;
pub type Sampler;
pub type BindGroupLayout;
pub type PipelineLayout;
pub type BindGroup;
pub type ShaderModule;
pub type RenderPipeline;
pub type ComputePipeline;
pub type PipelineCache;
pub type CommandEncoder;
pub type CommandBuffer;
pub type RenderPassEncoder;
pub type ComputePassEncoder;
pub type RenderBundleEncoder;
pub type RenderBundle;
pub type QuerySet;
pub type Blas;
pub type Tlas;
}