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)] |
9 | use std::borrow::Cow; |
10 | #[allow (unused_imports)] |
11 | use std::convert::TryInto; |
12 | #[allow (unused_imports)] |
13 | use crate::utils::RawFdContainer; |
14 | #[allow (unused_imports)] |
15 | use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; |
16 | use std::io::IoSlice; |
17 | use crate::connection::RequestConnection; |
18 | #[allow (unused_imports)] |
19 | use crate::connection::Connection as X11Connection; |
20 | #[allow (unused_imports)] |
21 | use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; |
22 | use crate::errors::ConnectionError; |
23 | #[allow (unused_imports)] |
24 | use crate::errors::ReplyOrIdError; |
25 | |
26 | pub use x11rb_protocol::protocol::xc_misc::*; |
27 | |
28 | /// Get the major opcode of this extension |
29 | fn 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 | |
35 | pub fn get_version<Conn>(conn: &Conn, client_major_version: u16, client_minor_version: u16) -> Result<Cookie<'_, Conn, GetVersionReply>, ConnectionError> |
36 | where |
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 | |
49 | pub fn get_xid_range<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetXIDRangeReply>, ConnectionError> |
50 | where |
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 | |
60 | pub fn get_xid_list<Conn>(conn: &Conn, count: u32) -> Result<Cookie<'_, Conn, GetXIDListReply>, ConnectionError> |
61 | where |
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. |
74 | pub 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 | |
89 | impl<C: RequestConnection + ?Sized> ConnectionExt for C {} |
90 | |