1 // This file contains generated code. Do not edit directly.
2 // To regenerate this, run 'make'.
3 
4 //! Bindings to the `Res` 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 = "X-Resource";
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, 2);
34 
35 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
36 pub struct Client {
37     pub resource_base: u32,
38     pub resource_mask: u32,
39 }
40 impl TryParse for Client {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>41     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
42         let (resource_base, remaining) = u32::try_parse(remaining)?;
43         let (resource_mask, remaining) = u32::try_parse(remaining)?;
44         let result = Client { resource_base, resource_mask };
45         Ok((result, remaining))
46     }
47 }
48 impl Serialize for Client {
49     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]50     fn serialize(&self) -> [u8; 8] {
51         let resource_base_bytes = self.resource_base.serialize();
52         let resource_mask_bytes = self.resource_mask.serialize();
53         [
54             resource_base_bytes[0],
55             resource_base_bytes[1],
56             resource_base_bytes[2],
57             resource_base_bytes[3],
58             resource_mask_bytes[0],
59             resource_mask_bytes[1],
60             resource_mask_bytes[2],
61             resource_mask_bytes[3],
62         ]
63     }
serialize_into(&self, bytes: &mut Vec<u8>)64     fn serialize_into(&self, bytes: &mut Vec<u8>) {
65         bytes.reserve(8);
66         self.resource_base.serialize_into(bytes);
67         self.resource_mask.serialize_into(bytes);
68     }
69 }
70 
71 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
72 pub struct Type {
73     pub resource_type: xproto::Atom,
74     pub count: u32,
75 }
76 impl TryParse for Type {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>77     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
78         let (resource_type, remaining) = xproto::Atom::try_parse(remaining)?;
79         let (count, remaining) = u32::try_parse(remaining)?;
80         let result = Type { resource_type, count };
81         Ok((result, remaining))
82     }
83 }
84 impl Serialize for Type {
85     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]86     fn serialize(&self) -> [u8; 8] {
87         let resource_type_bytes = self.resource_type.serialize();
88         let count_bytes = self.count.serialize();
89         [
90             resource_type_bytes[0],
91             resource_type_bytes[1],
92             resource_type_bytes[2],
93             resource_type_bytes[3],
94             count_bytes[0],
95             count_bytes[1],
96             count_bytes[2],
97             count_bytes[3],
98         ]
99     }
serialize_into(&self, bytes: &mut Vec<u8>)100     fn serialize_into(&self, bytes: &mut Vec<u8>) {
101         bytes.reserve(8);
102         self.resource_type.serialize_into(bytes);
103         self.count.serialize_into(bytes);
104     }
105 }
106 
107 #[derive(Clone, Copy, PartialEq, Eq)]
108 pub struct ClientIdMask(u8);
109 impl ClientIdMask {
110     pub const CLIENT_XID: Self = Self(1 << 0);
111     pub const LOCAL_CLIENT_PID: Self = Self(1 << 1);
112 }
113 impl From<ClientIdMask> for u8 {
114     #[inline]
from(input: ClientIdMask) -> Self115     fn from(input: ClientIdMask) -> Self {
116         input.0
117     }
118 }
119 impl From<ClientIdMask> for Option<u8> {
120     #[inline]
from(input: ClientIdMask) -> Self121     fn from(input: ClientIdMask) -> Self {
122         Some(input.0)
123     }
124 }
125 impl From<ClientIdMask> for u16 {
126     #[inline]
from(input: ClientIdMask) -> Self127     fn from(input: ClientIdMask) -> Self {
128         u16::from(input.0)
129     }
130 }
131 impl From<ClientIdMask> for Option<u16> {
132     #[inline]
from(input: ClientIdMask) -> Self133     fn from(input: ClientIdMask) -> Self {
134         Some(u16::from(input.0))
135     }
136 }
137 impl From<ClientIdMask> for u32 {
138     #[inline]
from(input: ClientIdMask) -> Self139     fn from(input: ClientIdMask) -> Self {
140         u32::from(input.0)
141     }
142 }
143 impl From<ClientIdMask> for Option<u32> {
144     #[inline]
from(input: ClientIdMask) -> Self145     fn from(input: ClientIdMask) -> Self {
146         Some(u32::from(input.0))
147     }
148 }
149 impl From<u8> for ClientIdMask {
150     #[inline]
from(value: u8) -> Self151     fn from(value: u8) -> Self {
152         Self(value)
153     }
154 }
155 impl std::fmt::Debug for ClientIdMask  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result156     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
157         let variants = [
158             (Self::CLIENT_XID.0.into(), "CLIENT_XID", "ClientXID"),
159             (Self::LOCAL_CLIENT_PID.0.into(), "LOCAL_CLIENT_PID", "LocalClientPID"),
160         ];
161         pretty_print_bitmask(fmt, self.0.into(), &variants)
162     }
163 }
164 bitmask_binop!(ClientIdMask, u8);
165 
166 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
167 pub struct ClientIdSpec {
168     pub client: u32,
169     pub mask: u32,
170 }
171 impl TryParse for ClientIdSpec {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>172     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
173         let (client, remaining) = u32::try_parse(remaining)?;
174         let (mask, remaining) = u32::try_parse(remaining)?;
175         let result = ClientIdSpec { client, mask };
176         Ok((result, remaining))
177     }
178 }
179 impl Serialize for ClientIdSpec {
180     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]181     fn serialize(&self) -> [u8; 8] {
182         let client_bytes = self.client.serialize();
183         let mask_bytes = self.mask.serialize();
184         [
185             client_bytes[0],
186             client_bytes[1],
187             client_bytes[2],
188             client_bytes[3],
189             mask_bytes[0],
190             mask_bytes[1],
191             mask_bytes[2],
192             mask_bytes[3],
193         ]
194     }
serialize_into(&self, bytes: &mut Vec<u8>)195     fn serialize_into(&self, bytes: &mut Vec<u8>) {
196         bytes.reserve(8);
197         self.client.serialize_into(bytes);
198         self.mask.serialize_into(bytes);
199     }
200 }
201 
202 #[derive(Debug, Clone, PartialEq, Eq)]
203 pub struct ClientIdValue {
204     pub spec: ClientIdSpec,
205     pub value: Vec<u32>,
206 }
207 impl TryParse for ClientIdValue {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>208     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
209         let (spec, remaining) = ClientIdSpec::try_parse(remaining)?;
210         let (length, remaining) = u32::try_parse(remaining)?;
211         let (value, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.checked_div(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
212         let result = ClientIdValue { spec, value };
213         Ok((result, remaining))
214     }
215 }
216 impl Serialize for ClientIdValue {
217     type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>218     fn serialize(&self) -> Vec<u8> {
219         let mut result = Vec::new();
220         self.serialize_into(&mut result);
221         result
222     }
serialize_into(&self, bytes: &mut Vec<u8>)223     fn serialize_into(&self, bytes: &mut Vec<u8>) {
224         bytes.reserve(12);
225         self.spec.serialize_into(bytes);
226         let length = u32::try_from(self.value.len()).ok().and_then(|len| len.checked_mul(4)).expect("`value` has too many elements");
227         length.serialize_into(bytes);
228         self.value.serialize_into(bytes);
229     }
230 }
231 impl ClientIdValue {
232     /// Get the value of the `length` field.
233     ///
234     /// The `length` field is used as the length field of the `value` field.
235     /// This function computes the field's value again based on the length of the list.
236     ///
237     /// # Panics
238     ///
239     /// Panics if the value cannot be represented in the target type. This
240     /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u32241     pub fn length(&self) -> u32 {
242         self.value.len()
243             .checked_mul(4).unwrap()
244             .try_into().unwrap()
245     }
246 }
247 
248 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
249 pub struct ResourceIdSpec {
250     pub resource: u32,
251     pub type_: u32,
252 }
253 impl TryParse for ResourceIdSpec {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>254     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
255         let (resource, remaining) = u32::try_parse(remaining)?;
256         let (type_, remaining) = u32::try_parse(remaining)?;
257         let result = ResourceIdSpec { resource, type_ };
258         Ok((result, remaining))
259     }
260 }
261 impl Serialize for ResourceIdSpec {
262     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]263     fn serialize(&self) -> [u8; 8] {
264         let resource_bytes = self.resource.serialize();
265         let type_bytes = self.type_.serialize();
266         [
267             resource_bytes[0],
268             resource_bytes[1],
269             resource_bytes[2],
270             resource_bytes[3],
271             type_bytes[0],
272             type_bytes[1],
273             type_bytes[2],
274             type_bytes[3],
275         ]
276     }
serialize_into(&self, bytes: &mut Vec<u8>)277     fn serialize_into(&self, bytes: &mut Vec<u8>) {
278         bytes.reserve(8);
279         self.resource.serialize_into(bytes);
280         self.type_.serialize_into(bytes);
281     }
282 }
283 
284 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
285 pub struct ResourceSizeSpec {
286     pub spec: ResourceIdSpec,
287     pub bytes: u32,
288     pub ref_count: u32,
289     pub use_count: u32,
290 }
291 impl TryParse for ResourceSizeSpec {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>292     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
293         let (spec, remaining) = ResourceIdSpec::try_parse(remaining)?;
294         let (bytes, remaining) = u32::try_parse(remaining)?;
295         let (ref_count, remaining) = u32::try_parse(remaining)?;
296         let (use_count, remaining) = u32::try_parse(remaining)?;
297         let result = ResourceSizeSpec { spec, bytes, ref_count, use_count };
298         Ok((result, remaining))
299     }
300 }
301 impl Serialize for ResourceSizeSpec {
302     type Bytes = [u8; 20];
serialize(&self) -> [u8; 20]303     fn serialize(&self) -> [u8; 20] {
304         let spec_bytes = self.spec.serialize();
305         let bytes_bytes = self.bytes.serialize();
306         let ref_count_bytes = self.ref_count.serialize();
307         let use_count_bytes = self.use_count.serialize();
308         [
309             spec_bytes[0],
310             spec_bytes[1],
311             spec_bytes[2],
312             spec_bytes[3],
313             spec_bytes[4],
314             spec_bytes[5],
315             spec_bytes[6],
316             spec_bytes[7],
317             bytes_bytes[0],
318             bytes_bytes[1],
319             bytes_bytes[2],
320             bytes_bytes[3],
321             ref_count_bytes[0],
322             ref_count_bytes[1],
323             ref_count_bytes[2],
324             ref_count_bytes[3],
325             use_count_bytes[0],
326             use_count_bytes[1],
327             use_count_bytes[2],
328             use_count_bytes[3],
329         ]
330     }
serialize_into(&self, bytes: &mut Vec<u8>)331     fn serialize_into(&self, bytes: &mut Vec<u8>) {
332         bytes.reserve(20);
333         self.spec.serialize_into(bytes);
334         self.bytes.serialize_into(bytes);
335         self.ref_count.serialize_into(bytes);
336         self.use_count.serialize_into(bytes);
337     }
338 }
339 
340 #[derive(Debug, Clone, PartialEq, Eq)]
341 pub struct ResourceSizeValue {
342     pub size: ResourceSizeSpec,
343     pub cross_references: Vec<ResourceSizeSpec>,
344 }
345 impl TryParse for ResourceSizeValue {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>346     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
347         let (size, remaining) = ResourceSizeSpec::try_parse(remaining)?;
348         let (num_cross_references, remaining) = u32::try_parse(remaining)?;
349         let (cross_references, remaining) = crate::x11_utils::parse_list::<ResourceSizeSpec>(remaining, num_cross_references.try_to_usize()?)?;
350         let result = ResourceSizeValue { size, cross_references };
351         Ok((result, remaining))
352     }
353 }
354 impl Serialize for ResourceSizeValue {
355     type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>356     fn serialize(&self) -> Vec<u8> {
357         let mut result = Vec::new();
358         self.serialize_into(&mut result);
359         result
360     }
serialize_into(&self, bytes: &mut Vec<u8>)361     fn serialize_into(&self, bytes: &mut Vec<u8>) {
362         bytes.reserve(24);
363         self.size.serialize_into(bytes);
364         let num_cross_references = u32::try_from(self.cross_references.len()).expect("`cross_references` has too many elements");
365         num_cross_references.serialize_into(bytes);
366         self.cross_references.serialize_into(bytes);
367     }
368 }
369 impl ResourceSizeValue {
370     /// Get the value of the `num_cross_references` field.
371     ///
372     /// The `num_cross_references` field is used as the length field of the `cross_references` field.
373     /// This function computes the field's value again based on the length of the list.
374     ///
375     /// # Panics
376     ///
377     /// Panics if the value cannot be represented in the target type. This
378     /// cannot happen with values of the struct received from the X11 server.
num_cross_references(&self) -> u32379     pub fn num_cross_references(&self) -> u32 {
380         self.cross_references.len()
381             .try_into().unwrap()
382     }
383 }
384 
385 /// Opcode for the QueryVersion request
386 pub const QUERY_VERSION_REQUEST: u8 = 0;
387 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
388 pub struct QueryVersionRequest {
389     pub client_major: u8,
390     pub client_minor: u8,
391 }
392 impl QueryVersionRequest {
393     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,394     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
395     where
396         Conn: RequestConnection + ?Sized,
397     {
398         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
399             .ok_or(ConnectionError::UnsupportedExtension)?;
400         let length_so_far = 0;
401         let client_major_bytes = self.client_major.serialize();
402         let client_minor_bytes = self.client_minor.serialize();
403         let mut request0 = vec![
404             extension_information.major_opcode,
405             QUERY_VERSION_REQUEST,
406             0,
407             0,
408             client_major_bytes[0],
409             client_minor_bytes[0],
410             0,
411             0,
412         ];
413         let length_so_far = length_so_far + request0.len();
414         assert_eq!(length_so_far % 4, 0);
415         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
416         request0[2..4].copy_from_slice(&length.to_ne_bytes());
417         Ok((vec![request0.into()], vec![]))
418     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,419     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
420     where
421         Conn: RequestConnection + ?Sized,
422     {
423         let (bytes, fds) = self.serialize(conn)?;
424         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
425         conn.send_request_with_reply(&slices, fds)
426     }
427     /// 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>428     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
429         if header.minor_opcode != QUERY_VERSION_REQUEST {
430             return Err(ParseError::InvalidValue);
431         }
432         let (client_major, remaining) = u8::try_parse(value)?;
433         let (client_minor, remaining) = u8::try_parse(remaining)?;
434         let _ = remaining;
435         Ok(QueryVersionRequest {
436             client_major,
437             client_minor,
438         })
439     }
440 }
441 impl Request for QueryVersionRequest {
442     type Reply = QueryVersionReply;
443 }
query_version<Conn>(conn: &Conn, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,444 pub fn query_version<Conn>(conn: &Conn, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
445 where
446     Conn: RequestConnection + ?Sized,
447 {
448     let request0 = QueryVersionRequest {
449         client_major,
450         client_minor,
451     };
452     request0.send(conn)
453 }
454 
455 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
456 pub struct QueryVersionReply {
457     pub sequence: u16,
458     pub length: u32,
459     pub server_major: u16,
460     pub server_minor: u16,
461 }
462 impl TryParse for QueryVersionReply {
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 (server_major, remaining) = u16::try_parse(remaining)?;
470         let (server_minor, remaining) = u16::try_parse(remaining)?;
471         if response_type != 1 {
472             return Err(ParseError::InvalidValue);
473         }
474         let result = QueryVersionReply { sequence, length, server_major, server_minor };
475         let _ = remaining;
476         let remaining = initial_value.get(32 + length as usize * 4..)
477             .ok_or(ParseError::InsufficientData)?;
478         Ok((result, remaining))
479     }
480 }
481 
482 /// Opcode for the QueryClients request
483 pub const QUERY_CLIENTS_REQUEST: u8 = 1;
484 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
485 pub struct QueryClientsRequest;
486 impl QueryClientsRequest {
487     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,488     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
489     where
490         Conn: RequestConnection + ?Sized,
491     {
492         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
493             .ok_or(ConnectionError::UnsupportedExtension)?;
494         let length_so_far = 0;
495         let mut request0 = vec![
496             extension_information.major_opcode,
497             QUERY_CLIENTS_REQUEST,
498             0,
499             0,
500         ];
501         let length_so_far = length_so_far + request0.len();
502         assert_eq!(length_so_far % 4, 0);
503         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
504         request0[2..4].copy_from_slice(&length.to_ne_bytes());
505         Ok((vec![request0.into()], vec![]))
506     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,507     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientsReply>, ConnectionError>
508     where
509         Conn: RequestConnection + ?Sized,
510     {
511         let (bytes, fds) = self.serialize(conn)?;
512         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
513         conn.send_request_with_reply(&slices, fds)
514     }
515     /// 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>516     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
517         if header.minor_opcode != QUERY_CLIENTS_REQUEST {
518             return Err(ParseError::InvalidValue);
519         }
520         let _ = value;
521         Ok(QueryClientsRequest
522         )
523     }
524 }
525 impl Request for QueryClientsRequest {
526     type Reply = QueryClientsReply;
527 }
query_clients<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,528 pub fn query_clients<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientsReply>, ConnectionError>
529 where
530     Conn: RequestConnection + ?Sized,
531 {
532     let request0 = QueryClientsRequest;
533     request0.send(conn)
534 }
535 
536 #[derive(Debug, Clone, PartialEq, Eq)]
537 pub struct QueryClientsReply {
538     pub sequence: u16,
539     pub length: u32,
540     pub clients: Vec<Client>,
541 }
542 impl TryParse for QueryClientsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>543     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
544         let remaining = initial_value;
545         let (response_type, remaining) = u8::try_parse(remaining)?;
546         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
547         let (sequence, remaining) = u16::try_parse(remaining)?;
548         let (length, remaining) = u32::try_parse(remaining)?;
549         let (num_clients, remaining) = u32::try_parse(remaining)?;
550         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
551         let (clients, remaining) = crate::x11_utils::parse_list::<Client>(remaining, num_clients.try_to_usize()?)?;
552         if response_type != 1 {
553             return Err(ParseError::InvalidValue);
554         }
555         let result = QueryClientsReply { sequence, length, clients };
556         let _ = remaining;
557         let remaining = initial_value.get(32 + length as usize * 4..)
558             .ok_or(ParseError::InsufficientData)?;
559         Ok((result, remaining))
560     }
561 }
562 impl QueryClientsReply {
563     /// Get the value of the `num_clients` field.
564     ///
565     /// The `num_clients` field is used as the length field of the `clients` field.
566     /// This function computes the field's value again based on the length of the list.
567     ///
568     /// # Panics
569     ///
570     /// Panics if the value cannot be represented in the target type. This
571     /// cannot happen with values of the struct received from the X11 server.
num_clients(&self) -> u32572     pub fn num_clients(&self) -> u32 {
573         self.clients.len()
574             .try_into().unwrap()
575     }
576 }
577 
578 /// Opcode for the QueryClientResources request
579 pub const QUERY_CLIENT_RESOURCES_REQUEST: u8 = 2;
580 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
581 pub struct QueryClientResourcesRequest {
582     pub xid: u32,
583 }
584 impl QueryClientResourcesRequest {
585     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,586     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
587     where
588         Conn: RequestConnection + ?Sized,
589     {
590         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
591             .ok_or(ConnectionError::UnsupportedExtension)?;
592         let length_so_far = 0;
593         let xid_bytes = self.xid.serialize();
594         let mut request0 = vec![
595             extension_information.major_opcode,
596             QUERY_CLIENT_RESOURCES_REQUEST,
597             0,
598             0,
599             xid_bytes[0],
600             xid_bytes[1],
601             xid_bytes[2],
602             xid_bytes[3],
603         ];
604         let length_so_far = length_so_far + request0.len();
605         assert_eq!(length_so_far % 4, 0);
606         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
607         request0[2..4].copy_from_slice(&length.to_ne_bytes());
608         Ok((vec![request0.into()], vec![]))
609     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientResourcesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,610     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientResourcesReply>, ConnectionError>
611     where
612         Conn: RequestConnection + ?Sized,
613     {
614         let (bytes, fds) = self.serialize(conn)?;
615         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
616         conn.send_request_with_reply(&slices, fds)
617     }
618     /// 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>619     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
620         if header.minor_opcode != QUERY_CLIENT_RESOURCES_REQUEST {
621             return Err(ParseError::InvalidValue);
622         }
623         let (xid, remaining) = u32::try_parse(value)?;
624         let _ = remaining;
625         Ok(QueryClientResourcesRequest {
626             xid,
627         })
628     }
629 }
630 impl Request for QueryClientResourcesRequest {
631     type Reply = QueryClientResourcesReply;
632 }
query_client_resources<Conn>(conn: &Conn, xid: u32) -> Result<Cookie<'_, Conn, QueryClientResourcesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,633 pub fn query_client_resources<Conn>(conn: &Conn, xid: u32) -> Result<Cookie<'_, Conn, QueryClientResourcesReply>, ConnectionError>
634 where
635     Conn: RequestConnection + ?Sized,
636 {
637     let request0 = QueryClientResourcesRequest {
638         xid,
639     };
640     request0.send(conn)
641 }
642 
643 #[derive(Debug, Clone, PartialEq, Eq)]
644 pub struct QueryClientResourcesReply {
645     pub sequence: u16,
646     pub length: u32,
647     pub types: Vec<Type>,
648 }
649 impl TryParse for QueryClientResourcesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>650     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
651         let remaining = initial_value;
652         let (response_type, remaining) = u8::try_parse(remaining)?;
653         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
654         let (sequence, remaining) = u16::try_parse(remaining)?;
655         let (length, remaining) = u32::try_parse(remaining)?;
656         let (num_types, remaining) = u32::try_parse(remaining)?;
657         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
658         let (types, remaining) = crate::x11_utils::parse_list::<Type>(remaining, num_types.try_to_usize()?)?;
659         if response_type != 1 {
660             return Err(ParseError::InvalidValue);
661         }
662         let result = QueryClientResourcesReply { sequence, length, types };
663         let _ = remaining;
664         let remaining = initial_value.get(32 + length as usize * 4..)
665             .ok_or(ParseError::InsufficientData)?;
666         Ok((result, remaining))
667     }
668 }
669 impl QueryClientResourcesReply {
670     /// Get the value of the `num_types` field.
671     ///
672     /// The `num_types` field is used as the length field of the `types` field.
673     /// This function computes the field's value again based on the length of the list.
674     ///
675     /// # Panics
676     ///
677     /// Panics if the value cannot be represented in the target type. This
678     /// cannot happen with values of the struct received from the X11 server.
num_types(&self) -> u32679     pub fn num_types(&self) -> u32 {
680         self.types.len()
681             .try_into().unwrap()
682     }
683 }
684 
685 /// Opcode for the QueryClientPixmapBytes request
686 pub const QUERY_CLIENT_PIXMAP_BYTES_REQUEST: u8 = 3;
687 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
688 pub struct QueryClientPixmapBytesRequest {
689     pub xid: u32,
690 }
691 impl QueryClientPixmapBytesRequest {
692     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,693     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
694     where
695         Conn: RequestConnection + ?Sized,
696     {
697         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
698             .ok_or(ConnectionError::UnsupportedExtension)?;
699         let length_so_far = 0;
700         let xid_bytes = self.xid.serialize();
701         let mut request0 = vec![
702             extension_information.major_opcode,
703             QUERY_CLIENT_PIXMAP_BYTES_REQUEST,
704             0,
705             0,
706             xid_bytes[0],
707             xid_bytes[1],
708             xid_bytes[2],
709             xid_bytes[3],
710         ];
711         let length_so_far = length_so_far + request0.len();
712         assert_eq!(length_so_far % 4, 0);
713         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
714         request0[2..4].copy_from_slice(&length.to_ne_bytes());
715         Ok((vec![request0.into()], vec![]))
716     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientPixmapBytesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,717     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientPixmapBytesReply>, ConnectionError>
718     where
719         Conn: RequestConnection + ?Sized,
720     {
721         let (bytes, fds) = self.serialize(conn)?;
722         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
723         conn.send_request_with_reply(&slices, fds)
724     }
725     /// 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>726     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
727         if header.minor_opcode != QUERY_CLIENT_PIXMAP_BYTES_REQUEST {
728             return Err(ParseError::InvalidValue);
729         }
730         let (xid, remaining) = u32::try_parse(value)?;
731         let _ = remaining;
732         Ok(QueryClientPixmapBytesRequest {
733             xid,
734         })
735     }
736 }
737 impl Request for QueryClientPixmapBytesRequest {
738     type Reply = QueryClientPixmapBytesReply;
739 }
query_client_pixmap_bytes<Conn>(conn: &Conn, xid: u32) -> Result<Cookie<'_, Conn, QueryClientPixmapBytesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,740 pub fn query_client_pixmap_bytes<Conn>(conn: &Conn, xid: u32) -> Result<Cookie<'_, Conn, QueryClientPixmapBytesReply>, ConnectionError>
741 where
742     Conn: RequestConnection + ?Sized,
743 {
744     let request0 = QueryClientPixmapBytesRequest {
745         xid,
746     };
747     request0.send(conn)
748 }
749 
750 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
751 pub struct QueryClientPixmapBytesReply {
752     pub sequence: u16,
753     pub length: u32,
754     pub bytes: u32,
755     pub bytes_overflow: u32,
756 }
757 impl TryParse for QueryClientPixmapBytesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>758     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
759         let remaining = initial_value;
760         let (response_type, remaining) = u8::try_parse(remaining)?;
761         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
762         let (sequence, remaining) = u16::try_parse(remaining)?;
763         let (length, remaining) = u32::try_parse(remaining)?;
764         let (bytes, remaining) = u32::try_parse(remaining)?;
765         let (bytes_overflow, remaining) = u32::try_parse(remaining)?;
766         if response_type != 1 {
767             return Err(ParseError::InvalidValue);
768         }
769         let result = QueryClientPixmapBytesReply { sequence, length, bytes, bytes_overflow };
770         let _ = remaining;
771         let remaining = initial_value.get(32 + length as usize * 4..)
772             .ok_or(ParseError::InsufficientData)?;
773         Ok((result, remaining))
774     }
775 }
776 
777 /// Opcode for the QueryClientIds request
778 pub const QUERY_CLIENT_IDS_REQUEST: u8 = 4;
779 #[derive(Debug, Clone, PartialEq, Eq)]
780 pub struct QueryClientIdsRequest<'input> {
781     pub specs: Cow<'input, [ClientIdSpec]>,
782 }
783 impl<'input> QueryClientIdsRequest<'input> {
784     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,785     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
786     where
787         Conn: RequestConnection + ?Sized,
788     {
789         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
790             .ok_or(ConnectionError::UnsupportedExtension)?;
791         let length_so_far = 0;
792         let num_specs = u32::try_from(self.specs.len()).expect("`specs` has too many elements");
793         let num_specs_bytes = num_specs.serialize();
794         let mut request0 = vec![
795             extension_information.major_opcode,
796             QUERY_CLIENT_IDS_REQUEST,
797             0,
798             0,
799             num_specs_bytes[0],
800             num_specs_bytes[1],
801             num_specs_bytes[2],
802             num_specs_bytes[3],
803         ];
804         let length_so_far = length_so_far + request0.len();
805         let specs_bytes = self.specs.serialize();
806         let length_so_far = length_so_far + specs_bytes.len();
807         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
808         let length_so_far = length_so_far + padding0.len();
809         assert_eq!(length_so_far % 4, 0);
810         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
811         request0[2..4].copy_from_slice(&length.to_ne_bytes());
812         Ok((vec![request0.into(), specs_bytes.into(), padding0.into()], vec![]))
813     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientIdsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,814     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryClientIdsReply>, ConnectionError>
815     where
816         Conn: RequestConnection + ?Sized,
817     {
818         let (bytes, fds) = self.serialize(conn)?;
819         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
820         conn.send_request_with_reply(&slices, fds)
821     }
822     /// 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>823     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
824         if header.minor_opcode != QUERY_CLIENT_IDS_REQUEST {
825             return Err(ParseError::InvalidValue);
826         }
827         let (num_specs, remaining) = u32::try_parse(value)?;
828         let (specs, remaining) = crate::x11_utils::parse_list::<ClientIdSpec>(remaining, num_specs.try_to_usize()?)?;
829         let _ = remaining;
830         Ok(QueryClientIdsRequest {
831             specs: Cow::Owned(specs),
832         })
833     }
834     /// Clone all borrowed data in this QueryClientIdsRequest.
into_owned(self) -> QueryClientIdsRequest<'static>835     pub fn into_owned(self) -> QueryClientIdsRequest<'static> {
836         QueryClientIdsRequest {
837             specs: Cow::Owned(self.specs.into_owned()),
838         }
839     }
840 }
841 impl<'input> Request for QueryClientIdsRequest<'input> {
842     type Reply = QueryClientIdsReply;
843 }
query_client_ids<'c, 'input, Conn>(conn: &'c Conn, specs: &'input [ClientIdSpec]) -> Result<Cookie<'c, Conn, QueryClientIdsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,844 pub fn query_client_ids<'c, 'input, Conn>(conn: &'c Conn, specs: &'input [ClientIdSpec]) -> Result<Cookie<'c, Conn, QueryClientIdsReply>, ConnectionError>
845 where
846     Conn: RequestConnection + ?Sized,
847 {
848     let request0 = QueryClientIdsRequest {
849         specs: Cow::Borrowed(specs),
850     };
851     request0.send(conn)
852 }
853 
854 #[derive(Debug, Clone, PartialEq, Eq)]
855 pub struct QueryClientIdsReply {
856     pub sequence: u16,
857     pub length: u32,
858     pub ids: Vec<ClientIdValue>,
859 }
860 impl TryParse for QueryClientIdsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>861     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
862         let remaining = initial_value;
863         let (response_type, remaining) = u8::try_parse(remaining)?;
864         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
865         let (sequence, remaining) = u16::try_parse(remaining)?;
866         let (length, remaining) = u32::try_parse(remaining)?;
867         let (num_ids, remaining) = u32::try_parse(remaining)?;
868         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
869         let (ids, remaining) = crate::x11_utils::parse_list::<ClientIdValue>(remaining, num_ids.try_to_usize()?)?;
870         if response_type != 1 {
871             return Err(ParseError::InvalidValue);
872         }
873         let result = QueryClientIdsReply { sequence, length, ids };
874         let _ = remaining;
875         let remaining = initial_value.get(32 + length as usize * 4..)
876             .ok_or(ParseError::InsufficientData)?;
877         Ok((result, remaining))
878     }
879 }
880 impl QueryClientIdsReply {
881     /// Get the value of the `num_ids` field.
882     ///
883     /// The `num_ids` field is used as the length field of the `ids` field.
884     /// This function computes the field's value again based on the length of the list.
885     ///
886     /// # Panics
887     ///
888     /// Panics if the value cannot be represented in the target type. This
889     /// cannot happen with values of the struct received from the X11 server.
num_ids(&self) -> u32890     pub fn num_ids(&self) -> u32 {
891         self.ids.len()
892             .try_into().unwrap()
893     }
894 }
895 
896 /// Opcode for the QueryResourceBytes request
897 pub const QUERY_RESOURCE_BYTES_REQUEST: u8 = 5;
898 #[derive(Debug, Clone, PartialEq, Eq)]
899 pub struct QueryResourceBytesRequest<'input> {
900     pub client: u32,
901     pub specs: Cow<'input, [ResourceIdSpec]>,
902 }
903 impl<'input> QueryResourceBytesRequest<'input> {
904     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,905     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
906     where
907         Conn: RequestConnection + ?Sized,
908     {
909         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
910             .ok_or(ConnectionError::UnsupportedExtension)?;
911         let length_so_far = 0;
912         let client_bytes = self.client.serialize();
913         let num_specs = u32::try_from(self.specs.len()).expect("`specs` has too many elements");
914         let num_specs_bytes = num_specs.serialize();
915         let mut request0 = vec![
916             extension_information.major_opcode,
917             QUERY_RESOURCE_BYTES_REQUEST,
918             0,
919             0,
920             client_bytes[0],
921             client_bytes[1],
922             client_bytes[2],
923             client_bytes[3],
924             num_specs_bytes[0],
925             num_specs_bytes[1],
926             num_specs_bytes[2],
927             num_specs_bytes[3],
928         ];
929         let length_so_far = length_so_far + request0.len();
930         let specs_bytes = self.specs.serialize();
931         let length_so_far = length_so_far + specs_bytes.len();
932         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
933         let length_so_far = length_so_far + padding0.len();
934         assert_eq!(length_so_far % 4, 0);
935         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
936         request0[2..4].copy_from_slice(&length.to_ne_bytes());
937         Ok((vec![request0.into(), specs_bytes.into(), padding0.into()], vec![]))
938     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryResourceBytesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,939     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryResourceBytesReply>, ConnectionError>
940     where
941         Conn: RequestConnection + ?Sized,
942     {
943         let (bytes, fds) = self.serialize(conn)?;
944         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
945         conn.send_request_with_reply(&slices, fds)
946     }
947     /// 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>948     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
949         if header.minor_opcode != QUERY_RESOURCE_BYTES_REQUEST {
950             return Err(ParseError::InvalidValue);
951         }
952         let (client, remaining) = u32::try_parse(value)?;
953         let (num_specs, remaining) = u32::try_parse(remaining)?;
954         let (specs, remaining) = crate::x11_utils::parse_list::<ResourceIdSpec>(remaining, num_specs.try_to_usize()?)?;
955         let _ = remaining;
956         Ok(QueryResourceBytesRequest {
957             client,
958             specs: Cow::Owned(specs),
959         })
960     }
961     /// Clone all borrowed data in this QueryResourceBytesRequest.
into_owned(self) -> QueryResourceBytesRequest<'static>962     pub fn into_owned(self) -> QueryResourceBytesRequest<'static> {
963         QueryResourceBytesRequest {
964             client: self.client,
965             specs: Cow::Owned(self.specs.into_owned()),
966         }
967     }
968 }
969 impl<'input> Request for QueryResourceBytesRequest<'input> {
970     type Reply = QueryResourceBytesReply;
971 }
query_resource_bytes<'c, 'input, Conn>(conn: &'c Conn, client: u32, specs: &'input [ResourceIdSpec]) -> Result<Cookie<'c, Conn, QueryResourceBytesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,972 pub fn query_resource_bytes<'c, 'input, Conn>(conn: &'c Conn, client: u32, specs: &'input [ResourceIdSpec]) -> Result<Cookie<'c, Conn, QueryResourceBytesReply>, ConnectionError>
973 where
974     Conn: RequestConnection + ?Sized,
975 {
976     let request0 = QueryResourceBytesRequest {
977         client,
978         specs: Cow::Borrowed(specs),
979     };
980     request0.send(conn)
981 }
982 
983 #[derive(Debug, Clone, PartialEq, Eq)]
984 pub struct QueryResourceBytesReply {
985     pub sequence: u16,
986     pub length: u32,
987     pub sizes: Vec<ResourceSizeValue>,
988 }
989 impl TryParse for QueryResourceBytesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>990     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
991         let remaining = initial_value;
992         let (response_type, remaining) = u8::try_parse(remaining)?;
993         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
994         let (sequence, remaining) = u16::try_parse(remaining)?;
995         let (length, remaining) = u32::try_parse(remaining)?;
996         let (num_sizes, remaining) = u32::try_parse(remaining)?;
997         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
998         let (sizes, remaining) = crate::x11_utils::parse_list::<ResourceSizeValue>(remaining, num_sizes.try_to_usize()?)?;
999         if response_type != 1 {
1000             return Err(ParseError::InvalidValue);
1001         }
1002         let result = QueryResourceBytesReply { sequence, length, sizes };
1003         let _ = remaining;
1004         let remaining = initial_value.get(32 + length as usize * 4..)
1005             .ok_or(ParseError::InsufficientData)?;
1006         Ok((result, remaining))
1007     }
1008 }
1009 impl QueryResourceBytesReply {
1010     /// Get the value of the `num_sizes` field.
1011     ///
1012     /// The `num_sizes` field is used as the length field of the `sizes` field.
1013     /// This function computes the field's value again based on the length of the list.
1014     ///
1015     /// # Panics
1016     ///
1017     /// Panics if the value cannot be represented in the target type. This
1018     /// cannot happen with values of the struct received from the X11 server.
num_sizes(&self) -> u321019     pub fn num_sizes(&self) -> u32 {
1020         self.sizes.len()
1021             .try_into().unwrap()
1022     }
1023 }
1024 
1025 /// Extension trait defining the requests of this extension.
1026 pub trait ConnectionExt: RequestConnection {
res_query_version(&self, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>1027     fn res_query_version(&self, client_major: u8, client_minor: u8) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>
1028     {
1029         query_version(self, client_major, client_minor)
1030     }
res_query_clients(&self) -> Result<Cookie<'_, Self, QueryClientsReply>, ConnectionError>1031     fn res_query_clients(&self) -> Result<Cookie<'_, Self, QueryClientsReply>, ConnectionError>
1032     {
1033         query_clients(self)
1034     }
res_query_client_resources(&self, xid: u32) -> Result<Cookie<'_, Self, QueryClientResourcesReply>, ConnectionError>1035     fn res_query_client_resources(&self, xid: u32) -> Result<Cookie<'_, Self, QueryClientResourcesReply>, ConnectionError>
1036     {
1037         query_client_resources(self, xid)
1038     }
res_query_client_pixmap_bytes(&self, xid: u32) -> Result<Cookie<'_, Self, QueryClientPixmapBytesReply>, ConnectionError>1039     fn res_query_client_pixmap_bytes(&self, xid: u32) -> Result<Cookie<'_, Self, QueryClientPixmapBytesReply>, ConnectionError>
1040     {
1041         query_client_pixmap_bytes(self, xid)
1042     }
res_query_client_ids<'c, 'input>(&'c self, specs: &'input [ClientIdSpec]) -> Result<Cookie<'c, Self, QueryClientIdsReply>, ConnectionError>1043     fn res_query_client_ids<'c, 'input>(&'c self, specs: &'input [ClientIdSpec]) -> Result<Cookie<'c, Self, QueryClientIdsReply>, ConnectionError>
1044     {
1045         query_client_ids(self, specs)
1046     }
res_query_resource_bytes<'c, 'input>(&'c self, client: u32, specs: &'input [ResourceIdSpec]) -> Result<Cookie<'c, Self, QueryResourceBytesReply>, ConnectionError>1047     fn res_query_resource_bytes<'c, 'input>(&'c self, client: u32, specs: &'input [ResourceIdSpec]) -> Result<Cookie<'c, Self, QueryResourceBytesReply>, ConnectionError>
1048     {
1049         query_resource_bytes(self, client, specs)
1050     }
1051 }
1052 
1053 impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
1054