quickgpu/builders/
origin_2_d_builder.rs1pub use super::super::Nested;
5pub use std::{borrow::Cow, num::NonZeroU32, ops::Range};
6pub trait Field {}
7pub trait IsOptional {}
8#[doc = "\nBuilder for [`wgpu::Origin2d`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [x](Origin2dBuilder::x) Required\n - [y](Origin2dBuilder::y) Required\n"]
9pub struct Origin2dBuilder<CS: State> {
10 x: CS::X,
11 y: CS::Y,
12}
13impl Origin2dBuilder<Empty> {
14 pub fn new() -> Origin2dBuilder<Empty> {
15 Origin2dBuilder {
16 x: XEmpty,
17 y: YEmpty,
18 }
19 }
20}
21#[doc = "\nReturns [Origin2dBuilder] for building [`wgpu::Origin2d`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [x](Origin2dBuilder::x) Required\n - [y](Origin2dBuilder::y) Required\n"]
22pub fn origin_2_d() -> Origin2dBuilder<Empty> {
23 Origin2dBuilder::new()
24}
25pub struct XEmpty;
26impl Field for XEmpty {}
27pub trait XIsEmpty {}
28impl XIsEmpty for XEmpty {}
29pub trait IsSetX {
30 fn get(self) -> u32;
31}
32pub struct XValue(pub u32);
33impl Field for XValue {}
34impl IsSetX for XValue {
35 fn get(self) -> u32 {
36 self.0
37 }
38}
39pub struct YEmpty;
40impl Field for YEmpty {}
41pub trait YIsEmpty {}
42impl YIsEmpty for YEmpty {}
43pub trait IsSetY {
44 fn get(self) -> u32;
45}
46pub struct YValue(pub u32);
47impl Field for YValue {}
48impl IsSetY for YValue {
49 fn get(self) -> u32 {
50 self.0
51 }
52}
53pub trait State {
54 type X: Field;
55 type Y: Field;
56}
57pub struct Empty;
58impl State for Empty {
59 type X = XEmpty;
60 type Y = YEmpty;
61}
62pub struct SetX<CS>(CS);
63impl<CS: State> State for SetX<CS> {
64 type X = XValue;
65 type Y = CS::Y;
66}
67pub struct SetY<CS>(CS);
68impl<CS: State> State for SetY<CS> {
69 type X = CS::X;
70 type Y = YValue;
71}
72impl<CS: State> Origin2dBuilder<CS> {
73 #[doc = "Setter for [wgpu::Origin2d::x]. Required.\n"]
74 pub fn x(self, x: u32) -> Origin2dBuilder<SetX<CS>>
75 where
76 CS::X: XIsEmpty,
77 {
78 Origin2dBuilder {
79 x: XValue(x),
80 y: self.y,
81 }
82 }
83 #[doc = "Setter for [wgpu::Origin2d::y]. Required.\n"]
84 pub fn y(self, y: u32) -> Origin2dBuilder<SetY<CS>>
85 where
86 CS::Y: YIsEmpty,
87 {
88 Origin2dBuilder {
89 x: self.x,
90 y: YValue(y),
91 }
92 }
93}
94pub trait Complete: State<X: IsSetX, Y: IsSetY> {}
95impl<CS: State<X: IsSetX, Y: IsSetY>> Complete for CS {}
96impl<CS: Complete> Origin2dBuilder<CS> {
97 pub fn build(self) -> wgpu::Origin2d {
98 wgpu::Origin2d {
99 x: IsSetX::get(self.x),
100 y: IsSetY::get(self.y),
101 }
102 }
103}
104impl Nested<wgpu::Origin2d> for wgpu::Origin2d {
105 fn unnest(self) -> wgpu::Origin2d {
106 self
107 }
108}
109impl<CS: Complete> Nested<wgpu::Origin2d> for Origin2dBuilder<CS> {
110 fn unnest(self) -> wgpu::Origin2d {
111 self.build()
112 }
113}
114#[cfg(test)]
115mod tests {
116 #[allow(unused_imports)]
117 #[allow(unused_imports)]
118 use std::num::NonZeroU32;
119 #[test]
120 pub fn test_default() {}
121}