x11rb_async/protocol/
screensaver.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `ScreenSaver` 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#[allow(unused_imports)]
28use super::xproto;
29
30pub use x11rb_protocol::protocol::screensaver::*;
31
32/// Get the major opcode of this extension
33async fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
34    let info = conn.extension_information(X11_EXTENSION_NAME).await?;
35    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
36    Ok(info.major_opcode)
37}
38
39pub async fn query_version<Conn>(conn: &Conn, client_major_version: u8, client_minor_version: u8) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
40where
41    Conn: RequestConnection + ?Sized,
42{
43    let request0 = QueryVersionRequest {
44        client_major_version,
45        client_minor_version,
46    };
47    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
48    let slices = [IoSlice::new(&bytes[0])];
49    assert_eq!(slices.len(), bytes.len());
50    conn.send_request_with_reply(&slices, fds).await
51}
52pub async fn query_info<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<Cookie<'_, Conn, QueryInfoReply>, ConnectionError>
53where
54    Conn: RequestConnection + ?Sized,
55{
56    let request0 = QueryInfoRequest {
57        drawable,
58    };
59    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
60    let slices = [IoSlice::new(&bytes[0])];
61    assert_eq!(slices.len(), bytes.len());
62    conn.send_request_with_reply(&slices, fds).await
63}
64pub async fn select_input<Conn>(conn: &Conn, drawable: xproto::Drawable, event_mask: Event) -> Result<VoidCookie<'_, Conn>, ConnectionError>
65where
66    Conn: RequestConnection + ?Sized,
67{
68    let request0 = SelectInputRequest {
69        drawable,
70        event_mask,
71    };
72    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
73    let slices = [IoSlice::new(&bytes[0])];
74    assert_eq!(slices.len(), bytes.len());
75    conn.send_request_without_reply(&slices, fds).await
76}
77pub async fn set_attributes<'c, 'input, Conn>(conn: &'c Conn, drawable: xproto::Drawable, x: i16, y: i16, width: u16, height: u16, border_width: u16, class: xproto::WindowClass, depth: u8, visual: xproto::Visualid, value_list: &'input SetAttributesAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
78where
79    Conn: RequestConnection + ?Sized,
80{
81    let request0 = SetAttributesRequest {
82        drawable,
83        x,
84        y,
85        width,
86        height,
87        border_width,
88        class,
89        depth,
90        visual,
91        value_list: Cow::Borrowed(value_list),
92    };
93    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
94    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
95    assert_eq!(slices.len(), bytes.len());
96    conn.send_request_without_reply(&slices, fds).await
97}
98pub async fn unset_attributes<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError>
99where
100    Conn: RequestConnection + ?Sized,
101{
102    let request0 = UnsetAttributesRequest {
103        drawable,
104    };
105    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
106    let slices = [IoSlice::new(&bytes[0])];
107    assert_eq!(slices.len(), bytes.len());
108    conn.send_request_without_reply(&slices, fds).await
109}
110pub async fn suspend<Conn>(conn: &Conn, suspend: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
111where
112    Conn: RequestConnection + ?Sized,
113{
114    let request0 = SuspendRequest {
115        suspend,
116    };
117    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
118    let slices = [IoSlice::new(&bytes[0])];
119    assert_eq!(slices.len(), bytes.len());
120    conn.send_request_without_reply(&slices, fds).await
121}
122/// Extension trait defining the requests of this extension.
123pub trait ConnectionExt: RequestConnection {
124    fn screensaver_query_version(&self, client_major_version: u8, client_minor_version: u8) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
125    {
126        Box::pin(query_version(self, client_major_version, client_minor_version))
127    }
128    fn screensaver_query_info(&self, drawable: xproto::Drawable) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryInfoReply>, ConnectionError>> + Send + '_>>
129    {
130        Box::pin(query_info(self, drawable))
131    }
132    fn screensaver_select_input(&self, drawable: xproto::Drawable, event_mask: Event) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
133    {
134        Box::pin(select_input(self, drawable, event_mask))
135    }
136    fn screensaver_set_attributes<'c, 'input, 'future>(&'c self, drawable: xproto::Drawable, x: i16, y: i16, width: u16, height: u16, border_width: u16, class: xproto::WindowClass, depth: u8, visual: xproto::Visualid, value_list: &'input SetAttributesAux) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
137    where
138        'c: 'future,
139        'input: 'future,
140    {
141        Box::pin(set_attributes(self, drawable, x, y, width, height, border_width, class, depth, visual, value_list))
142    }
143    fn screensaver_unset_attributes(&self, drawable: xproto::Drawable) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
144    {
145        Box::pin(unset_attributes(self, drawable))
146    }
147    fn screensaver_suspend(&self, suspend: u32) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
148    {
149        Box::pin(self::suspend(self, suspend))
150    }
151}
152
153impl<C: RequestConnection + ?Sized> ConnectionExt for C {}