x11rb_async/protocol/
shape.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Shape` 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::shape::*;
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) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
40where
41    Conn: RequestConnection + ?Sized,
42{
43    let request0 = QueryVersionRequest;
44    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
45    let slices = [IoSlice::new(&bytes[0])];
46    assert_eq!(slices.len(), bytes.len());
47    conn.send_request_with_reply(&slices, fds).await
48}
49pub async fn rectangles<'c, 'input, Conn>(conn: &'c Conn, operation: SO, destination_kind: SK, ordering: xproto::ClipOrdering, destination_window: xproto::Window, x_offset: i16, y_offset: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
50where
51    Conn: RequestConnection + ?Sized,
52{
53    let request0 = RectanglesRequest {
54        operation,
55        destination_kind,
56        ordering,
57        destination_window,
58        x_offset,
59        y_offset,
60        rectangles: Cow::Borrowed(rectangles),
61    };
62    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
63    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
64    assert_eq!(slices.len(), bytes.len());
65    conn.send_request_without_reply(&slices, fds).await
66}
67pub async fn mask<Conn, A>(conn: &Conn, operation: SO, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_bitmap: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
68where
69    Conn: RequestConnection + ?Sized,
70    A: Into<xproto::Pixmap> + Send,
71{
72    let source_bitmap: xproto::Pixmap = source_bitmap.into();
73    let request0 = MaskRequest {
74        operation,
75        destination_kind,
76        destination_window,
77        x_offset,
78        y_offset,
79        source_bitmap,
80    };
81    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
82    let slices = [IoSlice::new(&bytes[0])];
83    assert_eq!(slices.len(), bytes.len());
84    conn.send_request_without_reply(&slices, fds).await
85}
86pub async fn combine<Conn>(conn: &Conn, operation: SO, destination_kind: SK, source_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
87where
88    Conn: RequestConnection + ?Sized,
89{
90    let request0 = CombineRequest {
91        operation,
92        destination_kind,
93        source_kind,
94        destination_window,
95        x_offset,
96        y_offset,
97        source_window,
98    };
99    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
100    let slices = [IoSlice::new(&bytes[0])];
101    assert_eq!(slices.len(), bytes.len());
102    conn.send_request_without_reply(&slices, fds).await
103}
104pub async fn offset<Conn>(conn: &Conn, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
105where
106    Conn: RequestConnection + ?Sized,
107{
108    let request0 = OffsetRequest {
109        destination_kind,
110        destination_window,
111        x_offset,
112        y_offset,
113    };
114    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
115    let slices = [IoSlice::new(&bytes[0])];
116    assert_eq!(slices.len(), bytes.len());
117    conn.send_request_without_reply(&slices, fds).await
118}
119pub async fn query_extents<Conn>(conn: &Conn, destination_window: xproto::Window) -> Result<Cookie<'_, Conn, QueryExtentsReply>, ConnectionError>
120where
121    Conn: RequestConnection + ?Sized,
122{
123    let request0 = QueryExtentsRequest {
124        destination_window,
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 select_input<Conn>(conn: &Conn, destination_window: xproto::Window, enable: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
132where
133    Conn: RequestConnection + ?Sized,
134{
135    let request0 = SelectInputRequest {
136        destination_window,
137        enable,
138    };
139    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
140    let slices = [IoSlice::new(&bytes[0])];
141    assert_eq!(slices.len(), bytes.len());
142    conn.send_request_without_reply(&slices, fds).await
143}
144pub async fn input_selected<Conn>(conn: &Conn, destination_window: xproto::Window) -> Result<Cookie<'_, Conn, InputSelectedReply>, ConnectionError>
145where
146    Conn: RequestConnection + ?Sized,
147{
148    let request0 = InputSelectedRequest {
149        destination_window,
150    };
151    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
152    let slices = [IoSlice::new(&bytes[0])];
153    assert_eq!(slices.len(), bytes.len());
154    conn.send_request_with_reply(&slices, fds).await
155}
156pub async fn get_rectangles<Conn>(conn: &Conn, window: xproto::Window, source_kind: SK) -> Result<Cookie<'_, Conn, GetRectanglesReply>, ConnectionError>
157where
158    Conn: RequestConnection + ?Sized,
159{
160    let request0 = GetRectanglesRequest {
161        window,
162        source_kind,
163    };
164    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
165    let slices = [IoSlice::new(&bytes[0])];
166    assert_eq!(slices.len(), bytes.len());
167    conn.send_request_with_reply(&slices, fds).await
168}
169/// Extension trait defining the requests of this extension.
170pub trait ConnectionExt: RequestConnection {
171    fn shape_query_version(&self) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
172    {
173        Box::pin(query_version(self))
174    }
175    fn shape_rectangles<'c, 'input, 'future>(&'c self, operation: SO, destination_kind: SK, ordering: xproto::ClipOrdering, destination_window: xproto::Window, x_offset: i16, y_offset: i16, rectangles: &'input [xproto::Rectangle]) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
176    where
177        'c: 'future,
178        'input: 'future,
179    {
180        Box::pin(self::rectangles(self, operation, destination_kind, ordering, destination_window, x_offset, y_offset, rectangles))
181    }
182    fn shape_mask<A>(&self, operation: SO, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_bitmap: A) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
183    where
184        A: Into<xproto::Pixmap> + Send + 'static,
185    {
186        Box::pin(mask(self, operation, destination_kind, destination_window, x_offset, y_offset, source_bitmap))
187    }
188    fn shape_combine(&self, operation: SO, destination_kind: SK, source_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_window: xproto::Window) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
189    {
190        Box::pin(combine(self, operation, destination_kind, source_kind, destination_window, x_offset, y_offset, source_window))
191    }
192    fn shape_offset(&self, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
193    {
194        Box::pin(offset(self, destination_kind, destination_window, x_offset, y_offset))
195    }
196    fn shape_query_extents(&self, destination_window: xproto::Window) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryExtentsReply>, ConnectionError>> + Send + '_>>
197    {
198        Box::pin(query_extents(self, destination_window))
199    }
200    fn shape_select_input(&self, destination_window: xproto::Window, enable: bool) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
201    {
202        Box::pin(select_input(self, destination_window, enable))
203    }
204    fn shape_input_selected(&self, destination_window: xproto::Window) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, InputSelectedReply>, ConnectionError>> + Send + '_>>
205    {
206        Box::pin(input_selected(self, destination_window))
207    }
208    fn shape_get_rectangles(&self, window: xproto::Window, source_kind: SK) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, GetRectanglesReply>, ConnectionError>> + Send + '_>>
209    {
210        Box::pin(get_rectangles(self, window, source_kind))
211    }
212}
213
214impl<C: RequestConnection + ?Sized> ConnectionExt for C {}