x11rb_async/protocol/
xvmc.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `XvMC` 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::xv;
29
30pub use x11rb_protocol::protocol::xvmc::*;
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 list_surface_types<Conn>(conn: &Conn, port_id: xv::Port) -> Result<Cookie<'_, Conn, ListSurfaceTypesReply>, ConnectionError>
50where
51    Conn: RequestConnection + ?Sized,
52{
53    let request0 = ListSurfaceTypesRequest {
54        port_id,
55    };
56    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
57    let slices = [IoSlice::new(&bytes[0])];
58    assert_eq!(slices.len(), bytes.len());
59    conn.send_request_with_reply(&slices, fds).await
60}
61pub async fn create_context<Conn>(conn: &Conn, context_id: Context, port_id: xv::Port, surface_id: Surface, width: u16, height: u16, flags: u32) -> Result<Cookie<'_, Conn, CreateContextReply>, ConnectionError>
62where
63    Conn: RequestConnection + ?Sized,
64{
65    let request0 = CreateContextRequest {
66        context_id,
67        port_id,
68        surface_id,
69        width,
70        height,
71        flags,
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 destroy_context<Conn>(conn: &Conn, context_id: Context) -> Result<VoidCookie<'_, Conn>, ConnectionError>
79where
80    Conn: RequestConnection + ?Sized,
81{
82    let request0 = DestroyContextRequest {
83        context_id,
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 create_surface<Conn>(conn: &Conn, surface_id: Surface, context_id: Context) -> Result<Cookie<'_, Conn, CreateSurfaceReply>, ConnectionError>
91where
92    Conn: RequestConnection + ?Sized,
93{
94    let request0 = CreateSurfaceRequest {
95        surface_id,
96        context_id,
97    };
98    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
99    let slices = [IoSlice::new(&bytes[0])];
100    assert_eq!(slices.len(), bytes.len());
101    conn.send_request_with_reply(&slices, fds).await
102}
103pub async fn destroy_surface<Conn>(conn: &Conn, surface_id: Surface) -> Result<VoidCookie<'_, Conn>, ConnectionError>
104where
105    Conn: RequestConnection + ?Sized,
106{
107    let request0 = DestroySurfaceRequest {
108        surface_id,
109    };
110    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
111    let slices = [IoSlice::new(&bytes[0])];
112    assert_eq!(slices.len(), bytes.len());
113    conn.send_request_without_reply(&slices, fds).await
114}
115pub async fn create_subpicture<Conn>(conn: &Conn, subpicture_id: Subpicture, context: Context, xvimage_id: u32, width: u16, height: u16) -> Result<Cookie<'_, Conn, CreateSubpictureReply>, ConnectionError>
116where
117    Conn: RequestConnection + ?Sized,
118{
119    let request0 = CreateSubpictureRequest {
120        subpicture_id,
121        context,
122        xvimage_id,
123        width,
124        height,
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 destroy_subpicture<Conn>(conn: &Conn, subpicture_id: Subpicture) -> Result<VoidCookie<'_, Conn>, ConnectionError>
132where
133    Conn: RequestConnection + ?Sized,
134{
135    let request0 = DestroySubpictureRequest {
136        subpicture_id,
137    };
138    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
139    let slices = [IoSlice::new(&bytes[0])];
140    assert_eq!(slices.len(), bytes.len());
141    conn.send_request_without_reply(&slices, fds).await
142}
143pub async fn list_subpicture_types<Conn>(conn: &Conn, port_id: xv::Port, surface_id: Surface) -> Result<Cookie<'_, Conn, ListSubpictureTypesReply>, ConnectionError>
144where
145    Conn: RequestConnection + ?Sized,
146{
147    let request0 = ListSubpictureTypesRequest {
148        port_id,
149        surface_id,
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}
156/// Extension trait defining the requests of this extension.
157pub trait ConnectionExt: RequestConnection {
158    fn xvmc_query_version(&self) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
159    {
160        Box::pin(query_version(self))
161    }
162    fn xvmc_list_surface_types(&self, port_id: xv::Port) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, ListSurfaceTypesReply>, ConnectionError>> + Send + '_>>
163    {
164        Box::pin(list_surface_types(self, port_id))
165    }
166    fn xvmc_create_context(&self, context_id: Context, port_id: xv::Port, surface_id: Surface, width: u16, height: u16, flags: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, CreateContextReply>, ConnectionError>> + Send + '_>>
167    {
168        Box::pin(create_context(self, context_id, port_id, surface_id, width, height, flags))
169    }
170    fn xvmc_destroy_context(&self, context_id: Context) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
171    {
172        Box::pin(destroy_context(self, context_id))
173    }
174    fn xvmc_create_surface(&self, surface_id: Surface, context_id: Context) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, CreateSurfaceReply>, ConnectionError>> + Send + '_>>
175    {
176        Box::pin(create_surface(self, surface_id, context_id))
177    }
178    fn xvmc_destroy_surface(&self, surface_id: Surface) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
179    {
180        Box::pin(destroy_surface(self, surface_id))
181    }
182    fn xvmc_create_subpicture(&self, subpicture_id: Subpicture, context: Context, xvimage_id: u32, width: u16, height: u16) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, CreateSubpictureReply>, ConnectionError>> + Send + '_>>
183    {
184        Box::pin(create_subpicture(self, subpicture_id, context, xvimage_id, width, height))
185    }
186    fn xvmc_destroy_subpicture(&self, subpicture_id: Subpicture) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
187    {
188        Box::pin(destroy_subpicture(self, subpicture_id))
189    }
190    fn xvmc_list_subpicture_types(&self, port_id: xv::Port, surface_id: Surface) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, ListSubpictureTypesReply>, ConnectionError>> + Send + '_>>
191    {
192        Box::pin(list_subpicture_types(self, port_id, surface_id))
193    }
194}
195
196impl<C: RequestConnection + ?Sized> ConnectionExt for C {}