wl_client/test_protocols/core/
wl_dummy.rs

1use {super::super::all_types::*, crate::builder::prelude::*};
2
3static INTERFACE: wl_interface = wl_interface {
4    name: c"wl_dummy".as_ptr(),
5    version: 1,
6    method_count: 3,
7    methods: {
8        static MESSAGES: [wl_message; 3] = [
9            wl_message {
10                name: c"destroy".as_ptr(),
11                signature: c"".as_ptr(),
12                types: {
13                    static TYPES: [Option<&'static wl_interface>; 0] = [];
14                    TYPES.as_ptr().cast()
15                },
16            },
17            wl_message {
18                name: c"recycle".as_ptr(),
19                signature: c"n".as_ptr(),
20                types: {
21                    static TYPES: [Option<&'static wl_interface>; 1] =
22                        [Some(WlDummy::WL_INTERFACE)];
23                    TYPES.as_ptr().cast()
24                },
25            },
26            wl_message {
27                name: c"get_string".as_ptr(),
28                signature: c"n".as_ptr(),
29                types: {
30                    static TYPES: [Option<&'static wl_interface>; 1] =
31                        [Some(WlString::WL_INTERFACE)];
32                    TYPES.as_ptr().cast()
33                },
34            },
35        ];
36        MESSAGES.as_ptr()
37    },
38    event_count: 0,
39    events: ptr::null(),
40};
41
42/// An owned wl_dummy proxy.
43///
44/// See the documentation of [the module][self] for the interface description.
45#[derive(Clone, Eq, PartialEq)]
46#[repr(transparent)]
47pub struct WlDummy {
48    /// This proxy has the interface INTERFACE.
49    proxy: UntypedOwnedProxy,
50}
51
52/// A borrowed wl_dummy proxy.
53///
54/// See the documentation of [the module][self] for the interface description.
55#[derive(Eq, PartialEq)]
56#[repr(transparent)]
57pub struct WlDummyRef {
58    /// This proxy has the interface INTERFACE.
59    proxy: UntypedBorrowedProxy,
60}
61
62// SAFETY: WlDummy is a transparent wrapper around UntypedOwnedProxy
63unsafe impl UntypedOwnedProxyWrapper for WlDummy {}
64
65// SAFETY: - INTERFACE is a valid wl_interface
66//         - The only invariant is that self.proxy has a compatible interface
67unsafe impl OwnedProxy for WlDummy {
68    const INTERFACE: &'static str = "wl_dummy";
69    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
70    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
71        private::EventHandler(private::NoOpEventHandler);
72    const MAX_VERSION: u32 = 1;
73
74    type Borrowed = WlDummyRef;
75    type Api = private::ProxyApi;
76    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
77}
78
79// SAFETY: WlDummyRef is a transparent wrapper around UntypedBorrowedProxy
80unsafe impl UntypedBorrowedProxyWrapper for WlDummyRef {}
81
82// SAFETY: - The only invariant is that self.proxy has a compatible interface
83unsafe impl BorrowedProxy for WlDummyRef {
84    type Owned = WlDummy;
85}
86
87impl Deref for WlDummy {
88    type Target = WlDummyRef;
89
90    fn deref(&self) -> &Self::Target {
91        proxy::low_level::deref(self)
92    }
93}
94
95mod private {
96    pub struct ProxyApi;
97
98    #[allow(dead_code)]
99    pub struct EventHandler<H>(pub(super) H);
100
101    #[allow(dead_code)]
102    pub struct NoOpEventHandler;
103}
104
105impl Debug for WlDummy {
106    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
107        write!(f, "wl_dummy#{}", self.proxy.id())
108    }
109}
110
111impl Debug for WlDummyRef {
112    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
113        write!(f, "wl_dummy#{}", self.proxy.id())
114    }
115}
116
117impl PartialEq<WlDummyRef> for WlDummy {
118    fn eq(&self, other: &WlDummyRef) -> bool {
119        self.proxy == other.proxy
120    }
121}
122
123impl PartialEq<WlDummy> for WlDummyRef {
124    fn eq(&self, other: &WlDummy) -> bool {
125        self.proxy == other.proxy
126    }
127}
128
129#[allow(dead_code)]
130impl WlDummy {
131    /// Since when the destroy request is available.
132    #[allow(dead_code)]
133    pub const REQ__DESTROY__SINCE: u32 = 1;
134
135    #[inline]
136    pub fn destroy(&self) {
137        let mut args = [];
138        // SAFETY: - self.proxy has the interface INTERFACE
139        //         - 0 < INTERFACE.method_count = 3
140        //         - the request signature is ``
141        unsafe {
142            self.proxy.send_destructor(0, &mut args);
143        }
144    }
145
146    /// Since when the recycle request is available.
147    #[allow(dead_code)]
148    pub const REQ__RECYCLE__SINCE: u32 = 1;
149
150    #[inline]
151    pub fn recycle(&self) -> WlDummy {
152        let mut args = [wl_argument { n: 0 }];
153        // SAFETY: - self.proxy has the interface INTERFACE
154        //         - 1 < INTERFACE.method_count = 3
155        //         - the request signature is `n`
156        //         - OwnedProxy::WL_INTERFACE is always a valid interface
157        let data = unsafe {
158            self.proxy
159                .send_constructor::<true>(1, &mut args, WlDummy::WL_INTERFACE, None)
160        };
161        // SAFETY: data has the interface WlDummy::WL_INTERFACE
162        unsafe { proxy::low_level::from_untyped_owned(data) }
163    }
164
165    /// Since when the get_string request is available.
166    #[allow(dead_code)]
167    pub const REQ__GET_STRING__SINCE: u32 = 1;
168
169    #[inline]
170    pub fn get_string(&self) -> WlString {
171        let mut args = [wl_argument { n: 0 }];
172        // SAFETY: - self.proxy has the interface INTERFACE
173        //         - 2 < INTERFACE.method_count = 3
174        //         - the request signature is `n`
175        //         - OwnedProxy::WL_INTERFACE is always a valid interface
176        let data = unsafe {
177            self.proxy
178                .send_constructor::<false>(2, &mut args, WlString::WL_INTERFACE, None)
179        };
180        // SAFETY: data has the interface WlString::WL_INTERFACE
181        unsafe { proxy::low_level::from_untyped_owned(data) }
182    }
183}
184
185#[allow(dead_code)]
186impl WlDummyRef {
187    /// # Arguments
188    ///
189    /// - `_queue`: The queue that the returned proxy is assigned to.
190    #[inline]
191    pub fn get_string(&self, _queue: &Queue) -> WlString {
192        let mut args = [wl_argument { n: 0 }];
193        // SAFETY: - self.proxy has the interface INTERFACE
194        //         - 2 < INTERFACE.method_count = 3
195        //         - the request signature is `n`
196        //         - OwnedProxy::WL_INTERFACE is always a valid interface
197        let data = unsafe {
198            self.proxy
199                .send_constructor(_queue, 2, &mut args, WlString::WL_INTERFACE, None)
200        };
201        // SAFETY: data has the interface WlString::WL_INTERFACE
202        unsafe { proxy::low_level::from_untyped_owned(data) }
203    }
204}
205
206/// An event handler for [WlDummy] proxies.
207#[allow(dead_code)]
208pub trait WlDummyEventHandler {}
209
210impl WlDummyEventHandler for private::NoOpEventHandler {}
211
212// SAFETY: INTERFACE is a valid wl_interface
213unsafe impl<H> EventHandler for private::EventHandler<H>
214where
215    H: WlDummyEventHandler,
216{
217    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
218
219    #[allow(unused_variables)]
220    unsafe fn handle_event(
221        &self,
222        queue: &Queue,
223        slf: &UntypedBorrowedProxy,
224        opcode: u32,
225        args: *mut wl_argument,
226    ) {
227        invalid_opcode("wl_dummy", opcode);
228    }
229}
230
231impl<H> CreateEventHandler<H> for private::ProxyApi
232where
233    H: WlDummyEventHandler,
234{
235    type EventHandler = private::EventHandler<H>;
236
237    #[inline]
238    fn create_event_handler(handler: H) -> Self::EventHandler {
239        private::EventHandler(handler)
240    }
241}
242
243/// Functional event handlers.
244pub mod event_handlers {
245    use super::*;
246
247    impl WlDummy {}
248}