1pub use super::super::Nested;
5pub use std::{borrow::Cow, num::NonZeroU32, ops::Range};
6pub trait Field {}
7pub trait IsOptional {}
8#[doc = "\nBuilder for [`wgpu::ComputePassTimestampWrites`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [query_set](ComputePassTimestampWritesBuilder::query_set) Required\n - [beginning_of_pass_write_index](ComputePassTimestampWritesBuilder::beginning_of_pass_write_index) Optional, defaults to `None`\n - [end_of_pass_write_index](ComputePassTimestampWritesBuilder::end_of_pass_write_index) Optional, defaults to `None`\n"]
9pub struct ComputePassTimestampWritesBuilder<'a, CS: State<'a>> {
10 query_set: CS::QuerySet,
11 beginning_of_pass_write_index: CS::BeginningOfPassWriteIndex,
12 end_of_pass_write_index: CS::EndOfPassWriteIndex,
13}
14impl<'a> ComputePassTimestampWritesBuilder<'a, Empty> {
15 pub fn new() -> ComputePassTimestampWritesBuilder<'a, Empty> {
16 ComputePassTimestampWritesBuilder {
17 query_set: QuerySetEmpty,
18 beginning_of_pass_write_index: BeginningOfPassWriteIndexEmpty,
19 end_of_pass_write_index: EndOfPassWriteIndexEmpty,
20 }
21 }
22}
23#[doc = "\nReturns [ComputePassTimestampWritesBuilder] for building [`wgpu::ComputePassTimestampWrites`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [query_set](ComputePassTimestampWritesBuilder::query_set) Required\n - [beginning_of_pass_write_index](ComputePassTimestampWritesBuilder::beginning_of_pass_write_index) Optional, defaults to `None`\n - [end_of_pass_write_index](ComputePassTimestampWritesBuilder::end_of_pass_write_index) Optional, defaults to `None`\n"]
24pub fn compute_pass_timestamp_writes<'a>() -> ComputePassTimestampWritesBuilder<'a, Empty> {
25 ComputePassTimestampWritesBuilder::new()
26}
27pub struct QuerySetEmpty;
28impl Field for QuerySetEmpty {}
29pub trait QuerySetIsEmpty {}
30impl QuerySetIsEmpty for QuerySetEmpty {}
31pub trait IsSetQuerySet<'a> {
32 fn get(self) -> &'a wgpu::QuerySet;
33}
34pub struct QuerySetValue<'a>(pub &'a wgpu::QuerySet);
35impl<'a> Field for QuerySetValue<'a> {}
36impl<'a> IsSetQuerySet<'a> for QuerySetValue<'a> {
37 fn get(self) -> &'a wgpu::QuerySet {
38 self.0
39 }
40}
41pub struct BeginningOfPassWriteIndexEmpty;
42impl Field for BeginningOfPassWriteIndexEmpty {}
43pub trait BeginningOfPassWriteIndexIsEmpty {}
44impl BeginningOfPassWriteIndexIsEmpty for BeginningOfPassWriteIndexEmpty {}
45pub trait IsSetBeginningOfPassWriteIndex {
46 fn get(self) -> Option<u32>;
47}
48impl IsSetBeginningOfPassWriteIndex for BeginningOfPassWriteIndexEmpty {
49 fn get(self) -> Option<u32> {
50 None
51 }
52}
53pub struct BeginningOfPassWriteIndexValue(pub Option<u32>);
54impl Field for BeginningOfPassWriteIndexValue {}
55impl IsSetBeginningOfPassWriteIndex for BeginningOfPassWriteIndexValue {
56 fn get(self) -> Option<u32> {
57 self.0
58 }
59}
60pub struct EndOfPassWriteIndexEmpty;
61impl Field for EndOfPassWriteIndexEmpty {}
62pub trait EndOfPassWriteIndexIsEmpty {}
63impl EndOfPassWriteIndexIsEmpty for EndOfPassWriteIndexEmpty {}
64pub trait IsSetEndOfPassWriteIndex {
65 fn get(self) -> Option<u32>;
66}
67impl IsSetEndOfPassWriteIndex for EndOfPassWriteIndexEmpty {
68 fn get(self) -> Option<u32> {
69 None
70 }
71}
72pub struct EndOfPassWriteIndexValue(pub Option<u32>);
73impl Field for EndOfPassWriteIndexValue {}
74impl IsSetEndOfPassWriteIndex for EndOfPassWriteIndexValue {
75 fn get(self) -> Option<u32> {
76 self.0
77 }
78}
79pub trait State<'a> {
80 type QuerySet: Field;
81 type BeginningOfPassWriteIndex: Field;
82 type EndOfPassWriteIndex: Field;
83}
84pub struct Empty;
85impl<'a> State<'a> for Empty {
86 type QuerySet = QuerySetEmpty;
87 type BeginningOfPassWriteIndex = BeginningOfPassWriteIndexEmpty;
88 type EndOfPassWriteIndex = EndOfPassWriteIndexEmpty;
89}
90pub struct SetQuerySet<CS>(CS);
91impl<'a, CS: State<'a>> State<'a> for SetQuerySet<CS> {
92 type QuerySet = QuerySetValue<'a>;
93 type BeginningOfPassWriteIndex = CS::BeginningOfPassWriteIndex;
94 type EndOfPassWriteIndex = CS::EndOfPassWriteIndex;
95}
96pub struct SetBeginningOfPassWriteIndex<CS>(CS);
97impl<'a, CS: State<'a>> State<'a> for SetBeginningOfPassWriteIndex<CS> {
98 type QuerySet = CS::QuerySet;
99 type BeginningOfPassWriteIndex = BeginningOfPassWriteIndexValue;
100 type EndOfPassWriteIndex = CS::EndOfPassWriteIndex;
101}
102pub struct SetEndOfPassWriteIndex<CS>(CS);
103impl<'a, CS: State<'a>> State<'a> for SetEndOfPassWriteIndex<CS> {
104 type QuerySet = CS::QuerySet;
105 type BeginningOfPassWriteIndex = CS::BeginningOfPassWriteIndex;
106 type EndOfPassWriteIndex = EndOfPassWriteIndexValue;
107}
108impl<'a, CS: State<'a>> ComputePassTimestampWritesBuilder<'a, CS> {
109 #[doc = "Setter for [wgpu::ComputePassTimestampWrites::query_set]. Required.\n"]
110 pub fn query_set(
111 self,
112 query_set: &'a wgpu::QuerySet,
113 ) -> ComputePassTimestampWritesBuilder<'a, SetQuerySet<CS>>
114 where
115 CS::QuerySet: QuerySetIsEmpty,
116 {
117 ComputePassTimestampWritesBuilder {
118 query_set: QuerySetValue(query_set),
119 beginning_of_pass_write_index: self.beginning_of_pass_write_index,
120 end_of_pass_write_index: self.end_of_pass_write_index,
121 }
122 }
123 #[doc = "Setter for [wgpu::ComputePassTimestampWrites::beginning_of_pass_write_index]. Optional, defaults to `None`.\n"]
124 pub fn beginning_of_pass_write_index(
125 self,
126 beginning_of_pass_write_index: u32,
127 ) -> ComputePassTimestampWritesBuilder<'a, SetBeginningOfPassWriteIndex<CS>>
128 where
129 CS::BeginningOfPassWriteIndex: BeginningOfPassWriteIndexIsEmpty,
130 {
131 ComputePassTimestampWritesBuilder {
132 query_set: self.query_set,
133 beginning_of_pass_write_index: BeginningOfPassWriteIndexValue(Some(
134 beginning_of_pass_write_index,
135 )),
136 end_of_pass_write_index: self.end_of_pass_write_index,
137 }
138 }
139 #[doc = "Setter for [wgpu::ComputePassTimestampWrites::beginning_of_pass_write_index]. Optional, defaults to `None`.\n"]
140 pub fn maybe_beginning_of_pass_write_index(
141 self,
142 beginning_of_pass_write_index: Option<u32>,
143 ) -> ComputePassTimestampWritesBuilder<'a, SetBeginningOfPassWriteIndex<CS>>
144 where
145 CS::BeginningOfPassWriteIndex: BeginningOfPassWriteIndexIsEmpty,
146 {
147 ComputePassTimestampWritesBuilder {
148 query_set: self.query_set,
149 beginning_of_pass_write_index: BeginningOfPassWriteIndexValue(
150 beginning_of_pass_write_index,
151 ),
152 end_of_pass_write_index: self.end_of_pass_write_index,
153 }
154 }
155 #[doc = "Setter for [wgpu::ComputePassTimestampWrites::end_of_pass_write_index]. Optional, defaults to `None`.\n"]
156 pub fn end_of_pass_write_index(
157 self,
158 end_of_pass_write_index: u32,
159 ) -> ComputePassTimestampWritesBuilder<'a, SetEndOfPassWriteIndex<CS>>
160 where
161 CS::EndOfPassWriteIndex: EndOfPassWriteIndexIsEmpty,
162 {
163 ComputePassTimestampWritesBuilder {
164 query_set: self.query_set,
165 beginning_of_pass_write_index: self.beginning_of_pass_write_index,
166 end_of_pass_write_index: EndOfPassWriteIndexValue(Some(end_of_pass_write_index)),
167 }
168 }
169 #[doc = "Setter for [wgpu::ComputePassTimestampWrites::end_of_pass_write_index]. Optional, defaults to `None`.\n"]
170 pub fn maybe_end_of_pass_write_index(
171 self,
172 end_of_pass_write_index: Option<u32>,
173 ) -> ComputePassTimestampWritesBuilder<'a, SetEndOfPassWriteIndex<CS>>
174 where
175 CS::EndOfPassWriteIndex: EndOfPassWriteIndexIsEmpty,
176 {
177 ComputePassTimestampWritesBuilder {
178 query_set: self.query_set,
179 beginning_of_pass_write_index: self.beginning_of_pass_write_index,
180 end_of_pass_write_index: EndOfPassWriteIndexValue(end_of_pass_write_index),
181 }
182 }
183}
184pub trait Complete<'a>:
185 State<
186 'a,
187 QuerySet: IsSetQuerySet<'a>,
188 BeginningOfPassWriteIndex: IsSetBeginningOfPassWriteIndex,
189 EndOfPassWriteIndex: IsSetEndOfPassWriteIndex,
190>
191{
192}
193impl<
194 'a,
195 CS: State<
196 'a,
197 QuerySet: IsSetQuerySet<'a>,
198 BeginningOfPassWriteIndex: IsSetBeginningOfPassWriteIndex,
199 EndOfPassWriteIndex: IsSetEndOfPassWriteIndex,
200 >,
201 > Complete<'a> for CS
202{
203}
204impl<'a, CS: Complete<'a>> ComputePassTimestampWritesBuilder<'a, CS> {
205 pub fn build(self) -> wgpu::ComputePassTimestampWrites<'a> {
206 wgpu::ComputePassTimestampWrites {
207 query_set: IsSetQuerySet::get(self.query_set),
208 beginning_of_pass_write_index: IsSetBeginningOfPassWriteIndex::get(
209 self.beginning_of_pass_write_index,
210 ),
211 end_of_pass_write_index: IsSetEndOfPassWriteIndex::get(self.end_of_pass_write_index),
212 }
213 }
214}
215impl<'a> Nested<wgpu::ComputePassTimestampWrites<'a>> for wgpu::ComputePassTimestampWrites<'a> {
216 fn unnest(self) -> wgpu::ComputePassTimestampWrites<'a> {
217 self
218 }
219}
220impl<'a, CS: Complete<'a>> Nested<wgpu::ComputePassTimestampWrites<'a>>
221 for ComputePassTimestampWritesBuilder<'a, CS>
222{
223 fn unnest(self) -> wgpu::ComputePassTimestampWrites<'a> {
224 self.build()
225 }
226}
227#[cfg(test)]
228mod tests {
229 #[allow(unused_imports)]
230 #[allow(unused_imports)]
231 use std::num::NonZeroU32;
232 #[test]
233 pub fn test_default() {
234 assert_eq!(
235 format!(
236 "{:#?}",
237 super::IsSetBeginningOfPassWriteIndex::get(super::BeginningOfPassWriteIndexEmpty)
238 ),
239 format!("{:#?}", Option::<u32>::default()),
240 );
241 assert_eq!(
242 format!(
243 "{:#?}",
244 super::IsSetEndOfPassWriteIndex::get(super::EndOfPassWriteIndexEmpty)
245 ),
246 format!("{:#?}", Option::<u32>::default()),
247 );
248 }
249}