1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `XCMisc` 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;
25
26pub use x11rb_protocol::protocol::xc_misc::*;
27
28/// Get the major opcode of this extension
29fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
30 let info: Option = conn.extension_information(X11_EXTENSION_NAME)?;
31 let info: ExtensionInformation = info.ok_or(err:ConnectionError::UnsupportedExtension)?;
32 Ok(info.major_opcode)
33}
34
35pub fn get_version<Conn>(conn: &Conn, client_major_version: u16, client_minor_version: u16) -> Result<Cookie<'_, Conn, GetVersionReply>, ConnectionError>
36where
37 Conn: RequestConnection + ?Sized,
38{
39 let request0: GetVersionRequest = GetVersionRequest {
40 client_major_version,
41 client_minor_version,
42 };
43 let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?);
44 let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])];
45 assert_eq!(slices.len(), bytes.len());
46 conn.send_request_with_reply(&slices, fds)
47}
48
49pub fn get_xid_range<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetXIDRangeReply>, ConnectionError>
50where
51 Conn: RequestConnection + ?Sized,
52{
53 let request0: GetXIDRangeRequest = GetXIDRangeRequest;
54 let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?);
55 let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])];
56 assert_eq!(slices.len(), bytes.len());
57 conn.send_request_with_reply(&slices, fds)
58}
59
60pub fn get_xid_list<Conn>(conn: &Conn, count: u32) -> Result<Cookie<'_, Conn, GetXIDListReply>, ConnectionError>
61where
62 Conn: RequestConnection + ?Sized,
63{
64 let request0: GetXIDListRequest = GetXIDListRequest {
65 count,
66 };
67 let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?);
68 let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])];
69 assert_eq!(slices.len(), bytes.len());
70 conn.send_request_with_reply(&slices, fds)
71}
72
73/// Extension trait defining the requests of this extension.
74pub trait ConnectionExt: RequestConnection {
75 fn xc_misc_get_version(&self, client_major_version: u16, client_minor_version: u16) -> Result<Cookie<'_, Self, GetVersionReply>, ConnectionError>
76 {
77 get_version(self, client_major_version, client_minor_version)
78 }
79 fn xc_misc_get_xid_range(&self) -> Result<Cookie<'_, Self, GetXIDRangeReply>, ConnectionError>
80 {
81 get_xid_range(self)
82 }
83 fn xc_misc_get_xid_list(&self, count: u32) -> Result<Cookie<'_, Self, GetXIDListReply>, ConnectionError>
84 {
85 get_xid_list(self, count)
86 }
87}
88
89impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
90