x11rb_async/protocol/
xv.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Xv` 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::shm;
29#[allow(unused_imports)]
30use super::xproto;
31
32pub use x11rb_protocol::protocol::xv::*;
33
34/// Get the major opcode of this extension
35async fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
36    let info = conn.extension_information(X11_EXTENSION_NAME).await?;
37    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
38    Ok(info.major_opcode)
39}
40
41pub async fn query_extension<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryExtensionReply>, ConnectionError>
42where
43    Conn: RequestConnection + ?Sized,
44{
45    let request0 = QueryExtensionRequest;
46    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
47    let slices = [IoSlice::new(&bytes[0])];
48    assert_eq!(slices.len(), bytes.len());
49    conn.send_request_with_reply(&slices, fds).await
50}
51pub async fn query_adaptors<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, QueryAdaptorsReply>, ConnectionError>
52where
53    Conn: RequestConnection + ?Sized,
54{
55    let request0 = QueryAdaptorsRequest {
56        window,
57    };
58    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
59    let slices = [IoSlice::new(&bytes[0])];
60    assert_eq!(slices.len(), bytes.len());
61    conn.send_request_with_reply(&slices, fds).await
62}
63pub async fn query_encodings<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, QueryEncodingsReply>, ConnectionError>
64where
65    Conn: RequestConnection + ?Sized,
66{
67    let request0 = QueryEncodingsRequest {
68        port,
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_with_reply(&slices, fds).await
74}
75pub async fn grab_port<Conn, A>(conn: &Conn, port: Port, time: A) -> Result<Cookie<'_, Conn, GrabPortReply>, ConnectionError>
76where
77    Conn: RequestConnection + ?Sized,
78    A: Into<xproto::Timestamp> + Send,
79{
80    let time: xproto::Timestamp = time.into();
81    let request0 = GrabPortRequest {
82        port,
83        time,
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_with_reply(&slices, fds).await
89}
90pub async fn ungrab_port<Conn, A>(conn: &Conn, port: Port, time: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
91where
92    Conn: RequestConnection + ?Sized,
93    A: Into<xproto::Timestamp> + Send,
94{
95    let time: xproto::Timestamp = time.into();
96    let request0 = UngrabPortRequest {
97        port,
98        time,
99    };
100    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
101    let slices = [IoSlice::new(&bytes[0])];
102    assert_eq!(slices.len(), bytes.len());
103    conn.send_request_without_reply(&slices, fds).await
104}
105pub async fn put_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
106where
107    Conn: RequestConnection + ?Sized,
108{
109    let request0 = PutVideoRequest {
110        port,
111        drawable,
112        gc,
113        vid_x,
114        vid_y,
115        vid_w,
116        vid_h,
117        drw_x,
118        drw_y,
119        drw_w,
120        drw_h,
121    };
122    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
123    let slices = [IoSlice::new(&bytes[0])];
124    assert_eq!(slices.len(), bytes.len());
125    conn.send_request_without_reply(&slices, fds).await
126}
127pub async fn put_still<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
128where
129    Conn: RequestConnection + ?Sized,
130{
131    let request0 = PutStillRequest {
132        port,
133        drawable,
134        gc,
135        vid_x,
136        vid_y,
137        vid_w,
138        vid_h,
139        drw_x,
140        drw_y,
141        drw_w,
142        drw_h,
143    };
144    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
145    let slices = [IoSlice::new(&bytes[0])];
146    assert_eq!(slices.len(), bytes.len());
147    conn.send_request_without_reply(&slices, fds).await
148}
149pub async fn get_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
150where
151    Conn: RequestConnection + ?Sized,
152{
153    let request0 = GetVideoRequest {
154        port,
155        drawable,
156        gc,
157        vid_x,
158        vid_y,
159        vid_w,
160        vid_h,
161        drw_x,
162        drw_y,
163        drw_w,
164        drw_h,
165    };
166    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
167    let slices = [IoSlice::new(&bytes[0])];
168    assert_eq!(slices.len(), bytes.len());
169    conn.send_request_without_reply(&slices, fds).await
170}
171pub async fn get_still<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
172where
173    Conn: RequestConnection + ?Sized,
174{
175    let request0 = GetStillRequest {
176        port,
177        drawable,
178        gc,
179        vid_x,
180        vid_y,
181        vid_w,
182        vid_h,
183        drw_x,
184        drw_y,
185        drw_w,
186        drw_h,
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_without_reply(&slices, fds).await
192}
193pub async fn stop_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError>
194where
195    Conn: RequestConnection + ?Sized,
196{
197    let request0 = StopVideoRequest {
198        port,
199        drawable,
200    };
201    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
202    let slices = [IoSlice::new(&bytes[0])];
203    assert_eq!(slices.len(), bytes.len());
204    conn.send_request_without_reply(&slices, fds).await
205}
206pub async fn select_video_notify<Conn>(conn: &Conn, drawable: xproto::Drawable, onoff: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
207where
208    Conn: RequestConnection + ?Sized,
209{
210    let request0 = SelectVideoNotifyRequest {
211        drawable,
212        onoff,
213    };
214    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
215    let slices = [IoSlice::new(&bytes[0])];
216    assert_eq!(slices.len(), bytes.len());
217    conn.send_request_without_reply(&slices, fds).await
218}
219pub async fn select_port_notify<Conn>(conn: &Conn, port: Port, onoff: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
220where
221    Conn: RequestConnection + ?Sized,
222{
223    let request0 = SelectPortNotifyRequest {
224        port,
225        onoff,
226    };
227    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
228    let slices = [IoSlice::new(&bytes[0])];
229    assert_eq!(slices.len(), bytes.len());
230    conn.send_request_without_reply(&slices, fds).await
231}
232pub async fn query_best_size<Conn>(conn: &Conn, port: Port, vid_w: u16, vid_h: u16, drw_w: u16, drw_h: u16, motion: bool) -> Result<Cookie<'_, Conn, QueryBestSizeReply>, ConnectionError>
233where
234    Conn: RequestConnection + ?Sized,
235{
236    let request0 = QueryBestSizeRequest {
237        port,
238        vid_w,
239        vid_h,
240        drw_w,
241        drw_h,
242        motion,
243    };
244    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
245    let slices = [IoSlice::new(&bytes[0])];
246    assert_eq!(slices.len(), bytes.len());
247    conn.send_request_with_reply(&slices, fds).await
248}
249pub async fn set_port_attribute<Conn>(conn: &Conn, port: Port, attribute: xproto::Atom, value: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
250where
251    Conn: RequestConnection + ?Sized,
252{
253    let request0 = SetPortAttributeRequest {
254        port,
255        attribute,
256        value,
257    };
258    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
259    let slices = [IoSlice::new(&bytes[0])];
260    assert_eq!(slices.len(), bytes.len());
261    conn.send_request_without_reply(&slices, fds).await
262}
263pub async fn get_port_attribute<Conn>(conn: &Conn, port: Port, attribute: xproto::Atom) -> Result<Cookie<'_, Conn, GetPortAttributeReply>, ConnectionError>
264where
265    Conn: RequestConnection + ?Sized,
266{
267    let request0 = GetPortAttributeRequest {
268        port,
269        attribute,
270    };
271    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
272    let slices = [IoSlice::new(&bytes[0])];
273    assert_eq!(slices.len(), bytes.len());
274    conn.send_request_with_reply(&slices, fds).await
275}
276pub async fn query_port_attributes<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, QueryPortAttributesReply>, ConnectionError>
277where
278    Conn: RequestConnection + ?Sized,
279{
280    let request0 = QueryPortAttributesRequest {
281        port,
282    };
283    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
284    let slices = [IoSlice::new(&bytes[0])];
285    assert_eq!(slices.len(), bytes.len());
286    conn.send_request_with_reply(&slices, fds).await
287}
288pub async fn list_image_formats<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, ListImageFormatsReply>, ConnectionError>
289where
290    Conn: RequestConnection + ?Sized,
291{
292    let request0 = ListImageFormatsRequest {
293        port,
294    };
295    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
296    let slices = [IoSlice::new(&bytes[0])];
297    assert_eq!(slices.len(), bytes.len());
298    conn.send_request_with_reply(&slices, fds).await
299}
300pub async fn query_image_attributes<Conn>(conn: &Conn, port: Port, id: u32, width: u16, height: u16) -> Result<Cookie<'_, Conn, QueryImageAttributesReply>, ConnectionError>
301where
302    Conn: RequestConnection + ?Sized,
303{
304    let request0 = QueryImageAttributesRequest {
305        port,
306        id,
307        width,
308        height,
309    };
310    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
311    let slices = [IoSlice::new(&bytes[0])];
312    assert_eq!(slices.len(), bytes.len());
313    conn.send_request_with_reply(&slices, fds).await
314}
315pub async fn put_image<'c, 'input, Conn>(conn: &'c Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, id: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
316where
317    Conn: RequestConnection + ?Sized,
318{
319    let request0 = PutImageRequest {
320        port,
321        drawable,
322        gc,
323        id,
324        src_x,
325        src_y,
326        src_w,
327        src_h,
328        drw_x,
329        drw_y,
330        drw_w,
331        drw_h,
332        width,
333        height,
334        data: Cow::Borrowed(data),
335    };
336    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
337    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
338    assert_eq!(slices.len(), bytes.len());
339    conn.send_request_without_reply(&slices, fds).await
340}
341pub async fn shm_put_image<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, shmseg: shm::Seg, id: u32, offset: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, send_event: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError>
342where
343    Conn: RequestConnection + ?Sized,
344{
345    let request0 = ShmPutImageRequest {
346        port,
347        drawable,
348        gc,
349        shmseg,
350        id,
351        offset,
352        src_x,
353        src_y,
354        src_w,
355        src_h,
356        drw_x,
357        drw_y,
358        drw_w,
359        drw_h,
360        width,
361        height,
362        send_event,
363    };
364    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
365    let slices = [IoSlice::new(&bytes[0])];
366    assert_eq!(slices.len(), bytes.len());
367    conn.send_request_without_reply(&slices, fds).await
368}
369/// Extension trait defining the requests of this extension.
370pub trait ConnectionExt: RequestConnection {
371    fn xv_query_extension(&self) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryExtensionReply>, ConnectionError>> + Send + '_>>
372    {
373        Box::pin(query_extension(self))
374    }
375    fn xv_query_adaptors(&self, window: xproto::Window) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryAdaptorsReply>, ConnectionError>> + Send + '_>>
376    {
377        Box::pin(query_adaptors(self, window))
378    }
379    fn xv_query_encodings(&self, port: Port) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryEncodingsReply>, ConnectionError>> + Send + '_>>
380    {
381        Box::pin(query_encodings(self, port))
382    }
383    fn xv_grab_port<A>(&self, port: Port, time: A) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, GrabPortReply>, ConnectionError>> + Send + '_>>
384    where
385        A: Into<xproto::Timestamp> + Send + 'static,
386    {
387        Box::pin(grab_port(self, port, time))
388    }
389    fn xv_ungrab_port<A>(&self, port: Port, time: A) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
390    where
391        A: Into<xproto::Timestamp> + Send + 'static,
392    {
393        Box::pin(ungrab_port(self, port, time))
394    }
395    fn xv_put_video(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
396    {
397        Box::pin(put_video(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h))
398    }
399    fn xv_put_still(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
400    {
401        Box::pin(put_still(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h))
402    }
403    fn xv_get_video(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
404    {
405        Box::pin(get_video(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h))
406    }
407    fn xv_get_still(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
408    {
409        Box::pin(get_still(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h))
410    }
411    fn xv_stop_video(&self, port: Port, drawable: xproto::Drawable) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
412    {
413        Box::pin(stop_video(self, port, drawable))
414    }
415    fn xv_select_video_notify(&self, drawable: xproto::Drawable, onoff: bool) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
416    {
417        Box::pin(select_video_notify(self, drawable, onoff))
418    }
419    fn xv_select_port_notify(&self, port: Port, onoff: bool) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
420    {
421        Box::pin(select_port_notify(self, port, onoff))
422    }
423    fn xv_query_best_size(&self, port: Port, vid_w: u16, vid_h: u16, drw_w: u16, drw_h: u16, motion: bool) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryBestSizeReply>, ConnectionError>> + Send + '_>>
424    {
425        Box::pin(query_best_size(self, port, vid_w, vid_h, drw_w, drw_h, motion))
426    }
427    fn xv_set_port_attribute(&self, port: Port, attribute: xproto::Atom, value: i32) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
428    {
429        Box::pin(set_port_attribute(self, port, attribute, value))
430    }
431    fn xv_get_port_attribute(&self, port: Port, attribute: xproto::Atom) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, GetPortAttributeReply>, ConnectionError>> + Send + '_>>
432    {
433        Box::pin(get_port_attribute(self, port, attribute))
434    }
435    fn xv_query_port_attributes(&self, port: Port) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryPortAttributesReply>, ConnectionError>> + Send + '_>>
436    {
437        Box::pin(query_port_attributes(self, port))
438    }
439    fn xv_list_image_formats(&self, port: Port) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, ListImageFormatsReply>, ConnectionError>> + Send + '_>>
440    {
441        Box::pin(list_image_formats(self, port))
442    }
443    fn xv_query_image_attributes(&self, port: Port, id: u32, width: u16, height: u16) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryImageAttributesReply>, ConnectionError>> + Send + '_>>
444    {
445        Box::pin(query_image_attributes(self, port, id, width, height))
446    }
447    fn xv_put_image<'c, 'input, 'future>(&'c self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, id: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, data: &'input [u8]) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
448    where
449        'c: 'future,
450        'input: 'future,
451    {
452        Box::pin(put_image(self, port, drawable, gc, id, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, width, height, data))
453    }
454    fn xv_shm_put_image(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, shmseg: shm::Seg, id: u32, offset: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, send_event: u8) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
455    {
456        Box::pin(shm_put_image(self, port, drawable, gc, shmseg, id, offset, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, width, height, send_event))
457    }
458}
459
460impl<C: RequestConnection + ?Sized> ConnectionExt for C {}