dawn_sys/
lib.rs

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