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    WGPUStringView,
18    WGPUFlags,
19    WGPUBool,
20    WGPUChainedStruct,
21};
22
23impl WGPUStringView {
24    pub fn from_bytes(bytes: &[u8]) -> Self {
25        WGPUStringView {
26            data: bytes.as_ptr() as _,
27            length: bytes.len(),
28        }
29    }
30
31    pub fn as_bytes(&self) -> &[u8] {
32        unsafe {
33            core::slice::from_raw_parts(
34                self.data as _,
35                self.length)
36        }
37    }
38}
39
40/// `true` value of [`WGPUBool`].
41pub const WGPU_TRUE: WGPUBool = 1;
42
43/// `false` value of [`WGPUBool`].
44pub const WGPU_FALSE: WGPUBool = 0;
45
46/// Indicates no array layer count is specified.
47pub const WGPU_ARRAY_LAYER_COUNT_UNDEFINED: u32 = u32::MAX;
48
49/// Indicates no copy stride is specified.
50pub const WGPU_COPY_STRIDE_UNDEFINED: u32 = u32::MAX;
51
52/// Indicates no depth clear value is specified.
53pub const WGPU_DEPTH_CLEAR_VALUE_UNDEFINED: f32 = f32::NAN;
54
55/// Indicates no depth slice is specified.
56pub const WGPU_DEPTH_SLICE_UNDEFINED: u32 = u32::MAX;
57
58/// For `u32` limits, indicates no limit value is specified.
59pub const WGPU_LIMIT_U32_UNDEFINED: u32 = u32::MAX;
60
61/// For `u64` limits, indicates no limit value is specified.
62pub const WGPU_LIMIT_U64_UNDEFINED: u64 = u64::MAX;
63
64/// Indicates no mip level count is specified.
65pub const WGPU_MIP_LEVEL_COUNT_UNDEFINED: u32 = u32::MAX;
66
67/// Indicates no query set index is specified.
68pub const WGPU_QUERY_SET_INDEX_UNDEFINED: u32 = u32::MAX;
69
70/// Sentinel value used in [`WGPUStringView`].
71pub const WGPU_STRLEN: usize = usize::MAX;
72
73/// Indicates a size extending to the end of the buffer.
74pub const WGPU_WHOLE_MAP_SIZE: usize = usize::MAX;
75
76/// Indicates a size extending to the end of the buffer.
77pub const WGPU_WHOLE_SIZE: u64 = u64::MAX;