get_registry/common/protocols/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 #[inline]
189 fn release(&self, _slf: &WlBufferRef) {}
190}
191
192impl WlBufferEventHandler for private::NoOpEventHandler {}
193
194unsafe impl<H> EventHandler for private::EventHandler<H>
196where
197 H: WlBufferEventHandler,
198{
199 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
200
201 #[allow(unused_variables)]
202 unsafe fn handle_event(
203 &self,
204 queue: &Queue,
205 data: *mut u8,
206 slf: &UntypedBorrowedProxy,
207 opcode: u32,
208 args: *mut wl_argument,
209 ) {
210 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlBufferRef>(slf) };
212 match opcode {
213 0 => {
214 self.0.release(slf);
215 }
216 _ => {
217 invalid_opcode("wl_buffer", opcode);
218 }
219 }
220 }
221}
222
223impl<H> CreateEventHandler<H> for private::ProxyApi
224where
225 H: WlBufferEventHandler,
226{
227 type EventHandler = private::EventHandler<H>;
228
229 #[inline]
230 fn create_event_handler(handler: H) -> Self::EventHandler {
231 private::EventHandler(handler)
232 }
233}
234
235pub mod event_handlers {
237 use super::*;
238
239 pub struct Release<F>(F);
241 impl<F> WlBufferEventHandler for Release<F>
242 where
243 F: Fn(&WlBufferRef),
244 {
245 #[inline]
246 fn release(&self, _slf: &WlBufferRef) {
247 self.0(_slf)
248 }
249 }
250
251 impl WlBuffer {
252 #[allow(dead_code)]
256 pub fn on_release<F>(f: F) -> Release<F>
257 where
258 F: Fn(&WlBufferRef),
259 {
260 Release(f)
261 }
262 }
263}