dawn_sys/
lib.rs

1#![no_std]
2#![doc = include_str!("../README.md")]
3#![expect(non_camel_case_types)]
4#![expect(non_snake_case)]
5#![expect(non_upper_case_globals)]
6
7include!("../generated/bindings.rs");
8include!("../generated/lib.rs");
9
10impl WGPUStringView {
11    pub fn from_bytes(bytes: &[u8]) -> Self {
12        WGPUStringView {
13            data: bytes.as_ptr().cast(),
14            length: bytes.len(),
15        }
16    }
17
18    pub fn as_bytes(&self) -> &[u8] {
19        unsafe {
20            core::slice::from_raw_parts(
21                self.data.cast(),
22                self.length)
23        }
24    }
25}
26
27/// `true` value of [`WGPUBool`].
28pub const WGPU_TRUE: WGPUBool = 1;
29
30/// `false` value of [`WGPUBool`].
31pub const WGPU_FALSE: WGPUBool = 0;
32
33/// Indicates no array layer count is specified.
34pub const WGPU_ARRAY_LAYER_COUNT_UNDEFINED: u32 = u32::MAX;
35
36/// Indicates no copy stride is specified.
37pub const WGPU_COPY_STRIDE_UNDEFINED: u32 = u32::MAX;
38
39/// Indicates no depth clear value is specified.
40pub const WGPU_DEPTH_CLEAR_VALUE_UNDEFINED: f32 = f32::NAN;
41
42/// Indicates no depth slice is specified.
43pub const WGPU_DEPTH_SLICE_UNDEFINED: u32 = u32::MAX;
44
45/// For `u32` limits, indicates no limit value is specified.
46pub const WGPU_LIMIT_U32_UNDEFINED: u32 = u32::MAX;
47
48/// For `u64` limits, indicates no limit value is specified.
49pub const WGPU_LIMIT_U64_UNDEFINED: u64 = u64::MAX;
50
51/// Indicates no mip level count is specified.
52pub const WGPU_MIP_LEVEL_COUNT_UNDEFINED: u32 = u32::MAX;
53
54/// Indicates no query set index is specified.
55pub const WGPU_QUERY_SET_INDEX_UNDEFINED: u32 = u32::MAX;
56
57/// Sentinel value used in [`WGPUStringView`].
58pub const WGPU_STRLEN: usize = usize::MAX;
59
60/// Indicates a size extending to the end of the buffer.
61pub const WGPU_WHOLE_MAP_SIZE: usize = usize::MAX;
62
63/// Indicates a size extending to the end of the buffer.
64pub const WGPU_WHOLE_SIZE: u64 = u64::MAX;