1 // This file contains generated code. Do not edit directly.
2 // To regenerate this, run 'make'.
3 
4 //! Bindings to the `XPrint` 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 = "XpExtension";
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 pub type String8 = u8;
36 
37 #[derive(Debug, Clone, PartialEq, Eq)]
38 pub struct Printer {
39     pub name: Vec<String8>,
40     pub description: Vec<String8>,
41 }
42 impl TryParse for Printer {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>43     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
44         let value = remaining;
45         let (name_len, remaining) = u32::try_parse(remaining)?;
46         let (name, remaining) = crate::x11_utils::parse_u8_list(remaining, name_len.try_to_usize()?)?;
47         let name = name.to_vec();
48         // Align offset to multiple of 4
49         let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
50         let misalignment = (4 - (offset % 4)) % 4;
51         let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
52         let (desc_len, remaining) = u32::try_parse(remaining)?;
53         let (description, remaining) = crate::x11_utils::parse_u8_list(remaining, desc_len.try_to_usize()?)?;
54         let description = description.to_vec();
55         // Align offset to multiple of 4
56         let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
57         let misalignment = (4 - (offset % 4)) % 4;
58         let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
59         let result = Printer { name, description };
60         Ok((result, remaining))
61     }
62 }
63 impl Serialize for Printer {
64     type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>65     fn serialize(&self) -> Vec<u8> {
66         let mut result = Vec::new();
67         self.serialize_into(&mut result);
68         result
69     }
serialize_into(&self, bytes: &mut Vec<u8>)70     fn serialize_into(&self, bytes: &mut Vec<u8>) {
71         let name_len = u32::try_from(self.name.len()).expect("`name` has too many elements");
72         name_len.serialize_into(bytes);
73         bytes.extend_from_slice(&self.name);
74         bytes.extend_from_slice(&[0; 3][..(4 - (bytes.len() % 4)) % 4]);
75         let desc_len = u32::try_from(self.description.len()).expect("`description` has too many elements");
76         desc_len.serialize_into(bytes);
77         bytes.extend_from_slice(&self.description);
78         bytes.extend_from_slice(&[0; 3][..(4 - (bytes.len() % 4)) % 4]);
79     }
80 }
81 impl Printer {
82     /// Get the value of the `nameLen` field.
83     ///
84     /// The `nameLen` field is used as the length field of the `name` field.
85     /// This function computes the field's value again based on the length of the list.
86     ///
87     /// # Panics
88     ///
89     /// Panics if the value cannot be represented in the target type. This
90     /// cannot happen with values of the struct received from the X11 server.
name_len(&self) -> u3291     pub fn name_len(&self) -> u32 {
92         self.name.len()
93             .try_into().unwrap()
94     }
95     /// Get the value of the `descLen` field.
96     ///
97     /// The `descLen` field is used as the length field of the `description` field.
98     /// This function computes the field's value again based on the length of the list.
99     ///
100     /// # Panics
101     ///
102     /// Panics if the value cannot be represented in the target type. This
103     /// cannot happen with values of the struct received from the X11 server.
desc_len(&self) -> u32104     pub fn desc_len(&self) -> u32 {
105         self.description.len()
106             .try_into().unwrap()
107     }
108 }
109 
110 pub type Pcontext = u32;
111 
112 #[derive(Clone, Copy, PartialEq, Eq)]
113 pub struct GetDoc(bool);
114 impl GetDoc {
115     pub const FINISHED: Self = Self(false);
116     pub const SECOND_CONSUMER: Self = Self(true);
117 }
118 impl From<GetDoc> for bool {
119     #[inline]
from(input: GetDoc) -> Self120     fn from(input: GetDoc) -> Self {
121         input.0
122     }
123 }
124 impl From<GetDoc> for Option<bool> {
125     #[inline]
from(input: GetDoc) -> Self126     fn from(input: GetDoc) -> Self {
127         Some(input.0)
128     }
129 }
130 impl From<GetDoc> for u8 {
131     #[inline]
from(input: GetDoc) -> Self132     fn from(input: GetDoc) -> Self {
133         u8::from(input.0)
134     }
135 }
136 impl From<GetDoc> for Option<u8> {
137     #[inline]
from(input: GetDoc) -> Self138     fn from(input: GetDoc) -> Self {
139         Some(u8::from(input.0))
140     }
141 }
142 impl From<GetDoc> for u16 {
143     #[inline]
from(input: GetDoc) -> Self144     fn from(input: GetDoc) -> Self {
145         u16::from(input.0)
146     }
147 }
148 impl From<GetDoc> for Option<u16> {
149     #[inline]
from(input: GetDoc) -> Self150     fn from(input: GetDoc) -> Self {
151         Some(u16::from(input.0))
152     }
153 }
154 impl From<GetDoc> for u32 {
155     #[inline]
from(input: GetDoc) -> Self156     fn from(input: GetDoc) -> Self {
157         u32::from(input.0)
158     }
159 }
160 impl From<GetDoc> for Option<u32> {
161     #[inline]
from(input: GetDoc) -> Self162     fn from(input: GetDoc) -> Self {
163         Some(u32::from(input.0))
164     }
165 }
166 impl From<bool> for GetDoc {
167     #[inline]
from(value: bool) -> Self168     fn from(value: bool) -> Self {
169         Self(value)
170     }
171 }
172 impl std::fmt::Debug for GetDoc  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result173     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
174         let variants = [
175             (Self::FINISHED.0.into(), "FINISHED", "Finished"),
176             (Self::SECOND_CONSUMER.0.into(), "SECOND_CONSUMER", "SecondConsumer"),
177         ];
178         pretty_print_enum(fmt, self.0.into(), &variants)
179     }
180 }
181 
182 #[derive(Clone, Copy, PartialEq, Eq)]
183 pub struct EvMask(u8);
184 impl EvMask {
185     pub const NO_EVENT_MASK: Self = Self(0);
186     pub const PRINT_MASK: Self = Self(1 << 0);
187     pub const ATTRIBUTE_MASK: Self = Self(1 << 1);
188 }
189 impl From<EvMask> for u8 {
190     #[inline]
from(input: EvMask) -> Self191     fn from(input: EvMask) -> Self {
192         input.0
193     }
194 }
195 impl From<EvMask> for Option<u8> {
196     #[inline]
from(input: EvMask) -> Self197     fn from(input: EvMask) -> Self {
198         Some(input.0)
199     }
200 }
201 impl From<EvMask> for u16 {
202     #[inline]
from(input: EvMask) -> Self203     fn from(input: EvMask) -> Self {
204         u16::from(input.0)
205     }
206 }
207 impl From<EvMask> for Option<u16> {
208     #[inline]
from(input: EvMask) -> Self209     fn from(input: EvMask) -> Self {
210         Some(u16::from(input.0))
211     }
212 }
213 impl From<EvMask> for u32 {
214     #[inline]
from(input: EvMask) -> Self215     fn from(input: EvMask) -> Self {
216         u32::from(input.0)
217     }
218 }
219 impl From<EvMask> for Option<u32> {
220     #[inline]
from(input: EvMask) -> Self221     fn from(input: EvMask) -> Self {
222         Some(u32::from(input.0))
223     }
224 }
225 impl From<u8> for EvMask {
226     #[inline]
from(value: u8) -> Self227     fn from(value: u8) -> Self {
228         Self(value)
229     }
230 }
231 impl std::fmt::Debug for EvMask  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result232     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
233         let variants = [
234             (Self::NO_EVENT_MASK.0.into(), "NO_EVENT_MASK", "NoEventMask"),
235             (Self::PRINT_MASK.0.into(), "PRINT_MASK", "PrintMask"),
236             (Self::ATTRIBUTE_MASK.0.into(), "ATTRIBUTE_MASK", "AttributeMask"),
237         ];
238         pretty_print_bitmask(fmt, self.0.into(), &variants)
239     }
240 }
241 bitmask_binop!(EvMask, u8);
242 
243 #[derive(Clone, Copy, PartialEq, Eq)]
244 pub struct Detail(u8);
245 impl Detail {
246     pub const START_JOB_NOTIFY: Self = Self(1);
247     pub const END_JOB_NOTIFY: Self = Self(2);
248     pub const START_DOC_NOTIFY: Self = Self(3);
249     pub const END_DOC_NOTIFY: Self = Self(4);
250     pub const START_PAGE_NOTIFY: Self = Self(5);
251     pub const END_PAGE_NOTIFY: Self = Self(6);
252 }
253 impl From<Detail> for u8 {
254     #[inline]
from(input: Detail) -> Self255     fn from(input: Detail) -> Self {
256         input.0
257     }
258 }
259 impl From<Detail> for Option<u8> {
260     #[inline]
from(input: Detail) -> Self261     fn from(input: Detail) -> Self {
262         Some(input.0)
263     }
264 }
265 impl From<Detail> for u16 {
266     #[inline]
from(input: Detail) -> Self267     fn from(input: Detail) -> Self {
268         u16::from(input.0)
269     }
270 }
271 impl From<Detail> for Option<u16> {
272     #[inline]
from(input: Detail) -> Self273     fn from(input: Detail) -> Self {
274         Some(u16::from(input.0))
275     }
276 }
277 impl From<Detail> for u32 {
278     #[inline]
from(input: Detail) -> Self279     fn from(input: Detail) -> Self {
280         u32::from(input.0)
281     }
282 }
283 impl From<Detail> for Option<u32> {
284     #[inline]
from(input: Detail) -> Self285     fn from(input: Detail) -> Self {
286         Some(u32::from(input.0))
287     }
288 }
289 impl From<u8> for Detail {
290     #[inline]
from(value: u8) -> Self291     fn from(value: u8) -> Self {
292         Self(value)
293     }
294 }
295 impl std::fmt::Debug for Detail  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result296     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
297         let variants = [
298             (Self::START_JOB_NOTIFY.0.into(), "START_JOB_NOTIFY", "StartJobNotify"),
299             (Self::END_JOB_NOTIFY.0.into(), "END_JOB_NOTIFY", "EndJobNotify"),
300             (Self::START_DOC_NOTIFY.0.into(), "START_DOC_NOTIFY", "StartDocNotify"),
301             (Self::END_DOC_NOTIFY.0.into(), "END_DOC_NOTIFY", "EndDocNotify"),
302             (Self::START_PAGE_NOTIFY.0.into(), "START_PAGE_NOTIFY", "StartPageNotify"),
303             (Self::END_PAGE_NOTIFY.0.into(), "END_PAGE_NOTIFY", "EndPageNotify"),
304         ];
305         pretty_print_enum(fmt, self.0.into(), &variants)
306     }
307 }
308 
309 #[derive(Clone, Copy, PartialEq, Eq)]
310 pub struct Attr(u8);
311 impl Attr {
312     pub const JOB_ATTR: Self = Self(1);
313     pub const DOC_ATTR: Self = Self(2);
314     pub const PAGE_ATTR: Self = Self(3);
315     pub const PRINTER_ATTR: Self = Self(4);
316     pub const SERVER_ATTR: Self = Self(5);
317     pub const MEDIUM_ATTR: Self = Self(6);
318     pub const SPOOLER_ATTR: Self = Self(7);
319 }
320 impl From<Attr> for u8 {
321     #[inline]
from(input: Attr) -> Self322     fn from(input: Attr) -> Self {
323         input.0
324     }
325 }
326 impl From<Attr> for Option<u8> {
327     #[inline]
from(input: Attr) -> Self328     fn from(input: Attr) -> Self {
329         Some(input.0)
330     }
331 }
332 impl From<Attr> for u16 {
333     #[inline]
from(input: Attr) -> Self334     fn from(input: Attr) -> Self {
335         u16::from(input.0)
336     }
337 }
338 impl From<Attr> for Option<u16> {
339     #[inline]
from(input: Attr) -> Self340     fn from(input: Attr) -> Self {
341         Some(u16::from(input.0))
342     }
343 }
344 impl From<Attr> for u32 {
345     #[inline]
from(input: Attr) -> Self346     fn from(input: Attr) -> Self {
347         u32::from(input.0)
348     }
349 }
350 impl From<Attr> for Option<u32> {
351     #[inline]
from(input: Attr) -> Self352     fn from(input: Attr) -> Self {
353         Some(u32::from(input.0))
354     }
355 }
356 impl From<u8> for Attr {
357     #[inline]
from(value: u8) -> Self358     fn from(value: u8) -> Self {
359         Self(value)
360     }
361 }
362 impl std::fmt::Debug for Attr  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result363     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
364         let variants = [
365             (Self::JOB_ATTR.0.into(), "JOB_ATTR", "JobAttr"),
366             (Self::DOC_ATTR.0.into(), "DOC_ATTR", "DocAttr"),
367             (Self::PAGE_ATTR.0.into(), "PAGE_ATTR", "PageAttr"),
368             (Self::PRINTER_ATTR.0.into(), "PRINTER_ATTR", "PrinterAttr"),
369             (Self::SERVER_ATTR.0.into(), "SERVER_ATTR", "ServerAttr"),
370             (Self::MEDIUM_ATTR.0.into(), "MEDIUM_ATTR", "MediumAttr"),
371             (Self::SPOOLER_ATTR.0.into(), "SPOOLER_ATTR", "SpoolerAttr"),
372         ];
373         pretty_print_enum(fmt, self.0.into(), &variants)
374     }
375 }
376 
377 /// Opcode for the PrintQueryVersion request
378 pub const PRINT_QUERY_VERSION_REQUEST: u8 = 0;
379 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
380 pub struct PrintQueryVersionRequest;
381 impl PrintQueryVersionRequest {
382     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,383     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
384     where
385         Conn: RequestConnection + ?Sized,
386     {
387         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
388             .ok_or(ConnectionError::UnsupportedExtension)?;
389         let length_so_far = 0;
390         let mut request0 = vec![
391             extension_information.major_opcode,
392             PRINT_QUERY_VERSION_REQUEST,
393             0,
394             0,
395         ];
396         let length_so_far = length_so_far + request0.len();
397         assert_eq!(length_so_far % 4, 0);
398         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
399         request0[2..4].copy_from_slice(&length.to_ne_bytes());
400         Ok((vec![request0.into()], vec![]))
401     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,402     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryVersionReply>, ConnectionError>
403     where
404         Conn: RequestConnection + ?Sized,
405     {
406         let (bytes, fds) = self.serialize(conn)?;
407         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
408         conn.send_request_with_reply(&slices, fds)
409     }
410     /// 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>411     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
412         if header.minor_opcode != PRINT_QUERY_VERSION_REQUEST {
413             return Err(ParseError::InvalidValue);
414         }
415         let _ = value;
416         Ok(PrintQueryVersionRequest
417         )
418     }
419 }
420 impl Request for PrintQueryVersionRequest {
421     type Reply = PrintQueryVersionReply;
422 }
print_query_version<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,423 pub fn print_query_version<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryVersionReply>, ConnectionError>
424 where
425     Conn: RequestConnection + ?Sized,
426 {
427     let request0 = PrintQueryVersionRequest;
428     request0.send(conn)
429 }
430 
431 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
432 pub struct PrintQueryVersionReply {
433     pub sequence: u16,
434     pub length: u32,
435     pub major_version: u16,
436     pub minor_version: u16,
437 }
438 impl TryParse for PrintQueryVersionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>439     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
440         let remaining = initial_value;
441         let (response_type, remaining) = u8::try_parse(remaining)?;
442         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
443         let (sequence, remaining) = u16::try_parse(remaining)?;
444         let (length, remaining) = u32::try_parse(remaining)?;
445         let (major_version, remaining) = u16::try_parse(remaining)?;
446         let (minor_version, remaining) = u16::try_parse(remaining)?;
447         if response_type != 1 {
448             return Err(ParseError::InvalidValue);
449         }
450         let result = PrintQueryVersionReply { sequence, length, major_version, minor_version };
451         let _ = remaining;
452         let remaining = initial_value.get(32 + length as usize * 4..)
453             .ok_or(ParseError::InsufficientData)?;
454         Ok((result, remaining))
455     }
456 }
457 
458 /// Opcode for the PrintGetPrinterList request
459 pub const PRINT_GET_PRINTER_LIST_REQUEST: u8 = 1;
460 #[derive(Debug, Clone, PartialEq, Eq)]
461 pub struct PrintGetPrinterListRequest<'input> {
462     pub printer_name: Cow<'input, [String8]>,
463     pub locale: Cow<'input, [String8]>,
464 }
465 impl<'input> PrintGetPrinterListRequest<'input> {
466     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,467     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
468     where
469         Conn: RequestConnection + ?Sized,
470     {
471         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
472             .ok_or(ConnectionError::UnsupportedExtension)?;
473         let length_so_far = 0;
474         let printer_name_len = u32::try_from(self.printer_name.len()).expect("`printer_name` has too many elements");
475         let printer_name_len_bytes = printer_name_len.serialize();
476         let locale_len = u32::try_from(self.locale.len()).expect("`locale` has too many elements");
477         let locale_len_bytes = locale_len.serialize();
478         let mut request0 = vec![
479             extension_information.major_opcode,
480             PRINT_GET_PRINTER_LIST_REQUEST,
481             0,
482             0,
483             printer_name_len_bytes[0],
484             printer_name_len_bytes[1],
485             printer_name_len_bytes[2],
486             printer_name_len_bytes[3],
487             locale_len_bytes[0],
488             locale_len_bytes[1],
489             locale_len_bytes[2],
490             locale_len_bytes[3],
491         ];
492         let length_so_far = length_so_far + request0.len();
493         let length_so_far = length_so_far + self.printer_name.len();
494         let length_so_far = length_so_far + self.locale.len();
495         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
496         let length_so_far = length_so_far + padding0.len();
497         assert_eq!(length_so_far % 4, 0);
498         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
499         request0[2..4].copy_from_slice(&length.to_ne_bytes());
500         Ok((vec![request0.into(), self.printer_name, self.locale, padding0.into()], vec![]))
501     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetPrinterListReply>, ConnectionError> where Conn: RequestConnection + ?Sized,502     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetPrinterListReply>, ConnectionError>
503     where
504         Conn: RequestConnection + ?Sized,
505     {
506         let (bytes, fds) = self.serialize(conn)?;
507         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
508         conn.send_request_with_reply(&slices, fds)
509     }
510     /// 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>511     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
512         if header.minor_opcode != PRINT_GET_PRINTER_LIST_REQUEST {
513             return Err(ParseError::InvalidValue);
514         }
515         let (printer_name_len, remaining) = u32::try_parse(value)?;
516         let (locale_len, remaining) = u32::try_parse(remaining)?;
517         let (printer_name, remaining) = crate::x11_utils::parse_u8_list(remaining, printer_name_len.try_to_usize()?)?;
518         let (locale, remaining) = crate::x11_utils::parse_u8_list(remaining, locale_len.try_to_usize()?)?;
519         let _ = remaining;
520         Ok(PrintGetPrinterListRequest {
521             printer_name: Cow::Borrowed(printer_name),
522             locale: Cow::Borrowed(locale),
523         })
524     }
525     /// Clone all borrowed data in this PrintGetPrinterListRequest.
into_owned(self) -> PrintGetPrinterListRequest<'static>526     pub fn into_owned(self) -> PrintGetPrinterListRequest<'static> {
527         PrintGetPrinterListRequest {
528             printer_name: Cow::Owned(self.printer_name.into_owned()),
529             locale: Cow::Owned(self.locale.into_owned()),
530         }
531     }
532 }
533 impl<'input> Request for PrintGetPrinterListRequest<'input> {
534     type Reply = PrintGetPrinterListReply;
535 }
print_get_printer_list<'c, 'input, Conn>(conn: &'c Conn, printer_name: &'input [String8], locale: &'input [String8]) -> Result<Cookie<'c, Conn, PrintGetPrinterListReply>, ConnectionError> where Conn: RequestConnection + ?Sized,536 pub fn print_get_printer_list<'c, 'input, Conn>(conn: &'c Conn, printer_name: &'input [String8], locale: &'input [String8]) -> Result<Cookie<'c, Conn, PrintGetPrinterListReply>, ConnectionError>
537 where
538     Conn: RequestConnection + ?Sized,
539 {
540     let request0 = PrintGetPrinterListRequest {
541         printer_name: Cow::Borrowed(printer_name),
542         locale: Cow::Borrowed(locale),
543     };
544     request0.send(conn)
545 }
546 
547 #[derive(Debug, Clone, PartialEq, Eq)]
548 pub struct PrintGetPrinterListReply {
549     pub sequence: u16,
550     pub length: u32,
551     pub printers: Vec<Printer>,
552 }
553 impl TryParse for PrintGetPrinterListReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>554     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
555         let remaining = initial_value;
556         let (response_type, remaining) = u8::try_parse(remaining)?;
557         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
558         let (sequence, remaining) = u16::try_parse(remaining)?;
559         let (length, remaining) = u32::try_parse(remaining)?;
560         let (list_count, remaining) = u32::try_parse(remaining)?;
561         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
562         let (printers, remaining) = crate::x11_utils::parse_list::<Printer>(remaining, list_count.try_to_usize()?)?;
563         if response_type != 1 {
564             return Err(ParseError::InvalidValue);
565         }
566         let result = PrintGetPrinterListReply { sequence, length, printers };
567         let _ = remaining;
568         let remaining = initial_value.get(32 + length as usize * 4..)
569             .ok_or(ParseError::InsufficientData)?;
570         Ok((result, remaining))
571     }
572 }
573 impl PrintGetPrinterListReply {
574     /// Get the value of the `listCount` field.
575     ///
576     /// The `listCount` field is used as the length field of the `printers` field.
577     /// This function computes the field's value again based on the length of the list.
578     ///
579     /// # Panics
580     ///
581     /// Panics if the value cannot be represented in the target type. This
582     /// cannot happen with values of the struct received from the X11 server.
list_count(&self) -> u32583     pub fn list_count(&self) -> u32 {
584         self.printers.len()
585             .try_into().unwrap()
586     }
587 }
588 
589 /// Opcode for the PrintRehashPrinterList request
590 pub const PRINT_REHASH_PRINTER_LIST_REQUEST: u8 = 20;
591 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
592 pub struct PrintRehashPrinterListRequest;
593 impl PrintRehashPrinterListRequest {
594     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,595     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
596     where
597         Conn: RequestConnection + ?Sized,
598     {
599         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
600             .ok_or(ConnectionError::UnsupportedExtension)?;
601         let length_so_far = 0;
602         let mut request0 = vec![
603             extension_information.major_opcode,
604             PRINT_REHASH_PRINTER_LIST_REQUEST,
605             0,
606             0,
607         ];
608         let length_so_far = length_so_far + request0.len();
609         assert_eq!(length_so_far % 4, 0);
610         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
611         request0[2..4].copy_from_slice(&length.to_ne_bytes());
612         Ok((vec![request0.into()], vec![]))
613     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,614     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
615     where
616         Conn: RequestConnection + ?Sized,
617     {
618         let (bytes, fds) = self.serialize(conn)?;
619         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
620         conn.send_request_without_reply(&slices, fds)
621     }
622     /// 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>623     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
624         if header.minor_opcode != PRINT_REHASH_PRINTER_LIST_REQUEST {
625             return Err(ParseError::InvalidValue);
626         }
627         let _ = value;
628         Ok(PrintRehashPrinterListRequest
629         )
630     }
631 }
632 impl Request for PrintRehashPrinterListRequest {
633     type Reply = ();
634 }
print_rehash_printer_list<Conn>(conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,635 pub fn print_rehash_printer_list<Conn>(conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
636 where
637     Conn: RequestConnection + ?Sized,
638 {
639     let request0 = PrintRehashPrinterListRequest;
640     request0.send(conn)
641 }
642 
643 /// Opcode for the CreateContext request
644 pub const CREATE_CONTEXT_REQUEST: u8 = 2;
645 #[derive(Debug, Clone, PartialEq, Eq)]
646 pub struct CreateContextRequest<'input> {
647     pub context_id: u32,
648     pub printer_name: Cow<'input, [String8]>,
649     pub locale: Cow<'input, [String8]>,
650 }
651 impl<'input> CreateContextRequest<'input> {
652     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,653     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
654     where
655         Conn: RequestConnection + ?Sized,
656     {
657         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
658             .ok_or(ConnectionError::UnsupportedExtension)?;
659         let length_so_far = 0;
660         let context_id_bytes = self.context_id.serialize();
661         let printer_name_len = u32::try_from(self.printer_name.len()).expect("`printer_name` has too many elements");
662         let printer_name_len_bytes = printer_name_len.serialize();
663         let locale_len = u32::try_from(self.locale.len()).expect("`locale` has too many elements");
664         let locale_len_bytes = locale_len.serialize();
665         let mut request0 = vec![
666             extension_information.major_opcode,
667             CREATE_CONTEXT_REQUEST,
668             0,
669             0,
670             context_id_bytes[0],
671             context_id_bytes[1],
672             context_id_bytes[2],
673             context_id_bytes[3],
674             printer_name_len_bytes[0],
675             printer_name_len_bytes[1],
676             printer_name_len_bytes[2],
677             printer_name_len_bytes[3],
678             locale_len_bytes[0],
679             locale_len_bytes[1],
680             locale_len_bytes[2],
681             locale_len_bytes[3],
682         ];
683         let length_so_far = length_so_far + request0.len();
684         let length_so_far = length_so_far + self.printer_name.len();
685         let length_so_far = length_so_far + self.locale.len();
686         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
687         let length_so_far = length_so_far + padding0.len();
688         assert_eq!(length_so_far % 4, 0);
689         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
690         request0[2..4].copy_from_slice(&length.to_ne_bytes());
691         Ok((vec![request0.into(), self.printer_name, self.locale, padding0.into()], vec![]))
692     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,693     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
694     where
695         Conn: RequestConnection + ?Sized,
696     {
697         let (bytes, fds) = self.serialize(conn)?;
698         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
699         conn.send_request_without_reply(&slices, fds)
700     }
701     /// 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>702     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
703         if header.minor_opcode != CREATE_CONTEXT_REQUEST {
704             return Err(ParseError::InvalidValue);
705         }
706         let (context_id, remaining) = u32::try_parse(value)?;
707         let (printer_name_len, remaining) = u32::try_parse(remaining)?;
708         let (locale_len, remaining) = u32::try_parse(remaining)?;
709         let (printer_name, remaining) = crate::x11_utils::parse_u8_list(remaining, printer_name_len.try_to_usize()?)?;
710         let (locale, remaining) = crate::x11_utils::parse_u8_list(remaining, locale_len.try_to_usize()?)?;
711         let _ = remaining;
712         Ok(CreateContextRequest {
713             context_id,
714             printer_name: Cow::Borrowed(printer_name),
715             locale: Cow::Borrowed(locale),
716         })
717     }
718     /// Clone all borrowed data in this CreateContextRequest.
into_owned(self) -> CreateContextRequest<'static>719     pub fn into_owned(self) -> CreateContextRequest<'static> {
720         CreateContextRequest {
721             context_id: self.context_id,
722             printer_name: Cow::Owned(self.printer_name.into_owned()),
723             locale: Cow::Owned(self.locale.into_owned()),
724         }
725     }
726 }
727 impl<'input> Request for CreateContextRequest<'input> {
728     type Reply = ();
729 }
create_context<'c, 'input, Conn>(conn: &'c Conn, context_id: u32, printer_name: &'input [String8], locale: &'input [String8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,730 pub fn create_context<'c, 'input, Conn>(conn: &'c Conn, context_id: u32, printer_name: &'input [String8], locale: &'input [String8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
731 where
732     Conn: RequestConnection + ?Sized,
733 {
734     let request0 = CreateContextRequest {
735         context_id,
736         printer_name: Cow::Borrowed(printer_name),
737         locale: Cow::Borrowed(locale),
738     };
739     request0.send(conn)
740 }
741 
742 /// Opcode for the PrintSetContext request
743 pub const PRINT_SET_CONTEXT_REQUEST: u8 = 3;
744 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
745 pub struct PrintSetContextRequest {
746     pub context: u32,
747 }
748 impl PrintSetContextRequest {
749     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,750     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
751     where
752         Conn: RequestConnection + ?Sized,
753     {
754         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
755             .ok_or(ConnectionError::UnsupportedExtension)?;
756         let length_so_far = 0;
757         let context_bytes = self.context.serialize();
758         let mut request0 = vec![
759             extension_information.major_opcode,
760             PRINT_SET_CONTEXT_REQUEST,
761             0,
762             0,
763             context_bytes[0],
764             context_bytes[1],
765             context_bytes[2],
766             context_bytes[3],
767         ];
768         let length_so_far = length_so_far + request0.len();
769         assert_eq!(length_so_far % 4, 0);
770         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
771         request0[2..4].copy_from_slice(&length.to_ne_bytes());
772         Ok((vec![request0.into()], vec![]))
773     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,774     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
775     where
776         Conn: RequestConnection + ?Sized,
777     {
778         let (bytes, fds) = self.serialize(conn)?;
779         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
780         conn.send_request_without_reply(&slices, fds)
781     }
782     /// 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>783     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
784         if header.minor_opcode != PRINT_SET_CONTEXT_REQUEST {
785             return Err(ParseError::InvalidValue);
786         }
787         let (context, remaining) = u32::try_parse(value)?;
788         let _ = remaining;
789         Ok(PrintSetContextRequest {
790             context,
791         })
792     }
793 }
794 impl Request for PrintSetContextRequest {
795     type Reply = ();
796 }
print_set_context<Conn>(conn: &Conn, context: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,797 pub fn print_set_context<Conn>(conn: &Conn, context: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
798 where
799     Conn: RequestConnection + ?Sized,
800 {
801     let request0 = PrintSetContextRequest {
802         context,
803     };
804     request0.send(conn)
805 }
806 
807 /// Opcode for the PrintGetContext request
808 pub const PRINT_GET_CONTEXT_REQUEST: u8 = 4;
809 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
810 pub struct PrintGetContextRequest;
811 impl PrintGetContextRequest {
812     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,813     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
814     where
815         Conn: RequestConnection + ?Sized,
816     {
817         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
818             .ok_or(ConnectionError::UnsupportedExtension)?;
819         let length_so_far = 0;
820         let mut request0 = vec![
821             extension_information.major_opcode,
822             PRINT_GET_CONTEXT_REQUEST,
823             0,
824             0,
825         ];
826         let length_so_far = length_so_far + request0.len();
827         assert_eq!(length_so_far % 4, 0);
828         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
829         request0[2..4].copy_from_slice(&length.to_ne_bytes());
830         Ok((vec![request0.into()], vec![]))
831     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,832     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetContextReply>, ConnectionError>
833     where
834         Conn: RequestConnection + ?Sized,
835     {
836         let (bytes, fds) = self.serialize(conn)?;
837         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
838         conn.send_request_with_reply(&slices, fds)
839     }
840     /// 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>841     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
842         if header.minor_opcode != PRINT_GET_CONTEXT_REQUEST {
843             return Err(ParseError::InvalidValue);
844         }
845         let _ = value;
846         Ok(PrintGetContextRequest
847         )
848     }
849 }
850 impl Request for PrintGetContextRequest {
851     type Reply = PrintGetContextReply;
852 }
print_get_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,853 pub fn print_get_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetContextReply>, ConnectionError>
854 where
855     Conn: RequestConnection + ?Sized,
856 {
857     let request0 = PrintGetContextRequest;
858     request0.send(conn)
859 }
860 
861 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
862 pub struct PrintGetContextReply {
863     pub sequence: u16,
864     pub length: u32,
865     pub context: u32,
866 }
867 impl TryParse for PrintGetContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>868     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
869         let remaining = initial_value;
870         let (response_type, remaining) = u8::try_parse(remaining)?;
871         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
872         let (sequence, remaining) = u16::try_parse(remaining)?;
873         let (length, remaining) = u32::try_parse(remaining)?;
874         let (context, remaining) = u32::try_parse(remaining)?;
875         if response_type != 1 {
876             return Err(ParseError::InvalidValue);
877         }
878         let result = PrintGetContextReply { sequence, length, context };
879         let _ = remaining;
880         let remaining = initial_value.get(32 + length as usize * 4..)
881             .ok_or(ParseError::InsufficientData)?;
882         Ok((result, remaining))
883     }
884 }
885 
886 /// Opcode for the PrintDestroyContext request
887 pub const PRINT_DESTROY_CONTEXT_REQUEST: u8 = 5;
888 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
889 pub struct PrintDestroyContextRequest {
890     pub context: u32,
891 }
892 impl PrintDestroyContextRequest {
893     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,894     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
895     where
896         Conn: RequestConnection + ?Sized,
897     {
898         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
899             .ok_or(ConnectionError::UnsupportedExtension)?;
900         let length_so_far = 0;
901         let context_bytes = self.context.serialize();
902         let mut request0 = vec![
903             extension_information.major_opcode,
904             PRINT_DESTROY_CONTEXT_REQUEST,
905             0,
906             0,
907             context_bytes[0],
908             context_bytes[1],
909             context_bytes[2],
910             context_bytes[3],
911         ];
912         let length_so_far = length_so_far + request0.len();
913         assert_eq!(length_so_far % 4, 0);
914         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
915         request0[2..4].copy_from_slice(&length.to_ne_bytes());
916         Ok((vec![request0.into()], vec![]))
917     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,918     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
919     where
920         Conn: RequestConnection + ?Sized,
921     {
922         let (bytes, fds) = self.serialize(conn)?;
923         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
924         conn.send_request_without_reply(&slices, fds)
925     }
926     /// 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>927     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
928         if header.minor_opcode != PRINT_DESTROY_CONTEXT_REQUEST {
929             return Err(ParseError::InvalidValue);
930         }
931         let (context, remaining) = u32::try_parse(value)?;
932         let _ = remaining;
933         Ok(PrintDestroyContextRequest {
934             context,
935         })
936     }
937 }
938 impl Request for PrintDestroyContextRequest {
939     type Reply = ();
940 }
print_destroy_context<Conn>(conn: &Conn, context: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,941 pub fn print_destroy_context<Conn>(conn: &Conn, context: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
942 where
943     Conn: RequestConnection + ?Sized,
944 {
945     let request0 = PrintDestroyContextRequest {
946         context,
947     };
948     request0.send(conn)
949 }
950 
951 /// Opcode for the PrintGetScreenOfContext request
952 pub const PRINT_GET_SCREEN_OF_CONTEXT_REQUEST: u8 = 6;
953 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
954 pub struct PrintGetScreenOfContextRequest;
955 impl PrintGetScreenOfContextRequest {
956     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,957     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
958     where
959         Conn: RequestConnection + ?Sized,
960     {
961         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
962             .ok_or(ConnectionError::UnsupportedExtension)?;
963         let length_so_far = 0;
964         let mut request0 = vec![
965             extension_information.major_opcode,
966             PRINT_GET_SCREEN_OF_CONTEXT_REQUEST,
967             0,
968             0,
969         ];
970         let length_so_far = length_so_far + request0.len();
971         assert_eq!(length_so_far % 4, 0);
972         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
973         request0[2..4].copy_from_slice(&length.to_ne_bytes());
974         Ok((vec![request0.into()], vec![]))
975     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetScreenOfContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,976     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetScreenOfContextReply>, ConnectionError>
977     where
978         Conn: RequestConnection + ?Sized,
979     {
980         let (bytes, fds) = self.serialize(conn)?;
981         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
982         conn.send_request_with_reply(&slices, fds)
983     }
984     /// 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>985     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
986         if header.minor_opcode != PRINT_GET_SCREEN_OF_CONTEXT_REQUEST {
987             return Err(ParseError::InvalidValue);
988         }
989         let _ = value;
990         Ok(PrintGetScreenOfContextRequest
991         )
992     }
993 }
994 impl Request for PrintGetScreenOfContextRequest {
995     type Reply = PrintGetScreenOfContextReply;
996 }
print_get_screen_of_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetScreenOfContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,997 pub fn print_get_screen_of_context<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetScreenOfContextReply>, ConnectionError>
998 where
999     Conn: RequestConnection + ?Sized,
1000 {
1001     let request0 = PrintGetScreenOfContextRequest;
1002     request0.send(conn)
1003 }
1004 
1005 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1006 pub struct PrintGetScreenOfContextReply {
1007     pub sequence: u16,
1008     pub length: u32,
1009     pub root: xproto::Window,
1010 }
1011 impl TryParse for PrintGetScreenOfContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1012     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1013         let remaining = initial_value;
1014         let (response_type, remaining) = u8::try_parse(remaining)?;
1015         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1016         let (sequence, remaining) = u16::try_parse(remaining)?;
1017         let (length, remaining) = u32::try_parse(remaining)?;
1018         let (root, remaining) = xproto::Window::try_parse(remaining)?;
1019         if response_type != 1 {
1020             return Err(ParseError::InvalidValue);
1021         }
1022         let result = PrintGetScreenOfContextReply { sequence, length, root };
1023         let _ = remaining;
1024         let remaining = initial_value.get(32 + length as usize * 4..)
1025             .ok_or(ParseError::InsufficientData)?;
1026         Ok((result, remaining))
1027     }
1028 }
1029 
1030 /// Opcode for the PrintStartJob request
1031 pub const PRINT_START_JOB_REQUEST: u8 = 7;
1032 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1033 pub struct PrintStartJobRequest {
1034     pub output_mode: u8,
1035 }
1036 impl PrintStartJobRequest {
1037     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1038     fn serialize<'input, 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 output_mode_bytes = self.output_mode.serialize();
1046         let mut request0 = vec![
1047             extension_information.major_opcode,
1048             PRINT_START_JOB_REQUEST,
1049             0,
1050             0,
1051             output_mode_bytes[0],
1052             0,
1053             0,
1054             0,
1055         ];
1056         let length_so_far = length_so_far + request0.len();
1057         assert_eq!(length_so_far % 4, 0);
1058         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1059         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1060         Ok((vec![request0.into()], vec![]))
1061     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1062     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1063     where
1064         Conn: RequestConnection + ?Sized,
1065     {
1066         let (bytes, fds) = self.serialize(conn)?;
1067         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1068         conn.send_request_without_reply(&slices, fds)
1069     }
1070     /// 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>1071     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1072         if header.minor_opcode != PRINT_START_JOB_REQUEST {
1073             return Err(ParseError::InvalidValue);
1074         }
1075         let (output_mode, remaining) = u8::try_parse(value)?;
1076         let _ = remaining;
1077         Ok(PrintStartJobRequest {
1078             output_mode,
1079         })
1080     }
1081 }
1082 impl Request for PrintStartJobRequest {
1083     type Reply = ();
1084 }
print_start_job<Conn>(conn: &Conn, output_mode: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1085 pub fn print_start_job<Conn>(conn: &Conn, output_mode: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1086 where
1087     Conn: RequestConnection + ?Sized,
1088 {
1089     let request0 = PrintStartJobRequest {
1090         output_mode,
1091     };
1092     request0.send(conn)
1093 }
1094 
1095 /// Opcode for the PrintEndJob request
1096 pub const PRINT_END_JOB_REQUEST: u8 = 8;
1097 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1098 pub struct PrintEndJobRequest {
1099     pub cancel: bool,
1100 }
1101 impl PrintEndJobRequest {
1102     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1103     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1104     where
1105         Conn: RequestConnection + ?Sized,
1106     {
1107         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1108             .ok_or(ConnectionError::UnsupportedExtension)?;
1109         let length_so_far = 0;
1110         let cancel_bytes = self.cancel.serialize();
1111         let mut request0 = vec![
1112             extension_information.major_opcode,
1113             PRINT_END_JOB_REQUEST,
1114             0,
1115             0,
1116             cancel_bytes[0],
1117             0,
1118             0,
1119             0,
1120         ];
1121         let length_so_far = length_so_far + request0.len();
1122         assert_eq!(length_so_far % 4, 0);
1123         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1124         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1125         Ok((vec![request0.into()], vec![]))
1126     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1127     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1128     where
1129         Conn: RequestConnection + ?Sized,
1130     {
1131         let (bytes, fds) = self.serialize(conn)?;
1132         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1133         conn.send_request_without_reply(&slices, fds)
1134     }
1135     /// 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>1136     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1137         if header.minor_opcode != PRINT_END_JOB_REQUEST {
1138             return Err(ParseError::InvalidValue);
1139         }
1140         let (cancel, remaining) = bool::try_parse(value)?;
1141         let _ = remaining;
1142         Ok(PrintEndJobRequest {
1143             cancel,
1144         })
1145     }
1146 }
1147 impl Request for PrintEndJobRequest {
1148     type Reply = ();
1149 }
print_end_job<Conn>(conn: &Conn, cancel: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1150 pub fn print_end_job<Conn>(conn: &Conn, cancel: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1151 where
1152     Conn: RequestConnection + ?Sized,
1153 {
1154     let request0 = PrintEndJobRequest {
1155         cancel,
1156     };
1157     request0.send(conn)
1158 }
1159 
1160 /// Opcode for the PrintStartDoc request
1161 pub const PRINT_START_DOC_REQUEST: u8 = 9;
1162 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1163 pub struct PrintStartDocRequest {
1164     pub driver_mode: u8,
1165 }
1166 impl PrintStartDocRequest {
1167     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1168     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1169     where
1170         Conn: RequestConnection + ?Sized,
1171     {
1172         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1173             .ok_or(ConnectionError::UnsupportedExtension)?;
1174         let length_so_far = 0;
1175         let driver_mode_bytes = self.driver_mode.serialize();
1176         let mut request0 = vec![
1177             extension_information.major_opcode,
1178             PRINT_START_DOC_REQUEST,
1179             0,
1180             0,
1181             driver_mode_bytes[0],
1182             0,
1183             0,
1184             0,
1185         ];
1186         let length_so_far = length_so_far + request0.len();
1187         assert_eq!(length_so_far % 4, 0);
1188         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1189         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1190         Ok((vec![request0.into()], vec![]))
1191     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1192     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1193     where
1194         Conn: RequestConnection + ?Sized,
1195     {
1196         let (bytes, fds) = self.serialize(conn)?;
1197         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1198         conn.send_request_without_reply(&slices, fds)
1199     }
1200     /// 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>1201     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1202         if header.minor_opcode != PRINT_START_DOC_REQUEST {
1203             return Err(ParseError::InvalidValue);
1204         }
1205         let (driver_mode, remaining) = u8::try_parse(value)?;
1206         let _ = remaining;
1207         Ok(PrintStartDocRequest {
1208             driver_mode,
1209         })
1210     }
1211 }
1212 impl Request for PrintStartDocRequest {
1213     type Reply = ();
1214 }
print_start_doc<Conn>(conn: &Conn, driver_mode: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1215 pub fn print_start_doc<Conn>(conn: &Conn, driver_mode: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1216 where
1217     Conn: RequestConnection + ?Sized,
1218 {
1219     let request0 = PrintStartDocRequest {
1220         driver_mode,
1221     };
1222     request0.send(conn)
1223 }
1224 
1225 /// Opcode for the PrintEndDoc request
1226 pub const PRINT_END_DOC_REQUEST: u8 = 10;
1227 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1228 pub struct PrintEndDocRequest {
1229     pub cancel: bool,
1230 }
1231 impl PrintEndDocRequest {
1232     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1233     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1234     where
1235         Conn: RequestConnection + ?Sized,
1236     {
1237         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1238             .ok_or(ConnectionError::UnsupportedExtension)?;
1239         let length_so_far = 0;
1240         let cancel_bytes = self.cancel.serialize();
1241         let mut request0 = vec![
1242             extension_information.major_opcode,
1243             PRINT_END_DOC_REQUEST,
1244             0,
1245             0,
1246             cancel_bytes[0],
1247             0,
1248             0,
1249             0,
1250         ];
1251         let length_so_far = length_so_far + request0.len();
1252         assert_eq!(length_so_far % 4, 0);
1253         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1254         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1255         Ok((vec![request0.into()], vec![]))
1256     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1257     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1258     where
1259         Conn: RequestConnection + ?Sized,
1260     {
1261         let (bytes, fds) = self.serialize(conn)?;
1262         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1263         conn.send_request_without_reply(&slices, fds)
1264     }
1265     /// 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>1266     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1267         if header.minor_opcode != PRINT_END_DOC_REQUEST {
1268             return Err(ParseError::InvalidValue);
1269         }
1270         let (cancel, remaining) = bool::try_parse(value)?;
1271         let _ = remaining;
1272         Ok(PrintEndDocRequest {
1273             cancel,
1274         })
1275     }
1276 }
1277 impl Request for PrintEndDocRequest {
1278     type Reply = ();
1279 }
print_end_doc<Conn>(conn: &Conn, cancel: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1280 pub fn print_end_doc<Conn>(conn: &Conn, cancel: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1281 where
1282     Conn: RequestConnection + ?Sized,
1283 {
1284     let request0 = PrintEndDocRequest {
1285         cancel,
1286     };
1287     request0.send(conn)
1288 }
1289 
1290 /// Opcode for the PrintPutDocumentData request
1291 pub const PRINT_PUT_DOCUMENT_DATA_REQUEST: u8 = 11;
1292 #[derive(Debug, Clone, PartialEq, Eq)]
1293 pub struct PrintPutDocumentDataRequest<'input> {
1294     pub drawable: xproto::Drawable,
1295     pub data: Cow<'input, [u8]>,
1296     pub doc_format: Cow<'input, [String8]>,
1297     pub options: Cow<'input, [String8]>,
1298 }
1299 impl<'input> PrintPutDocumentDataRequest<'input> {
1300     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1301     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1302     where
1303         Conn: RequestConnection + ?Sized,
1304     {
1305         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1306             .ok_or(ConnectionError::UnsupportedExtension)?;
1307         let length_so_far = 0;
1308         let drawable_bytes = self.drawable.serialize();
1309         let len_data = u32::try_from(self.data.len()).expect("`data` has too many elements");
1310         let len_data_bytes = len_data.serialize();
1311         let len_fmt = u16::try_from(self.doc_format.len()).expect("`doc_format` has too many elements");
1312         let len_fmt_bytes = len_fmt.serialize();
1313         let len_options = u16::try_from(self.options.len()).expect("`options` has too many elements");
1314         let len_options_bytes = len_options.serialize();
1315         let mut request0 = vec![
1316             extension_information.major_opcode,
1317             PRINT_PUT_DOCUMENT_DATA_REQUEST,
1318             0,
1319             0,
1320             drawable_bytes[0],
1321             drawable_bytes[1],
1322             drawable_bytes[2],
1323             drawable_bytes[3],
1324             len_data_bytes[0],
1325             len_data_bytes[1],
1326             len_data_bytes[2],
1327             len_data_bytes[3],
1328             len_fmt_bytes[0],
1329             len_fmt_bytes[1],
1330             len_options_bytes[0],
1331             len_options_bytes[1],
1332         ];
1333         let length_so_far = length_so_far + request0.len();
1334         let length_so_far = length_so_far + self.data.len();
1335         let length_so_far = length_so_far + self.doc_format.len();
1336         let length_so_far = length_so_far + self.options.len();
1337         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1338         let length_so_far = length_so_far + padding0.len();
1339         assert_eq!(length_so_far % 4, 0);
1340         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1341         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1342         Ok((vec![request0.into(), self.data, self.doc_format, self.options, padding0.into()], vec![]))
1343     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1344     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1345     where
1346         Conn: RequestConnection + ?Sized,
1347     {
1348         let (bytes, fds) = self.serialize(conn)?;
1349         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1350         conn.send_request_without_reply(&slices, fds)
1351     }
1352     /// 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>1353     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1354         if header.minor_opcode != PRINT_PUT_DOCUMENT_DATA_REQUEST {
1355             return Err(ParseError::InvalidValue);
1356         }
1357         let (drawable, remaining) = xproto::Drawable::try_parse(value)?;
1358         let (len_data, remaining) = u32::try_parse(remaining)?;
1359         let (len_fmt, remaining) = u16::try_parse(remaining)?;
1360         let (len_options, remaining) = u16::try_parse(remaining)?;
1361         let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, len_data.try_to_usize()?)?;
1362         let (doc_format, remaining) = crate::x11_utils::parse_u8_list(remaining, len_fmt.try_to_usize()?)?;
1363         let (options, remaining) = crate::x11_utils::parse_u8_list(remaining, len_options.try_to_usize()?)?;
1364         let _ = remaining;
1365         Ok(PrintPutDocumentDataRequest {
1366             drawable,
1367             data: Cow::Borrowed(data),
1368             doc_format: Cow::Borrowed(doc_format),
1369             options: Cow::Borrowed(options),
1370         })
1371     }
1372     /// Clone all borrowed data in this PrintPutDocumentDataRequest.
into_owned(self) -> PrintPutDocumentDataRequest<'static>1373     pub fn into_owned(self) -> PrintPutDocumentDataRequest<'static> {
1374         PrintPutDocumentDataRequest {
1375             drawable: self.drawable,
1376             data: Cow::Owned(self.data.into_owned()),
1377             doc_format: Cow::Owned(self.doc_format.into_owned()),
1378             options: Cow::Owned(self.options.into_owned()),
1379         }
1380     }
1381 }
1382 impl<'input> Request for PrintPutDocumentDataRequest<'input> {
1383     type Reply = ();
1384 }
print_put_document_data<'c, 'input, Conn>(conn: &'c Conn, drawable: xproto::Drawable, data: &'input [u8], doc_format: &'input [String8], options: &'input [String8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1385 pub fn print_put_document_data<'c, 'input, Conn>(conn: &'c Conn, drawable: xproto::Drawable, data: &'input [u8], doc_format: &'input [String8], options: &'input [String8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1386 where
1387     Conn: RequestConnection + ?Sized,
1388 {
1389     let request0 = PrintPutDocumentDataRequest {
1390         drawable,
1391         data: Cow::Borrowed(data),
1392         doc_format: Cow::Borrowed(doc_format),
1393         options: Cow::Borrowed(options),
1394     };
1395     request0.send(conn)
1396 }
1397 
1398 /// Opcode for the PrintGetDocumentData request
1399 pub const PRINT_GET_DOCUMENT_DATA_REQUEST: u8 = 12;
1400 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1401 pub struct PrintGetDocumentDataRequest {
1402     pub context: Pcontext,
1403     pub max_bytes: u32,
1404 }
1405 impl PrintGetDocumentDataRequest {
1406     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1407     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1408     where
1409         Conn: RequestConnection + ?Sized,
1410     {
1411         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1412             .ok_or(ConnectionError::UnsupportedExtension)?;
1413         let length_so_far = 0;
1414         let context_bytes = self.context.serialize();
1415         let max_bytes_bytes = self.max_bytes.serialize();
1416         let mut request0 = vec![
1417             extension_information.major_opcode,
1418             PRINT_GET_DOCUMENT_DATA_REQUEST,
1419             0,
1420             0,
1421             context_bytes[0],
1422             context_bytes[1],
1423             context_bytes[2],
1424             context_bytes[3],
1425             max_bytes_bytes[0],
1426             max_bytes_bytes[1],
1427             max_bytes_bytes[2],
1428             max_bytes_bytes[3],
1429         ];
1430         let length_so_far = length_so_far + request0.len();
1431         assert_eq!(length_so_far % 4, 0);
1432         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1433         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1434         Ok((vec![request0.into()], vec![]))
1435     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetDocumentDataReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1436     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetDocumentDataReply>, ConnectionError>
1437     where
1438         Conn: RequestConnection + ?Sized,
1439     {
1440         let (bytes, fds) = self.serialize(conn)?;
1441         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1442         conn.send_request_with_reply(&slices, fds)
1443     }
1444     /// 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>1445     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1446         if header.minor_opcode != PRINT_GET_DOCUMENT_DATA_REQUEST {
1447             return Err(ParseError::InvalidValue);
1448         }
1449         let (context, remaining) = Pcontext::try_parse(value)?;
1450         let (max_bytes, remaining) = u32::try_parse(remaining)?;
1451         let _ = remaining;
1452         Ok(PrintGetDocumentDataRequest {
1453             context,
1454             max_bytes,
1455         })
1456     }
1457 }
1458 impl Request for PrintGetDocumentDataRequest {
1459     type Reply = PrintGetDocumentDataReply;
1460 }
print_get_document_data<Conn>(conn: &Conn, context: Pcontext, max_bytes: u32) -> Result<Cookie<'_, Conn, PrintGetDocumentDataReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1461 pub fn print_get_document_data<Conn>(conn: &Conn, context: Pcontext, max_bytes: u32) -> Result<Cookie<'_, Conn, PrintGetDocumentDataReply>, ConnectionError>
1462 where
1463     Conn: RequestConnection + ?Sized,
1464 {
1465     let request0 = PrintGetDocumentDataRequest {
1466         context,
1467         max_bytes,
1468     };
1469     request0.send(conn)
1470 }
1471 
1472 #[derive(Debug, Clone, PartialEq, Eq)]
1473 pub struct PrintGetDocumentDataReply {
1474     pub sequence: u16,
1475     pub length: u32,
1476     pub status_code: u32,
1477     pub finished_flag: u32,
1478     pub data: Vec<u8>,
1479 }
1480 impl TryParse for PrintGetDocumentDataReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1481     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1482         let remaining = initial_value;
1483         let (response_type, remaining) = u8::try_parse(remaining)?;
1484         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1485         let (sequence, remaining) = u16::try_parse(remaining)?;
1486         let (length, remaining) = u32::try_parse(remaining)?;
1487         let (status_code, remaining) = u32::try_parse(remaining)?;
1488         let (finished_flag, remaining) = u32::try_parse(remaining)?;
1489         let (data_len, remaining) = u32::try_parse(remaining)?;
1490         let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
1491         let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, data_len.try_to_usize()?)?;
1492         let data = data.to_vec();
1493         if response_type != 1 {
1494             return Err(ParseError::InvalidValue);
1495         }
1496         let result = PrintGetDocumentDataReply { sequence, length, status_code, finished_flag, data };
1497         let _ = remaining;
1498         let remaining = initial_value.get(32 + length as usize * 4..)
1499             .ok_or(ParseError::InsufficientData)?;
1500         Ok((result, remaining))
1501     }
1502 }
1503 impl PrintGetDocumentDataReply {
1504     /// Get the value of the `dataLen` field.
1505     ///
1506     /// The `dataLen` field is used as the length field of the `data` field.
1507     /// This function computes the field's value again based on the length of the list.
1508     ///
1509     /// # Panics
1510     ///
1511     /// Panics if the value cannot be represented in the target type. This
1512     /// cannot happen with values of the struct received from the X11 server.
data_len(&self) -> u321513     pub fn data_len(&self) -> u32 {
1514         self.data.len()
1515             .try_into().unwrap()
1516     }
1517 }
1518 
1519 /// Opcode for the PrintStartPage request
1520 pub const PRINT_START_PAGE_REQUEST: u8 = 13;
1521 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1522 pub struct PrintStartPageRequest {
1523     pub window: xproto::Window,
1524 }
1525 impl PrintStartPageRequest {
1526     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1527     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1528     where
1529         Conn: RequestConnection + ?Sized,
1530     {
1531         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1532             .ok_or(ConnectionError::UnsupportedExtension)?;
1533         let length_so_far = 0;
1534         let window_bytes = self.window.serialize();
1535         let mut request0 = vec![
1536             extension_information.major_opcode,
1537             PRINT_START_PAGE_REQUEST,
1538             0,
1539             0,
1540             window_bytes[0],
1541             window_bytes[1],
1542             window_bytes[2],
1543             window_bytes[3],
1544         ];
1545         let length_so_far = length_so_far + request0.len();
1546         assert_eq!(length_so_far % 4, 0);
1547         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1548         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1549         Ok((vec![request0.into()], vec![]))
1550     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1551     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1552     where
1553         Conn: RequestConnection + ?Sized,
1554     {
1555         let (bytes, fds) = self.serialize(conn)?;
1556         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1557         conn.send_request_without_reply(&slices, fds)
1558     }
1559     /// 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>1560     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1561         if header.minor_opcode != PRINT_START_PAGE_REQUEST {
1562             return Err(ParseError::InvalidValue);
1563         }
1564         let (window, remaining) = xproto::Window::try_parse(value)?;
1565         let _ = remaining;
1566         Ok(PrintStartPageRequest {
1567             window,
1568         })
1569     }
1570 }
1571 impl Request for PrintStartPageRequest {
1572     type Reply = ();
1573 }
print_start_page<Conn>(conn: &Conn, window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1574 pub fn print_start_page<Conn>(conn: &Conn, window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1575 where
1576     Conn: RequestConnection + ?Sized,
1577 {
1578     let request0 = PrintStartPageRequest {
1579         window,
1580     };
1581     request0.send(conn)
1582 }
1583 
1584 /// Opcode for the PrintEndPage request
1585 pub const PRINT_END_PAGE_REQUEST: u8 = 14;
1586 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1587 pub struct PrintEndPageRequest {
1588     pub cancel: bool,
1589 }
1590 impl PrintEndPageRequest {
1591     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1592     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1593     where
1594         Conn: RequestConnection + ?Sized,
1595     {
1596         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1597             .ok_or(ConnectionError::UnsupportedExtension)?;
1598         let length_so_far = 0;
1599         let cancel_bytes = self.cancel.serialize();
1600         let mut request0 = vec![
1601             extension_information.major_opcode,
1602             PRINT_END_PAGE_REQUEST,
1603             0,
1604             0,
1605             cancel_bytes[0],
1606             0,
1607             0,
1608             0,
1609         ];
1610         let length_so_far = length_so_far + request0.len();
1611         assert_eq!(length_so_far % 4, 0);
1612         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1613         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1614         Ok((vec![request0.into()], vec![]))
1615     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1616     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1617     where
1618         Conn: RequestConnection + ?Sized,
1619     {
1620         let (bytes, fds) = self.serialize(conn)?;
1621         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1622         conn.send_request_without_reply(&slices, fds)
1623     }
1624     /// 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>1625     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1626         if header.minor_opcode != PRINT_END_PAGE_REQUEST {
1627             return Err(ParseError::InvalidValue);
1628         }
1629         let (cancel, remaining) = bool::try_parse(value)?;
1630         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
1631         let _ = remaining;
1632         Ok(PrintEndPageRequest {
1633             cancel,
1634         })
1635     }
1636 }
1637 impl Request for PrintEndPageRequest {
1638     type Reply = ();
1639 }
print_end_page<Conn>(conn: &Conn, cancel: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1640 pub fn print_end_page<Conn>(conn: &Conn, cancel: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1641 where
1642     Conn: RequestConnection + ?Sized,
1643 {
1644     let request0 = PrintEndPageRequest {
1645         cancel,
1646     };
1647     request0.send(conn)
1648 }
1649 
1650 /// Opcode for the PrintSelectInput request
1651 pub const PRINT_SELECT_INPUT_REQUEST: u8 = 15;
1652 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1653 pub struct PrintSelectInputRequest {
1654     pub context: Pcontext,
1655     pub event_mask: u32,
1656 }
1657 impl PrintSelectInputRequest {
1658     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1659     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1660     where
1661         Conn: RequestConnection + ?Sized,
1662     {
1663         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1664             .ok_or(ConnectionError::UnsupportedExtension)?;
1665         let length_so_far = 0;
1666         let context_bytes = self.context.serialize();
1667         let event_mask_bytes = self.event_mask.serialize();
1668         let mut request0 = vec![
1669             extension_information.major_opcode,
1670             PRINT_SELECT_INPUT_REQUEST,
1671             0,
1672             0,
1673             context_bytes[0],
1674             context_bytes[1],
1675             context_bytes[2],
1676             context_bytes[3],
1677             event_mask_bytes[0],
1678             event_mask_bytes[1],
1679             event_mask_bytes[2],
1680             event_mask_bytes[3],
1681         ];
1682         let length_so_far = length_so_far + request0.len();
1683         assert_eq!(length_so_far % 4, 0);
1684         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1685         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1686         Ok((vec![request0.into()], vec![]))
1687     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1688     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1689     where
1690         Conn: RequestConnection + ?Sized,
1691     {
1692         let (bytes, fds) = self.serialize(conn)?;
1693         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1694         conn.send_request_without_reply(&slices, fds)
1695     }
1696     /// 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>1697     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1698         if header.minor_opcode != PRINT_SELECT_INPUT_REQUEST {
1699             return Err(ParseError::InvalidValue);
1700         }
1701         let (context, remaining) = Pcontext::try_parse(value)?;
1702         let (event_mask, remaining) = u32::try_parse(remaining)?;
1703         let _ = remaining;
1704         Ok(PrintSelectInputRequest {
1705             context,
1706             event_mask,
1707         })
1708     }
1709 }
1710 impl Request for PrintSelectInputRequest {
1711     type Reply = ();
1712 }
print_select_input<Conn>(conn: &Conn, context: Pcontext, event_mask: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1713 pub fn print_select_input<Conn>(conn: &Conn, context: Pcontext, event_mask: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1714 where
1715     Conn: RequestConnection + ?Sized,
1716 {
1717     let request0 = PrintSelectInputRequest {
1718         context,
1719         event_mask,
1720     };
1721     request0.send(conn)
1722 }
1723 
1724 /// Opcode for the PrintInputSelected request
1725 pub const PRINT_INPUT_SELECTED_REQUEST: u8 = 16;
1726 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1727 pub struct PrintInputSelectedRequest {
1728     pub context: Pcontext,
1729 }
1730 impl PrintInputSelectedRequest {
1731     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1732     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1733     where
1734         Conn: RequestConnection + ?Sized,
1735     {
1736         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1737             .ok_or(ConnectionError::UnsupportedExtension)?;
1738         let length_so_far = 0;
1739         let context_bytes = self.context.serialize();
1740         let mut request0 = vec![
1741             extension_information.major_opcode,
1742             PRINT_INPUT_SELECTED_REQUEST,
1743             0,
1744             0,
1745             context_bytes[0],
1746             context_bytes[1],
1747             context_bytes[2],
1748             context_bytes[3],
1749         ];
1750         let length_so_far = length_so_far + request0.len();
1751         assert_eq!(length_so_far % 4, 0);
1752         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1753         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1754         Ok((vec![request0.into()], vec![]))
1755     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintInputSelectedReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1756     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintInputSelectedReply>, ConnectionError>
1757     where
1758         Conn: RequestConnection + ?Sized,
1759     {
1760         let (bytes, fds) = self.serialize(conn)?;
1761         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1762         conn.send_request_with_reply(&slices, fds)
1763     }
1764     /// 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>1765     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1766         if header.minor_opcode != PRINT_INPUT_SELECTED_REQUEST {
1767             return Err(ParseError::InvalidValue);
1768         }
1769         let (context, remaining) = Pcontext::try_parse(value)?;
1770         let _ = remaining;
1771         Ok(PrintInputSelectedRequest {
1772             context,
1773         })
1774     }
1775 }
1776 impl Request for PrintInputSelectedRequest {
1777     type Reply = PrintInputSelectedReply;
1778 }
print_input_selected<Conn>(conn: &Conn, context: Pcontext) -> Result<Cookie<'_, Conn, PrintInputSelectedReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1779 pub fn print_input_selected<Conn>(conn: &Conn, context: Pcontext) -> Result<Cookie<'_, Conn, PrintInputSelectedReply>, ConnectionError>
1780 where
1781     Conn: RequestConnection + ?Sized,
1782 {
1783     let request0 = PrintInputSelectedRequest {
1784         context,
1785     };
1786     request0.send(conn)
1787 }
1788 
1789 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1790 pub struct PrintInputSelectedReply {
1791     pub sequence: u16,
1792     pub length: u32,
1793     pub event_mask: u32,
1794     pub all_events_mask: u32,
1795 }
1796 impl TryParse for PrintInputSelectedReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1797     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1798         let remaining = initial_value;
1799         let (response_type, remaining) = u8::try_parse(remaining)?;
1800         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1801         let (sequence, remaining) = u16::try_parse(remaining)?;
1802         let (length, remaining) = u32::try_parse(remaining)?;
1803         let (event_mask, remaining) = u32::try_parse(remaining)?;
1804         let (all_events_mask, remaining) = u32::try_parse(remaining)?;
1805         if response_type != 1 {
1806             return Err(ParseError::InvalidValue);
1807         }
1808         let result = PrintInputSelectedReply { sequence, length, event_mask, all_events_mask };
1809         let _ = remaining;
1810         let remaining = initial_value.get(32 + length as usize * 4..)
1811             .ok_or(ParseError::InsufficientData)?;
1812         Ok((result, remaining))
1813     }
1814 }
1815 
1816 /// Opcode for the PrintGetAttributes request
1817 pub const PRINT_GET_ATTRIBUTES_REQUEST: u8 = 17;
1818 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1819 pub struct PrintGetAttributesRequest {
1820     pub context: Pcontext,
1821     pub pool: u8,
1822 }
1823 impl PrintGetAttributesRequest {
1824     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1825     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1826     where
1827         Conn: RequestConnection + ?Sized,
1828     {
1829         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1830             .ok_or(ConnectionError::UnsupportedExtension)?;
1831         let length_so_far = 0;
1832         let context_bytes = self.context.serialize();
1833         let pool_bytes = self.pool.serialize();
1834         let mut request0 = vec![
1835             extension_information.major_opcode,
1836             PRINT_GET_ATTRIBUTES_REQUEST,
1837             0,
1838             0,
1839             context_bytes[0],
1840             context_bytes[1],
1841             context_bytes[2],
1842             context_bytes[3],
1843             pool_bytes[0],
1844             0,
1845             0,
1846             0,
1847         ];
1848         let length_so_far = length_so_far + request0.len();
1849         assert_eq!(length_so_far % 4, 0);
1850         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1851         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1852         Ok((vec![request0.into()], vec![]))
1853     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1854     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetAttributesReply>, ConnectionError>
1855     where
1856         Conn: RequestConnection + ?Sized,
1857     {
1858         let (bytes, fds) = self.serialize(conn)?;
1859         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1860         conn.send_request_with_reply(&slices, fds)
1861     }
1862     /// 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>1863     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1864         if header.minor_opcode != PRINT_GET_ATTRIBUTES_REQUEST {
1865             return Err(ParseError::InvalidValue);
1866         }
1867         let (context, remaining) = Pcontext::try_parse(value)?;
1868         let (pool, remaining) = u8::try_parse(remaining)?;
1869         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
1870         let _ = remaining;
1871         Ok(PrintGetAttributesRequest {
1872             context,
1873             pool,
1874         })
1875     }
1876 }
1877 impl Request for PrintGetAttributesRequest {
1878     type Reply = PrintGetAttributesReply;
1879 }
print_get_attributes<Conn>(conn: &Conn, context: Pcontext, pool: u8) -> Result<Cookie<'_, Conn, PrintGetAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1880 pub fn print_get_attributes<Conn>(conn: &Conn, context: Pcontext, pool: u8) -> Result<Cookie<'_, Conn, PrintGetAttributesReply>, ConnectionError>
1881 where
1882     Conn: RequestConnection + ?Sized,
1883 {
1884     let request0 = PrintGetAttributesRequest {
1885         context,
1886         pool,
1887     };
1888     request0.send(conn)
1889 }
1890 
1891 #[derive(Debug, Clone, PartialEq, Eq)]
1892 pub struct PrintGetAttributesReply {
1893     pub sequence: u16,
1894     pub length: u32,
1895     pub attributes: Vec<String8>,
1896 }
1897 impl TryParse for PrintGetAttributesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1898     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1899         let remaining = initial_value;
1900         let (response_type, remaining) = u8::try_parse(remaining)?;
1901         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1902         let (sequence, remaining) = u16::try_parse(remaining)?;
1903         let (length, remaining) = u32::try_parse(remaining)?;
1904         let (string_len, remaining) = u32::try_parse(remaining)?;
1905         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1906         let (attributes, remaining) = crate::x11_utils::parse_u8_list(remaining, string_len.try_to_usize()?)?;
1907         let attributes = attributes.to_vec();
1908         if response_type != 1 {
1909             return Err(ParseError::InvalidValue);
1910         }
1911         let result = PrintGetAttributesReply { sequence, length, attributes };
1912         let _ = remaining;
1913         let remaining = initial_value.get(32 + length as usize * 4..)
1914             .ok_or(ParseError::InsufficientData)?;
1915         Ok((result, remaining))
1916     }
1917 }
1918 impl PrintGetAttributesReply {
1919     /// Get the value of the `stringLen` field.
1920     ///
1921     /// The `stringLen` field is used as the length field of the `attributes` field.
1922     /// This function computes the field's value again based on the length of the list.
1923     ///
1924     /// # Panics
1925     ///
1926     /// Panics if the value cannot be represented in the target type. This
1927     /// cannot happen with values of the struct received from the X11 server.
string_len(&self) -> u321928     pub fn string_len(&self) -> u32 {
1929         self.attributes.len()
1930             .try_into().unwrap()
1931     }
1932 }
1933 
1934 /// Opcode for the PrintGetOneAttributes request
1935 pub const PRINT_GET_ONE_ATTRIBUTES_REQUEST: u8 = 19;
1936 #[derive(Debug, Clone, PartialEq, Eq)]
1937 pub struct PrintGetOneAttributesRequest<'input> {
1938     pub context: Pcontext,
1939     pub pool: u8,
1940     pub name: Cow<'input, [String8]>,
1941 }
1942 impl<'input> PrintGetOneAttributesRequest<'input> {
1943     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1944     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1945     where
1946         Conn: RequestConnection + ?Sized,
1947     {
1948         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1949             .ok_or(ConnectionError::UnsupportedExtension)?;
1950         let length_so_far = 0;
1951         let context_bytes = self.context.serialize();
1952         let name_len = u32::try_from(self.name.len()).expect("`name` has too many elements");
1953         let name_len_bytes = name_len.serialize();
1954         let pool_bytes = self.pool.serialize();
1955         let mut request0 = vec![
1956             extension_information.major_opcode,
1957             PRINT_GET_ONE_ATTRIBUTES_REQUEST,
1958             0,
1959             0,
1960             context_bytes[0],
1961             context_bytes[1],
1962             context_bytes[2],
1963             context_bytes[3],
1964             name_len_bytes[0],
1965             name_len_bytes[1],
1966             name_len_bytes[2],
1967             name_len_bytes[3],
1968             pool_bytes[0],
1969             0,
1970             0,
1971             0,
1972         ];
1973         let length_so_far = length_so_far + request0.len();
1974         let length_so_far = length_so_far + self.name.len();
1975         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1976         let length_so_far = length_so_far + padding0.len();
1977         assert_eq!(length_so_far % 4, 0);
1978         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1979         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1980         Ok((vec![request0.into(), self.name, padding0.into()], vec![]))
1981     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetOneAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1982     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetOneAttributesReply>, ConnectionError>
1983     where
1984         Conn: RequestConnection + ?Sized,
1985     {
1986         let (bytes, fds) = self.serialize(conn)?;
1987         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1988         conn.send_request_with_reply(&slices, fds)
1989     }
1990     /// 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>1991     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1992         if header.minor_opcode != PRINT_GET_ONE_ATTRIBUTES_REQUEST {
1993             return Err(ParseError::InvalidValue);
1994         }
1995         let (context, remaining) = Pcontext::try_parse(value)?;
1996         let (name_len, remaining) = u32::try_parse(remaining)?;
1997         let (pool, remaining) = u8::try_parse(remaining)?;
1998         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
1999         let (name, remaining) = crate::x11_utils::parse_u8_list(remaining, name_len.try_to_usize()?)?;
2000         let _ = remaining;
2001         Ok(PrintGetOneAttributesRequest {
2002             context,
2003             pool,
2004             name: Cow::Borrowed(name),
2005         })
2006     }
2007     /// Clone all borrowed data in this PrintGetOneAttributesRequest.
into_owned(self) -> PrintGetOneAttributesRequest<'static>2008     pub fn into_owned(self) -> PrintGetOneAttributesRequest<'static> {
2009         PrintGetOneAttributesRequest {
2010             context: self.context,
2011             pool: self.pool,
2012             name: Cow::Owned(self.name.into_owned()),
2013         }
2014     }
2015 }
2016 impl<'input> Request for PrintGetOneAttributesRequest<'input> {
2017     type Reply = PrintGetOneAttributesReply;
2018 }
print_get_one_attributes<'c, 'input, Conn>(conn: &'c Conn, context: Pcontext, pool: u8, name: &'input [String8]) -> Result<Cookie<'c, Conn, PrintGetOneAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2019 pub fn print_get_one_attributes<'c, 'input, Conn>(conn: &'c Conn, context: Pcontext, pool: u8, name: &'input [String8]) -> Result<Cookie<'c, Conn, PrintGetOneAttributesReply>, ConnectionError>
2020 where
2021     Conn: RequestConnection + ?Sized,
2022 {
2023     let request0 = PrintGetOneAttributesRequest {
2024         context,
2025         pool,
2026         name: Cow::Borrowed(name),
2027     };
2028     request0.send(conn)
2029 }
2030 
2031 #[derive(Debug, Clone, PartialEq, Eq)]
2032 pub struct PrintGetOneAttributesReply {
2033     pub sequence: u16,
2034     pub length: u32,
2035     pub value: Vec<String8>,
2036 }
2037 impl TryParse for PrintGetOneAttributesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2038     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2039         let remaining = initial_value;
2040         let (response_type, remaining) = u8::try_parse(remaining)?;
2041         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2042         let (sequence, remaining) = u16::try_parse(remaining)?;
2043         let (length, remaining) = u32::try_parse(remaining)?;
2044         let (value_len, remaining) = u32::try_parse(remaining)?;
2045         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2046         let (value, remaining) = crate::x11_utils::parse_u8_list(remaining, value_len.try_to_usize()?)?;
2047         let value = value.to_vec();
2048         if response_type != 1 {
2049             return Err(ParseError::InvalidValue);
2050         }
2051         let result = PrintGetOneAttributesReply { sequence, length, value };
2052         let _ = remaining;
2053         let remaining = initial_value.get(32 + length as usize * 4..)
2054             .ok_or(ParseError::InsufficientData)?;
2055         Ok((result, remaining))
2056     }
2057 }
2058 impl PrintGetOneAttributesReply {
2059     /// Get the value of the `valueLen` field.
2060     ///
2061     /// The `valueLen` field is used as the length field of the `value` field.
2062     /// This function computes the field's value again based on the length of the list.
2063     ///
2064     /// # Panics
2065     ///
2066     /// Panics if the value cannot be represented in the target type. This
2067     /// cannot happen with values of the struct received from the X11 server.
value_len(&self) -> u322068     pub fn value_len(&self) -> u32 {
2069         self.value.len()
2070             .try_into().unwrap()
2071     }
2072 }
2073 
2074 /// Opcode for the PrintSetAttributes request
2075 pub const PRINT_SET_ATTRIBUTES_REQUEST: u8 = 18;
2076 #[derive(Debug, Clone, PartialEq, Eq)]
2077 pub struct PrintSetAttributesRequest<'input> {
2078     pub context: Pcontext,
2079     pub string_len: u32,
2080     pub pool: u8,
2081     pub rule: u8,
2082     pub attributes: Cow<'input, [String8]>,
2083 }
2084 impl<'input> PrintSetAttributesRequest<'input> {
2085     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2086     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2087     where
2088         Conn: RequestConnection + ?Sized,
2089     {
2090         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2091             .ok_or(ConnectionError::UnsupportedExtension)?;
2092         let length_so_far = 0;
2093         let context_bytes = self.context.serialize();
2094         let string_len_bytes = self.string_len.serialize();
2095         let pool_bytes = self.pool.serialize();
2096         let rule_bytes = self.rule.serialize();
2097         let mut request0 = vec![
2098             extension_information.major_opcode,
2099             PRINT_SET_ATTRIBUTES_REQUEST,
2100             0,
2101             0,
2102             context_bytes[0],
2103             context_bytes[1],
2104             context_bytes[2],
2105             context_bytes[3],
2106             string_len_bytes[0],
2107             string_len_bytes[1],
2108             string_len_bytes[2],
2109             string_len_bytes[3],
2110             pool_bytes[0],
2111             rule_bytes[0],
2112             0,
2113             0,
2114         ];
2115         let length_so_far = length_so_far + request0.len();
2116         let length_so_far = length_so_far + self.attributes.len();
2117         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2118         let length_so_far = length_so_far + padding0.len();
2119         assert_eq!(length_so_far % 4, 0);
2120         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2121         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2122         Ok((vec![request0.into(), self.attributes, padding0.into()], vec![]))
2123     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2124     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2125     where
2126         Conn: RequestConnection + ?Sized,
2127     {
2128         let (bytes, fds) = self.serialize(conn)?;
2129         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2130         conn.send_request_without_reply(&slices, fds)
2131     }
2132     /// 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>2133     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2134         if header.minor_opcode != PRINT_SET_ATTRIBUTES_REQUEST {
2135             return Err(ParseError::InvalidValue);
2136         }
2137         let (context, remaining) = Pcontext::try_parse(value)?;
2138         let (string_len, remaining) = u32::try_parse(remaining)?;
2139         let (pool, remaining) = u8::try_parse(remaining)?;
2140         let (rule, remaining) = u8::try_parse(remaining)?;
2141         let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
2142         let (attributes, remaining) = remaining.split_at(remaining.len());
2143         let _ = remaining;
2144         Ok(PrintSetAttributesRequest {
2145             context,
2146             string_len,
2147             pool,
2148             rule,
2149             attributes: Cow::Borrowed(attributes),
2150         })
2151     }
2152     /// Clone all borrowed data in this PrintSetAttributesRequest.
into_owned(self) -> PrintSetAttributesRequest<'static>2153     pub fn into_owned(self) -> PrintSetAttributesRequest<'static> {
2154         PrintSetAttributesRequest {
2155             context: self.context,
2156             string_len: self.string_len,
2157             pool: self.pool,
2158             rule: self.rule,
2159             attributes: Cow::Owned(self.attributes.into_owned()),
2160         }
2161     }
2162 }
2163 impl<'input> Request for PrintSetAttributesRequest<'input> {
2164     type Reply = ();
2165 }
print_set_attributes<'c, 'input, Conn>(conn: &'c Conn, context: Pcontext, string_len: u32, pool: u8, rule: u8, attributes: &'input [String8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2166 pub fn print_set_attributes<'c, 'input, Conn>(conn: &'c Conn, context: Pcontext, string_len: u32, pool: u8, rule: u8, attributes: &'input [String8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2167 where
2168     Conn: RequestConnection + ?Sized,
2169 {
2170     let request0 = PrintSetAttributesRequest {
2171         context,
2172         string_len,
2173         pool,
2174         rule,
2175         attributes: Cow::Borrowed(attributes),
2176     };
2177     request0.send(conn)
2178 }
2179 
2180 /// Opcode for the PrintGetPageDimensions request
2181 pub const PRINT_GET_PAGE_DIMENSIONS_REQUEST: u8 = 21;
2182 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2183 pub struct PrintGetPageDimensionsRequest {
2184     pub context: Pcontext,
2185 }
2186 impl PrintGetPageDimensionsRequest {
2187     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2188     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2189     where
2190         Conn: RequestConnection + ?Sized,
2191     {
2192         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2193             .ok_or(ConnectionError::UnsupportedExtension)?;
2194         let length_so_far = 0;
2195         let context_bytes = self.context.serialize();
2196         let mut request0 = vec![
2197             extension_information.major_opcode,
2198             PRINT_GET_PAGE_DIMENSIONS_REQUEST,
2199             0,
2200             0,
2201             context_bytes[0],
2202             context_bytes[1],
2203             context_bytes[2],
2204             context_bytes[3],
2205         ];
2206         let length_so_far = length_so_far + request0.len();
2207         assert_eq!(length_so_far % 4, 0);
2208         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2209         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2210         Ok((vec![request0.into()], vec![]))
2211     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetPageDimensionsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2212     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetPageDimensionsReply>, ConnectionError>
2213     where
2214         Conn: RequestConnection + ?Sized,
2215     {
2216         let (bytes, fds) = self.serialize(conn)?;
2217         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2218         conn.send_request_with_reply(&slices, fds)
2219     }
2220     /// 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>2221     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2222         if header.minor_opcode != PRINT_GET_PAGE_DIMENSIONS_REQUEST {
2223             return Err(ParseError::InvalidValue);
2224         }
2225         let (context, remaining) = Pcontext::try_parse(value)?;
2226         let _ = remaining;
2227         Ok(PrintGetPageDimensionsRequest {
2228             context,
2229         })
2230     }
2231 }
2232 impl Request for PrintGetPageDimensionsRequest {
2233     type Reply = PrintGetPageDimensionsReply;
2234 }
print_get_page_dimensions<Conn>(conn: &Conn, context: Pcontext) -> Result<Cookie<'_, Conn, PrintGetPageDimensionsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2235 pub fn print_get_page_dimensions<Conn>(conn: &Conn, context: Pcontext) -> Result<Cookie<'_, Conn, PrintGetPageDimensionsReply>, ConnectionError>
2236 where
2237     Conn: RequestConnection + ?Sized,
2238 {
2239     let request0 = PrintGetPageDimensionsRequest {
2240         context,
2241     };
2242     request0.send(conn)
2243 }
2244 
2245 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2246 pub struct PrintGetPageDimensionsReply {
2247     pub sequence: u16,
2248     pub length: u32,
2249     pub width: u16,
2250     pub height: u16,
2251     pub offset_x: u16,
2252     pub offset_y: u16,
2253     pub reproducible_width: u16,
2254     pub reproducible_height: u16,
2255 }
2256 impl TryParse for PrintGetPageDimensionsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2257     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2258         let remaining = initial_value;
2259         let (response_type, remaining) = u8::try_parse(remaining)?;
2260         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2261         let (sequence, remaining) = u16::try_parse(remaining)?;
2262         let (length, remaining) = u32::try_parse(remaining)?;
2263         let (width, remaining) = u16::try_parse(remaining)?;
2264         let (height, remaining) = u16::try_parse(remaining)?;
2265         let (offset_x, remaining) = u16::try_parse(remaining)?;
2266         let (offset_y, remaining) = u16::try_parse(remaining)?;
2267         let (reproducible_width, remaining) = u16::try_parse(remaining)?;
2268         let (reproducible_height, remaining) = u16::try_parse(remaining)?;
2269         if response_type != 1 {
2270             return Err(ParseError::InvalidValue);
2271         }
2272         let result = PrintGetPageDimensionsReply { sequence, length, width, height, offset_x, offset_y, reproducible_width, reproducible_height };
2273         let _ = remaining;
2274         let remaining = initial_value.get(32 + length as usize * 4..)
2275             .ok_or(ParseError::InsufficientData)?;
2276         Ok((result, remaining))
2277     }
2278 }
2279 
2280 /// Opcode for the PrintQueryScreens request
2281 pub const PRINT_QUERY_SCREENS_REQUEST: u8 = 22;
2282 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2283 pub struct PrintQueryScreensRequest;
2284 impl PrintQueryScreensRequest {
2285     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2286     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2287     where
2288         Conn: RequestConnection + ?Sized,
2289     {
2290         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2291             .ok_or(ConnectionError::UnsupportedExtension)?;
2292         let length_so_far = 0;
2293         let mut request0 = vec![
2294             extension_information.major_opcode,
2295             PRINT_QUERY_SCREENS_REQUEST,
2296             0,
2297             0,
2298         ];
2299         let length_so_far = length_so_far + request0.len();
2300         assert_eq!(length_so_far % 4, 0);
2301         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2302         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2303         Ok((vec![request0.into()], vec![]))
2304     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryScreensReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2305     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryScreensReply>, ConnectionError>
2306     where
2307         Conn: RequestConnection + ?Sized,
2308     {
2309         let (bytes, fds) = self.serialize(conn)?;
2310         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2311         conn.send_request_with_reply(&slices, fds)
2312     }
2313     /// 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>2314     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2315         if header.minor_opcode != PRINT_QUERY_SCREENS_REQUEST {
2316             return Err(ParseError::InvalidValue);
2317         }
2318         let _ = value;
2319         Ok(PrintQueryScreensRequest
2320         )
2321     }
2322 }
2323 impl Request for PrintQueryScreensRequest {
2324     type Reply = PrintQueryScreensReply;
2325 }
print_query_screens<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryScreensReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2326 pub fn print_query_screens<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, PrintQueryScreensReply>, ConnectionError>
2327 where
2328     Conn: RequestConnection + ?Sized,
2329 {
2330     let request0 = PrintQueryScreensRequest;
2331     request0.send(conn)
2332 }
2333 
2334 #[derive(Debug, Clone, PartialEq, Eq)]
2335 pub struct PrintQueryScreensReply {
2336     pub sequence: u16,
2337     pub length: u32,
2338     pub roots: Vec<xproto::Window>,
2339 }
2340 impl TryParse for PrintQueryScreensReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2341     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2342         let remaining = initial_value;
2343         let (response_type, remaining) = u8::try_parse(remaining)?;
2344         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2345         let (sequence, remaining) = u16::try_parse(remaining)?;
2346         let (length, remaining) = u32::try_parse(remaining)?;
2347         let (list_count, remaining) = u32::try_parse(remaining)?;
2348         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2349         let (roots, remaining) = crate::x11_utils::parse_list::<xproto::Window>(remaining, list_count.try_to_usize()?)?;
2350         if response_type != 1 {
2351             return Err(ParseError::InvalidValue);
2352         }
2353         let result = PrintQueryScreensReply { sequence, length, roots };
2354         let _ = remaining;
2355         let remaining = initial_value.get(32 + length as usize * 4..)
2356             .ok_or(ParseError::InsufficientData)?;
2357         Ok((result, remaining))
2358     }
2359 }
2360 impl PrintQueryScreensReply {
2361     /// Get the value of the `listCount` field.
2362     ///
2363     /// The `listCount` field is used as the length field of the `roots` field.
2364     /// This function computes the field's value again based on the length of the list.
2365     ///
2366     /// # Panics
2367     ///
2368     /// Panics if the value cannot be represented in the target type. This
2369     /// cannot happen with values of the struct received from the X11 server.
list_count(&self) -> u322370     pub fn list_count(&self) -> u32 {
2371         self.roots.len()
2372             .try_into().unwrap()
2373     }
2374 }
2375 
2376 /// Opcode for the PrintSetImageResolution request
2377 pub const PRINT_SET_IMAGE_RESOLUTION_REQUEST: u8 = 23;
2378 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2379 pub struct PrintSetImageResolutionRequest {
2380     pub context: Pcontext,
2381     pub image_resolution: u16,
2382 }
2383 impl PrintSetImageResolutionRequest {
2384     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2385     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2386     where
2387         Conn: RequestConnection + ?Sized,
2388     {
2389         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2390             .ok_or(ConnectionError::UnsupportedExtension)?;
2391         let length_so_far = 0;
2392         let context_bytes = self.context.serialize();
2393         let image_resolution_bytes = self.image_resolution.serialize();
2394         let mut request0 = vec![
2395             extension_information.major_opcode,
2396             PRINT_SET_IMAGE_RESOLUTION_REQUEST,
2397             0,
2398             0,
2399             context_bytes[0],
2400             context_bytes[1],
2401             context_bytes[2],
2402             context_bytes[3],
2403             image_resolution_bytes[0],
2404             image_resolution_bytes[1],
2405             0,
2406             0,
2407         ];
2408         let length_so_far = length_so_far + request0.len();
2409         assert_eq!(length_so_far % 4, 0);
2410         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2411         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2412         Ok((vec![request0.into()], vec![]))
2413     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintSetImageResolutionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2414     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintSetImageResolutionReply>, ConnectionError>
2415     where
2416         Conn: RequestConnection + ?Sized,
2417     {
2418         let (bytes, fds) = self.serialize(conn)?;
2419         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2420         conn.send_request_with_reply(&slices, fds)
2421     }
2422     /// 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>2423     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2424         if header.minor_opcode != PRINT_SET_IMAGE_RESOLUTION_REQUEST {
2425             return Err(ParseError::InvalidValue);
2426         }
2427         let (context, remaining) = Pcontext::try_parse(value)?;
2428         let (image_resolution, remaining) = u16::try_parse(remaining)?;
2429         let _ = remaining;
2430         Ok(PrintSetImageResolutionRequest {
2431             context,
2432             image_resolution,
2433         })
2434     }
2435 }
2436 impl Request for PrintSetImageResolutionRequest {
2437     type Reply = PrintSetImageResolutionReply;
2438 }
print_set_image_resolution<Conn>(conn: &Conn, context: Pcontext, image_resolution: u16) -> Result<Cookie<'_, Conn, PrintSetImageResolutionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2439 pub fn print_set_image_resolution<Conn>(conn: &Conn, context: Pcontext, image_resolution: u16) -> Result<Cookie<'_, Conn, PrintSetImageResolutionReply>, ConnectionError>
2440 where
2441     Conn: RequestConnection + ?Sized,
2442 {
2443     let request0 = PrintSetImageResolutionRequest {
2444         context,
2445         image_resolution,
2446     };
2447     request0.send(conn)
2448 }
2449 
2450 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2451 pub struct PrintSetImageResolutionReply {
2452     pub status: bool,
2453     pub sequence: u16,
2454     pub length: u32,
2455     pub previous_resolutions: u16,
2456 }
2457 impl TryParse for PrintSetImageResolutionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2458     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2459         let remaining = initial_value;
2460         let (response_type, remaining) = u8::try_parse(remaining)?;
2461         let (status, remaining) = bool::try_parse(remaining)?;
2462         let (sequence, remaining) = u16::try_parse(remaining)?;
2463         let (length, remaining) = u32::try_parse(remaining)?;
2464         let (previous_resolutions, remaining) = u16::try_parse(remaining)?;
2465         if response_type != 1 {
2466             return Err(ParseError::InvalidValue);
2467         }
2468         let result = PrintSetImageResolutionReply { status, sequence, length, previous_resolutions };
2469         let _ = remaining;
2470         let remaining = initial_value.get(32 + length as usize * 4..)
2471             .ok_or(ParseError::InsufficientData)?;
2472         Ok((result, remaining))
2473     }
2474 }
2475 
2476 /// Opcode for the PrintGetImageResolution request
2477 pub const PRINT_GET_IMAGE_RESOLUTION_REQUEST: u8 = 24;
2478 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2479 pub struct PrintGetImageResolutionRequest {
2480     pub context: Pcontext,
2481 }
2482 impl PrintGetImageResolutionRequest {
2483     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2484     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2485     where
2486         Conn: RequestConnection + ?Sized,
2487     {
2488         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2489             .ok_or(ConnectionError::UnsupportedExtension)?;
2490         let length_so_far = 0;
2491         let context_bytes = self.context.serialize();
2492         let mut request0 = vec![
2493             extension_information.major_opcode,
2494             PRINT_GET_IMAGE_RESOLUTION_REQUEST,
2495             0,
2496             0,
2497             context_bytes[0],
2498             context_bytes[1],
2499             context_bytes[2],
2500             context_bytes[3],
2501         ];
2502         let length_so_far = length_so_far + request0.len();
2503         assert_eq!(length_so_far % 4, 0);
2504         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2505         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2506         Ok((vec![request0.into()], vec![]))
2507     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetImageResolutionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2508     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, PrintGetImageResolutionReply>, ConnectionError>
2509     where
2510         Conn: RequestConnection + ?Sized,
2511     {
2512         let (bytes, fds) = self.serialize(conn)?;
2513         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2514         conn.send_request_with_reply(&slices, fds)
2515     }
2516     /// 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>2517     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2518         if header.minor_opcode != PRINT_GET_IMAGE_RESOLUTION_REQUEST {
2519             return Err(ParseError::InvalidValue);
2520         }
2521         let (context, remaining) = Pcontext::try_parse(value)?;
2522         let _ = remaining;
2523         Ok(PrintGetImageResolutionRequest {
2524             context,
2525         })
2526     }
2527 }
2528 impl Request for PrintGetImageResolutionRequest {
2529     type Reply = PrintGetImageResolutionReply;
2530 }
print_get_image_resolution<Conn>(conn: &Conn, context: Pcontext) -> Result<Cookie<'_, Conn, PrintGetImageResolutionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2531 pub fn print_get_image_resolution<Conn>(conn: &Conn, context: Pcontext) -> Result<Cookie<'_, Conn, PrintGetImageResolutionReply>, ConnectionError>
2532 where
2533     Conn: RequestConnection + ?Sized,
2534 {
2535     let request0 = PrintGetImageResolutionRequest {
2536         context,
2537     };
2538     request0.send(conn)
2539 }
2540 
2541 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2542 pub struct PrintGetImageResolutionReply {
2543     pub sequence: u16,
2544     pub length: u32,
2545     pub image_resolution: u16,
2546 }
2547 impl TryParse for PrintGetImageResolutionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2548     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2549         let remaining = initial_value;
2550         let (response_type, remaining) = u8::try_parse(remaining)?;
2551         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2552         let (sequence, remaining) = u16::try_parse(remaining)?;
2553         let (length, remaining) = u32::try_parse(remaining)?;
2554         let (image_resolution, remaining) = u16::try_parse(remaining)?;
2555         if response_type != 1 {
2556             return Err(ParseError::InvalidValue);
2557         }
2558         let result = PrintGetImageResolutionReply { sequence, length, image_resolution };
2559         let _ = remaining;
2560         let remaining = initial_value.get(32 + length as usize * 4..)
2561             .ok_or(ParseError::InsufficientData)?;
2562         Ok((result, remaining))
2563     }
2564 }
2565 
2566 /// Opcode for the Notify event
2567 pub const NOTIFY_EVENT: u8 = 0;
2568 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2569 pub struct NotifyEvent {
2570     pub response_type: u8,
2571     pub detail: u8,
2572     pub sequence: u16,
2573     pub context: Pcontext,
2574     pub cancel: bool,
2575 }
2576 impl TryParse for NotifyEvent {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2577     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2578         let remaining = initial_value;
2579         let (response_type, remaining) = u8::try_parse(remaining)?;
2580         let (detail, remaining) = u8::try_parse(remaining)?;
2581         let (sequence, remaining) = u16::try_parse(remaining)?;
2582         let (context, remaining) = Pcontext::try_parse(remaining)?;
2583         let (cancel, remaining) = bool::try_parse(remaining)?;
2584         let result = NotifyEvent { response_type, detail, sequence, context, cancel };
2585         let _ = remaining;
2586         let remaining = initial_value.get(32..)
2587             .ok_or(ParseError::InsufficientData)?;
2588         Ok((result, remaining))
2589     }
2590 }
2591 impl From<&NotifyEvent> for [u8; 32] {
from(input: &NotifyEvent) -> Self2592     fn from(input: &NotifyEvent) -> Self {
2593         let response_type_bytes = input.response_type.serialize();
2594         let detail_bytes = input.detail.serialize();
2595         let sequence_bytes = input.sequence.serialize();
2596         let context_bytes = input.context.serialize();
2597         let cancel_bytes = input.cancel.serialize();
2598         [
2599             response_type_bytes[0],
2600             detail_bytes[0],
2601             sequence_bytes[0],
2602             sequence_bytes[1],
2603             context_bytes[0],
2604             context_bytes[1],
2605             context_bytes[2],
2606             context_bytes[3],
2607             cancel_bytes[0],
2608             // trailing padding
2609             0,
2610             0,
2611             0,
2612             0,
2613             0,
2614             0,
2615             0,
2616             0,
2617             0,
2618             0,
2619             0,
2620             0,
2621             0,
2622             0,
2623             0,
2624             0,
2625             0,
2626             0,
2627             0,
2628             0,
2629             0,
2630             0,
2631             0,
2632         ]
2633     }
2634 }
2635 impl From<NotifyEvent> for [u8; 32] {
from(input: NotifyEvent) -> Self2636     fn from(input: NotifyEvent) -> Self {
2637         Self::from(&input)
2638     }
2639 }
2640 
2641 /// Opcode for the AttributNotify event
2642 pub const ATTRIBUT_NOTIFY_EVENT: u8 = 1;
2643 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2644 pub struct AttributNotifyEvent {
2645     pub response_type: u8,
2646     pub detail: u8,
2647     pub sequence: u16,
2648     pub context: Pcontext,
2649 }
2650 impl TryParse for AttributNotifyEvent {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2651     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2652         let remaining = initial_value;
2653         let (response_type, remaining) = u8::try_parse(remaining)?;
2654         let (detail, remaining) = u8::try_parse(remaining)?;
2655         let (sequence, remaining) = u16::try_parse(remaining)?;
2656         let (context, remaining) = Pcontext::try_parse(remaining)?;
2657         let result = AttributNotifyEvent { response_type, detail, sequence, context };
2658         let _ = remaining;
2659         let remaining = initial_value.get(32..)
2660             .ok_or(ParseError::InsufficientData)?;
2661         Ok((result, remaining))
2662     }
2663 }
2664 impl From<&AttributNotifyEvent> for [u8; 32] {
from(input: &AttributNotifyEvent) -> Self2665     fn from(input: &AttributNotifyEvent) -> Self {
2666         let response_type_bytes = input.response_type.serialize();
2667         let detail_bytes = input.detail.serialize();
2668         let sequence_bytes = input.sequence.serialize();
2669         let context_bytes = input.context.serialize();
2670         [
2671             response_type_bytes[0],
2672             detail_bytes[0],
2673             sequence_bytes[0],
2674             sequence_bytes[1],
2675             context_bytes[0],
2676             context_bytes[1],
2677             context_bytes[2],
2678             context_bytes[3],
2679             // trailing padding
2680             0,
2681             0,
2682             0,
2683             0,
2684             0,
2685             0,
2686             0,
2687             0,
2688             0,
2689             0,
2690             0,
2691             0,
2692             0,
2693             0,
2694             0,
2695             0,
2696             0,
2697             0,
2698             0,
2699             0,
2700             0,
2701             0,
2702             0,
2703             0,
2704         ]
2705     }
2706 }
2707 impl From<AttributNotifyEvent> for [u8; 32] {
from(input: AttributNotifyEvent) -> Self2708     fn from(input: AttributNotifyEvent) -> Self {
2709         Self::from(&input)
2710     }
2711 }
2712 
2713 /// Opcode for the BadContext error
2714 pub const BAD_CONTEXT_ERROR: u8 = 0;
2715 
2716 /// Opcode for the BadSequence error
2717 pub const BAD_SEQUENCE_ERROR: u8 = 1;
2718 
2719 /// Extension trait defining the requests of this extension.
2720 pub trait ConnectionExt: RequestConnection {
xprint_print_query_version(&self) -> Result<Cookie<'_, Self, PrintQueryVersionReply>, ConnectionError>2721     fn xprint_print_query_version(&self) -> Result<Cookie<'_, Self, PrintQueryVersionReply>, ConnectionError>
2722     {
2723         print_query_version(self)
2724     }
xprint_print_get_printer_list<'c, 'input>(&'c self, printer_name: &'input [String8], locale: &'input [String8]) -> Result<Cookie<'c, Self, PrintGetPrinterListReply>, ConnectionError>2725     fn xprint_print_get_printer_list<'c, 'input>(&'c self, printer_name: &'input [String8], locale: &'input [String8]) -> Result<Cookie<'c, Self, PrintGetPrinterListReply>, ConnectionError>
2726     {
2727         print_get_printer_list(self, printer_name, locale)
2728     }
xprint_print_rehash_printer_list(&self) -> Result<VoidCookie<'_, Self>, ConnectionError>2729     fn xprint_print_rehash_printer_list(&self) -> Result<VoidCookie<'_, Self>, ConnectionError>
2730     {
2731         print_rehash_printer_list(self)
2732     }
xprint_create_context<'c, 'input>(&'c self, context_id: u32, printer_name: &'input [String8], locale: &'input [String8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2733     fn xprint_create_context<'c, 'input>(&'c self, context_id: u32, printer_name: &'input [String8], locale: &'input [String8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2734     {
2735         create_context(self, context_id, printer_name, locale)
2736     }
xprint_print_set_context(&self, context: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>2737     fn xprint_print_set_context(&self, context: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
2738     {
2739         print_set_context(self, context)
2740     }
xprint_print_get_context(&self) -> Result<Cookie<'_, Self, PrintGetContextReply>, ConnectionError>2741     fn xprint_print_get_context(&self) -> Result<Cookie<'_, Self, PrintGetContextReply>, ConnectionError>
2742     {
2743         print_get_context(self)
2744     }
xprint_print_destroy_context(&self, context: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>2745     fn xprint_print_destroy_context(&self, context: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
2746     {
2747         print_destroy_context(self, context)
2748     }
xprint_print_get_screen_of_context(&self) -> Result<Cookie<'_, Self, PrintGetScreenOfContextReply>, ConnectionError>2749     fn xprint_print_get_screen_of_context(&self) -> Result<Cookie<'_, Self, PrintGetScreenOfContextReply>, ConnectionError>
2750     {
2751         print_get_screen_of_context(self)
2752     }
xprint_print_start_job(&self, output_mode: u8) -> Result<VoidCookie<'_, Self>, ConnectionError>2753     fn xprint_print_start_job(&self, output_mode: u8) -> Result<VoidCookie<'_, Self>, ConnectionError>
2754     {
2755         print_start_job(self, output_mode)
2756     }
xprint_print_end_job(&self, cancel: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>2757     fn xprint_print_end_job(&self, cancel: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
2758     {
2759         print_end_job(self, cancel)
2760     }
xprint_print_start_doc(&self, driver_mode: u8) -> Result<VoidCookie<'_, Self>, ConnectionError>2761     fn xprint_print_start_doc(&self, driver_mode: u8) -> Result<VoidCookie<'_, Self>, ConnectionError>
2762     {
2763         print_start_doc(self, driver_mode)
2764     }
xprint_print_end_doc(&self, cancel: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>2765     fn xprint_print_end_doc(&self, cancel: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
2766     {
2767         print_end_doc(self, cancel)
2768     }
xprint_print_put_document_data<'c, 'input>(&'c self, drawable: xproto::Drawable, data: &'input [u8], doc_format: &'input [String8], options: &'input [String8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2769     fn xprint_print_put_document_data<'c, 'input>(&'c self, drawable: xproto::Drawable, data: &'input [u8], doc_format: &'input [String8], options: &'input [String8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2770     {
2771         print_put_document_data(self, drawable, data, doc_format, options)
2772     }
xprint_print_get_document_data(&self, context: Pcontext, max_bytes: u32) -> Result<Cookie<'_, Self, PrintGetDocumentDataReply>, ConnectionError>2773     fn xprint_print_get_document_data(&self, context: Pcontext, max_bytes: u32) -> Result<Cookie<'_, Self, PrintGetDocumentDataReply>, ConnectionError>
2774     {
2775         print_get_document_data(self, context, max_bytes)
2776     }
xprint_print_start_page(&self, window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError>2777     fn xprint_print_start_page(&self, window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
2778     {
2779         print_start_page(self, window)
2780     }
xprint_print_end_page(&self, cancel: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>2781     fn xprint_print_end_page(&self, cancel: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
2782     {
2783         print_end_page(self, cancel)
2784     }
xprint_print_select_input(&self, context: Pcontext, event_mask: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>2785     fn xprint_print_select_input(&self, context: Pcontext, event_mask: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
2786     {
2787         print_select_input(self, context, event_mask)
2788     }
xprint_print_input_selected(&self, context: Pcontext) -> Result<Cookie<'_, Self, PrintInputSelectedReply>, ConnectionError>2789     fn xprint_print_input_selected(&self, context: Pcontext) -> Result<Cookie<'_, Self, PrintInputSelectedReply>, ConnectionError>
2790     {
2791         print_input_selected(self, context)
2792     }
xprint_print_get_attributes(&self, context: Pcontext, pool: u8) -> Result<Cookie<'_, Self, PrintGetAttributesReply>, ConnectionError>2793     fn xprint_print_get_attributes(&self, context: Pcontext, pool: u8) -> Result<Cookie<'_, Self, PrintGetAttributesReply>, ConnectionError>
2794     {
2795         print_get_attributes(self, context, pool)
2796     }
xprint_print_get_one_attributes<'c, 'input>(&'c self, context: Pcontext, pool: u8, name: &'input [String8]) -> Result<Cookie<'c, Self, PrintGetOneAttributesReply>, ConnectionError>2797     fn xprint_print_get_one_attributes<'c, 'input>(&'c self, context: Pcontext, pool: u8, name: &'input [String8]) -> Result<Cookie<'c, Self, PrintGetOneAttributesReply>, ConnectionError>
2798     {
2799         print_get_one_attributes(self, context, pool, name)
2800     }
xprint_print_set_attributes<'c, 'input>(&'c self, context: Pcontext, string_len: u32, pool: u8, rule: u8, attributes: &'input [String8]) -> Result<VoidCookie<'c, Self>, ConnectionError>2801     fn xprint_print_set_attributes<'c, 'input>(&'c self, context: Pcontext, string_len: u32, pool: u8, rule: u8, attributes: &'input [String8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
2802     {
2803         print_set_attributes(self, context, string_len, pool, rule, attributes)
2804     }
xprint_print_get_page_dimensions(&self, context: Pcontext) -> Result<Cookie<'_, Self, PrintGetPageDimensionsReply>, ConnectionError>2805     fn xprint_print_get_page_dimensions(&self, context: Pcontext) -> Result<Cookie<'_, Self, PrintGetPageDimensionsReply>, ConnectionError>
2806     {
2807         print_get_page_dimensions(self, context)
2808     }
xprint_print_query_screens(&self) -> Result<Cookie<'_, Self, PrintQueryScreensReply>, ConnectionError>2809     fn xprint_print_query_screens(&self) -> Result<Cookie<'_, Self, PrintQueryScreensReply>, ConnectionError>
2810     {
2811         print_query_screens(self)
2812     }
xprint_print_set_image_resolution(&self, context: Pcontext, image_resolution: u16) -> Result<Cookie<'_, Self, PrintSetImageResolutionReply>, ConnectionError>2813     fn xprint_print_set_image_resolution(&self, context: Pcontext, image_resolution: u16) -> Result<Cookie<'_, Self, PrintSetImageResolutionReply>, ConnectionError>
2814     {
2815         print_set_image_resolution(self, context, image_resolution)
2816     }
xprint_print_get_image_resolution(&self, context: Pcontext) -> Result<Cookie<'_, Self, PrintGetImageResolutionReply>, ConnectionError>2817     fn xprint_print_get_image_resolution(&self, context: Pcontext) -> Result<Cookie<'_, Self, PrintGetImageResolutionReply>, ConnectionError>
2818     {
2819         print_get_image_resolution(self, context)
2820     }
2821 }
2822 
2823 impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
2824