x11rb_async/protocol/
bigreq.rs

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)]
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
28pub use x11rb_protocol::protocol::bigreq::*;
29
30/// Get the major opcode of this extension
31async fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
32    let info = conn.extension_information(X11_EXTENSION_NAME).await?;
33    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
34    Ok(info.major_opcode)
35}
36
37/// Enable the BIG-REQUESTS extension.
38///
39/// This enables the BIG-REQUESTS extension, which allows for requests larger than
40/// 262140 bytes in length.  When enabled, if the 16-bit length field is zero, it
41/// is immediately followed by a 32-bit length field specifying the length of the
42/// request in 4-byte units.
43pub async fn enable<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, EnableReply>, ConnectionError>
44where
45    Conn: RequestConnection + ?Sized,
46{
47    let request0 = EnableRequest;
48    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
49    let slices = [IoSlice::new(&bytes[0])];
50    assert_eq!(slices.len(), bytes.len());
51    conn.send_request_with_reply(&slices, fds).await
52}
53/// Extension trait defining the requests of this extension.
54pub trait ConnectionExt: RequestConnection {
55    /// Enable the BIG-REQUESTS extension.
56    ///
57    /// This enables the BIG-REQUESTS extension, which allows for requests larger than
58    /// 262140 bytes in length.  When enabled, if the 16-bit length field is zero, it
59    /// is immediately followed by a 32-bit length field specifying the length of the
60    /// request in 4-byte units.
61    fn bigreq_enable(&self) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, EnableReply>, ConnectionError>> + Send + '_>>
62    {
63        Box::pin(enable(self))
64    }
65}
66
67impl<C: RequestConnection + ?Sized> ConnectionExt for C {}