get_registry/common/protocols_data/wayland/
wl_buffer.rs1use super::super::all_types::*;
20use ::wl_client::builder::prelude::*;
21
22static INTERFACE: wl_interface = wl_interface {
23 name: c"wl_buffer".as_ptr(),
24 version: 1,
25 method_count: 1,
26 methods: {
27 static MESSAGES: [wl_message; 1] = [wl_message {
28 name: c"destroy".as_ptr(),
29 signature: c"".as_ptr(),
30 types: {
31 static TYPES: [Option<&'static wl_interface>; 0] = [];
32 TYPES.as_ptr().cast()
33 },
34 }];
35 MESSAGES.as_ptr()
36 },
37 event_count: 1,
38 events: {
39 static MESSAGES: [wl_message; 1] = [wl_message {
40 name: c"release".as_ptr(),
41 signature: c"".as_ptr(),
42 types: {
43 static TYPES: [Option<&'static wl_interface>; 0] = [];
44 TYPES.as_ptr().cast()
45 },
46 }];
47 MESSAGES.as_ptr()
48 },
49};
50
51#[derive(Clone, Eq, PartialEq)]
55#[repr(transparent)]
56pub struct WlBuffer {
57 proxy: UntypedOwnedProxy,
59}
60
61#[derive(Eq, PartialEq)]
65#[repr(transparent)]
66pub struct WlBufferRef {
67 proxy: UntypedBorrowedProxy,
69}
70
71unsafe impl UntypedOwnedProxyWrapper for WlBuffer {}
73
74unsafe impl OwnedProxy for WlBuffer {
77 const INTERFACE: &'static str = "wl_buffer";
78 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
79 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
80 private::EventHandler(private::NoOpEventHandler);
81 const MAX_VERSION: u32 = 1;
82
83 type Borrowed = WlBufferRef;
84 type Api = private::ProxyApi;
85 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
86}
87
88unsafe impl UntypedBorrowedProxyWrapper for WlBufferRef {}
90
91unsafe impl BorrowedProxy for WlBufferRef {
93 type Owned = WlBuffer;
94}
95
96impl Deref for WlBuffer {
97 type Target = WlBufferRef;
98
99 fn deref(&self) -> &Self::Target {
100 proxy::low_level::deref(self)
101 }
102}
103
104mod private {
105 pub struct ProxyApi;
106
107 #[allow(dead_code)]
108 pub struct EventHandler<H>(pub(super) H);
109
110 #[allow(dead_code)]
111 pub struct NoOpEventHandler;
112}
113
114impl Debug for WlBuffer {
115 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
116 write!(f, "wl_buffer#{}", self.proxy.id())
117 }
118}
119
120impl Debug for WlBufferRef {
121 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
122 write!(f, "wl_buffer#{}", self.proxy.id())
123 }
124}
125
126impl PartialEq<WlBufferRef> for WlBuffer {
127 fn eq(&self, other: &WlBufferRef) -> bool {
128 self.proxy == other.proxy
129 }
130}
131
132impl PartialEq<WlBuffer> for WlBufferRef {
133 fn eq(&self, other: &WlBuffer) -> bool {
134 self.proxy == other.proxy
135 }
136}
137
138#[allow(dead_code)]
139impl WlBuffer {
140 #[allow(dead_code)]
142 pub const REQ__DESTROY__SINCE: u32 = 1;
143}
144
145#[allow(dead_code)]
146impl WlBuffer {
147 #[inline]
154 pub fn destroy(&self) {
155 let mut args = [];
156 unsafe {
160 self.proxy.send_destructor(0, &mut args);
161 }
162 }
163}
164
165impl WlBuffer {
166 #[allow(dead_code)]
168 pub const EVT__RELEASE__SINCE: u32 = 1;
169}
170
171#[allow(dead_code)]
173pub trait WlBufferEventHandler {
174 type Data: 'static;
175
176 #[inline]
191 fn release(&self, _data: &mut Self::Data, _slf: &WlBufferRef) {}
192}
193
194impl WlBufferEventHandler for private::NoOpEventHandler {
195 type Data = ();
196}
197
198unsafe impl<H> EventHandler for private::EventHandler<H>
201where
202 H: WlBufferEventHandler,
203{
204 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
205
206 #[inline]
207 fn mutable_type() -> Option<(TypeId, &'static str)> {
208 let id = TypeId::of::<H::Data>();
209 let name = std::any::type_name::<H::Data>();
210 Some((id, name))
211 }
212
213 #[allow(unused_variables)]
214 unsafe fn handle_event(
215 &self,
216 queue: &Queue,
217 data: *mut u8,
218 slf: &UntypedBorrowedProxy,
219 opcode: u32,
220 args: *mut wl_argument,
221 ) {
222 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlBufferRef>(slf) };
224 let data: &mut H::Data = unsafe { &mut *data.cast() };
228 match opcode {
229 0 => {
230 self.0.release(data, slf);
231 }
232 _ => {
233 invalid_opcode("wl_buffer", opcode);
234 }
235 }
236 }
237}
238
239impl<H> CreateEventHandler<H> for private::ProxyApi
240where
241 H: WlBufferEventHandler,
242{
243 type EventHandler = private::EventHandler<H>;
244
245 #[inline]
246 fn create_event_handler(handler: H) -> Self::EventHandler {
247 private::EventHandler(handler)
248 }
249}
250
251pub mod event_handlers {
253 use super::*;
254
255 pub struct Release<T, F>(F, PhantomData<fn(&mut T)>);
257 impl<T, F> WlBufferEventHandler for Release<T, F>
258 where
259 T: 'static,
260 F: Fn(&mut T, &WlBufferRef),
261 {
262 type Data = T;
263
264 #[inline]
265 fn release(&self, _data: &mut T, _slf: &WlBufferRef) {
266 self.0(_data, _slf)
267 }
268 }
269
270 impl WlBuffer {
271 #[allow(dead_code)]
275 pub fn on_release<T, F>(f: F) -> Release<T, F>
276 where
277 T: 'static,
278 F: Fn(&mut T, &WlBufferRef),
279 {
280 Release(f, PhantomData)
281 }
282 }
283}