1 // This file contains generated code. Do not edit directly.
2 // To regenerate this, run 'make'.
3 
4 //! Bindings to the `SELinux` X11 extension.
5 
6 #![allow(clippy::too_many_arguments)]
7 
8 #[allow(unused_imports)]
9 use std::borrow::Cow;
10 use std::convert::TryFrom;
11 #[allow(unused_imports)]
12 use std::convert::TryInto;
13 use std::io::IoSlice;
14 #[allow(unused_imports)]
15 use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum};
16 #[allow(unused_imports)]
17 use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize};
18 use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection};
19 #[allow(unused_imports)]
20 use crate::cookie::{Cookie, CookieWithFds, VoidCookie};
21 use crate::errors::{ConnectionError, ParseError};
22 use super::xproto;
23 
24 /// The X11 name of the extension for QueryExtension
25 pub const X11_EXTENSION_NAME: &str = "SELinux";
26 
27 /// The version number of this extension that this client library supports.
28 ///
29 /// This constant contains the version number of this extension that is supported
30 /// by this build of x11rb. For most things, it does not make sense to use this
31 /// information. If you need to send a `QueryVersion`, it is recommended to instead
32 /// send the maximum version of the extension that you need.
33 pub const X11_XML_VERSION: (u32, u32) = (1, 0);
34 
35 /// Opcode for the QueryVersion request
36 pub const QUERY_VERSION_REQUEST: u8 = 0;
37 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
38 pub struct QueryVersionRequest {
39     pub client_major: u8,
40     pub client_minor: u8,
41 }
42 impl QueryVersionRequest {
43     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,44     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
45     where
46         Conn: RequestConnection + ?Sized,
47     {
48         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
49             .ok_or(ConnectionError::UnsupportedExtension)?;
50         let length_so_far = 0;
51         let client_major_bytes = self.client_major.serialize();
52         let client_minor_bytes = self.client_minor.serialize();
53         let mut request0 = vec![
54             extension_information.major_opcode,
55             QUERY_VERSION_REQUEST,
56             0,
57             0,
58             client_major_bytes[0],
59             client_minor_bytes[0],
60             0,
61             0,
62         ];
63         let length_so_far = length_so_far + request0.len();
64         assert_eq!(length_so_far % 4, 0);
65         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
66         request0[2..4].copy_from_slice(&length.to_ne_bytes());
67         Ok((vec![request0.into()], vec![]))
68     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,69     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
70     where
71         Conn: RequestConnection + ?Sized,
72     {
73         let (bytes, fds) = self.serialize(conn)?;
74         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
75         conn.send_request_with_reply(&slices, fds)
76     }
77     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>78     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
79         if header.minor_opcode != QUERY_VERSION_REQUEST {
80             return Err(ParseError::InvalidValue);
81         }
82         let (client_major, remaining) = u8::try_parse(value)?;
83         let (client_minor, remaining) = u8::try_parse(remaining)?;
84         let _ = remaining;
85         Ok(QueryVersionRequest {
86             client_major,
87             client_minor,
88         })
89     }
90 }
91 impl Request for QueryVersionRequest {
92     type Reply = QueryVersionReply;
93 }
query_version<Conn>(conn: &Conn, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,94 pub fn query_version<Conn>(conn: &Conn, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
95 where
96     Conn: RequestConnection + ?Sized,
97 {
98     let request0 = QueryVersionRequest {
99         client_major,
100         client_minor,
101     };
102     request0.send(conn)
103 }
104 
105 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
106 pub struct QueryVersionReply {
107     pub sequence: u16,
108     pub length: u32,
109     pub server_major: u16,
110     pub server_minor: u16,
111 }
112 impl TryParse for QueryVersionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>113     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
114         let remaining = initial_value;
115         let (response_type, remaining) = u8::try_parse(remaining)?;
116         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
117         let (sequence, remaining) = u16::try_parse(remaining)?;
118         let (length, remaining) = u32::try_parse(remaining)?;
119         let (server_major, remaining) = u16::try_parse(remaining)?;
120         let (server_minor, remaining) = u16::try_parse(remaining)?;
121         if response_type != 1 {
122             return Err(ParseError::InvalidValue);
123         }
124         let result = QueryVersionReply { sequence, length, server_major, server_minor };
125         let _ = remaining;
126         let remaining = initial_value.get(32 + length as usize * 4..)
127             .ok_or(ParseError::InsufficientData)?;
128         Ok((result, remaining))
129     }
130 }
131 
132 /// Opcode for the SetDeviceCreateContext request
133 pub const SET_DEVICE_CREATE_CONTEXT_REQUEST: u8 = 1;
134 #[derive(Debug, Clone, PartialEq, Eq)]
135 pub struct SetDeviceCreateContextRequest<'input> {
136     pub context: Cow<'input, [u8]>,
137 }
138 impl<'input> SetDeviceCreateContextRequest<'input> {
139     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,140     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
141     where
142         Conn: RequestConnection + ?Sized,
143     {
144         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
145             .ok_or(ConnectionError::UnsupportedExtension)?;
146         let length_so_far = 0;
147         let context_len = u32::try_from(self.context.len()).expect("`context` has too many elements");
148         let context_len_bytes = context_len.serialize();
149         let mut request0 = vec![
150             extension_information.major_opcode,
151             SET_DEVICE_CREATE_CONTEXT_REQUEST,
152             0,
153             0,
154             context_len_bytes[0],
155             context_len_bytes[1],
156             context_len_bytes[2],
157             context_len_bytes[3],
158         ];
159         let length_so_far = length_so_far + request0.len();
160         let length_so_far = length_so_far + self.context.len();
161         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
162         let length_so_far = length_so_far + padding0.len();
163         assert_eq!(length_so_far % 4, 0);
164         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
165         request0[2..4].copy_from_slice(&length.to_ne_bytes());
166         Ok((vec![request0.into(), self.context, padding0.into()], vec![]))
167     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,168     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
169     where
170         Conn: RequestConnection + ?Sized,
171     {
172         let (bytes, fds) = self.serialize(conn)?;
173         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
174         conn.send_request_without_reply(&slices, fds)
175     }
176     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>177     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
178         if header.minor_opcode != SET_DEVICE_CREATE_CONTEXT_REQUEST {
179             return Err(ParseError::InvalidValue);
180         }
181         let (context_len, remaining) = u32::try_parse(value)?;
182         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
183         let _ = remaining;
184         Ok(SetDeviceCreateContextRequest {
185             context: Cow::Borrowed(context),
186         })
187     }
188     /// Clone all borrowed data in this SetDeviceCreateContextRequest.
into_owned(self) -> SetDeviceCreateContextRequest<'static>189     pub fn into_owned(self) -> SetDeviceCreateContextRequest<'static> {
190         SetDeviceCreateContextRequest {
191             context: Cow::Owned(self.context.into_owned()),
192         }
193     }
194 }
195 impl<'input> Request for SetDeviceCreateContextRequest<'input> {
196     type Reply = ();
197 }
set_device_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,198 pub fn set_device_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
199 where
200     Conn: RequestConnection + ?Sized,
201 {
202     let request0 = SetDeviceCreateContextRequest {
203         context: Cow::Borrowed(context),
204     };
205     request0.send(conn)
206 }
207 
208 /// Opcode for the GetDeviceCreateContext request
209 pub const GET_DEVICE_CREATE_CONTEXT_REQUEST: u8 = 2;
210 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
211 pub struct GetDeviceCreateContextRequest;
212 impl GetDeviceCreateContextRequest {
213     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,214     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
215     where
216         Conn: RequestConnection + ?Sized,
217     {
218         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
219             .ok_or(ConnectionError::UnsupportedExtension)?;
220         let length_so_far = 0;
221         let mut request0 = vec![
222             extension_information.major_opcode,
223             GET_DEVICE_CREATE_CONTEXT_REQUEST,
224             0,
225             0,
226         ];
227         let length_so_far = length_so_far + request0.len();
228         assert_eq!(length_so_far % 4, 0);
229         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
230         request0[2..4].copy_from_slice(&length.to_ne_bytes());
231         Ok((vec![request0.into()], vec![]))
232     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDeviceCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,233     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDeviceCreateContextReply>, ConnectionError>
234     where
235         Conn: RequestConnection + ?Sized,
236     {
237         let (bytes, fds) = self.serialize(conn)?;
238         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
239         conn.send_request_with_reply(&slices, fds)
240     }
241     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>242     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
243         if header.minor_opcode != GET_DEVICE_CREATE_CONTEXT_REQUEST {
244             return Err(ParseError::InvalidValue);
245         }
246         let _ = value;
247         Ok(GetDeviceCreateContextRequest
248         )
249     }
250 }
251 impl Request for GetDeviceCreateContextRequest {
252     type Reply = GetDeviceCreateContextReply;
253 }
get_device_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetDeviceCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,254 pub fn get_device_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetDeviceCreateContextReply>, ConnectionError>
255 where
256     Conn: RequestConnection + ?Sized,
257 {
258     let request0 = GetDeviceCreateContextRequest;
259     request0.send(conn)
260 }
261 
262 #[derive(Debug, Clone, PartialEq, Eq)]
263 pub struct GetDeviceCreateContextReply {
264     pub sequence: u16,
265     pub length: u32,
266     pub context: Vec<u8>,
267 }
268 impl TryParse for GetDeviceCreateContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>269     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
270         let remaining = initial_value;
271         let (response_type, remaining) = u8::try_parse(remaining)?;
272         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
273         let (sequence, remaining) = u16::try_parse(remaining)?;
274         let (length, remaining) = u32::try_parse(remaining)?;
275         let (context_len, remaining) = u32::try_parse(remaining)?;
276         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
277         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
278         let context = context.to_vec();
279         if response_type != 1 {
280             return Err(ParseError::InvalidValue);
281         }
282         let result = GetDeviceCreateContextReply { sequence, length, context };
283         let _ = remaining;
284         let remaining = initial_value.get(32 + length as usize * 4..)
285             .ok_or(ParseError::InsufficientData)?;
286         Ok((result, remaining))
287     }
288 }
289 impl GetDeviceCreateContextReply {
290     /// Get the value of the `context_len` field.
291     ///
292     /// The `context_len` field is used as the length field of the `context` field.
293     /// This function computes the field's value again based on the length of the list.
294     ///
295     /// # Panics
296     ///
297     /// Panics if the value cannot be represented in the target type. This
298     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u32299     pub fn context_len(&self) -> u32 {
300         self.context.len()
301             .try_into().unwrap()
302     }
303 }
304 
305 /// Opcode for the SetDeviceContext request
306 pub const SET_DEVICE_CONTEXT_REQUEST: u8 = 3;
307 #[derive(Debug, Clone, PartialEq, Eq)]
308 pub struct SetDeviceContextRequest<'input> {
309     pub device: u32,
310     pub context: Cow<'input, [u8]>,
311 }
312 impl<'input> SetDeviceContextRequest<'input> {
313     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,314     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
315     where
316         Conn: RequestConnection + ?Sized,
317     {
318         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
319             .ok_or(ConnectionError::UnsupportedExtension)?;
320         let length_so_far = 0;
321         let device_bytes = self.device.serialize();
322         let context_len = u32::try_from(self.context.len()).expect("`context` has too many elements");
323         let context_len_bytes = context_len.serialize();
324         let mut request0 = vec![
325             extension_information.major_opcode,
326             SET_DEVICE_CONTEXT_REQUEST,
327             0,
328             0,
329             device_bytes[0],
330             device_bytes[1],
331             device_bytes[2],
332             device_bytes[3],
333             context_len_bytes[0],
334             context_len_bytes[1],
335             context_len_bytes[2],
336             context_len_bytes[3],
337         ];
338         let length_so_far = length_so_far + request0.len();
339         let length_so_far = length_so_far + self.context.len();
340         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
341         let length_so_far = length_so_far + padding0.len();
342         assert_eq!(length_so_far % 4, 0);
343         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
344         request0[2..4].copy_from_slice(&length.to_ne_bytes());
345         Ok((vec![request0.into(), self.context, padding0.into()], vec![]))
346     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,347     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
348     where
349         Conn: RequestConnection + ?Sized,
350     {
351         let (bytes, fds) = self.serialize(conn)?;
352         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
353         conn.send_request_without_reply(&slices, fds)
354     }
355     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>356     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
357         if header.minor_opcode != SET_DEVICE_CONTEXT_REQUEST {
358             return Err(ParseError::InvalidValue);
359         }
360         let (device, remaining) = u32::try_parse(value)?;
361         let (context_len, remaining) = u32::try_parse(remaining)?;
362         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
363         let _ = remaining;
364         Ok(SetDeviceContextRequest {
365             device,
366             context: Cow::Borrowed(context),
367         })
368     }
369     /// Clone all borrowed data in this SetDeviceContextRequest.
into_owned(self) -> SetDeviceContextRequest<'static>370     pub fn into_owned(self) -> SetDeviceContextRequest<'static> {
371         SetDeviceContextRequest {
372             device: self.device,
373             context: Cow::Owned(self.context.into_owned()),
374         }
375     }
376 }
377 impl<'input> Request for SetDeviceContextRequest<'input> {
378     type Reply = ();
379 }
set_device_context<'c, 'input, Conn>(conn: &'c Conn, device: u32, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,380 pub fn set_device_context<'c, 'input, Conn>(conn: &'c Conn, device: u32, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
381 where
382     Conn: RequestConnection + ?Sized,
383 {
384     let request0 = SetDeviceContextRequest {
385         device,
386         context: Cow::Borrowed(context),
387     };
388     request0.send(conn)
389 }
390 
391 /// Opcode for the GetDeviceContext request
392 pub const GET_DEVICE_CONTEXT_REQUEST: u8 = 4;
393 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
394 pub struct GetDeviceContextRequest {
395     pub device: u32,
396 }
397 impl GetDeviceContextRequest {
398     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,399     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
400     where
401         Conn: RequestConnection + ?Sized,
402     {
403         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
404             .ok_or(ConnectionError::UnsupportedExtension)?;
405         let length_so_far = 0;
406         let device_bytes = self.device.serialize();
407         let mut request0 = vec![
408             extension_information.major_opcode,
409             GET_DEVICE_CONTEXT_REQUEST,
410             0,
411             0,
412             device_bytes[0],
413             device_bytes[1],
414             device_bytes[2],
415             device_bytes[3],
416         ];
417         let length_so_far = length_so_far + request0.len();
418         assert_eq!(length_so_far % 4, 0);
419         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
420         request0[2..4].copy_from_slice(&length.to_ne_bytes());
421         Ok((vec![request0.into()], vec![]))
422     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDeviceContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,423     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDeviceContextReply>, ConnectionError>
424     where
425         Conn: RequestConnection + ?Sized,
426     {
427         let (bytes, fds) = self.serialize(conn)?;
428         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
429         conn.send_request_with_reply(&slices, fds)
430     }
431     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>432     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
433         if header.minor_opcode != GET_DEVICE_CONTEXT_REQUEST {
434             return Err(ParseError::InvalidValue);
435         }
436         let (device, remaining) = u32::try_parse(value)?;
437         let _ = remaining;
438         Ok(GetDeviceContextRequest {
439             device,
440         })
441     }
442 }
443 impl Request for GetDeviceContextRequest {
444     type Reply = GetDeviceContextReply;
445 }
get_device_context<Conn>(conn: &Conn, device: u32) -> Result<Cookie<'_, Conn, GetDeviceContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,446 pub fn get_device_context<Conn>(conn: &Conn, device: u32) -> Result<Cookie<'_, Conn, GetDeviceContextReply>, ConnectionError>
447 where
448     Conn: RequestConnection + ?Sized,
449 {
450     let request0 = GetDeviceContextRequest {
451         device,
452     };
453     request0.send(conn)
454 }
455 
456 #[derive(Debug, Clone, PartialEq, Eq)]
457 pub struct GetDeviceContextReply {
458     pub sequence: u16,
459     pub length: u32,
460     pub context: Vec<u8>,
461 }
462 impl TryParse for GetDeviceContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>463     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
464         let remaining = initial_value;
465         let (response_type, remaining) = u8::try_parse(remaining)?;
466         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
467         let (sequence, remaining) = u16::try_parse(remaining)?;
468         let (length, remaining) = u32::try_parse(remaining)?;
469         let (context_len, remaining) = u32::try_parse(remaining)?;
470         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
471         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
472         let context = context.to_vec();
473         if response_type != 1 {
474             return Err(ParseError::InvalidValue);
475         }
476         let result = GetDeviceContextReply { sequence, length, context };
477         let _ = remaining;
478         let remaining = initial_value.get(32 + length as usize * 4..)
479             .ok_or(ParseError::InsufficientData)?;
480         Ok((result, remaining))
481     }
482 }
483 impl GetDeviceContextReply {
484     /// Get the value of the `context_len` field.
485     ///
486     /// The `context_len` field is used as the length field of the `context` field.
487     /// This function computes the field's value again based on the length of the list.
488     ///
489     /// # Panics
490     ///
491     /// Panics if the value cannot be represented in the target type. This
492     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u32493     pub fn context_len(&self) -> u32 {
494         self.context.len()
495             .try_into().unwrap()
496     }
497 }
498 
499 /// Opcode for the SetWindowCreateContext request
500 pub const SET_WINDOW_CREATE_CONTEXT_REQUEST: u8 = 5;
501 #[derive(Debug, Clone, PartialEq, Eq)]
502 pub struct SetWindowCreateContextRequest<'input> {
503     pub context: Cow<'input, [u8]>,
504 }
505 impl<'input> SetWindowCreateContextRequest<'input> {
506     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,507     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
508     where
509         Conn: RequestConnection + ?Sized,
510     {
511         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
512             .ok_or(ConnectionError::UnsupportedExtension)?;
513         let length_so_far = 0;
514         let context_len = u32::try_from(self.context.len()).expect("`context` has too many elements");
515         let context_len_bytes = context_len.serialize();
516         let mut request0 = vec![
517             extension_information.major_opcode,
518             SET_WINDOW_CREATE_CONTEXT_REQUEST,
519             0,
520             0,
521             context_len_bytes[0],
522             context_len_bytes[1],
523             context_len_bytes[2],
524             context_len_bytes[3],
525         ];
526         let length_so_far = length_so_far + request0.len();
527         let length_so_far = length_so_far + self.context.len();
528         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
529         let length_so_far = length_so_far + padding0.len();
530         assert_eq!(length_so_far % 4, 0);
531         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
532         request0[2..4].copy_from_slice(&length.to_ne_bytes());
533         Ok((vec![request0.into(), self.context, padding0.into()], vec![]))
534     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,535     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
536     where
537         Conn: RequestConnection + ?Sized,
538     {
539         let (bytes, fds) = self.serialize(conn)?;
540         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
541         conn.send_request_without_reply(&slices, fds)
542     }
543     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>544     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
545         if header.minor_opcode != SET_WINDOW_CREATE_CONTEXT_REQUEST {
546             return Err(ParseError::InvalidValue);
547         }
548         let (context_len, remaining) = u32::try_parse(value)?;
549         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
550         let _ = remaining;
551         Ok(SetWindowCreateContextRequest {
552             context: Cow::Borrowed(context),
553         })
554     }
555     /// Clone all borrowed data in this SetWindowCreateContextRequest.
into_owned(self) -> SetWindowCreateContextRequest<'static>556     pub fn into_owned(self) -> SetWindowCreateContextRequest<'static> {
557         SetWindowCreateContextRequest {
558             context: Cow::Owned(self.context.into_owned()),
559         }
560     }
561 }
562 impl<'input> Request for SetWindowCreateContextRequest<'input> {
563     type Reply = ();
564 }
set_window_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,565 pub fn set_window_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
566 where
567     Conn: RequestConnection + ?Sized,
568 {
569     let request0 = SetWindowCreateContextRequest {
570         context: Cow::Borrowed(context),
571     };
572     request0.send(conn)
573 }
574 
575 /// Opcode for the GetWindowCreateContext request
576 pub const GET_WINDOW_CREATE_CONTEXT_REQUEST: u8 = 6;
577 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
578 pub struct GetWindowCreateContextRequest;
579 impl GetWindowCreateContextRequest {
580     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,581     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
582     where
583         Conn: RequestConnection + ?Sized,
584     {
585         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
586             .ok_or(ConnectionError::UnsupportedExtension)?;
587         let length_so_far = 0;
588         let mut request0 = vec![
589             extension_information.major_opcode,
590             GET_WINDOW_CREATE_CONTEXT_REQUEST,
591             0,
592             0,
593         ];
594         let length_so_far = length_so_far + request0.len();
595         assert_eq!(length_so_far % 4, 0);
596         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
597         request0[2..4].copy_from_slice(&length.to_ne_bytes());
598         Ok((vec![request0.into()], vec![]))
599     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetWindowCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,600     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetWindowCreateContextReply>, ConnectionError>
601     where
602         Conn: RequestConnection + ?Sized,
603     {
604         let (bytes, fds) = self.serialize(conn)?;
605         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
606         conn.send_request_with_reply(&slices, fds)
607     }
608     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>609     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
610         if header.minor_opcode != GET_WINDOW_CREATE_CONTEXT_REQUEST {
611             return Err(ParseError::InvalidValue);
612         }
613         let _ = value;
614         Ok(GetWindowCreateContextRequest
615         )
616     }
617 }
618 impl Request for GetWindowCreateContextRequest {
619     type Reply = GetWindowCreateContextReply;
620 }
get_window_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetWindowCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,621 pub fn get_window_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetWindowCreateContextReply>, ConnectionError>
622 where
623     Conn: RequestConnection + ?Sized,
624 {
625     let request0 = GetWindowCreateContextRequest;
626     request0.send(conn)
627 }
628 
629 #[derive(Debug, Clone, PartialEq, Eq)]
630 pub struct GetWindowCreateContextReply {
631     pub sequence: u16,
632     pub length: u32,
633     pub context: Vec<u8>,
634 }
635 impl TryParse for GetWindowCreateContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>636     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
637         let remaining = initial_value;
638         let (response_type, remaining) = u8::try_parse(remaining)?;
639         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
640         let (sequence, remaining) = u16::try_parse(remaining)?;
641         let (length, remaining) = u32::try_parse(remaining)?;
642         let (context_len, remaining) = u32::try_parse(remaining)?;
643         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
644         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
645         let context = context.to_vec();
646         if response_type != 1 {
647             return Err(ParseError::InvalidValue);
648         }
649         let result = GetWindowCreateContextReply { sequence, length, context };
650         let _ = remaining;
651         let remaining = initial_value.get(32 + length as usize * 4..)
652             .ok_or(ParseError::InsufficientData)?;
653         Ok((result, remaining))
654     }
655 }
656 impl GetWindowCreateContextReply {
657     /// Get the value of the `context_len` field.
658     ///
659     /// The `context_len` field is used as the length field of the `context` field.
660     /// This function computes the field's value again based on the length of the list.
661     ///
662     /// # Panics
663     ///
664     /// Panics if the value cannot be represented in the target type. This
665     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u32666     pub fn context_len(&self) -> u32 {
667         self.context.len()
668             .try_into().unwrap()
669     }
670 }
671 
672 /// Opcode for the GetWindowContext request
673 pub const GET_WINDOW_CONTEXT_REQUEST: u8 = 7;
674 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
675 pub struct GetWindowContextRequest {
676     pub window: xproto::Window,
677 }
678 impl GetWindowContextRequest {
679     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,680     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
681     where
682         Conn: RequestConnection + ?Sized,
683     {
684         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
685             .ok_or(ConnectionError::UnsupportedExtension)?;
686         let length_so_far = 0;
687         let window_bytes = self.window.serialize();
688         let mut request0 = vec![
689             extension_information.major_opcode,
690             GET_WINDOW_CONTEXT_REQUEST,
691             0,
692             0,
693             window_bytes[0],
694             window_bytes[1],
695             window_bytes[2],
696             window_bytes[3],
697         ];
698         let length_so_far = length_so_far + request0.len();
699         assert_eq!(length_so_far % 4, 0);
700         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
701         request0[2..4].copy_from_slice(&length.to_ne_bytes());
702         Ok((vec![request0.into()], vec![]))
703     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetWindowContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,704     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetWindowContextReply>, ConnectionError>
705     where
706         Conn: RequestConnection + ?Sized,
707     {
708         let (bytes, fds) = self.serialize(conn)?;
709         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
710         conn.send_request_with_reply(&slices, fds)
711     }
712     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>713     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
714         if header.minor_opcode != GET_WINDOW_CONTEXT_REQUEST {
715             return Err(ParseError::InvalidValue);
716         }
717         let (window, remaining) = xproto::Window::try_parse(value)?;
718         let _ = remaining;
719         Ok(GetWindowContextRequest {
720             window,
721         })
722     }
723 }
724 impl Request for GetWindowContextRequest {
725     type Reply = GetWindowContextReply;
726 }
get_window_context<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, GetWindowContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,727 pub fn get_window_context<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, GetWindowContextReply>, ConnectionError>
728 where
729     Conn: RequestConnection + ?Sized,
730 {
731     let request0 = GetWindowContextRequest {
732         window,
733     };
734     request0.send(conn)
735 }
736 
737 #[derive(Debug, Clone, PartialEq, Eq)]
738 pub struct GetWindowContextReply {
739     pub sequence: u16,
740     pub length: u32,
741     pub context: Vec<u8>,
742 }
743 impl TryParse for GetWindowContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>744     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
745         let remaining = initial_value;
746         let (response_type, remaining) = u8::try_parse(remaining)?;
747         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
748         let (sequence, remaining) = u16::try_parse(remaining)?;
749         let (length, remaining) = u32::try_parse(remaining)?;
750         let (context_len, remaining) = u32::try_parse(remaining)?;
751         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
752         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
753         let context = context.to_vec();
754         if response_type != 1 {
755             return Err(ParseError::InvalidValue);
756         }
757         let result = GetWindowContextReply { sequence, length, context };
758         let _ = remaining;
759         let remaining = initial_value.get(32 + length as usize * 4..)
760             .ok_or(ParseError::InsufficientData)?;
761         Ok((result, remaining))
762     }
763 }
764 impl GetWindowContextReply {
765     /// Get the value of the `context_len` field.
766     ///
767     /// The `context_len` field is used as the length field of the `context` field.
768     /// This function computes the field's value again based on the length of the list.
769     ///
770     /// # Panics
771     ///
772     /// Panics if the value cannot be represented in the target type. This
773     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u32774     pub fn context_len(&self) -> u32 {
775         self.context.len()
776             .try_into().unwrap()
777     }
778 }
779 
780 #[derive(Debug, Clone, PartialEq, Eq)]
781 pub struct ListItem {
782     pub name: xproto::Atom,
783     pub object_context: Vec<u8>,
784     pub data_context: Vec<u8>,
785 }
786 impl TryParse for ListItem {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>787     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
788         let value = remaining;
789         let (name, remaining) = xproto::Atom::try_parse(remaining)?;
790         let (object_context_len, remaining) = u32::try_parse(remaining)?;
791         let (data_context_len, remaining) = u32::try_parse(remaining)?;
792         let (object_context, remaining) = crate::x11_utils::parse_u8_list(remaining, object_context_len.try_to_usize()?)?;
793         let object_context = object_context.to_vec();
794         // Align offset to multiple of 4
795         let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
796         let misalignment = (4 - (offset % 4)) % 4;
797         let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
798         let (data_context, remaining) = crate::x11_utils::parse_u8_list(remaining, data_context_len.try_to_usize()?)?;
799         let data_context = data_context.to_vec();
800         // Align offset to multiple of 4
801         let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
802         let misalignment = (4 - (offset % 4)) % 4;
803         let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
804         let result = ListItem { name, object_context, data_context };
805         Ok((result, remaining))
806     }
807 }
808 impl Serialize for ListItem {
809     type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>810     fn serialize(&self) -> Vec<u8> {
811         let mut result = Vec::new();
812         self.serialize_into(&mut result);
813         result
814     }
serialize_into(&self, bytes: &mut Vec<u8>)815     fn serialize_into(&self, bytes: &mut Vec<u8>) {
816         bytes.reserve(12);
817         self.name.serialize_into(bytes);
818         let object_context_len = u32::try_from(self.object_context.len()).expect("`object_context` has too many elements");
819         object_context_len.serialize_into(bytes);
820         let data_context_len = u32::try_from(self.data_context.len()).expect("`data_context` has too many elements");
821         data_context_len.serialize_into(bytes);
822         bytes.extend_from_slice(&self.object_context);
823         bytes.extend_from_slice(&[0; 3][..(4 - (bytes.len() % 4)) % 4]);
824         bytes.extend_from_slice(&self.data_context);
825         bytes.extend_from_slice(&[0; 3][..(4 - (bytes.len() % 4)) % 4]);
826     }
827 }
828 impl ListItem {
829     /// Get the value of the `object_context_len` field.
830     ///
831     /// The `object_context_len` field is used as the length field of the `object_context` field.
832     /// This function computes the field's value again based on the length of the list.
833     ///
834     /// # Panics
835     ///
836     /// Panics if the value cannot be represented in the target type. This
837     /// cannot happen with values of the struct received from the X11 server.
object_context_len(&self) -> u32838     pub fn object_context_len(&self) -> u32 {
839         self.object_context.len()
840             .try_into().unwrap()
841     }
842     /// Get the value of the `data_context_len` field.
843     ///
844     /// The `data_context_len` field is used as the length field of the `data_context` field.
845     /// This function computes the field's value again based on the length of the list.
846     ///
847     /// # Panics
848     ///
849     /// Panics if the value cannot be represented in the target type. This
850     /// cannot happen with values of the struct received from the X11 server.
data_context_len(&self) -> u32851     pub fn data_context_len(&self) -> u32 {
852         self.data_context.len()
853             .try_into().unwrap()
854     }
855 }
856 
857 /// Opcode for the SetPropertyCreateContext request
858 pub const SET_PROPERTY_CREATE_CONTEXT_REQUEST: u8 = 8;
859 #[derive(Debug, Clone, PartialEq, Eq)]
860 pub struct SetPropertyCreateContextRequest<'input> {
861     pub context: Cow<'input, [u8]>,
862 }
863 impl<'input> SetPropertyCreateContextRequest<'input> {
864     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,865     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
866     where
867         Conn: RequestConnection + ?Sized,
868     {
869         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
870             .ok_or(ConnectionError::UnsupportedExtension)?;
871         let length_so_far = 0;
872         let context_len = u32::try_from(self.context.len()).expect("`context` has too many elements");
873         let context_len_bytes = context_len.serialize();
874         let mut request0 = vec![
875             extension_information.major_opcode,
876             SET_PROPERTY_CREATE_CONTEXT_REQUEST,
877             0,
878             0,
879             context_len_bytes[0],
880             context_len_bytes[1],
881             context_len_bytes[2],
882             context_len_bytes[3],
883         ];
884         let length_so_far = length_so_far + request0.len();
885         let length_so_far = length_so_far + self.context.len();
886         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
887         let length_so_far = length_so_far + padding0.len();
888         assert_eq!(length_so_far % 4, 0);
889         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
890         request0[2..4].copy_from_slice(&length.to_ne_bytes());
891         Ok((vec![request0.into(), self.context, padding0.into()], vec![]))
892     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,893     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
894     where
895         Conn: RequestConnection + ?Sized,
896     {
897         let (bytes, fds) = self.serialize(conn)?;
898         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
899         conn.send_request_without_reply(&slices, fds)
900     }
901     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>902     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
903         if header.minor_opcode != SET_PROPERTY_CREATE_CONTEXT_REQUEST {
904             return Err(ParseError::InvalidValue);
905         }
906         let (context_len, remaining) = u32::try_parse(value)?;
907         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
908         let _ = remaining;
909         Ok(SetPropertyCreateContextRequest {
910             context: Cow::Borrowed(context),
911         })
912     }
913     /// Clone all borrowed data in this SetPropertyCreateContextRequest.
into_owned(self) -> SetPropertyCreateContextRequest<'static>914     pub fn into_owned(self) -> SetPropertyCreateContextRequest<'static> {
915         SetPropertyCreateContextRequest {
916             context: Cow::Owned(self.context.into_owned()),
917         }
918     }
919 }
920 impl<'input> Request for SetPropertyCreateContextRequest<'input> {
921     type Reply = ();
922 }
set_property_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,923 pub fn set_property_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
924 where
925     Conn: RequestConnection + ?Sized,
926 {
927     let request0 = SetPropertyCreateContextRequest {
928         context: Cow::Borrowed(context),
929     };
930     request0.send(conn)
931 }
932 
933 /// Opcode for the GetPropertyCreateContext request
934 pub const GET_PROPERTY_CREATE_CONTEXT_REQUEST: u8 = 9;
935 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
936 pub struct GetPropertyCreateContextRequest;
937 impl GetPropertyCreateContextRequest {
938     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,939     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
940     where
941         Conn: RequestConnection + ?Sized,
942     {
943         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
944             .ok_or(ConnectionError::UnsupportedExtension)?;
945         let length_so_far = 0;
946         let mut request0 = vec![
947             extension_information.major_opcode,
948             GET_PROPERTY_CREATE_CONTEXT_REQUEST,
949             0,
950             0,
951         ];
952         let length_so_far = length_so_far + request0.len();
953         assert_eq!(length_so_far % 4, 0);
954         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
955         request0[2..4].copy_from_slice(&length.to_ne_bytes());
956         Ok((vec![request0.into()], vec![]))
957     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,958     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyCreateContextReply>, ConnectionError>
959     where
960         Conn: RequestConnection + ?Sized,
961     {
962         let (bytes, fds) = self.serialize(conn)?;
963         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
964         conn.send_request_with_reply(&slices, fds)
965     }
966     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>967     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
968         if header.minor_opcode != GET_PROPERTY_CREATE_CONTEXT_REQUEST {
969             return Err(ParseError::InvalidValue);
970         }
971         let _ = value;
972         Ok(GetPropertyCreateContextRequest
973         )
974     }
975 }
976 impl Request for GetPropertyCreateContextRequest {
977     type Reply = GetPropertyCreateContextReply;
978 }
get_property_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,979 pub fn get_property_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyCreateContextReply>, ConnectionError>
980 where
981     Conn: RequestConnection + ?Sized,
982 {
983     let request0 = GetPropertyCreateContextRequest;
984     request0.send(conn)
985 }
986 
987 #[derive(Debug, Clone, PartialEq, Eq)]
988 pub struct GetPropertyCreateContextReply {
989     pub sequence: u16,
990     pub length: u32,
991     pub context: Vec<u8>,
992 }
993 impl TryParse for GetPropertyCreateContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>994     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
995         let remaining = initial_value;
996         let (response_type, remaining) = u8::try_parse(remaining)?;
997         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
998         let (sequence, remaining) = u16::try_parse(remaining)?;
999         let (length, remaining) = u32::try_parse(remaining)?;
1000         let (context_len, remaining) = u32::try_parse(remaining)?;
1001         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1002         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1003         let context = context.to_vec();
1004         if response_type != 1 {
1005             return Err(ParseError::InvalidValue);
1006         }
1007         let result = GetPropertyCreateContextReply { sequence, length, context };
1008         let _ = remaining;
1009         let remaining = initial_value.get(32 + length as usize * 4..)
1010             .ok_or(ParseError::InsufficientData)?;
1011         Ok((result, remaining))
1012     }
1013 }
1014 impl GetPropertyCreateContextReply {
1015     /// Get the value of the `context_len` field.
1016     ///
1017     /// The `context_len` field is used as the length field of the `context` field.
1018     /// This function computes the field's value again based on the length of the list.
1019     ///
1020     /// # Panics
1021     ///
1022     /// Panics if the value cannot be represented in the target type. This
1023     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u321024     pub fn context_len(&self) -> u32 {
1025         self.context.len()
1026             .try_into().unwrap()
1027     }
1028 }
1029 
1030 /// Opcode for the SetPropertyUseContext request
1031 pub const SET_PROPERTY_USE_CONTEXT_REQUEST: u8 = 10;
1032 #[derive(Debug, Clone, PartialEq, Eq)]
1033 pub struct SetPropertyUseContextRequest<'input> {
1034     pub context: Cow<'input, [u8]>,
1035 }
1036 impl<'input> SetPropertyUseContextRequest<'input> {
1037     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1038     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1039     where
1040         Conn: RequestConnection + ?Sized,
1041     {
1042         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1043             .ok_or(ConnectionError::UnsupportedExtension)?;
1044         let length_so_far = 0;
1045         let context_len = u32::try_from(self.context.len()).expect("`context` has too many elements");
1046         let context_len_bytes = context_len.serialize();
1047         let mut request0 = vec![
1048             extension_information.major_opcode,
1049             SET_PROPERTY_USE_CONTEXT_REQUEST,
1050             0,
1051             0,
1052             context_len_bytes[0],
1053             context_len_bytes[1],
1054             context_len_bytes[2],
1055             context_len_bytes[3],
1056         ];
1057         let length_so_far = length_so_far + request0.len();
1058         let length_so_far = length_so_far + self.context.len();
1059         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1060         let length_so_far = length_so_far + padding0.len();
1061         assert_eq!(length_so_far % 4, 0);
1062         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1063         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1064         Ok((vec![request0.into(), self.context, padding0.into()], vec![]))
1065     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1066     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1067     where
1068         Conn: RequestConnection + ?Sized,
1069     {
1070         let (bytes, fds) = self.serialize(conn)?;
1071         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1072         conn.send_request_without_reply(&slices, fds)
1073     }
1074     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>1075     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1076         if header.minor_opcode != SET_PROPERTY_USE_CONTEXT_REQUEST {
1077             return Err(ParseError::InvalidValue);
1078         }
1079         let (context_len, remaining) = u32::try_parse(value)?;
1080         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1081         let _ = remaining;
1082         Ok(SetPropertyUseContextRequest {
1083             context: Cow::Borrowed(context),
1084         })
1085     }
1086     /// Clone all borrowed data in this SetPropertyUseContextRequest.
into_owned(self) -> SetPropertyUseContextRequest<'static>1087     pub fn into_owned(self) -> SetPropertyUseContextRequest<'static> {
1088         SetPropertyUseContextRequest {
1089             context: Cow::Owned(self.context.into_owned()),
1090         }
1091     }
1092 }
1093 impl<'input> Request for SetPropertyUseContextRequest<'input> {
1094     type Reply = ();
1095 }
set_property_use_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1096 pub fn set_property_use_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1097 where
1098     Conn: RequestConnection + ?Sized,
1099 {
1100     let request0 = SetPropertyUseContextRequest {
1101         context: Cow::Borrowed(context),
1102     };
1103     request0.send(conn)
1104 }
1105 
1106 /// Opcode for the GetPropertyUseContext request
1107 pub const GET_PROPERTY_USE_CONTEXT_REQUEST: u8 = 11;
1108 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1109 pub struct GetPropertyUseContextRequest;
1110 impl GetPropertyUseContextRequest {
1111     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1112     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1113     where
1114         Conn: RequestConnection + ?Sized,
1115     {
1116         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1117             .ok_or(ConnectionError::UnsupportedExtension)?;
1118         let length_so_far = 0;
1119         let mut request0 = vec![
1120             extension_information.major_opcode,
1121             GET_PROPERTY_USE_CONTEXT_REQUEST,
1122             0,
1123             0,
1124         ];
1125         let length_so_far = length_so_far + request0.len();
1126         assert_eq!(length_so_far % 4, 0);
1127         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1128         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1129         Ok((vec![request0.into()], vec![]))
1130     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyUseContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1131     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyUseContextReply>, ConnectionError>
1132     where
1133         Conn: RequestConnection + ?Sized,
1134     {
1135         let (bytes, fds) = self.serialize(conn)?;
1136         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1137         conn.send_request_with_reply(&slices, fds)
1138     }
1139     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1140     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1141         if header.minor_opcode != GET_PROPERTY_USE_CONTEXT_REQUEST {
1142             return Err(ParseError::InvalidValue);
1143         }
1144         let _ = value;
1145         Ok(GetPropertyUseContextRequest
1146         )
1147     }
1148 }
1149 impl Request for GetPropertyUseContextRequest {
1150     type Reply = GetPropertyUseContextReply;
1151 }
get_property_use_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyUseContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1152 pub fn get_property_use_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyUseContextReply>, ConnectionError>
1153 where
1154     Conn: RequestConnection + ?Sized,
1155 {
1156     let request0 = GetPropertyUseContextRequest;
1157     request0.send(conn)
1158 }
1159 
1160 #[derive(Debug, Clone, PartialEq, Eq)]
1161 pub struct GetPropertyUseContextReply {
1162     pub sequence: u16,
1163     pub length: u32,
1164     pub context: Vec<u8>,
1165 }
1166 impl TryParse for GetPropertyUseContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1167     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1168         let remaining = initial_value;
1169         let (response_type, remaining) = u8::try_parse(remaining)?;
1170         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1171         let (sequence, remaining) = u16::try_parse(remaining)?;
1172         let (length, remaining) = u32::try_parse(remaining)?;
1173         let (context_len, remaining) = u32::try_parse(remaining)?;
1174         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1175         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1176         let context = context.to_vec();
1177         if response_type != 1 {
1178             return Err(ParseError::InvalidValue);
1179         }
1180         let result = GetPropertyUseContextReply { sequence, length, context };
1181         let _ = remaining;
1182         let remaining = initial_value.get(32 + length as usize * 4..)
1183             .ok_or(ParseError::InsufficientData)?;
1184         Ok((result, remaining))
1185     }
1186 }
1187 impl GetPropertyUseContextReply {
1188     /// Get the value of the `context_len` field.
1189     ///
1190     /// The `context_len` field is used as the length field of the `context` field.
1191     /// This function computes the field's value again based on the length of the list.
1192     ///
1193     /// # Panics
1194     ///
1195     /// Panics if the value cannot be represented in the target type. This
1196     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u321197     pub fn context_len(&self) -> u32 {
1198         self.context.len()
1199             .try_into().unwrap()
1200     }
1201 }
1202 
1203 /// Opcode for the GetPropertyContext request
1204 pub const GET_PROPERTY_CONTEXT_REQUEST: u8 = 12;
1205 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1206 pub struct GetPropertyContextRequest {
1207     pub window: xproto::Window,
1208     pub property: xproto::Atom,
1209 }
1210 impl GetPropertyContextRequest {
1211     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1212     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1213     where
1214         Conn: RequestConnection + ?Sized,
1215     {
1216         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1217             .ok_or(ConnectionError::UnsupportedExtension)?;
1218         let length_so_far = 0;
1219         let window_bytes = self.window.serialize();
1220         let property_bytes = self.property.serialize();
1221         let mut request0 = vec![
1222             extension_information.major_opcode,
1223             GET_PROPERTY_CONTEXT_REQUEST,
1224             0,
1225             0,
1226             window_bytes[0],
1227             window_bytes[1],
1228             window_bytes[2],
1229             window_bytes[3],
1230             property_bytes[0],
1231             property_bytes[1],
1232             property_bytes[2],
1233             property_bytes[3],
1234         ];
1235         let length_so_far = length_so_far + request0.len();
1236         assert_eq!(length_so_far % 4, 0);
1237         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1238         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1239         Ok((vec![request0.into()], vec![]))
1240     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1241     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyContextReply>, ConnectionError>
1242     where
1243         Conn: RequestConnection + ?Sized,
1244     {
1245         let (bytes, fds) = self.serialize(conn)?;
1246         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1247         conn.send_request_with_reply(&slices, fds)
1248     }
1249     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1250     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1251         if header.minor_opcode != GET_PROPERTY_CONTEXT_REQUEST {
1252             return Err(ParseError::InvalidValue);
1253         }
1254         let (window, remaining) = xproto::Window::try_parse(value)?;
1255         let (property, remaining) = xproto::Atom::try_parse(remaining)?;
1256         let _ = remaining;
1257         Ok(GetPropertyContextRequest {
1258             window,
1259             property,
1260         })
1261     }
1262 }
1263 impl Request for GetPropertyContextRequest {
1264     type Reply = GetPropertyContextReply;
1265 }
get_property_context<Conn>(conn: &Conn, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Conn, GetPropertyContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1266 pub fn get_property_context<Conn>(conn: &Conn, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Conn, GetPropertyContextReply>, ConnectionError>
1267 where
1268     Conn: RequestConnection + ?Sized,
1269 {
1270     let request0 = GetPropertyContextRequest {
1271         window,
1272         property,
1273     };
1274     request0.send(conn)
1275 }
1276 
1277 #[derive(Debug, Clone, PartialEq, Eq)]
1278 pub struct GetPropertyContextReply {
1279     pub sequence: u16,
1280     pub length: u32,
1281     pub context: Vec<u8>,
1282 }
1283 impl TryParse for GetPropertyContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1284     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1285         let remaining = initial_value;
1286         let (response_type, remaining) = u8::try_parse(remaining)?;
1287         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1288         let (sequence, remaining) = u16::try_parse(remaining)?;
1289         let (length, remaining) = u32::try_parse(remaining)?;
1290         let (context_len, remaining) = u32::try_parse(remaining)?;
1291         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1292         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1293         let context = context.to_vec();
1294         if response_type != 1 {
1295             return Err(ParseError::InvalidValue);
1296         }
1297         let result = GetPropertyContextReply { sequence, length, context };
1298         let _ = remaining;
1299         let remaining = initial_value.get(32 + length as usize * 4..)
1300             .ok_or(ParseError::InsufficientData)?;
1301         Ok((result, remaining))
1302     }
1303 }
1304 impl GetPropertyContextReply {
1305     /// Get the value of the `context_len` field.
1306     ///
1307     /// The `context_len` field is used as the length field of the `context` field.
1308     /// This function computes the field's value again based on the length of the list.
1309     ///
1310     /// # Panics
1311     ///
1312     /// Panics if the value cannot be represented in the target type. This
1313     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u321314     pub fn context_len(&self) -> u32 {
1315         self.context.len()
1316             .try_into().unwrap()
1317     }
1318 }
1319 
1320 /// Opcode for the GetPropertyDataContext request
1321 pub const GET_PROPERTY_DATA_CONTEXT_REQUEST: u8 = 13;
1322 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1323 pub struct GetPropertyDataContextRequest {
1324     pub window: xproto::Window,
1325     pub property: xproto::Atom,
1326 }
1327 impl GetPropertyDataContextRequest {
1328     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1329     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1330     where
1331         Conn: RequestConnection + ?Sized,
1332     {
1333         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1334             .ok_or(ConnectionError::UnsupportedExtension)?;
1335         let length_so_far = 0;
1336         let window_bytes = self.window.serialize();
1337         let property_bytes = self.property.serialize();
1338         let mut request0 = vec![
1339             extension_information.major_opcode,
1340             GET_PROPERTY_DATA_CONTEXT_REQUEST,
1341             0,
1342             0,
1343             window_bytes[0],
1344             window_bytes[1],
1345             window_bytes[2],
1346             window_bytes[3],
1347             property_bytes[0],
1348             property_bytes[1],
1349             property_bytes[2],
1350             property_bytes[3],
1351         ];
1352         let length_so_far = length_so_far + request0.len();
1353         assert_eq!(length_so_far % 4, 0);
1354         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1355         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1356         Ok((vec![request0.into()], vec![]))
1357     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyDataContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1358     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPropertyDataContextReply>, ConnectionError>
1359     where
1360         Conn: RequestConnection + ?Sized,
1361     {
1362         let (bytes, fds) = self.serialize(conn)?;
1363         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1364         conn.send_request_with_reply(&slices, fds)
1365     }
1366     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1367     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1368         if header.minor_opcode != GET_PROPERTY_DATA_CONTEXT_REQUEST {
1369             return Err(ParseError::InvalidValue);
1370         }
1371         let (window, remaining) = xproto::Window::try_parse(value)?;
1372         let (property, remaining) = xproto::Atom::try_parse(remaining)?;
1373         let _ = remaining;
1374         Ok(GetPropertyDataContextRequest {
1375             window,
1376             property,
1377         })
1378     }
1379 }
1380 impl Request for GetPropertyDataContextRequest {
1381     type Reply = GetPropertyDataContextReply;
1382 }
get_property_data_context<Conn>(conn: &Conn, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Conn, GetPropertyDataContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1383 pub fn get_property_data_context<Conn>(conn: &Conn, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Conn, GetPropertyDataContextReply>, ConnectionError>
1384 where
1385     Conn: RequestConnection + ?Sized,
1386 {
1387     let request0 = GetPropertyDataContextRequest {
1388         window,
1389         property,
1390     };
1391     request0.send(conn)
1392 }
1393 
1394 #[derive(Debug, Clone, PartialEq, Eq)]
1395 pub struct GetPropertyDataContextReply {
1396     pub sequence: u16,
1397     pub length: u32,
1398     pub context: Vec<u8>,
1399 }
1400 impl TryParse for GetPropertyDataContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1401     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1402         let remaining = initial_value;
1403         let (response_type, remaining) = u8::try_parse(remaining)?;
1404         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1405         let (sequence, remaining) = u16::try_parse(remaining)?;
1406         let (length, remaining) = u32::try_parse(remaining)?;
1407         let (context_len, remaining) = u32::try_parse(remaining)?;
1408         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1409         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1410         let context = context.to_vec();
1411         if response_type != 1 {
1412             return Err(ParseError::InvalidValue);
1413         }
1414         let result = GetPropertyDataContextReply { sequence, length, context };
1415         let _ = remaining;
1416         let remaining = initial_value.get(32 + length as usize * 4..)
1417             .ok_or(ParseError::InsufficientData)?;
1418         Ok((result, remaining))
1419     }
1420 }
1421 impl GetPropertyDataContextReply {
1422     /// Get the value of the `context_len` field.
1423     ///
1424     /// The `context_len` field is used as the length field of the `context` field.
1425     /// This function computes the field's value again based on the length of the list.
1426     ///
1427     /// # Panics
1428     ///
1429     /// Panics if the value cannot be represented in the target type. This
1430     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u321431     pub fn context_len(&self) -> u32 {
1432         self.context.len()
1433             .try_into().unwrap()
1434     }
1435 }
1436 
1437 /// Opcode for the ListProperties request
1438 pub const LIST_PROPERTIES_REQUEST: u8 = 14;
1439 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1440 pub struct ListPropertiesRequest {
1441     pub window: xproto::Window,
1442 }
1443 impl ListPropertiesRequest {
1444     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1445     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1446     where
1447         Conn: RequestConnection + ?Sized,
1448     {
1449         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1450             .ok_or(ConnectionError::UnsupportedExtension)?;
1451         let length_so_far = 0;
1452         let window_bytes = self.window.serialize();
1453         let mut request0 = vec![
1454             extension_information.major_opcode,
1455             LIST_PROPERTIES_REQUEST,
1456             0,
1457             0,
1458             window_bytes[0],
1459             window_bytes[1],
1460             window_bytes[2],
1461             window_bytes[3],
1462         ];
1463         let length_so_far = length_so_far + request0.len();
1464         assert_eq!(length_so_far % 4, 0);
1465         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1466         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1467         Ok((vec![request0.into()], vec![]))
1468     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ListPropertiesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1469     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ListPropertiesReply>, ConnectionError>
1470     where
1471         Conn: RequestConnection + ?Sized,
1472     {
1473         let (bytes, fds) = self.serialize(conn)?;
1474         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1475         conn.send_request_with_reply(&slices, fds)
1476     }
1477     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1478     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1479         if header.minor_opcode != LIST_PROPERTIES_REQUEST {
1480             return Err(ParseError::InvalidValue);
1481         }
1482         let (window, remaining) = xproto::Window::try_parse(value)?;
1483         let _ = remaining;
1484         Ok(ListPropertiesRequest {
1485             window,
1486         })
1487     }
1488 }
1489 impl Request for ListPropertiesRequest {
1490     type Reply = ListPropertiesReply;
1491 }
list_properties<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, ListPropertiesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1492 pub fn list_properties<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, ListPropertiesReply>, ConnectionError>
1493 where
1494     Conn: RequestConnection + ?Sized,
1495 {
1496     let request0 = ListPropertiesRequest {
1497         window,
1498     };
1499     request0.send(conn)
1500 }
1501 
1502 #[derive(Debug, Clone, PartialEq, Eq)]
1503 pub struct ListPropertiesReply {
1504     pub sequence: u16,
1505     pub length: u32,
1506     pub properties: Vec<ListItem>,
1507 }
1508 impl TryParse for ListPropertiesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1509     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1510         let remaining = initial_value;
1511         let (response_type, remaining) = u8::try_parse(remaining)?;
1512         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1513         let (sequence, remaining) = u16::try_parse(remaining)?;
1514         let (length, remaining) = u32::try_parse(remaining)?;
1515         let (properties_len, remaining) = u32::try_parse(remaining)?;
1516         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1517         let (properties, remaining) = crate::x11_utils::parse_list::<ListItem>(remaining, properties_len.try_to_usize()?)?;
1518         if response_type != 1 {
1519             return Err(ParseError::InvalidValue);
1520         }
1521         let result = ListPropertiesReply { sequence, length, properties };
1522         let _ = remaining;
1523         let remaining = initial_value.get(32 + length as usize * 4..)
1524             .ok_or(ParseError::InsufficientData)?;
1525         Ok((result, remaining))
1526     }
1527 }
1528 impl ListPropertiesReply {
1529     /// Get the value of the `properties_len` field.
1530     ///
1531     /// The `properties_len` field is used as the length field of the `properties` field.
1532     /// This function computes the field's value again based on the length of the list.
1533     ///
1534     /// # Panics
1535     ///
1536     /// Panics if the value cannot be represented in the target type. This
1537     /// cannot happen with values of the struct received from the X11 server.
properties_len(&self) -> u321538     pub fn properties_len(&self) -> u32 {
1539         self.properties.len()
1540             .try_into().unwrap()
1541     }
1542 }
1543 
1544 /// Opcode for the SetSelectionCreateContext request
1545 pub const SET_SELECTION_CREATE_CONTEXT_REQUEST: u8 = 15;
1546 #[derive(Debug, Clone, PartialEq, Eq)]
1547 pub struct SetSelectionCreateContextRequest<'input> {
1548     pub context: Cow<'input, [u8]>,
1549 }
1550 impl<'input> SetSelectionCreateContextRequest<'input> {
1551     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1552     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1553     where
1554         Conn: RequestConnection + ?Sized,
1555     {
1556         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1557             .ok_or(ConnectionError::UnsupportedExtension)?;
1558         let length_so_far = 0;
1559         let context_len = u32::try_from(self.context.len()).expect("`context` has too many elements");
1560         let context_len_bytes = context_len.serialize();
1561         let mut request0 = vec![
1562             extension_information.major_opcode,
1563             SET_SELECTION_CREATE_CONTEXT_REQUEST,
1564             0,
1565             0,
1566             context_len_bytes[0],
1567             context_len_bytes[1],
1568             context_len_bytes[2],
1569             context_len_bytes[3],
1570         ];
1571         let length_so_far = length_so_far + request0.len();
1572         let length_so_far = length_so_far + self.context.len();
1573         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1574         let length_so_far = length_so_far + padding0.len();
1575         assert_eq!(length_so_far % 4, 0);
1576         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1577         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1578         Ok((vec![request0.into(), self.context, padding0.into()], vec![]))
1579     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1580     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1581     where
1582         Conn: RequestConnection + ?Sized,
1583     {
1584         let (bytes, fds) = self.serialize(conn)?;
1585         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1586         conn.send_request_without_reply(&slices, fds)
1587     }
1588     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>1589     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1590         if header.minor_opcode != SET_SELECTION_CREATE_CONTEXT_REQUEST {
1591             return Err(ParseError::InvalidValue);
1592         }
1593         let (context_len, remaining) = u32::try_parse(value)?;
1594         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1595         let _ = remaining;
1596         Ok(SetSelectionCreateContextRequest {
1597             context: Cow::Borrowed(context),
1598         })
1599     }
1600     /// Clone all borrowed data in this SetSelectionCreateContextRequest.
into_owned(self) -> SetSelectionCreateContextRequest<'static>1601     pub fn into_owned(self) -> SetSelectionCreateContextRequest<'static> {
1602         SetSelectionCreateContextRequest {
1603             context: Cow::Owned(self.context.into_owned()),
1604         }
1605     }
1606 }
1607 impl<'input> Request for SetSelectionCreateContextRequest<'input> {
1608     type Reply = ();
1609 }
set_selection_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1610 pub fn set_selection_create_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1611 where
1612     Conn: RequestConnection + ?Sized,
1613 {
1614     let request0 = SetSelectionCreateContextRequest {
1615         context: Cow::Borrowed(context),
1616     };
1617     request0.send(conn)
1618 }
1619 
1620 /// Opcode for the GetSelectionCreateContext request
1621 pub const GET_SELECTION_CREATE_CONTEXT_REQUEST: u8 = 16;
1622 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1623 pub struct GetSelectionCreateContextRequest;
1624 impl GetSelectionCreateContextRequest {
1625     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1626     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1627     where
1628         Conn: RequestConnection + ?Sized,
1629     {
1630         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1631             .ok_or(ConnectionError::UnsupportedExtension)?;
1632         let length_so_far = 0;
1633         let mut request0 = vec![
1634             extension_information.major_opcode,
1635             GET_SELECTION_CREATE_CONTEXT_REQUEST,
1636             0,
1637             0,
1638         ];
1639         let length_so_far = length_so_far + request0.len();
1640         assert_eq!(length_so_far % 4, 0);
1641         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1642         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1643         Ok((vec![request0.into()], vec![]))
1644     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1645     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionCreateContextReply>, ConnectionError>
1646     where
1647         Conn: RequestConnection + ?Sized,
1648     {
1649         let (bytes, fds) = self.serialize(conn)?;
1650         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1651         conn.send_request_with_reply(&slices, fds)
1652     }
1653     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1654     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1655         if header.minor_opcode != GET_SELECTION_CREATE_CONTEXT_REQUEST {
1656             return Err(ParseError::InvalidValue);
1657         }
1658         let _ = value;
1659         Ok(GetSelectionCreateContextRequest
1660         )
1661     }
1662 }
1663 impl Request for GetSelectionCreateContextRequest {
1664     type Reply = GetSelectionCreateContextReply;
1665 }
get_selection_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionCreateContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1666 pub fn get_selection_create_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionCreateContextReply>, ConnectionError>
1667 where
1668     Conn: RequestConnection + ?Sized,
1669 {
1670     let request0 = GetSelectionCreateContextRequest;
1671     request0.send(conn)
1672 }
1673 
1674 #[derive(Debug, Clone, PartialEq, Eq)]
1675 pub struct GetSelectionCreateContextReply {
1676     pub sequence: u16,
1677     pub length: u32,
1678     pub context: Vec<u8>,
1679 }
1680 impl TryParse for GetSelectionCreateContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1681     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1682         let remaining = initial_value;
1683         let (response_type, remaining) = u8::try_parse(remaining)?;
1684         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1685         let (sequence, remaining) = u16::try_parse(remaining)?;
1686         let (length, remaining) = u32::try_parse(remaining)?;
1687         let (context_len, remaining) = u32::try_parse(remaining)?;
1688         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1689         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1690         let context = context.to_vec();
1691         if response_type != 1 {
1692             return Err(ParseError::InvalidValue);
1693         }
1694         let result = GetSelectionCreateContextReply { sequence, length, context };
1695         let _ = remaining;
1696         let remaining = initial_value.get(32 + length as usize * 4..)
1697             .ok_or(ParseError::InsufficientData)?;
1698         Ok((result, remaining))
1699     }
1700 }
1701 impl GetSelectionCreateContextReply {
1702     /// Get the value of the `context_len` field.
1703     ///
1704     /// The `context_len` field is used as the length field of the `context` field.
1705     /// This function computes the field's value again based on the length of the list.
1706     ///
1707     /// # Panics
1708     ///
1709     /// Panics if the value cannot be represented in the target type. This
1710     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u321711     pub fn context_len(&self) -> u32 {
1712         self.context.len()
1713             .try_into().unwrap()
1714     }
1715 }
1716 
1717 /// Opcode for the SetSelectionUseContext request
1718 pub const SET_SELECTION_USE_CONTEXT_REQUEST: u8 = 17;
1719 #[derive(Debug, Clone, PartialEq, Eq)]
1720 pub struct SetSelectionUseContextRequest<'input> {
1721     pub context: Cow<'input, [u8]>,
1722 }
1723 impl<'input> SetSelectionUseContextRequest<'input> {
1724     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1725     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1726     where
1727         Conn: RequestConnection + ?Sized,
1728     {
1729         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1730             .ok_or(ConnectionError::UnsupportedExtension)?;
1731         let length_so_far = 0;
1732         let context_len = u32::try_from(self.context.len()).expect("`context` has too many elements");
1733         let context_len_bytes = context_len.serialize();
1734         let mut request0 = vec![
1735             extension_information.major_opcode,
1736             SET_SELECTION_USE_CONTEXT_REQUEST,
1737             0,
1738             0,
1739             context_len_bytes[0],
1740             context_len_bytes[1],
1741             context_len_bytes[2],
1742             context_len_bytes[3],
1743         ];
1744         let length_so_far = length_so_far + request0.len();
1745         let length_so_far = length_so_far + self.context.len();
1746         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1747         let length_so_far = length_so_far + padding0.len();
1748         assert_eq!(length_so_far % 4, 0);
1749         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1750         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1751         Ok((vec![request0.into(), self.context, padding0.into()], vec![]))
1752     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1753     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1754     where
1755         Conn: RequestConnection + ?Sized,
1756     {
1757         let (bytes, fds) = self.serialize(conn)?;
1758         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1759         conn.send_request_without_reply(&slices, fds)
1760     }
1761     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>1762     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1763         if header.minor_opcode != SET_SELECTION_USE_CONTEXT_REQUEST {
1764             return Err(ParseError::InvalidValue);
1765         }
1766         let (context_len, remaining) = u32::try_parse(value)?;
1767         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1768         let _ = remaining;
1769         Ok(SetSelectionUseContextRequest {
1770             context: Cow::Borrowed(context),
1771         })
1772     }
1773     /// Clone all borrowed data in this SetSelectionUseContextRequest.
into_owned(self) -> SetSelectionUseContextRequest<'static>1774     pub fn into_owned(self) -> SetSelectionUseContextRequest<'static> {
1775         SetSelectionUseContextRequest {
1776             context: Cow::Owned(self.context.into_owned()),
1777         }
1778     }
1779 }
1780 impl<'input> Request for SetSelectionUseContextRequest<'input> {
1781     type Reply = ();
1782 }
set_selection_use_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1783 pub fn set_selection_use_context<'c, 'input, Conn>(conn: &'c Conn, context: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1784 where
1785     Conn: RequestConnection + ?Sized,
1786 {
1787     let request0 = SetSelectionUseContextRequest {
1788         context: Cow::Borrowed(context),
1789     };
1790     request0.send(conn)
1791 }
1792 
1793 /// Opcode for the GetSelectionUseContext request
1794 pub const GET_SELECTION_USE_CONTEXT_REQUEST: u8 = 18;
1795 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1796 pub struct GetSelectionUseContextRequest;
1797 impl GetSelectionUseContextRequest {
1798     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1799     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1800     where
1801         Conn: RequestConnection + ?Sized,
1802     {
1803         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1804             .ok_or(ConnectionError::UnsupportedExtension)?;
1805         let length_so_far = 0;
1806         let mut request0 = vec![
1807             extension_information.major_opcode,
1808             GET_SELECTION_USE_CONTEXT_REQUEST,
1809             0,
1810             0,
1811         ];
1812         let length_so_far = length_so_far + request0.len();
1813         assert_eq!(length_so_far % 4, 0);
1814         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1815         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1816         Ok((vec![request0.into()], vec![]))
1817     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionUseContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1818     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionUseContextReply>, ConnectionError>
1819     where
1820         Conn: RequestConnection + ?Sized,
1821     {
1822         let (bytes, fds) = self.serialize(conn)?;
1823         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1824         conn.send_request_with_reply(&slices, fds)
1825     }
1826     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1827     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1828         if header.minor_opcode != GET_SELECTION_USE_CONTEXT_REQUEST {
1829             return Err(ParseError::InvalidValue);
1830         }
1831         let _ = value;
1832         Ok(GetSelectionUseContextRequest
1833         )
1834     }
1835 }
1836 impl Request for GetSelectionUseContextRequest {
1837     type Reply = GetSelectionUseContextReply;
1838 }
get_selection_use_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionUseContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1839 pub fn get_selection_use_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionUseContextReply>, ConnectionError>
1840 where
1841     Conn: RequestConnection + ?Sized,
1842 {
1843     let request0 = GetSelectionUseContextRequest;
1844     request0.send(conn)
1845 }
1846 
1847 #[derive(Debug, Clone, PartialEq, Eq)]
1848 pub struct GetSelectionUseContextReply {
1849     pub sequence: u16,
1850     pub length: u32,
1851     pub context: Vec<u8>,
1852 }
1853 impl TryParse for GetSelectionUseContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1854     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1855         let remaining = initial_value;
1856         let (response_type, remaining) = u8::try_parse(remaining)?;
1857         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1858         let (sequence, remaining) = u16::try_parse(remaining)?;
1859         let (length, remaining) = u32::try_parse(remaining)?;
1860         let (context_len, remaining) = u32::try_parse(remaining)?;
1861         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1862         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1863         let context = context.to_vec();
1864         if response_type != 1 {
1865             return Err(ParseError::InvalidValue);
1866         }
1867         let result = GetSelectionUseContextReply { sequence, length, context };
1868         let _ = remaining;
1869         let remaining = initial_value.get(32 + length as usize * 4..)
1870             .ok_or(ParseError::InsufficientData)?;
1871         Ok((result, remaining))
1872     }
1873 }
1874 impl GetSelectionUseContextReply {
1875     /// Get the value of the `context_len` field.
1876     ///
1877     /// The `context_len` field is used as the length field of the `context` field.
1878     /// This function computes the field's value again based on the length of the list.
1879     ///
1880     /// # Panics
1881     ///
1882     /// Panics if the value cannot be represented in the target type. This
1883     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u321884     pub fn context_len(&self) -> u32 {
1885         self.context.len()
1886             .try_into().unwrap()
1887     }
1888 }
1889 
1890 /// Opcode for the GetSelectionContext request
1891 pub const GET_SELECTION_CONTEXT_REQUEST: u8 = 19;
1892 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1893 pub struct GetSelectionContextRequest {
1894     pub selection: xproto::Atom,
1895 }
1896 impl GetSelectionContextRequest {
1897     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1898     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1899     where
1900         Conn: RequestConnection + ?Sized,
1901     {
1902         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1903             .ok_or(ConnectionError::UnsupportedExtension)?;
1904         let length_so_far = 0;
1905         let selection_bytes = self.selection.serialize();
1906         let mut request0 = vec![
1907             extension_information.major_opcode,
1908             GET_SELECTION_CONTEXT_REQUEST,
1909             0,
1910             0,
1911             selection_bytes[0],
1912             selection_bytes[1],
1913             selection_bytes[2],
1914             selection_bytes[3],
1915         ];
1916         let length_so_far = length_so_far + request0.len();
1917         assert_eq!(length_so_far % 4, 0);
1918         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1919         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1920         Ok((vec![request0.into()], vec![]))
1921     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1922     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionContextReply>, ConnectionError>
1923     where
1924         Conn: RequestConnection + ?Sized,
1925     {
1926         let (bytes, fds) = self.serialize(conn)?;
1927         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1928         conn.send_request_with_reply(&slices, fds)
1929     }
1930     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1931     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1932         if header.minor_opcode != GET_SELECTION_CONTEXT_REQUEST {
1933             return Err(ParseError::InvalidValue);
1934         }
1935         let (selection, remaining) = xproto::Atom::try_parse(value)?;
1936         let _ = remaining;
1937         Ok(GetSelectionContextRequest {
1938             selection,
1939         })
1940     }
1941 }
1942 impl Request for GetSelectionContextRequest {
1943     type Reply = GetSelectionContextReply;
1944 }
get_selection_context<Conn>(conn: &Conn, selection: xproto::Atom) -> Result<Cookie<'_, Conn, GetSelectionContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1945 pub fn get_selection_context<Conn>(conn: &Conn, selection: xproto::Atom) -> Result<Cookie<'_, Conn, GetSelectionContextReply>, ConnectionError>
1946 where
1947     Conn: RequestConnection + ?Sized,
1948 {
1949     let request0 = GetSelectionContextRequest {
1950         selection,
1951     };
1952     request0.send(conn)
1953 }
1954 
1955 #[derive(Debug, Clone, PartialEq, Eq)]
1956 pub struct GetSelectionContextReply {
1957     pub sequence: u16,
1958     pub length: u32,
1959     pub context: Vec<u8>,
1960 }
1961 impl TryParse for GetSelectionContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1962     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1963         let remaining = initial_value;
1964         let (response_type, remaining) = u8::try_parse(remaining)?;
1965         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1966         let (sequence, remaining) = u16::try_parse(remaining)?;
1967         let (length, remaining) = u32::try_parse(remaining)?;
1968         let (context_len, remaining) = u32::try_parse(remaining)?;
1969         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1970         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
1971         let context = context.to_vec();
1972         if response_type != 1 {
1973             return Err(ParseError::InvalidValue);
1974         }
1975         let result = GetSelectionContextReply { sequence, length, context };
1976         let _ = remaining;
1977         let remaining = initial_value.get(32 + length as usize * 4..)
1978             .ok_or(ParseError::InsufficientData)?;
1979         Ok((result, remaining))
1980     }
1981 }
1982 impl GetSelectionContextReply {
1983     /// Get the value of the `context_len` field.
1984     ///
1985     /// The `context_len` field is used as the length field of the `context` field.
1986     /// This function computes the field's value again based on the length of the list.
1987     ///
1988     /// # Panics
1989     ///
1990     /// Panics if the value cannot be represented in the target type. This
1991     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u321992     pub fn context_len(&self) -> u32 {
1993         self.context.len()
1994             .try_into().unwrap()
1995     }
1996 }
1997 
1998 /// Opcode for the GetSelectionDataContext request
1999 pub const GET_SELECTION_DATA_CONTEXT_REQUEST: u8 = 20;
2000 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2001 pub struct GetSelectionDataContextRequest {
2002     pub selection: xproto::Atom,
2003 }
2004 impl GetSelectionDataContextRequest {
2005     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2006     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2007     where
2008         Conn: RequestConnection + ?Sized,
2009     {
2010         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2011             .ok_or(ConnectionError::UnsupportedExtension)?;
2012         let length_so_far = 0;
2013         let selection_bytes = self.selection.serialize();
2014         let mut request0 = vec![
2015             extension_information.major_opcode,
2016             GET_SELECTION_DATA_CONTEXT_REQUEST,
2017             0,
2018             0,
2019             selection_bytes[0],
2020             selection_bytes[1],
2021             selection_bytes[2],
2022             selection_bytes[3],
2023         ];
2024         let length_so_far = length_so_far + request0.len();
2025         assert_eq!(length_so_far % 4, 0);
2026         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2027         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2028         Ok((vec![request0.into()], vec![]))
2029     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionDataContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2030     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSelectionDataContextReply>, ConnectionError>
2031     where
2032         Conn: RequestConnection + ?Sized,
2033     {
2034         let (bytes, fds) = self.serialize(conn)?;
2035         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2036         conn.send_request_with_reply(&slices, fds)
2037     }
2038     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2039     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2040         if header.minor_opcode != GET_SELECTION_DATA_CONTEXT_REQUEST {
2041             return Err(ParseError::InvalidValue);
2042         }
2043         let (selection, remaining) = xproto::Atom::try_parse(value)?;
2044         let _ = remaining;
2045         Ok(GetSelectionDataContextRequest {
2046             selection,
2047         })
2048     }
2049 }
2050 impl Request for GetSelectionDataContextRequest {
2051     type Reply = GetSelectionDataContextReply;
2052 }
get_selection_data_context<Conn>(conn: &Conn, selection: xproto::Atom) -> Result<Cookie<'_, Conn, GetSelectionDataContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2053 pub fn get_selection_data_context<Conn>(conn: &Conn, selection: xproto::Atom) -> Result<Cookie<'_, Conn, GetSelectionDataContextReply>, ConnectionError>
2054 where
2055     Conn: RequestConnection + ?Sized,
2056 {
2057     let request0 = GetSelectionDataContextRequest {
2058         selection,
2059     };
2060     request0.send(conn)
2061 }
2062 
2063 #[derive(Debug, Clone, PartialEq, Eq)]
2064 pub struct GetSelectionDataContextReply {
2065     pub sequence: u16,
2066     pub length: u32,
2067     pub context: Vec<u8>,
2068 }
2069 impl TryParse for GetSelectionDataContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2070     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2071         let remaining = initial_value;
2072         let (response_type, remaining) = u8::try_parse(remaining)?;
2073         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2074         let (sequence, remaining) = u16::try_parse(remaining)?;
2075         let (length, remaining) = u32::try_parse(remaining)?;
2076         let (context_len, remaining) = u32::try_parse(remaining)?;
2077         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2078         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
2079         let context = context.to_vec();
2080         if response_type != 1 {
2081             return Err(ParseError::InvalidValue);
2082         }
2083         let result = GetSelectionDataContextReply { sequence, length, context };
2084         let _ = remaining;
2085         let remaining = initial_value.get(32 + length as usize * 4..)
2086             .ok_or(ParseError::InsufficientData)?;
2087         Ok((result, remaining))
2088     }
2089 }
2090 impl GetSelectionDataContextReply {
2091     /// Get the value of the `context_len` field.
2092     ///
2093     /// The `context_len` field is used as the length field of the `context` field.
2094     /// This function computes the field's value again based on the length of the list.
2095     ///
2096     /// # Panics
2097     ///
2098     /// Panics if the value cannot be represented in the target type. This
2099     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u322100     pub fn context_len(&self) -> u32 {
2101         self.context.len()
2102             .try_into().unwrap()
2103     }
2104 }
2105 
2106 /// Opcode for the ListSelections request
2107 pub const LIST_SELECTIONS_REQUEST: u8 = 21;
2108 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2109 pub struct ListSelectionsRequest;
2110 impl ListSelectionsRequest {
2111     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2112     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2113     where
2114         Conn: RequestConnection + ?Sized,
2115     {
2116         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2117             .ok_or(ConnectionError::UnsupportedExtension)?;
2118         let length_so_far = 0;
2119         let mut request0 = vec![
2120             extension_information.major_opcode,
2121             LIST_SELECTIONS_REQUEST,
2122             0,
2123             0,
2124         ];
2125         let length_so_far = length_so_far + request0.len();
2126         assert_eq!(length_so_far % 4, 0);
2127         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2128         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2129         Ok((vec![request0.into()], vec![]))
2130     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ListSelectionsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2131     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ListSelectionsReply>, ConnectionError>
2132     where
2133         Conn: RequestConnection + ?Sized,
2134     {
2135         let (bytes, fds) = self.serialize(conn)?;
2136         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2137         conn.send_request_with_reply(&slices, fds)
2138     }
2139     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2140     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2141         if header.minor_opcode != LIST_SELECTIONS_REQUEST {
2142             return Err(ParseError::InvalidValue);
2143         }
2144         let _ = value;
2145         Ok(ListSelectionsRequest
2146         )
2147     }
2148 }
2149 impl Request for ListSelectionsRequest {
2150     type Reply = ListSelectionsReply;
2151 }
list_selections<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, ListSelectionsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2152 pub fn list_selections<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, ListSelectionsReply>, ConnectionError>
2153 where
2154     Conn: RequestConnection + ?Sized,
2155 {
2156     let request0 = ListSelectionsRequest;
2157     request0.send(conn)
2158 }
2159 
2160 #[derive(Debug, Clone, PartialEq, Eq)]
2161 pub struct ListSelectionsReply {
2162     pub sequence: u16,
2163     pub length: u32,
2164     pub selections: Vec<ListItem>,
2165 }
2166 impl TryParse for ListSelectionsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2167     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2168         let remaining = initial_value;
2169         let (response_type, remaining) = u8::try_parse(remaining)?;
2170         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2171         let (sequence, remaining) = u16::try_parse(remaining)?;
2172         let (length, remaining) = u32::try_parse(remaining)?;
2173         let (selections_len, remaining) = u32::try_parse(remaining)?;
2174         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2175         let (selections, remaining) = crate::x11_utils::parse_list::<ListItem>(remaining, selections_len.try_to_usize()?)?;
2176         if response_type != 1 {
2177             return Err(ParseError::InvalidValue);
2178         }
2179         let result = ListSelectionsReply { sequence, length, selections };
2180         let _ = remaining;
2181         let remaining = initial_value.get(32 + length as usize * 4..)
2182             .ok_or(ParseError::InsufficientData)?;
2183         Ok((result, remaining))
2184     }
2185 }
2186 impl ListSelectionsReply {
2187     /// Get the value of the `selections_len` field.
2188     ///
2189     /// The `selections_len` field is used as the length field of the `selections` field.
2190     /// This function computes the field's value again based on the length of the list.
2191     ///
2192     /// # Panics
2193     ///
2194     /// Panics if the value cannot be represented in the target type. This
2195     /// cannot happen with values of the struct received from the X11 server.
selections_len(&self) -> u322196     pub fn selections_len(&self) -> u32 {
2197         self.selections.len()
2198             .try_into().unwrap()
2199     }
2200 }
2201 
2202 /// Opcode for the GetClientContext request
2203 pub const GET_CLIENT_CONTEXT_REQUEST: u8 = 22;
2204 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2205 pub struct GetClientContextRequest {
2206     pub resource: u32,
2207 }
2208 impl GetClientContextRequest {
2209     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2210     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2211     where
2212         Conn: RequestConnection + ?Sized,
2213     {
2214         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2215             .ok_or(ConnectionError::UnsupportedExtension)?;
2216         let length_so_far = 0;
2217         let resource_bytes = self.resource.serialize();
2218         let mut request0 = vec![
2219             extension_information.major_opcode,
2220             GET_CLIENT_CONTEXT_REQUEST,
2221             0,
2222             0,
2223             resource_bytes[0],
2224             resource_bytes[1],
2225             resource_bytes[2],
2226             resource_bytes[3],
2227         ];
2228         let length_so_far = length_so_far + request0.len();
2229         assert_eq!(length_so_far % 4, 0);
2230         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2231         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2232         Ok((vec![request0.into()], vec![]))
2233     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetClientContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2234     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetClientContextReply>, ConnectionError>
2235     where
2236         Conn: RequestConnection + ?Sized,
2237     {
2238         let (bytes, fds) = self.serialize(conn)?;
2239         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2240         conn.send_request_with_reply(&slices, fds)
2241     }
2242     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2243     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2244         if header.minor_opcode != GET_CLIENT_CONTEXT_REQUEST {
2245             return Err(ParseError::InvalidValue);
2246         }
2247         let (resource, remaining) = u32::try_parse(value)?;
2248         let _ = remaining;
2249         Ok(GetClientContextRequest {
2250             resource,
2251         })
2252     }
2253 }
2254 impl Request for GetClientContextRequest {
2255     type Reply = GetClientContextReply;
2256 }
get_client_context<Conn>(conn: &Conn, resource: u32) -> Result<Cookie<'_, Conn, GetClientContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2257 pub fn get_client_context<Conn>(conn: &Conn, resource: u32) -> Result<Cookie<'_, Conn, GetClientContextReply>, ConnectionError>
2258 where
2259     Conn: RequestConnection + ?Sized,
2260 {
2261     let request0 = GetClientContextRequest {
2262         resource,
2263     };
2264     request0.send(conn)
2265 }
2266 
2267 #[derive(Debug, Clone, PartialEq, Eq)]
2268 pub struct GetClientContextReply {
2269     pub sequence: u16,
2270     pub length: u32,
2271     pub context: Vec<u8>,
2272 }
2273 impl TryParse for GetClientContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2274     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2275         let remaining = initial_value;
2276         let (response_type, remaining) = u8::try_parse(remaining)?;
2277         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2278         let (sequence, remaining) = u16::try_parse(remaining)?;
2279         let (length, remaining) = u32::try_parse(remaining)?;
2280         let (context_len, remaining) = u32::try_parse(remaining)?;
2281         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2282         let (context, remaining) = crate::x11_utils::parse_u8_list(remaining, context_len.try_to_usize()?)?;
2283         let context = context.to_vec();
2284         if response_type != 1 {
2285             return Err(ParseError::InvalidValue);
2286         }
2287         let result = GetClientContextReply { sequence, length, context };
2288         let _ = remaining;
2289         let remaining = initial_value.get(32 + length as usize * 4..)
2290             .ok_or(ParseError::InsufficientData)?;
2291         Ok((result, remaining))
2292     }
2293 }
2294 impl GetClientContextReply {
2295     /// Get the value of the `context_len` field.
2296     ///
2297     /// The `context_len` field is used as the length field of the `context` field.
2298     /// This function computes the field's value again based on the length of the list.
2299     ///
2300     /// # Panics
2301     ///
2302     /// Panics if the value cannot be represented in the target type. This
2303     /// cannot happen with values of the struct received from the X11 server.
context_len(&self) -> u322304     pub fn context_len(&self) -> u32 {
2305         self.context.len()
2306             .try_into().unwrap()
2307     }
2308 }
2309 
2310 /// Extension trait defining the requests of this extension.
2311 pub trait ConnectionExt: RequestConnection {
xselinux_query_version(&self, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>2312     fn xselinux_query_version(&self, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>
2313     {
2314         query_version(self, client_major, client_minor)
2315     }
xselinux_set_device_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2316     fn xselinux_set_device_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2317     {
2318         set_device_create_context(self, context)
2319     }
xselinux_get_device_create_context(&self) -> Result<Cookie<'_, Self, GetDeviceCreateContextReply>, ConnectionError>2320     fn xselinux_get_device_create_context(&self) -> Result<Cookie<'_, Self, GetDeviceCreateContextReply>, ConnectionError>
2321     {
2322         get_device_create_context(self)
2323     }
xselinux_set_device_context<'c, 'input>(&'c self, device: u32, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2324     fn xselinux_set_device_context<'c, 'input>(&'c self, device: u32, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2325     {
2326         set_device_context(self, device, context)
2327     }
xselinux_get_device_context(&self, device: u32) -> Result<Cookie<'_, Self, GetDeviceContextReply>, ConnectionError>2328     fn xselinux_get_device_context(&self, device: u32) -> Result<Cookie<'_, Self, GetDeviceContextReply>, ConnectionError>
2329     {
2330         get_device_context(self, device)
2331     }
xselinux_set_window_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2332     fn xselinux_set_window_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2333     {
2334         set_window_create_context(self, context)
2335     }
xselinux_get_window_create_context(&self) -> Result<Cookie<'_, Self, GetWindowCreateContextReply>, ConnectionError>2336     fn xselinux_get_window_create_context(&self) -> Result<Cookie<'_, Self, GetWindowCreateContextReply>, ConnectionError>
2337     {
2338         get_window_create_context(self)
2339     }
xselinux_get_window_context(&self, window: xproto::Window) -> Result<Cookie<'_, Self, GetWindowContextReply>, ConnectionError>2340     fn xselinux_get_window_context(&self, window: xproto::Window) -> Result<Cookie<'_, Self, GetWindowContextReply>, ConnectionError>
2341     {
2342         get_window_context(self, window)
2343     }
xselinux_set_property_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2344     fn xselinux_set_property_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2345     {
2346         set_property_create_context(self, context)
2347     }
xselinux_get_property_create_context(&self) -> Result<Cookie<'_, Self, GetPropertyCreateContextReply>, ConnectionError>2348     fn xselinux_get_property_create_context(&self) -> Result<Cookie<'_, Self, GetPropertyCreateContextReply>, ConnectionError>
2349     {
2350         get_property_create_context(self)
2351     }
xselinux_set_property_use_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2352     fn xselinux_set_property_use_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2353     {
2354         set_property_use_context(self, context)
2355     }
xselinux_get_property_use_context(&self) -> Result<Cookie<'_, Self, GetPropertyUseContextReply>, ConnectionError>2356     fn xselinux_get_property_use_context(&self) -> Result<Cookie<'_, Self, GetPropertyUseContextReply>, ConnectionError>
2357     {
2358         get_property_use_context(self)
2359     }
xselinux_get_property_context(&self, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Self, GetPropertyContextReply>, ConnectionError>2360     fn xselinux_get_property_context(&self, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Self, GetPropertyContextReply>, ConnectionError>
2361     {
2362         get_property_context(self, window, property)
2363     }
xselinux_get_property_data_context(&self, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Self, GetPropertyDataContextReply>, ConnectionError>2364     fn xselinux_get_property_data_context(&self, window: xproto::Window, property: xproto::Atom) -> Result<Cookie<'_, Self, GetPropertyDataContextReply>, ConnectionError>
2365     {
2366         get_property_data_context(self, window, property)
2367     }
xselinux_list_properties(&self, window: xproto::Window) -> Result<Cookie<'_, Self, ListPropertiesReply>, ConnectionError>2368     fn xselinux_list_properties(&self, window: xproto::Window) -> Result<Cookie<'_, Self, ListPropertiesReply>, ConnectionError>
2369     {
2370         list_properties(self, window)
2371     }
xselinux_set_selection_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2372     fn xselinux_set_selection_create_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2373     {
2374         set_selection_create_context(self, context)
2375     }
xselinux_get_selection_create_context(&self) -> Result<Cookie<'_, Self, GetSelectionCreateContextReply>, ConnectionError>2376     fn xselinux_get_selection_create_context(&self) -> Result<Cookie<'_, Self, GetSelectionCreateContextReply>, ConnectionError>
2377     {
2378         get_selection_create_context(self)
2379     }
xselinux_set_selection_use_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2380     fn xselinux_set_selection_use_context<'c, 'input>(&'c self, context: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2381     {
2382         set_selection_use_context(self, context)
2383     }
xselinux_get_selection_use_context(&self) -> Result<Cookie<'_, Self, GetSelectionUseContextReply>, ConnectionError>2384     fn xselinux_get_selection_use_context(&self) -> Result<Cookie<'_, Self, GetSelectionUseContextReply>, ConnectionError>
2385     {
2386         get_selection_use_context(self)
2387     }
xselinux_get_selection_context(&self, selection: xproto::Atom) -> Result<Cookie<'_, Self, GetSelectionContextReply>, ConnectionError>2388     fn xselinux_get_selection_context(&self, selection: xproto::Atom) -> Result<Cookie<'_, Self, GetSelectionContextReply>, ConnectionError>
2389     {
2390         get_selection_context(self, selection)
2391     }
xselinux_get_selection_data_context(&self, selection: xproto::Atom) -> Result<Cookie<'_, Self, GetSelectionDataContextReply>, ConnectionError>2392     fn xselinux_get_selection_data_context(&self, selection: xproto::Atom) -> Result<Cookie<'_, Self, GetSelectionDataContextReply>, ConnectionError>
2393     {
2394         get_selection_data_context(self, selection)
2395     }
xselinux_list_selections(&self) -> Result<Cookie<'_, Self, ListSelectionsReply>, ConnectionError>2396     fn xselinux_list_selections(&self) -> Result<Cookie<'_, Self, ListSelectionsReply>, ConnectionError>
2397     {
2398         list_selections(self)
2399     }
xselinux_get_client_context(&self, resource: u32) -> Result<Cookie<'_, Self, GetClientContextReply>, ConnectionError>2400     fn xselinux_get_client_context(&self, resource: u32) -> Result<Cookie<'_, Self, GetClientContextReply>, ConnectionError>
2401     {
2402         get_client_context(self, resource)
2403     }
2404 }
2405 
2406 impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
2407