x11rb_async/protocol/
dri2.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `DRI2` 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::dri2::*;
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 query_version<Conn>(conn: &Conn, major_version: u32, minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
40where
41    Conn: RequestConnection + ?Sized,
42{
43    let request0 = QueryVersionRequest {
44        major_version,
45        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 connect<Conn>(conn: &Conn, window: xproto::Window, driver_type: DriverType) -> Result<Cookie<'_, Conn, ConnectReply>, ConnectionError>
53where
54    Conn: RequestConnection + ?Sized,
55{
56    let request0 = ConnectRequest {
57        window,
58        driver_type,
59    };
60    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
61    let slices = [IoSlice::new(&bytes[0])];
62    assert_eq!(slices.len(), bytes.len());
63    conn.send_request_with_reply(&slices, fds).await
64}
65pub async fn authenticate<Conn>(conn: &Conn, window: xproto::Window, magic: u32) -> Result<Cookie<'_, Conn, AuthenticateReply>, ConnectionError>
66where
67    Conn: RequestConnection + ?Sized,
68{
69    let request0 = AuthenticateRequest {
70        window,
71        magic,
72    };
73    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
74    let slices = [IoSlice::new(&bytes[0])];
75    assert_eq!(slices.len(), bytes.len());
76    conn.send_request_with_reply(&slices, fds).await
77}
78pub async fn create_drawable<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError>
79where
80    Conn: RequestConnection + ?Sized,
81{
82    let request0 = CreateDrawableRequest {
83        drawable,
84    };
85    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
86    let slices = [IoSlice::new(&bytes[0])];
87    assert_eq!(slices.len(), bytes.len());
88    conn.send_request_without_reply(&slices, fds).await
89}
90pub async fn destroy_drawable<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError>
91where
92    Conn: RequestConnection + ?Sized,
93{
94    let request0 = DestroyDrawableRequest {
95        drawable,
96    };
97    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
98    let slices = [IoSlice::new(&bytes[0])];
99    assert_eq!(slices.len(), bytes.len());
100    conn.send_request_without_reply(&slices, fds).await
101}
102pub async fn get_buffers<'c, 'input, Conn>(conn: &'c Conn, drawable: xproto::Drawable, count: u32, attachments: &'input [u32]) -> Result<Cookie<'c, Conn, GetBuffersReply>, ConnectionError>
103where
104    Conn: RequestConnection + ?Sized,
105{
106    let request0 = GetBuffersRequest {
107        drawable,
108        count,
109        attachments: Cow::Borrowed(attachments),
110    };
111    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
112    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
113    assert_eq!(slices.len(), bytes.len());
114    conn.send_request_with_reply(&slices, fds).await
115}
116pub async fn copy_region<Conn>(conn: &Conn, drawable: xproto::Drawable, region: u32, dest: u32, src: u32) -> Result<Cookie<'_, Conn, CopyRegionReply>, ConnectionError>
117where
118    Conn: RequestConnection + ?Sized,
119{
120    let request0 = CopyRegionRequest {
121        drawable,
122        region,
123        dest,
124        src,
125    };
126    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
127    let slices = [IoSlice::new(&bytes[0])];
128    assert_eq!(slices.len(), bytes.len());
129    conn.send_request_with_reply(&slices, fds).await
130}
131pub async fn get_buffers_with_format<'c, 'input, Conn>(conn: &'c Conn, drawable: xproto::Drawable, count: u32, attachments: &'input [AttachFormat]) -> Result<Cookie<'c, Conn, GetBuffersWithFormatReply>, ConnectionError>
132where
133    Conn: RequestConnection + ?Sized,
134{
135    let request0 = GetBuffersWithFormatRequest {
136        drawable,
137        count,
138        attachments: Cow::Borrowed(attachments),
139    };
140    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
141    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
142    assert_eq!(slices.len(), bytes.len());
143    conn.send_request_with_reply(&slices, fds).await
144}
145pub async fn swap_buffers<Conn>(conn: &Conn, drawable: xproto::Drawable, target_msc_hi: u32, target_msc_lo: u32, divisor_hi: u32, divisor_lo: u32, remainder_hi: u32, remainder_lo: u32) -> Result<Cookie<'_, Conn, SwapBuffersReply>, ConnectionError>
146where
147    Conn: RequestConnection + ?Sized,
148{
149    let request0 = SwapBuffersRequest {
150        drawable,
151        target_msc_hi,
152        target_msc_lo,
153        divisor_hi,
154        divisor_lo,
155        remainder_hi,
156        remainder_lo,
157    };
158    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
159    let slices = [IoSlice::new(&bytes[0])];
160    assert_eq!(slices.len(), bytes.len());
161    conn.send_request_with_reply(&slices, fds).await
162}
163pub async fn get_msc<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<Cookie<'_, Conn, GetMSCReply>, ConnectionError>
164where
165    Conn: RequestConnection + ?Sized,
166{
167    let request0 = GetMSCRequest {
168        drawable,
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_with_reply(&slices, fds).await
174}
175pub async fn wait_msc<Conn>(conn: &Conn, drawable: xproto::Drawable, target_msc_hi: u32, target_msc_lo: u32, divisor_hi: u32, divisor_lo: u32, remainder_hi: u32, remainder_lo: u32) -> Result<Cookie<'_, Conn, WaitMSCReply>, ConnectionError>
176where
177    Conn: RequestConnection + ?Sized,
178{
179    let request0 = WaitMSCRequest {
180        drawable,
181        target_msc_hi,
182        target_msc_lo,
183        divisor_hi,
184        divisor_lo,
185        remainder_hi,
186        remainder_lo,
187    };
188    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
189    let slices = [IoSlice::new(&bytes[0])];
190    assert_eq!(slices.len(), bytes.len());
191    conn.send_request_with_reply(&slices, fds).await
192}
193pub async fn wait_sbc<Conn>(conn: &Conn, drawable: xproto::Drawable, target_sbc_hi: u32, target_sbc_lo: u32) -> Result<Cookie<'_, Conn, WaitSBCReply>, ConnectionError>
194where
195    Conn: RequestConnection + ?Sized,
196{
197    let request0 = WaitSBCRequest {
198        drawable,
199        target_sbc_hi,
200        target_sbc_lo,
201    };
202    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
203    let slices = [IoSlice::new(&bytes[0])];
204    assert_eq!(slices.len(), bytes.len());
205    conn.send_request_with_reply(&slices, fds).await
206}
207pub async fn swap_interval<Conn>(conn: &Conn, drawable: xproto::Drawable, interval: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
208where
209    Conn: RequestConnection + ?Sized,
210{
211    let request0 = SwapIntervalRequest {
212        drawable,
213        interval,
214    };
215    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
216    let slices = [IoSlice::new(&bytes[0])];
217    assert_eq!(slices.len(), bytes.len());
218    conn.send_request_without_reply(&slices, fds).await
219}
220pub async fn get_param<Conn>(conn: &Conn, drawable: xproto::Drawable, param: u32) -> Result<Cookie<'_, Conn, GetParamReply>, ConnectionError>
221where
222    Conn: RequestConnection + ?Sized,
223{
224    let request0 = GetParamRequest {
225        drawable,
226        param,
227    };
228    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
229    let slices = [IoSlice::new(&bytes[0])];
230    assert_eq!(slices.len(), bytes.len());
231    conn.send_request_with_reply(&slices, fds).await
232}
233/// Extension trait defining the requests of this extension.
234pub trait ConnectionExt: RequestConnection {
235    fn dri2_query_version(&self, major_version: u32, minor_version: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
236    {
237        Box::pin(query_version(self, major_version, minor_version))
238    }
239    fn dri2_connect(&self, window: xproto::Window, driver_type: DriverType) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, ConnectReply>, ConnectionError>> + Send + '_>>
240    {
241        Box::pin(connect(self, window, driver_type))
242    }
243    fn dri2_authenticate(&self, window: xproto::Window, magic: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, AuthenticateReply>, ConnectionError>> + Send + '_>>
244    {
245        Box::pin(authenticate(self, window, magic))
246    }
247    fn dri2_create_drawable(&self, drawable: xproto::Drawable) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
248    {
249        Box::pin(create_drawable(self, drawable))
250    }
251    fn dri2_destroy_drawable(&self, drawable: xproto::Drawable) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
252    {
253        Box::pin(destroy_drawable(self, drawable))
254    }
255    fn dri2_get_buffers<'c, 'input, 'future>(&'c self, drawable: xproto::Drawable, count: u32, attachments: &'input [u32]) -> Pin<Box<dyn Future<Output = Result<Cookie<'c, Self, GetBuffersReply>, ConnectionError>> + Send + 'future>>
256    where
257        'c: 'future,
258        'input: 'future,
259    {
260        Box::pin(get_buffers(self, drawable, count, attachments))
261    }
262    fn dri2_copy_region(&self, drawable: xproto::Drawable, region: u32, dest: u32, src: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, CopyRegionReply>, ConnectionError>> + Send + '_>>
263    {
264        Box::pin(copy_region(self, drawable, region, dest, src))
265    }
266    fn dri2_get_buffers_with_format<'c, 'input, 'future>(&'c self, drawable: xproto::Drawable, count: u32, attachments: &'input [AttachFormat]) -> Pin<Box<dyn Future<Output = Result<Cookie<'c, Self, GetBuffersWithFormatReply>, ConnectionError>> + Send + 'future>>
267    where
268        'c: 'future,
269        'input: 'future,
270    {
271        Box::pin(get_buffers_with_format(self, drawable, count, attachments))
272    }
273    fn dri2_swap_buffers(&self, drawable: xproto::Drawable, target_msc_hi: u32, target_msc_lo: u32, divisor_hi: u32, divisor_lo: u32, remainder_hi: u32, remainder_lo: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, SwapBuffersReply>, ConnectionError>> + Send + '_>>
274    {
275        Box::pin(swap_buffers(self, drawable, target_msc_hi, target_msc_lo, divisor_hi, divisor_lo, remainder_hi, remainder_lo))
276    }
277    fn dri2_get_msc(&self, drawable: xproto::Drawable) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, GetMSCReply>, ConnectionError>> + Send + '_>>
278    {
279        Box::pin(get_msc(self, drawable))
280    }
281    fn dri2_wait_msc(&self, drawable: xproto::Drawable, target_msc_hi: u32, target_msc_lo: u32, divisor_hi: u32, divisor_lo: u32, remainder_hi: u32, remainder_lo: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, WaitMSCReply>, ConnectionError>> + Send + '_>>
282    {
283        Box::pin(wait_msc(self, drawable, target_msc_hi, target_msc_lo, divisor_hi, divisor_lo, remainder_hi, remainder_lo))
284    }
285    fn dri2_wait_sbc(&self, drawable: xproto::Drawable, target_sbc_hi: u32, target_sbc_lo: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, WaitSBCReply>, ConnectionError>> + Send + '_>>
286    {
287        Box::pin(wait_sbc(self, drawable, target_sbc_hi, target_sbc_lo))
288    }
289    fn dri2_swap_interval(&self, drawable: xproto::Drawable, interval: u32) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
290    {
291        Box::pin(swap_interval(self, drawable, interval))
292    }
293    fn dri2_get_param(&self, drawable: xproto::Drawable, param: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, GetParamReply>, ConnectionError>> + Send + '_>>
294    {
295        Box::pin(get_param(self, drawable, param))
296    }
297}
298
299impl<C: RequestConnection + ?Sized> ConnectionExt for C {}