| 1 | // This file contains generated code. Do not edit directly. |
| 2 | // To regenerate this, run 'make'. |
| 3 | |
| 4 | //! Bindings to the `BigRequests` 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::bigreq::*; |
| 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 | /// Enable the BIG-REQUESTS extension. |
| 36 | /// |
| 37 | /// This enables the BIG-REQUESTS extension, which allows for requests larger than |
| 38 | /// 262140 bytes in length. When enabled, if the 16-bit length field is zero, it |
| 39 | /// is immediately followed by a 32-bit length field specifying the length of the |
| 40 | /// request in 4-byte units. |
| 41 | pub fn enable<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, EnableReply>, ConnectionError> |
| 42 | where |
| 43 | Conn: RequestConnection + ?Sized, |
| 44 | { |
| 45 | let request0: EnableRequest = EnableRequest; |
| 46 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
| 47 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
| 48 | assert_eq!(slices.len(), bytes.len()); |
| 49 | conn.send_request_with_reply(&slices, fds) |
| 50 | } |
| 51 | |
| 52 | /// Extension trait defining the requests of this extension. |
| 53 | pub trait ConnectionExt: RequestConnection { |
| 54 | /// Enable the BIG-REQUESTS extension. |
| 55 | /// |
| 56 | /// This enables the BIG-REQUESTS extension, which allows for requests larger than |
| 57 | /// 262140 bytes in length. When enabled, if the 16-bit length field is zero, it |
| 58 | /// is immediately followed by a 32-bit length field specifying the length of the |
| 59 | /// request in 4-byte units. |
| 60 | fn bigreq_enable(&self) -> Result<Cookie<'_, Self, EnableReply>, ConnectionError> |
| 61 | { |
| 62 | enable(self) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | impl<C: RequestConnection + ?Sized> ConnectionExt for C {} |
| 67 | |