x11rb_async/protocol/
sync.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Sync` X11 extension.
5
6#![allow(clippy::too_many_arguments)]
7
8#[allow(unused_imports)]
9use std::borrow::Cow;
10#[allow(unused_imports)]
11use std::convert::TryInto;
12#[allow(unused_imports)]
13use crate::utils::RawFdContainer;
14#[allow(unused_imports)]
15use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd};
16use std::io::IoSlice;
17use crate::connection::RequestConnection;
18#[allow(unused_imports)]
19use crate::connection::Connection as X11Connection;
20#[allow(unused_imports)]
21use crate::cookie::{Cookie, CookieWithFds, VoidCookie};
22use crate::errors::ConnectionError;
23#[allow(unused_imports)]
24use crate::errors::ReplyOrIdError;
25use std::future::Future;
26use std::pin::Pin;
27#[allow(unused_imports)]
28use super::xproto;
29
30pub use x11rb_protocol::protocol::sync::*;
31
32/// Get the major opcode of this extension
33async fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
34    let info = conn.extension_information(X11_EXTENSION_NAME).await?;
35    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
36    Ok(info.major_opcode)
37}
38
39pub async fn initialize<Conn>(conn: &Conn, desired_major_version: u8, desired_minor_version: u8) -> Result<Cookie<'_, Conn, InitializeReply>, ConnectionError>
40where
41    Conn: RequestConnection + ?Sized,
42{
43    let request0 = InitializeRequest {
44        desired_major_version,
45        desired_minor_version,
46    };
47    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
48    let slices = [IoSlice::new(&bytes[0])];
49    assert_eq!(slices.len(), bytes.len());
50    conn.send_request_with_reply(&slices, fds).await
51}
52pub async fn list_system_counters<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, ListSystemCountersReply>, ConnectionError>
53where
54    Conn: RequestConnection + ?Sized,
55{
56    let request0 = ListSystemCountersRequest;
57    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
58    let slices = [IoSlice::new(&bytes[0])];
59    assert_eq!(slices.len(), bytes.len());
60    conn.send_request_with_reply(&slices, fds).await
61}
62pub async fn create_counter<Conn>(conn: &Conn, id: Counter, initial_value: Int64) -> Result<VoidCookie<'_, Conn>, ConnectionError>
63where
64    Conn: RequestConnection + ?Sized,
65{
66    let request0 = CreateCounterRequest {
67        id,
68        initial_value,
69    };
70    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
71    let slices = [IoSlice::new(&bytes[0])];
72    assert_eq!(slices.len(), bytes.len());
73    conn.send_request_without_reply(&slices, fds).await
74}
75pub async fn destroy_counter<Conn>(conn: &Conn, counter: Counter) -> Result<VoidCookie<'_, Conn>, ConnectionError>
76where
77    Conn: RequestConnection + ?Sized,
78{
79    let request0 = DestroyCounterRequest {
80        counter,
81    };
82    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
83    let slices = [IoSlice::new(&bytes[0])];
84    assert_eq!(slices.len(), bytes.len());
85    conn.send_request_without_reply(&slices, fds).await
86}
87pub async fn query_counter<Conn>(conn: &Conn, counter: Counter) -> Result<Cookie<'_, Conn, QueryCounterReply>, ConnectionError>
88where
89    Conn: RequestConnection + ?Sized,
90{
91    let request0 = QueryCounterRequest {
92        counter,
93    };
94    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
95    let slices = [IoSlice::new(&bytes[0])];
96    assert_eq!(slices.len(), bytes.len());
97    conn.send_request_with_reply(&slices, fds).await
98}
99pub async fn await_<'c, 'input, Conn>(conn: &'c Conn, wait_list: &'input [Waitcondition]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
100where
101    Conn: RequestConnection + ?Sized,
102{
103    let request0 = AwaitRequest {
104        wait_list: Cow::Borrowed(wait_list),
105    };
106    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
107    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
108    assert_eq!(slices.len(), bytes.len());
109    conn.send_request_without_reply(&slices, fds).await
110}
111pub async fn change_counter<Conn>(conn: &Conn, counter: Counter, amount: Int64) -> Result<VoidCookie<'_, Conn>, ConnectionError>
112where
113    Conn: RequestConnection + ?Sized,
114{
115    let request0 = ChangeCounterRequest {
116        counter,
117        amount,
118    };
119    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
120    let slices = [IoSlice::new(&bytes[0])];
121    assert_eq!(slices.len(), bytes.len());
122    conn.send_request_without_reply(&slices, fds).await
123}
124pub async fn set_counter<Conn>(conn: &Conn, counter: Counter, value: Int64) -> Result<VoidCookie<'_, Conn>, ConnectionError>
125where
126    Conn: RequestConnection + ?Sized,
127{
128    let request0 = SetCounterRequest {
129        counter,
130        value,
131    };
132    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
133    let slices = [IoSlice::new(&bytes[0])];
134    assert_eq!(slices.len(), bytes.len());
135    conn.send_request_without_reply(&slices, fds).await
136}
137pub async fn create_alarm<'c, 'input, Conn>(conn: &'c Conn, id: Alarm, value_list: &'input CreateAlarmAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
138where
139    Conn: RequestConnection + ?Sized,
140{
141    let request0 = CreateAlarmRequest {
142        id,
143        value_list: Cow::Borrowed(value_list),
144    };
145    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
146    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
147    assert_eq!(slices.len(), bytes.len());
148    conn.send_request_without_reply(&slices, fds).await
149}
150pub async fn change_alarm<'c, 'input, Conn>(conn: &'c Conn, id: Alarm, value_list: &'input ChangeAlarmAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
151where
152    Conn: RequestConnection + ?Sized,
153{
154    let request0 = ChangeAlarmRequest {
155        id,
156        value_list: Cow::Borrowed(value_list),
157    };
158    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
159    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
160    assert_eq!(slices.len(), bytes.len());
161    conn.send_request_without_reply(&slices, fds).await
162}
163pub async fn destroy_alarm<Conn>(conn: &Conn, alarm: Alarm) -> Result<VoidCookie<'_, Conn>, ConnectionError>
164where
165    Conn: RequestConnection + ?Sized,
166{
167    let request0 = DestroyAlarmRequest {
168        alarm,
169    };
170    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
171    let slices = [IoSlice::new(&bytes[0])];
172    assert_eq!(slices.len(), bytes.len());
173    conn.send_request_without_reply(&slices, fds).await
174}
175pub async fn query_alarm<Conn>(conn: &Conn, alarm: Alarm) -> Result<Cookie<'_, Conn, QueryAlarmReply>, ConnectionError>
176where
177    Conn: RequestConnection + ?Sized,
178{
179    let request0 = QueryAlarmRequest {
180        alarm,
181    };
182    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
183    let slices = [IoSlice::new(&bytes[0])];
184    assert_eq!(slices.len(), bytes.len());
185    conn.send_request_with_reply(&slices, fds).await
186}
187pub async fn set_priority<Conn>(conn: &Conn, id: u32, priority: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
188where
189    Conn: RequestConnection + ?Sized,
190{
191    let request0 = SetPriorityRequest {
192        id,
193        priority,
194    };
195    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
196    let slices = [IoSlice::new(&bytes[0])];
197    assert_eq!(slices.len(), bytes.len());
198    conn.send_request_without_reply(&slices, fds).await
199}
200pub async fn get_priority<Conn>(conn: &Conn, id: u32) -> Result<Cookie<'_, Conn, GetPriorityReply>, ConnectionError>
201where
202    Conn: RequestConnection + ?Sized,
203{
204    let request0 = GetPriorityRequest {
205        id,
206    };
207    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
208    let slices = [IoSlice::new(&bytes[0])];
209    assert_eq!(slices.len(), bytes.len());
210    conn.send_request_with_reply(&slices, fds).await
211}
212pub async fn create_fence<Conn>(conn: &Conn, drawable: xproto::Drawable, fence: Fence, initially_triggered: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
213where
214    Conn: RequestConnection + ?Sized,
215{
216    let request0 = CreateFenceRequest {
217        drawable,
218        fence,
219        initially_triggered,
220    };
221    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
222    let slices = [IoSlice::new(&bytes[0])];
223    assert_eq!(slices.len(), bytes.len());
224    conn.send_request_without_reply(&slices, fds).await
225}
226pub async fn trigger_fence<Conn>(conn: &Conn, fence: Fence) -> Result<VoidCookie<'_, Conn>, ConnectionError>
227where
228    Conn: RequestConnection + ?Sized,
229{
230    let request0 = TriggerFenceRequest {
231        fence,
232    };
233    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
234    let slices = [IoSlice::new(&bytes[0])];
235    assert_eq!(slices.len(), bytes.len());
236    conn.send_request_without_reply(&slices, fds).await
237}
238pub async fn reset_fence<Conn>(conn: &Conn, fence: Fence) -> Result<VoidCookie<'_, Conn>, ConnectionError>
239where
240    Conn: RequestConnection + ?Sized,
241{
242    let request0 = ResetFenceRequest {
243        fence,
244    };
245    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
246    let slices = [IoSlice::new(&bytes[0])];
247    assert_eq!(slices.len(), bytes.len());
248    conn.send_request_without_reply(&slices, fds).await
249}
250pub async fn destroy_fence<Conn>(conn: &Conn, fence: Fence) -> Result<VoidCookie<'_, Conn>, ConnectionError>
251where
252    Conn: RequestConnection + ?Sized,
253{
254    let request0 = DestroyFenceRequest {
255        fence,
256    };
257    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
258    let slices = [IoSlice::new(&bytes[0])];
259    assert_eq!(slices.len(), bytes.len());
260    conn.send_request_without_reply(&slices, fds).await
261}
262pub async fn query_fence<Conn>(conn: &Conn, fence: Fence) -> Result<Cookie<'_, Conn, QueryFenceReply>, ConnectionError>
263where
264    Conn: RequestConnection + ?Sized,
265{
266    let request0 = QueryFenceRequest {
267        fence,
268    };
269    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
270    let slices = [IoSlice::new(&bytes[0])];
271    assert_eq!(slices.len(), bytes.len());
272    conn.send_request_with_reply(&slices, fds).await
273}
274pub async fn await_fence<'c, 'input, Conn>(conn: &'c Conn, fence_list: &'input [Fence]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
275where
276    Conn: RequestConnection + ?Sized,
277{
278    let request0 = AwaitFenceRequest {
279        fence_list: Cow::Borrowed(fence_list),
280    };
281    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
282    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
283    assert_eq!(slices.len(), bytes.len());
284    conn.send_request_without_reply(&slices, fds).await
285}
286/// Extension trait defining the requests of this extension.
287pub trait ConnectionExt: RequestConnection {
288    fn sync_initialize(&self, desired_major_version: u8, desired_minor_version: u8) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, InitializeReply>, ConnectionError>> + Send + '_>>
289    {
290        Box::pin(initialize(self, desired_major_version, desired_minor_version))
291    }
292    fn sync_list_system_counters(&self) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, ListSystemCountersReply>, ConnectionError>> + Send + '_>>
293    {
294        Box::pin(list_system_counters(self))
295    }
296    fn sync_create_counter(&self, id: Counter, initial_value: Int64) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
297    {
298        Box::pin(create_counter(self, id, initial_value))
299    }
300    fn sync_destroy_counter(&self, counter: Counter) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
301    {
302        Box::pin(destroy_counter(self, counter))
303    }
304    fn sync_query_counter(&self, counter: Counter) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryCounterReply>, ConnectionError>> + Send + '_>>
305    {
306        Box::pin(query_counter(self, counter))
307    }
308    fn sync_await_<'c, 'input, 'future>(&'c self, wait_list: &'input [Waitcondition]) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
309    where
310        'c: 'future,
311        'input: 'future,
312    {
313        Box::pin(await_(self, wait_list))
314    }
315    fn sync_change_counter(&self, counter: Counter, amount: Int64) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
316    {
317        Box::pin(change_counter(self, counter, amount))
318    }
319    fn sync_set_counter(&self, counter: Counter, value: Int64) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
320    {
321        Box::pin(set_counter(self, counter, value))
322    }
323    fn sync_create_alarm<'c, 'input, 'future>(&'c self, id: Alarm, value_list: &'input CreateAlarmAux) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
324    where
325        'c: 'future,
326        'input: 'future,
327    {
328        Box::pin(create_alarm(self, id, value_list))
329    }
330    fn sync_change_alarm<'c, 'input, 'future>(&'c self, id: Alarm, value_list: &'input ChangeAlarmAux) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
331    where
332        'c: 'future,
333        'input: 'future,
334    {
335        Box::pin(change_alarm(self, id, value_list))
336    }
337    fn sync_destroy_alarm(&self, alarm: Alarm) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
338    {
339        Box::pin(destroy_alarm(self, alarm))
340    }
341    fn sync_query_alarm(&self, alarm: Alarm) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryAlarmReply>, ConnectionError>> + Send + '_>>
342    {
343        Box::pin(query_alarm(self, alarm))
344    }
345    fn sync_set_priority(&self, id: u32, priority: i32) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
346    {
347        Box::pin(set_priority(self, id, priority))
348    }
349    fn sync_get_priority(&self, id: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, GetPriorityReply>, ConnectionError>> + Send + '_>>
350    {
351        Box::pin(get_priority(self, id))
352    }
353    fn sync_create_fence(&self, drawable: xproto::Drawable, fence: Fence, initially_triggered: bool) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
354    {
355        Box::pin(create_fence(self, drawable, fence, initially_triggered))
356    }
357    fn sync_trigger_fence(&self, fence: Fence) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
358    {
359        Box::pin(trigger_fence(self, fence))
360    }
361    fn sync_reset_fence(&self, fence: Fence) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
362    {
363        Box::pin(reset_fence(self, fence))
364    }
365    fn sync_destroy_fence(&self, fence: Fence) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
366    {
367        Box::pin(destroy_fence(self, fence))
368    }
369    fn sync_query_fence(&self, fence: Fence) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryFenceReply>, ConnectionError>> + Send + '_>>
370    {
371        Box::pin(query_fence(self, fence))
372    }
373    fn sync_await_fence<'c, 'input, 'future>(&'c self, fence_list: &'input [Fence]) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
374    where
375        'c: 'future,
376        'input: 'future,
377    {
378        Box::pin(await_fence(self, fence_list))
379    }
380}
381
382impl<C: RequestConnection + ?Sized> ConnectionExt for C {}