1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
34//! Bindings to the `BigRequests` X11 extension.
56#![allow(clippy::too_many_arguments)]
78#[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;
2526pub use x11rb_protocol::protocol::bigreq::*;
2728/// Get the major opcode of this extension
29fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
30let info = conn.extension_information(X11_EXTENSION_NAME)?;
31let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
32Ok(info.major_opcode)
33}
3435/// 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.
41pub fn enable<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, EnableReply>, ConnectionError>
42where
43Conn: RequestConnection + ?Sized,
44{
45let request0 = EnableRequest;
46let (bytes, fds) = request0.serialize(major_opcode(conn)?);
47let slices = [IoSlice::new(&bytes[0])];
48assert_eq!(slices.len(), bytes.len());
49 conn.send_request_with_reply(&slices, fds)
50}
5152/// Extension trait defining the requests of this extension.
53pub 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.
60fn bigreq_enable(&self) -> Result<Cookie<'_, Self, EnableReply>, ConnectionError>
61 {
62 enable(self)
63 }
64}
6566impl<C: RequestConnection + ?Sized> ConnectionExt for C {}