1 // This file contains generated code. Do not edit directly.
2 // To regenerate this, run 'make'.
3 
4 //! Bindings to the `Render` 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 = "RENDER";
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) = (0, 11);
34 
35 #[derive(Clone, Copy, PartialEq, Eq)]
36 pub struct PictType(u8);
37 impl PictType {
38     pub const INDEXED: Self = Self(0);
39     pub const DIRECT: Self = Self(1);
40 }
41 impl From<PictType> for u8 {
42     #[inline]
from(input: PictType) -> Self43     fn from(input: PictType) -> Self {
44         input.0
45     }
46 }
47 impl From<PictType> for Option<u8> {
48     #[inline]
from(input: PictType) -> Self49     fn from(input: PictType) -> Self {
50         Some(input.0)
51     }
52 }
53 impl From<PictType> for u16 {
54     #[inline]
from(input: PictType) -> Self55     fn from(input: PictType) -> Self {
56         u16::from(input.0)
57     }
58 }
59 impl From<PictType> for Option<u16> {
60     #[inline]
from(input: PictType) -> Self61     fn from(input: PictType) -> Self {
62         Some(u16::from(input.0))
63     }
64 }
65 impl From<PictType> for u32 {
66     #[inline]
from(input: PictType) -> Self67     fn from(input: PictType) -> Self {
68         u32::from(input.0)
69     }
70 }
71 impl From<PictType> for Option<u32> {
72     #[inline]
from(input: PictType) -> Self73     fn from(input: PictType) -> Self {
74         Some(u32::from(input.0))
75     }
76 }
77 impl From<u8> for PictType {
78     #[inline]
from(value: u8) -> Self79     fn from(value: u8) -> Self {
80         Self(value)
81     }
82 }
83 impl std::fmt::Debug for PictType  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result84     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
85         let variants = [
86             (Self::INDEXED.0.into(), "INDEXED", "Indexed"),
87             (Self::DIRECT.0.into(), "DIRECT", "Direct"),
88         ];
89         pretty_print_enum(fmt, self.0.into(), &variants)
90     }
91 }
92 
93 #[derive(Clone, Copy, PartialEq, Eq)]
94 pub struct PictureEnum(u8);
95 impl PictureEnum {
96     pub const NONE: Self = Self(0);
97 }
98 impl From<PictureEnum> for u8 {
99     #[inline]
from(input: PictureEnum) -> Self100     fn from(input: PictureEnum) -> Self {
101         input.0
102     }
103 }
104 impl From<PictureEnum> for Option<u8> {
105     #[inline]
from(input: PictureEnum) -> Self106     fn from(input: PictureEnum) -> Self {
107         Some(input.0)
108     }
109 }
110 impl From<PictureEnum> for u16 {
111     #[inline]
from(input: PictureEnum) -> Self112     fn from(input: PictureEnum) -> Self {
113         u16::from(input.0)
114     }
115 }
116 impl From<PictureEnum> for Option<u16> {
117     #[inline]
from(input: PictureEnum) -> Self118     fn from(input: PictureEnum) -> Self {
119         Some(u16::from(input.0))
120     }
121 }
122 impl From<PictureEnum> for u32 {
123     #[inline]
from(input: PictureEnum) -> Self124     fn from(input: PictureEnum) -> Self {
125         u32::from(input.0)
126     }
127 }
128 impl From<PictureEnum> for Option<u32> {
129     #[inline]
from(input: PictureEnum) -> Self130     fn from(input: PictureEnum) -> Self {
131         Some(u32::from(input.0))
132     }
133 }
134 impl From<u8> for PictureEnum {
135     #[inline]
from(value: u8) -> Self136     fn from(value: u8) -> Self {
137         Self(value)
138     }
139 }
140 impl std::fmt::Debug for PictureEnum  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result141     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
142         let variants = [
143             (Self::NONE.0.into(), "NONE", "None"),
144         ];
145         pretty_print_enum(fmt, self.0.into(), &variants)
146     }
147 }
148 
149 #[derive(Clone, Copy, PartialEq, Eq)]
150 pub struct PictOp(u8);
151 impl PictOp {
152     pub const CLEAR: Self = Self(0);
153     pub const SRC: Self = Self(1);
154     pub const DST: Self = Self(2);
155     pub const OVER: Self = Self(3);
156     pub const OVER_REVERSE: Self = Self(4);
157     pub const IN: Self = Self(5);
158     pub const IN_REVERSE: Self = Self(6);
159     pub const OUT: Self = Self(7);
160     pub const OUT_REVERSE: Self = Self(8);
161     pub const ATOP: Self = Self(9);
162     pub const ATOP_REVERSE: Self = Self(10);
163     pub const XOR: Self = Self(11);
164     pub const ADD: Self = Self(12);
165     pub const SATURATE: Self = Self(13);
166     pub const DISJOINT_CLEAR: Self = Self(16);
167     pub const DISJOINT_SRC: Self = Self(17);
168     pub const DISJOINT_DST: Self = Self(18);
169     pub const DISJOINT_OVER: Self = Self(19);
170     pub const DISJOINT_OVER_REVERSE: Self = Self(20);
171     pub const DISJOINT_IN: Self = Self(21);
172     pub const DISJOINT_IN_REVERSE: Self = Self(22);
173     pub const DISJOINT_OUT: Self = Self(23);
174     pub const DISJOINT_OUT_REVERSE: Self = Self(24);
175     pub const DISJOINT_ATOP: Self = Self(25);
176     pub const DISJOINT_ATOP_REVERSE: Self = Self(26);
177     pub const DISJOINT_XOR: Self = Self(27);
178     pub const CONJOINT_CLEAR: Self = Self(32);
179     pub const CONJOINT_SRC: Self = Self(33);
180     pub const CONJOINT_DST: Self = Self(34);
181     pub const CONJOINT_OVER: Self = Self(35);
182     pub const CONJOINT_OVER_REVERSE: Self = Self(36);
183     pub const CONJOINT_IN: Self = Self(37);
184     pub const CONJOINT_IN_REVERSE: Self = Self(38);
185     pub const CONJOINT_OUT: Self = Self(39);
186     pub const CONJOINT_OUT_REVERSE: Self = Self(40);
187     pub const CONJOINT_ATOP: Self = Self(41);
188     pub const CONJOINT_ATOP_REVERSE: Self = Self(42);
189     pub const CONJOINT_XOR: Self = Self(43);
190     pub const MULTIPLY: Self = Self(48);
191     pub const SCREEN: Self = Self(49);
192     pub const OVERLAY: Self = Self(50);
193     pub const DARKEN: Self = Self(51);
194     pub const LIGHTEN: Self = Self(52);
195     pub const COLOR_DODGE: Self = Self(53);
196     pub const COLOR_BURN: Self = Self(54);
197     pub const HARD_LIGHT: Self = Self(55);
198     pub const SOFT_LIGHT: Self = Self(56);
199     pub const DIFFERENCE: Self = Self(57);
200     pub const EXCLUSION: Self = Self(58);
201     pub const HSL_HUE: Self = Self(59);
202     pub const HSL_SATURATION: Self = Self(60);
203     pub const HSL_COLOR: Self = Self(61);
204     pub const HSL_LUMINOSITY: Self = Self(62);
205 }
206 impl From<PictOp> for u8 {
207     #[inline]
from(input: PictOp) -> Self208     fn from(input: PictOp) -> Self {
209         input.0
210     }
211 }
212 impl From<PictOp> for Option<u8> {
213     #[inline]
from(input: PictOp) -> Self214     fn from(input: PictOp) -> Self {
215         Some(input.0)
216     }
217 }
218 impl From<PictOp> for u16 {
219     #[inline]
from(input: PictOp) -> Self220     fn from(input: PictOp) -> Self {
221         u16::from(input.0)
222     }
223 }
224 impl From<PictOp> for Option<u16> {
225     #[inline]
from(input: PictOp) -> Self226     fn from(input: PictOp) -> Self {
227         Some(u16::from(input.0))
228     }
229 }
230 impl From<PictOp> for u32 {
231     #[inline]
from(input: PictOp) -> Self232     fn from(input: PictOp) -> Self {
233         u32::from(input.0)
234     }
235 }
236 impl From<PictOp> for Option<u32> {
237     #[inline]
from(input: PictOp) -> Self238     fn from(input: PictOp) -> Self {
239         Some(u32::from(input.0))
240     }
241 }
242 impl From<u8> for PictOp {
243     #[inline]
from(value: u8) -> Self244     fn from(value: u8) -> Self {
245         Self(value)
246     }
247 }
248 impl std::fmt::Debug for PictOp  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result249     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
250         let variants = [
251             (Self::CLEAR.0.into(), "CLEAR", "Clear"),
252             (Self::SRC.0.into(), "SRC", "Src"),
253             (Self::DST.0.into(), "DST", "Dst"),
254             (Self::OVER.0.into(), "OVER", "Over"),
255             (Self::OVER_REVERSE.0.into(), "OVER_REVERSE", "OverReverse"),
256             (Self::IN.0.into(), "IN", "In"),
257             (Self::IN_REVERSE.0.into(), "IN_REVERSE", "InReverse"),
258             (Self::OUT.0.into(), "OUT", "Out"),
259             (Self::OUT_REVERSE.0.into(), "OUT_REVERSE", "OutReverse"),
260             (Self::ATOP.0.into(), "ATOP", "Atop"),
261             (Self::ATOP_REVERSE.0.into(), "ATOP_REVERSE", "AtopReverse"),
262             (Self::XOR.0.into(), "XOR", "Xor"),
263             (Self::ADD.0.into(), "ADD", "Add"),
264             (Self::SATURATE.0.into(), "SATURATE", "Saturate"),
265             (Self::DISJOINT_CLEAR.0.into(), "DISJOINT_CLEAR", "DisjointClear"),
266             (Self::DISJOINT_SRC.0.into(), "DISJOINT_SRC", "DisjointSrc"),
267             (Self::DISJOINT_DST.0.into(), "DISJOINT_DST", "DisjointDst"),
268             (Self::DISJOINT_OVER.0.into(), "DISJOINT_OVER", "DisjointOver"),
269             (Self::DISJOINT_OVER_REVERSE.0.into(), "DISJOINT_OVER_REVERSE", "DisjointOverReverse"),
270             (Self::DISJOINT_IN.0.into(), "DISJOINT_IN", "DisjointIn"),
271             (Self::DISJOINT_IN_REVERSE.0.into(), "DISJOINT_IN_REVERSE", "DisjointInReverse"),
272             (Self::DISJOINT_OUT.0.into(), "DISJOINT_OUT", "DisjointOut"),
273             (Self::DISJOINT_OUT_REVERSE.0.into(), "DISJOINT_OUT_REVERSE", "DisjointOutReverse"),
274             (Self::DISJOINT_ATOP.0.into(), "DISJOINT_ATOP", "DisjointAtop"),
275             (Self::DISJOINT_ATOP_REVERSE.0.into(), "DISJOINT_ATOP_REVERSE", "DisjointAtopReverse"),
276             (Self::DISJOINT_XOR.0.into(), "DISJOINT_XOR", "DisjointXor"),
277             (Self::CONJOINT_CLEAR.0.into(), "CONJOINT_CLEAR", "ConjointClear"),
278             (Self::CONJOINT_SRC.0.into(), "CONJOINT_SRC", "ConjointSrc"),
279             (Self::CONJOINT_DST.0.into(), "CONJOINT_DST", "ConjointDst"),
280             (Self::CONJOINT_OVER.0.into(), "CONJOINT_OVER", "ConjointOver"),
281             (Self::CONJOINT_OVER_REVERSE.0.into(), "CONJOINT_OVER_REVERSE", "ConjointOverReverse"),
282             (Self::CONJOINT_IN.0.into(), "CONJOINT_IN", "ConjointIn"),
283             (Self::CONJOINT_IN_REVERSE.0.into(), "CONJOINT_IN_REVERSE", "ConjointInReverse"),
284             (Self::CONJOINT_OUT.0.into(), "CONJOINT_OUT", "ConjointOut"),
285             (Self::CONJOINT_OUT_REVERSE.0.into(), "CONJOINT_OUT_REVERSE", "ConjointOutReverse"),
286             (Self::CONJOINT_ATOP.0.into(), "CONJOINT_ATOP", "ConjointAtop"),
287             (Self::CONJOINT_ATOP_REVERSE.0.into(), "CONJOINT_ATOP_REVERSE", "ConjointAtopReverse"),
288             (Self::CONJOINT_XOR.0.into(), "CONJOINT_XOR", "ConjointXor"),
289             (Self::MULTIPLY.0.into(), "MULTIPLY", "Multiply"),
290             (Self::SCREEN.0.into(), "SCREEN", "Screen"),
291             (Self::OVERLAY.0.into(), "OVERLAY", "Overlay"),
292             (Self::DARKEN.0.into(), "DARKEN", "Darken"),
293             (Self::LIGHTEN.0.into(), "LIGHTEN", "Lighten"),
294             (Self::COLOR_DODGE.0.into(), "COLOR_DODGE", "ColorDodge"),
295             (Self::COLOR_BURN.0.into(), "COLOR_BURN", "ColorBurn"),
296             (Self::HARD_LIGHT.0.into(), "HARD_LIGHT", "HardLight"),
297             (Self::SOFT_LIGHT.0.into(), "SOFT_LIGHT", "SoftLight"),
298             (Self::DIFFERENCE.0.into(), "DIFFERENCE", "Difference"),
299             (Self::EXCLUSION.0.into(), "EXCLUSION", "Exclusion"),
300             (Self::HSL_HUE.0.into(), "HSL_HUE", "HSLHue"),
301             (Self::HSL_SATURATION.0.into(), "HSL_SATURATION", "HSLSaturation"),
302             (Self::HSL_COLOR.0.into(), "HSL_COLOR", "HSLColor"),
303             (Self::HSL_LUMINOSITY.0.into(), "HSL_LUMINOSITY", "HSLLuminosity"),
304         ];
305         pretty_print_enum(fmt, self.0.into(), &variants)
306     }
307 }
308 
309 #[derive(Clone, Copy, PartialEq, Eq)]
310 pub struct PolyEdge(u32);
311 impl PolyEdge {
312     pub const SHARP: Self = Self(0);
313     pub const SMOOTH: Self = Self(1);
314 }
315 impl From<PolyEdge> for u32 {
316     #[inline]
from(input: PolyEdge) -> Self317     fn from(input: PolyEdge) -> Self {
318         input.0
319     }
320 }
321 impl From<PolyEdge> for Option<u32> {
322     #[inline]
from(input: PolyEdge) -> Self323     fn from(input: PolyEdge) -> Self {
324         Some(input.0)
325     }
326 }
327 impl From<u8> for PolyEdge {
328     #[inline]
from(value: u8) -> Self329     fn from(value: u8) -> Self {
330         Self(value.into())
331     }
332 }
333 impl From<u16> for PolyEdge {
334     #[inline]
from(value: u16) -> Self335     fn from(value: u16) -> Self {
336         Self(value.into())
337     }
338 }
339 impl From<u32> for PolyEdge {
340     #[inline]
from(value: u32) -> Self341     fn from(value: u32) -> Self {
342         Self(value)
343     }
344 }
345 impl std::fmt::Debug for PolyEdge  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result346     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
347         let variants = [
348             (Self::SHARP.0, "SHARP", "Sharp"),
349             (Self::SMOOTH.0, "SMOOTH", "Smooth"),
350         ];
351         pretty_print_enum(fmt, self.0, &variants)
352     }
353 }
354 
355 #[derive(Clone, Copy, PartialEq, Eq)]
356 pub struct PolyMode(u32);
357 impl PolyMode {
358     pub const PRECISE: Self = Self(0);
359     pub const IMPRECISE: Self = Self(1);
360 }
361 impl From<PolyMode> for u32 {
362     #[inline]
from(input: PolyMode) -> Self363     fn from(input: PolyMode) -> Self {
364         input.0
365     }
366 }
367 impl From<PolyMode> for Option<u32> {
368     #[inline]
from(input: PolyMode) -> Self369     fn from(input: PolyMode) -> Self {
370         Some(input.0)
371     }
372 }
373 impl From<u8> for PolyMode {
374     #[inline]
from(value: u8) -> Self375     fn from(value: u8) -> Self {
376         Self(value.into())
377     }
378 }
379 impl From<u16> for PolyMode {
380     #[inline]
from(value: u16) -> Self381     fn from(value: u16) -> Self {
382         Self(value.into())
383     }
384 }
385 impl From<u32> for PolyMode {
386     #[inline]
from(value: u32) -> Self387     fn from(value: u32) -> Self {
388         Self(value)
389     }
390 }
391 impl std::fmt::Debug for PolyMode  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result392     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
393         let variants = [
394             (Self::PRECISE.0, "PRECISE", "Precise"),
395             (Self::IMPRECISE.0, "IMPRECISE", "Imprecise"),
396         ];
397         pretty_print_enum(fmt, self.0, &variants)
398     }
399 }
400 
401 #[derive(Clone, Copy, PartialEq, Eq)]
402 pub struct CP(u16);
403 impl CP {
404     pub const REPEAT: Self = Self(1 << 0);
405     pub const ALPHA_MAP: Self = Self(1 << 1);
406     pub const ALPHA_X_ORIGIN: Self = Self(1 << 2);
407     pub const ALPHA_Y_ORIGIN: Self = Self(1 << 3);
408     pub const CLIP_X_ORIGIN: Self = Self(1 << 4);
409     pub const CLIP_Y_ORIGIN: Self = Self(1 << 5);
410     pub const CLIP_MASK: Self = Self(1 << 6);
411     pub const GRAPHICS_EXPOSURE: Self = Self(1 << 7);
412     pub const SUBWINDOW_MODE: Self = Self(1 << 8);
413     pub const POLY_EDGE: Self = Self(1 << 9);
414     pub const POLY_MODE: Self = Self(1 << 10);
415     pub const DITHER: Self = Self(1 << 11);
416     pub const COMPONENT_ALPHA: Self = Self(1 << 12);
417 }
418 impl From<CP> for u16 {
419     #[inline]
from(input: CP) -> Self420     fn from(input: CP) -> Self {
421         input.0
422     }
423 }
424 impl From<CP> for Option<u16> {
425     #[inline]
from(input: CP) -> Self426     fn from(input: CP) -> Self {
427         Some(input.0)
428     }
429 }
430 impl From<CP> for u32 {
431     #[inline]
from(input: CP) -> Self432     fn from(input: CP) -> Self {
433         u32::from(input.0)
434     }
435 }
436 impl From<CP> for Option<u32> {
437     #[inline]
from(input: CP) -> Self438     fn from(input: CP) -> Self {
439         Some(u32::from(input.0))
440     }
441 }
442 impl From<u8> for CP {
443     #[inline]
from(value: u8) -> Self444     fn from(value: u8) -> Self {
445         Self(value.into())
446     }
447 }
448 impl From<u16> for CP {
449     #[inline]
from(value: u16) -> Self450     fn from(value: u16) -> Self {
451         Self(value)
452     }
453 }
454 impl std::fmt::Debug for CP  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result455     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
456         let variants = [
457             (Self::REPEAT.0.into(), "REPEAT", "Repeat"),
458             (Self::ALPHA_MAP.0.into(), "ALPHA_MAP", "AlphaMap"),
459             (Self::ALPHA_X_ORIGIN.0.into(), "ALPHA_X_ORIGIN", "AlphaXOrigin"),
460             (Self::ALPHA_Y_ORIGIN.0.into(), "ALPHA_Y_ORIGIN", "AlphaYOrigin"),
461             (Self::CLIP_X_ORIGIN.0.into(), "CLIP_X_ORIGIN", "ClipXOrigin"),
462             (Self::CLIP_Y_ORIGIN.0.into(), "CLIP_Y_ORIGIN", "ClipYOrigin"),
463             (Self::CLIP_MASK.0.into(), "CLIP_MASK", "ClipMask"),
464             (Self::GRAPHICS_EXPOSURE.0.into(), "GRAPHICS_EXPOSURE", "GraphicsExposure"),
465             (Self::SUBWINDOW_MODE.0.into(), "SUBWINDOW_MODE", "SubwindowMode"),
466             (Self::POLY_EDGE.0.into(), "POLY_EDGE", "PolyEdge"),
467             (Self::POLY_MODE.0.into(), "POLY_MODE", "PolyMode"),
468             (Self::DITHER.0.into(), "DITHER", "Dither"),
469             (Self::COMPONENT_ALPHA.0.into(), "COMPONENT_ALPHA", "ComponentAlpha"),
470         ];
471         pretty_print_bitmask(fmt, self.0.into(), &variants)
472     }
473 }
474 bitmask_binop!(CP, u16);
475 
476 #[derive(Clone, Copy, PartialEq, Eq)]
477 pub struct SubPixel(u32);
478 impl SubPixel {
479     pub const UNKNOWN: Self = Self(0);
480     pub const HORIZONTAL_RGB: Self = Self(1);
481     pub const HORIZONTAL_BGR: Self = Self(2);
482     pub const VERTICAL_RGB: Self = Self(3);
483     pub const VERTICAL_BGR: Self = Self(4);
484     pub const NONE: Self = Self(5);
485 }
486 impl From<SubPixel> for u32 {
487     #[inline]
from(input: SubPixel) -> Self488     fn from(input: SubPixel) -> Self {
489         input.0
490     }
491 }
492 impl From<SubPixel> for Option<u32> {
493     #[inline]
from(input: SubPixel) -> Self494     fn from(input: SubPixel) -> Self {
495         Some(input.0)
496     }
497 }
498 impl From<u8> for SubPixel {
499     #[inline]
from(value: u8) -> Self500     fn from(value: u8) -> Self {
501         Self(value.into())
502     }
503 }
504 impl From<u16> for SubPixel {
505     #[inline]
from(value: u16) -> Self506     fn from(value: u16) -> Self {
507         Self(value.into())
508     }
509 }
510 impl From<u32> for SubPixel {
511     #[inline]
from(value: u32) -> Self512     fn from(value: u32) -> Self {
513         Self(value)
514     }
515 }
516 impl std::fmt::Debug for SubPixel  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result517     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
518         let variants = [
519             (Self::UNKNOWN.0, "UNKNOWN", "Unknown"),
520             (Self::HORIZONTAL_RGB.0, "HORIZONTAL_RGB", "HorizontalRGB"),
521             (Self::HORIZONTAL_BGR.0, "HORIZONTAL_BGR", "HorizontalBGR"),
522             (Self::VERTICAL_RGB.0, "VERTICAL_RGB", "VerticalRGB"),
523             (Self::VERTICAL_BGR.0, "VERTICAL_BGR", "VerticalBGR"),
524             (Self::NONE.0, "NONE", "None"),
525         ];
526         pretty_print_enum(fmt, self.0, &variants)
527     }
528 }
529 
530 #[derive(Clone, Copy, PartialEq, Eq)]
531 pub struct Repeat(u32);
532 impl Repeat {
533     pub const NONE: Self = Self(0);
534     pub const NORMAL: Self = Self(1);
535     pub const PAD: Self = Self(2);
536     pub const REFLECT: Self = Self(3);
537 }
538 impl From<Repeat> for u32 {
539     #[inline]
from(input: Repeat) -> Self540     fn from(input: Repeat) -> Self {
541         input.0
542     }
543 }
544 impl From<Repeat> for Option<u32> {
545     #[inline]
from(input: Repeat) -> Self546     fn from(input: Repeat) -> Self {
547         Some(input.0)
548     }
549 }
550 impl From<u8> for Repeat {
551     #[inline]
from(value: u8) -> Self552     fn from(value: u8) -> Self {
553         Self(value.into())
554     }
555 }
556 impl From<u16> for Repeat {
557     #[inline]
from(value: u16) -> Self558     fn from(value: u16) -> Self {
559         Self(value.into())
560     }
561 }
562 impl From<u32> for Repeat {
563     #[inline]
from(value: u32) -> Self564     fn from(value: u32) -> Self {
565         Self(value)
566     }
567 }
568 impl std::fmt::Debug for Repeat  {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result569     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
570         let variants = [
571             (Self::NONE.0, "NONE", "None"),
572             (Self::NORMAL.0, "NORMAL", "Normal"),
573             (Self::PAD.0, "PAD", "Pad"),
574             (Self::REFLECT.0, "REFLECT", "Reflect"),
575         ];
576         pretty_print_enum(fmt, self.0, &variants)
577     }
578 }
579 
580 pub type Glyph = u32;
581 
582 pub type Glyphset = u32;
583 
584 pub type Picture = u32;
585 
586 pub type Pictformat = u32;
587 
588 pub type Fixed = i32;
589 
590 /// Opcode for the PictFormat error
591 pub const PICT_FORMAT_ERROR: u8 = 0;
592 
593 /// Opcode for the Picture error
594 pub const PICTURE_ERROR: u8 = 1;
595 
596 /// Opcode for the PictOp error
597 pub const PICT_OP_ERROR: u8 = 2;
598 
599 /// Opcode for the GlyphSet error
600 pub const GLYPH_SET_ERROR: u8 = 3;
601 
602 /// Opcode for the Glyph error
603 pub const GLYPH_ERROR: u8 = 4;
604 
605 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
606 pub struct Directformat {
607     pub red_shift: u16,
608     pub red_mask: u16,
609     pub green_shift: u16,
610     pub green_mask: u16,
611     pub blue_shift: u16,
612     pub blue_mask: u16,
613     pub alpha_shift: u16,
614     pub alpha_mask: u16,
615 }
616 impl TryParse for Directformat {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>617     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
618         let (red_shift, remaining) = u16::try_parse(remaining)?;
619         let (red_mask, remaining) = u16::try_parse(remaining)?;
620         let (green_shift, remaining) = u16::try_parse(remaining)?;
621         let (green_mask, remaining) = u16::try_parse(remaining)?;
622         let (blue_shift, remaining) = u16::try_parse(remaining)?;
623         let (blue_mask, remaining) = u16::try_parse(remaining)?;
624         let (alpha_shift, remaining) = u16::try_parse(remaining)?;
625         let (alpha_mask, remaining) = u16::try_parse(remaining)?;
626         let result = Directformat { red_shift, red_mask, green_shift, green_mask, blue_shift, blue_mask, alpha_shift, alpha_mask };
627         Ok((result, remaining))
628     }
629 }
630 impl Serialize for Directformat {
631     type Bytes = [u8; 16];
serialize(&self) -> [u8; 16]632     fn serialize(&self) -> [u8; 16] {
633         let red_shift_bytes = self.red_shift.serialize();
634         let red_mask_bytes = self.red_mask.serialize();
635         let green_shift_bytes = self.green_shift.serialize();
636         let green_mask_bytes = self.green_mask.serialize();
637         let blue_shift_bytes = self.blue_shift.serialize();
638         let blue_mask_bytes = self.blue_mask.serialize();
639         let alpha_shift_bytes = self.alpha_shift.serialize();
640         let alpha_mask_bytes = self.alpha_mask.serialize();
641         [
642             red_shift_bytes[0],
643             red_shift_bytes[1],
644             red_mask_bytes[0],
645             red_mask_bytes[1],
646             green_shift_bytes[0],
647             green_shift_bytes[1],
648             green_mask_bytes[0],
649             green_mask_bytes[1],
650             blue_shift_bytes[0],
651             blue_shift_bytes[1],
652             blue_mask_bytes[0],
653             blue_mask_bytes[1],
654             alpha_shift_bytes[0],
655             alpha_shift_bytes[1],
656             alpha_mask_bytes[0],
657             alpha_mask_bytes[1],
658         ]
659     }
serialize_into(&self, bytes: &mut Vec<u8>)660     fn serialize_into(&self, bytes: &mut Vec<u8>) {
661         bytes.reserve(16);
662         self.red_shift.serialize_into(bytes);
663         self.red_mask.serialize_into(bytes);
664         self.green_shift.serialize_into(bytes);
665         self.green_mask.serialize_into(bytes);
666         self.blue_shift.serialize_into(bytes);
667         self.blue_mask.serialize_into(bytes);
668         self.alpha_shift.serialize_into(bytes);
669         self.alpha_mask.serialize_into(bytes);
670     }
671 }
672 
673 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
674 pub struct Pictforminfo {
675     pub id: Pictformat,
676     pub type_: PictType,
677     pub depth: u8,
678     pub direct: Directformat,
679     pub colormap: xproto::Colormap,
680 }
681 impl TryParse for Pictforminfo {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>682     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
683         let (id, remaining) = Pictformat::try_parse(remaining)?;
684         let (type_, remaining) = u8::try_parse(remaining)?;
685         let (depth, remaining) = u8::try_parse(remaining)?;
686         let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
687         let (direct, remaining) = Directformat::try_parse(remaining)?;
688         let (colormap, remaining) = xproto::Colormap::try_parse(remaining)?;
689         let type_ = type_.into();
690         let result = Pictforminfo { id, type_, depth, direct, colormap };
691         Ok((result, remaining))
692     }
693 }
694 impl Serialize for Pictforminfo {
695     type Bytes = [u8; 28];
serialize(&self) -> [u8; 28]696     fn serialize(&self) -> [u8; 28] {
697         let id_bytes = self.id.serialize();
698         let type_bytes = u8::from(self.type_).serialize();
699         let depth_bytes = self.depth.serialize();
700         let direct_bytes = self.direct.serialize();
701         let colormap_bytes = self.colormap.serialize();
702         [
703             id_bytes[0],
704             id_bytes[1],
705             id_bytes[2],
706             id_bytes[3],
707             type_bytes[0],
708             depth_bytes[0],
709             0,
710             0,
711             direct_bytes[0],
712             direct_bytes[1],
713             direct_bytes[2],
714             direct_bytes[3],
715             direct_bytes[4],
716             direct_bytes[5],
717             direct_bytes[6],
718             direct_bytes[7],
719             direct_bytes[8],
720             direct_bytes[9],
721             direct_bytes[10],
722             direct_bytes[11],
723             direct_bytes[12],
724             direct_bytes[13],
725             direct_bytes[14],
726             direct_bytes[15],
727             colormap_bytes[0],
728             colormap_bytes[1],
729             colormap_bytes[2],
730             colormap_bytes[3],
731         ]
732     }
serialize_into(&self, bytes: &mut Vec<u8>)733     fn serialize_into(&self, bytes: &mut Vec<u8>) {
734         bytes.reserve(28);
735         self.id.serialize_into(bytes);
736         u8::from(self.type_).serialize_into(bytes);
737         self.depth.serialize_into(bytes);
738         bytes.extend_from_slice(&[0; 2]);
739         self.direct.serialize_into(bytes);
740         self.colormap.serialize_into(bytes);
741     }
742 }
743 
744 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
745 pub struct Pictvisual {
746     pub visual: xproto::Visualid,
747     pub format: Pictformat,
748 }
749 impl TryParse for Pictvisual {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>750     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
751         let (visual, remaining) = xproto::Visualid::try_parse(remaining)?;
752         let (format, remaining) = Pictformat::try_parse(remaining)?;
753         let result = Pictvisual { visual, format };
754         Ok((result, remaining))
755     }
756 }
757 impl Serialize for Pictvisual {
758     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]759     fn serialize(&self) -> [u8; 8] {
760         let visual_bytes = self.visual.serialize();
761         let format_bytes = self.format.serialize();
762         [
763             visual_bytes[0],
764             visual_bytes[1],
765             visual_bytes[2],
766             visual_bytes[3],
767             format_bytes[0],
768             format_bytes[1],
769             format_bytes[2],
770             format_bytes[3],
771         ]
772     }
serialize_into(&self, bytes: &mut Vec<u8>)773     fn serialize_into(&self, bytes: &mut Vec<u8>) {
774         bytes.reserve(8);
775         self.visual.serialize_into(bytes);
776         self.format.serialize_into(bytes);
777     }
778 }
779 
780 #[derive(Debug, Clone, PartialEq, Eq)]
781 pub struct Pictdepth {
782     pub depth: u8,
783     pub visuals: Vec<Pictvisual>,
784 }
785 impl TryParse for Pictdepth {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>786     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
787         let (depth, remaining) = u8::try_parse(remaining)?;
788         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
789         let (num_visuals, remaining) = u16::try_parse(remaining)?;
790         let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
791         let (visuals, remaining) = crate::x11_utils::parse_list::<Pictvisual>(remaining, num_visuals.try_to_usize()?)?;
792         let result = Pictdepth { depth, visuals };
793         Ok((result, remaining))
794     }
795 }
796 impl Serialize for Pictdepth {
797     type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>798     fn serialize(&self) -> Vec<u8> {
799         let mut result = Vec::new();
800         self.serialize_into(&mut result);
801         result
802     }
serialize_into(&self, bytes: &mut Vec<u8>)803     fn serialize_into(&self, bytes: &mut Vec<u8>) {
804         bytes.reserve(8);
805         self.depth.serialize_into(bytes);
806         bytes.extend_from_slice(&[0; 1]);
807         let num_visuals = u16::try_from(self.visuals.len()).expect("`visuals` has too many elements");
808         num_visuals.serialize_into(bytes);
809         bytes.extend_from_slice(&[0; 4]);
810         self.visuals.serialize_into(bytes);
811     }
812 }
813 impl Pictdepth {
814     /// Get the value of the `num_visuals` field.
815     ///
816     /// The `num_visuals` field is used as the length field of the `visuals` field.
817     /// This function computes the field's value again based on the length of the list.
818     ///
819     /// # Panics
820     ///
821     /// Panics if the value cannot be represented in the target type. This
822     /// cannot happen with values of the struct received from the X11 server.
num_visuals(&self) -> u16823     pub fn num_visuals(&self) -> u16 {
824         self.visuals.len()
825             .try_into().unwrap()
826     }
827 }
828 
829 #[derive(Debug, Clone, PartialEq, Eq)]
830 pub struct Pictscreen {
831     pub fallback: Pictformat,
832     pub depths: Vec<Pictdepth>,
833 }
834 impl TryParse for Pictscreen {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>835     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
836         let (num_depths, remaining) = u32::try_parse(remaining)?;
837         let (fallback, remaining) = Pictformat::try_parse(remaining)?;
838         let (depths, remaining) = crate::x11_utils::parse_list::<Pictdepth>(remaining, num_depths.try_to_usize()?)?;
839         let result = Pictscreen { fallback, depths };
840         Ok((result, remaining))
841     }
842 }
843 impl Serialize for Pictscreen {
844     type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>845     fn serialize(&self) -> Vec<u8> {
846         let mut result = Vec::new();
847         self.serialize_into(&mut result);
848         result
849     }
serialize_into(&self, bytes: &mut Vec<u8>)850     fn serialize_into(&self, bytes: &mut Vec<u8>) {
851         bytes.reserve(8);
852         let num_depths = u32::try_from(self.depths.len()).expect("`depths` has too many elements");
853         num_depths.serialize_into(bytes);
854         self.fallback.serialize_into(bytes);
855         self.depths.serialize_into(bytes);
856     }
857 }
858 impl Pictscreen {
859     /// Get the value of the `num_depths` field.
860     ///
861     /// The `num_depths` field is used as the length field of the `depths` field.
862     /// This function computes the field's value again based on the length of the list.
863     ///
864     /// # Panics
865     ///
866     /// Panics if the value cannot be represented in the target type. This
867     /// cannot happen with values of the struct received from the X11 server.
num_depths(&self) -> u32868     pub fn num_depths(&self) -> u32 {
869         self.depths.len()
870             .try_into().unwrap()
871     }
872 }
873 
874 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
875 pub struct Indexvalue {
876     pub pixel: u32,
877     pub red: u16,
878     pub green: u16,
879     pub blue: u16,
880     pub alpha: u16,
881 }
882 impl TryParse for Indexvalue {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>883     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
884         let (pixel, remaining) = u32::try_parse(remaining)?;
885         let (red, remaining) = u16::try_parse(remaining)?;
886         let (green, remaining) = u16::try_parse(remaining)?;
887         let (blue, remaining) = u16::try_parse(remaining)?;
888         let (alpha, remaining) = u16::try_parse(remaining)?;
889         let result = Indexvalue { pixel, red, green, blue, alpha };
890         Ok((result, remaining))
891     }
892 }
893 impl Serialize for Indexvalue {
894     type Bytes = [u8; 12];
serialize(&self) -> [u8; 12]895     fn serialize(&self) -> [u8; 12] {
896         let pixel_bytes = self.pixel.serialize();
897         let red_bytes = self.red.serialize();
898         let green_bytes = self.green.serialize();
899         let blue_bytes = self.blue.serialize();
900         let alpha_bytes = self.alpha.serialize();
901         [
902             pixel_bytes[0],
903             pixel_bytes[1],
904             pixel_bytes[2],
905             pixel_bytes[3],
906             red_bytes[0],
907             red_bytes[1],
908             green_bytes[0],
909             green_bytes[1],
910             blue_bytes[0],
911             blue_bytes[1],
912             alpha_bytes[0],
913             alpha_bytes[1],
914         ]
915     }
serialize_into(&self, bytes: &mut Vec<u8>)916     fn serialize_into(&self, bytes: &mut Vec<u8>) {
917         bytes.reserve(12);
918         self.pixel.serialize_into(bytes);
919         self.red.serialize_into(bytes);
920         self.green.serialize_into(bytes);
921         self.blue.serialize_into(bytes);
922         self.alpha.serialize_into(bytes);
923     }
924 }
925 
926 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
927 pub struct Color {
928     pub red: u16,
929     pub green: u16,
930     pub blue: u16,
931     pub alpha: u16,
932 }
933 impl TryParse for Color {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>934     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
935         let (red, remaining) = u16::try_parse(remaining)?;
936         let (green, remaining) = u16::try_parse(remaining)?;
937         let (blue, remaining) = u16::try_parse(remaining)?;
938         let (alpha, remaining) = u16::try_parse(remaining)?;
939         let result = Color { red, green, blue, alpha };
940         Ok((result, remaining))
941     }
942 }
943 impl Serialize for Color {
944     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]945     fn serialize(&self) -> [u8; 8] {
946         let red_bytes = self.red.serialize();
947         let green_bytes = self.green.serialize();
948         let blue_bytes = self.blue.serialize();
949         let alpha_bytes = self.alpha.serialize();
950         [
951             red_bytes[0],
952             red_bytes[1],
953             green_bytes[0],
954             green_bytes[1],
955             blue_bytes[0],
956             blue_bytes[1],
957             alpha_bytes[0],
958             alpha_bytes[1],
959         ]
960     }
serialize_into(&self, bytes: &mut Vec<u8>)961     fn serialize_into(&self, bytes: &mut Vec<u8>) {
962         bytes.reserve(8);
963         self.red.serialize_into(bytes);
964         self.green.serialize_into(bytes);
965         self.blue.serialize_into(bytes);
966         self.alpha.serialize_into(bytes);
967     }
968 }
969 
970 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
971 pub struct Pointfix {
972     pub x: Fixed,
973     pub y: Fixed,
974 }
975 impl TryParse for Pointfix {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>976     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
977         let (x, remaining) = Fixed::try_parse(remaining)?;
978         let (y, remaining) = Fixed::try_parse(remaining)?;
979         let result = Pointfix { x, y };
980         Ok((result, remaining))
981     }
982 }
983 impl Serialize for Pointfix {
984     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]985     fn serialize(&self) -> [u8; 8] {
986         let x_bytes = self.x.serialize();
987         let y_bytes = self.y.serialize();
988         [
989             x_bytes[0],
990             x_bytes[1],
991             x_bytes[2],
992             x_bytes[3],
993             y_bytes[0],
994             y_bytes[1],
995             y_bytes[2],
996             y_bytes[3],
997         ]
998     }
serialize_into(&self, bytes: &mut Vec<u8>)999     fn serialize_into(&self, bytes: &mut Vec<u8>) {
1000         bytes.reserve(8);
1001         self.x.serialize_into(bytes);
1002         self.y.serialize_into(bytes);
1003     }
1004 }
1005 
1006 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1007 pub struct Linefix {
1008     pub p1: Pointfix,
1009     pub p2: Pointfix,
1010 }
1011 impl TryParse for Linefix {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>1012     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1013         let (p1, remaining) = Pointfix::try_parse(remaining)?;
1014         let (p2, remaining) = Pointfix::try_parse(remaining)?;
1015         let result = Linefix { p1, p2 };
1016         Ok((result, remaining))
1017     }
1018 }
1019 impl Serialize for Linefix {
1020     type Bytes = [u8; 16];
serialize(&self) -> [u8; 16]1021     fn serialize(&self) -> [u8; 16] {
1022         let p1_bytes = self.p1.serialize();
1023         let p2_bytes = self.p2.serialize();
1024         [
1025             p1_bytes[0],
1026             p1_bytes[1],
1027             p1_bytes[2],
1028             p1_bytes[3],
1029             p1_bytes[4],
1030             p1_bytes[5],
1031             p1_bytes[6],
1032             p1_bytes[7],
1033             p2_bytes[0],
1034             p2_bytes[1],
1035             p2_bytes[2],
1036             p2_bytes[3],
1037             p2_bytes[4],
1038             p2_bytes[5],
1039             p2_bytes[6],
1040             p2_bytes[7],
1041         ]
1042     }
serialize_into(&self, bytes: &mut Vec<u8>)1043     fn serialize_into(&self, bytes: &mut Vec<u8>) {
1044         bytes.reserve(16);
1045         self.p1.serialize_into(bytes);
1046         self.p2.serialize_into(bytes);
1047     }
1048 }
1049 
1050 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1051 pub struct Triangle {
1052     pub p1: Pointfix,
1053     pub p2: Pointfix,
1054     pub p3: Pointfix,
1055 }
1056 impl TryParse for Triangle {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>1057     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1058         let (p1, remaining) = Pointfix::try_parse(remaining)?;
1059         let (p2, remaining) = Pointfix::try_parse(remaining)?;
1060         let (p3, remaining) = Pointfix::try_parse(remaining)?;
1061         let result = Triangle { p1, p2, p3 };
1062         Ok((result, remaining))
1063     }
1064 }
1065 impl Serialize for Triangle {
1066     type Bytes = [u8; 24];
serialize(&self) -> [u8; 24]1067     fn serialize(&self) -> [u8; 24] {
1068         let p1_bytes = self.p1.serialize();
1069         let p2_bytes = self.p2.serialize();
1070         let p3_bytes = self.p3.serialize();
1071         [
1072             p1_bytes[0],
1073             p1_bytes[1],
1074             p1_bytes[2],
1075             p1_bytes[3],
1076             p1_bytes[4],
1077             p1_bytes[5],
1078             p1_bytes[6],
1079             p1_bytes[7],
1080             p2_bytes[0],
1081             p2_bytes[1],
1082             p2_bytes[2],
1083             p2_bytes[3],
1084             p2_bytes[4],
1085             p2_bytes[5],
1086             p2_bytes[6],
1087             p2_bytes[7],
1088             p3_bytes[0],
1089             p3_bytes[1],
1090             p3_bytes[2],
1091             p3_bytes[3],
1092             p3_bytes[4],
1093             p3_bytes[5],
1094             p3_bytes[6],
1095             p3_bytes[7],
1096         ]
1097     }
serialize_into(&self, bytes: &mut Vec<u8>)1098     fn serialize_into(&self, bytes: &mut Vec<u8>) {
1099         bytes.reserve(24);
1100         self.p1.serialize_into(bytes);
1101         self.p2.serialize_into(bytes);
1102         self.p3.serialize_into(bytes);
1103     }
1104 }
1105 
1106 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1107 pub struct Trapezoid {
1108     pub top: Fixed,
1109     pub bottom: Fixed,
1110     pub left: Linefix,
1111     pub right: Linefix,
1112 }
1113 impl TryParse for Trapezoid {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>1114     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1115         let (top, remaining) = Fixed::try_parse(remaining)?;
1116         let (bottom, remaining) = Fixed::try_parse(remaining)?;
1117         let (left, remaining) = Linefix::try_parse(remaining)?;
1118         let (right, remaining) = Linefix::try_parse(remaining)?;
1119         let result = Trapezoid { top, bottom, left, right };
1120         Ok((result, remaining))
1121     }
1122 }
1123 impl Serialize for Trapezoid {
1124     type Bytes = [u8; 40];
serialize(&self) -> [u8; 40]1125     fn serialize(&self) -> [u8; 40] {
1126         let top_bytes = self.top.serialize();
1127         let bottom_bytes = self.bottom.serialize();
1128         let left_bytes = self.left.serialize();
1129         let right_bytes = self.right.serialize();
1130         [
1131             top_bytes[0],
1132             top_bytes[1],
1133             top_bytes[2],
1134             top_bytes[3],
1135             bottom_bytes[0],
1136             bottom_bytes[1],
1137             bottom_bytes[2],
1138             bottom_bytes[3],
1139             left_bytes[0],
1140             left_bytes[1],
1141             left_bytes[2],
1142             left_bytes[3],
1143             left_bytes[4],
1144             left_bytes[5],
1145             left_bytes[6],
1146             left_bytes[7],
1147             left_bytes[8],
1148             left_bytes[9],
1149             left_bytes[10],
1150             left_bytes[11],
1151             left_bytes[12],
1152             left_bytes[13],
1153             left_bytes[14],
1154             left_bytes[15],
1155             right_bytes[0],
1156             right_bytes[1],
1157             right_bytes[2],
1158             right_bytes[3],
1159             right_bytes[4],
1160             right_bytes[5],
1161             right_bytes[6],
1162             right_bytes[7],
1163             right_bytes[8],
1164             right_bytes[9],
1165             right_bytes[10],
1166             right_bytes[11],
1167             right_bytes[12],
1168             right_bytes[13],
1169             right_bytes[14],
1170             right_bytes[15],
1171         ]
1172     }
serialize_into(&self, bytes: &mut Vec<u8>)1173     fn serialize_into(&self, bytes: &mut Vec<u8>) {
1174         bytes.reserve(40);
1175         self.top.serialize_into(bytes);
1176         self.bottom.serialize_into(bytes);
1177         self.left.serialize_into(bytes);
1178         self.right.serialize_into(bytes);
1179     }
1180 }
1181 
1182 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1183 pub struct Glyphinfo {
1184     pub width: u16,
1185     pub height: u16,
1186     pub x: i16,
1187     pub y: i16,
1188     pub x_off: i16,
1189     pub y_off: i16,
1190 }
1191 impl TryParse for Glyphinfo {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>1192     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1193         let (width, remaining) = u16::try_parse(remaining)?;
1194         let (height, remaining) = u16::try_parse(remaining)?;
1195         let (x, remaining) = i16::try_parse(remaining)?;
1196         let (y, remaining) = i16::try_parse(remaining)?;
1197         let (x_off, remaining) = i16::try_parse(remaining)?;
1198         let (y_off, remaining) = i16::try_parse(remaining)?;
1199         let result = Glyphinfo { width, height, x, y, x_off, y_off };
1200         Ok((result, remaining))
1201     }
1202 }
1203 impl Serialize for Glyphinfo {
1204     type Bytes = [u8; 12];
serialize(&self) -> [u8; 12]1205     fn serialize(&self) -> [u8; 12] {
1206         let width_bytes = self.width.serialize();
1207         let height_bytes = self.height.serialize();
1208         let x_bytes = self.x.serialize();
1209         let y_bytes = self.y.serialize();
1210         let x_off_bytes = self.x_off.serialize();
1211         let y_off_bytes = self.y_off.serialize();
1212         [
1213             width_bytes[0],
1214             width_bytes[1],
1215             height_bytes[0],
1216             height_bytes[1],
1217             x_bytes[0],
1218             x_bytes[1],
1219             y_bytes[0],
1220             y_bytes[1],
1221             x_off_bytes[0],
1222             x_off_bytes[1],
1223             y_off_bytes[0],
1224             y_off_bytes[1],
1225         ]
1226     }
serialize_into(&self, bytes: &mut Vec<u8>)1227     fn serialize_into(&self, bytes: &mut Vec<u8>) {
1228         bytes.reserve(12);
1229         self.width.serialize_into(bytes);
1230         self.height.serialize_into(bytes);
1231         self.x.serialize_into(bytes);
1232         self.y.serialize_into(bytes);
1233         self.x_off.serialize_into(bytes);
1234         self.y_off.serialize_into(bytes);
1235     }
1236 }
1237 
1238 /// Opcode for the QueryVersion request
1239 pub const QUERY_VERSION_REQUEST: u8 = 0;
1240 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1241 pub struct QueryVersionRequest {
1242     pub client_major_version: u32,
1243     pub client_minor_version: u32,
1244 }
1245 impl QueryVersionRequest {
1246     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1247     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1248     where
1249         Conn: RequestConnection + ?Sized,
1250     {
1251         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1252             .ok_or(ConnectionError::UnsupportedExtension)?;
1253         let length_so_far = 0;
1254         let client_major_version_bytes = self.client_major_version.serialize();
1255         let client_minor_version_bytes = self.client_minor_version.serialize();
1256         let mut request0 = vec![
1257             extension_information.major_opcode,
1258             QUERY_VERSION_REQUEST,
1259             0,
1260             0,
1261             client_major_version_bytes[0],
1262             client_major_version_bytes[1],
1263             client_major_version_bytes[2],
1264             client_major_version_bytes[3],
1265             client_minor_version_bytes[0],
1266             client_minor_version_bytes[1],
1267             client_minor_version_bytes[2],
1268             client_minor_version_bytes[3],
1269         ];
1270         let length_so_far = length_so_far + request0.len();
1271         assert_eq!(length_so_far % 4, 0);
1272         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1273         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1274         Ok((vec![request0.into()], vec![]))
1275     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1276     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
1277     where
1278         Conn: RequestConnection + ?Sized,
1279     {
1280         let (bytes, fds) = self.serialize(conn)?;
1281         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1282         conn.send_request_with_reply(&slices, fds)
1283     }
1284     /// 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>1285     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1286         if header.minor_opcode != QUERY_VERSION_REQUEST {
1287             return Err(ParseError::InvalidValue);
1288         }
1289         let (client_major_version, remaining) = u32::try_parse(value)?;
1290         let (client_minor_version, remaining) = u32::try_parse(remaining)?;
1291         let _ = remaining;
1292         Ok(QueryVersionRequest {
1293             client_major_version,
1294             client_minor_version,
1295         })
1296     }
1297 }
1298 impl Request for QueryVersionRequest {
1299     type Reply = QueryVersionReply;
1300 }
query_version<Conn>(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1301 pub fn query_version<Conn>(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
1302 where
1303     Conn: RequestConnection + ?Sized,
1304 {
1305     let request0 = QueryVersionRequest {
1306         client_major_version,
1307         client_minor_version,
1308     };
1309     request0.send(conn)
1310 }
1311 
1312 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1313 pub struct QueryVersionReply {
1314     pub sequence: u16,
1315     pub length: u32,
1316     pub major_version: u32,
1317     pub minor_version: u32,
1318 }
1319 impl TryParse for QueryVersionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1320     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1321         let remaining = initial_value;
1322         let (response_type, remaining) = u8::try_parse(remaining)?;
1323         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1324         let (sequence, remaining) = u16::try_parse(remaining)?;
1325         let (length, remaining) = u32::try_parse(remaining)?;
1326         let (major_version, remaining) = u32::try_parse(remaining)?;
1327         let (minor_version, remaining) = u32::try_parse(remaining)?;
1328         let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
1329         if response_type != 1 {
1330             return Err(ParseError::InvalidValue);
1331         }
1332         let result = QueryVersionReply { sequence, length, major_version, minor_version };
1333         let _ = remaining;
1334         let remaining = initial_value.get(32 + length as usize * 4..)
1335             .ok_or(ParseError::InsufficientData)?;
1336         Ok((result, remaining))
1337     }
1338 }
1339 
1340 /// Opcode for the QueryPictFormats request
1341 pub const QUERY_PICT_FORMATS_REQUEST: u8 = 1;
1342 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1343 pub struct QueryPictFormatsRequest;
1344 impl QueryPictFormatsRequest {
1345     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1346     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1347     where
1348         Conn: RequestConnection + ?Sized,
1349     {
1350         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1351             .ok_or(ConnectionError::UnsupportedExtension)?;
1352         let length_so_far = 0;
1353         let mut request0 = vec![
1354             extension_information.major_opcode,
1355             QUERY_PICT_FORMATS_REQUEST,
1356             0,
1357             0,
1358         ];
1359         let length_so_far = length_so_far + request0.len();
1360         assert_eq!(length_so_far % 4, 0);
1361         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1362         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1363         Ok((vec![request0.into()], vec![]))
1364     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryPictFormatsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1365     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryPictFormatsReply>, ConnectionError>
1366     where
1367         Conn: RequestConnection + ?Sized,
1368     {
1369         let (bytes, fds) = self.serialize(conn)?;
1370         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1371         conn.send_request_with_reply(&slices, fds)
1372     }
1373     /// 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>1374     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1375         if header.minor_opcode != QUERY_PICT_FORMATS_REQUEST {
1376             return Err(ParseError::InvalidValue);
1377         }
1378         let _ = value;
1379         Ok(QueryPictFormatsRequest
1380         )
1381     }
1382 }
1383 impl Request for QueryPictFormatsRequest {
1384     type Reply = QueryPictFormatsReply;
1385 }
query_pict_formats<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryPictFormatsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1386 pub fn query_pict_formats<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryPictFormatsReply>, ConnectionError>
1387 where
1388     Conn: RequestConnection + ?Sized,
1389 {
1390     let request0 = QueryPictFormatsRequest;
1391     request0.send(conn)
1392 }
1393 
1394 #[derive(Debug, Clone, PartialEq, Eq)]
1395 pub struct QueryPictFormatsReply {
1396     pub sequence: u16,
1397     pub length: u32,
1398     pub num_depths: u32,
1399     pub num_visuals: u32,
1400     pub formats: Vec<Pictforminfo>,
1401     pub screens: Vec<Pictscreen>,
1402     pub subpixels: Vec<SubPixel>,
1403 }
1404 impl TryParse for QueryPictFormatsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1405     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1406         let remaining = initial_value;
1407         let (response_type, remaining) = u8::try_parse(remaining)?;
1408         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1409         let (sequence, remaining) = u16::try_parse(remaining)?;
1410         let (length, remaining) = u32::try_parse(remaining)?;
1411         let (num_formats, remaining) = u32::try_parse(remaining)?;
1412         let (num_screens, remaining) = u32::try_parse(remaining)?;
1413         let (num_depths, remaining) = u32::try_parse(remaining)?;
1414         let (num_visuals, remaining) = u32::try_parse(remaining)?;
1415         let (num_subpixel, remaining) = u32::try_parse(remaining)?;
1416         let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
1417         let (formats, remaining) = crate::x11_utils::parse_list::<Pictforminfo>(remaining, num_formats.try_to_usize()?)?;
1418         let (screens, remaining) = crate::x11_utils::parse_list::<Pictscreen>(remaining, num_screens.try_to_usize()?)?;
1419         let mut remaining = remaining;
1420         let list_length = num_subpixel.try_to_usize()?;
1421         let mut subpixels = Vec::with_capacity(list_length);
1422         for _ in 0..list_length {
1423             let (v, new_remaining) = u32::try_parse(remaining)?;
1424             let v = v.into();
1425             remaining = new_remaining;
1426             subpixels.push(v);
1427         }
1428         if response_type != 1 {
1429             return Err(ParseError::InvalidValue);
1430         }
1431         let result = QueryPictFormatsReply { sequence, length, num_depths, num_visuals, formats, screens, subpixels };
1432         let _ = remaining;
1433         let remaining = initial_value.get(32 + length as usize * 4..)
1434             .ok_or(ParseError::InsufficientData)?;
1435         Ok((result, remaining))
1436     }
1437 }
1438 impl QueryPictFormatsReply {
1439     /// Get the value of the `num_formats` field.
1440     ///
1441     /// The `num_formats` field is used as the length field of the `formats` field.
1442     /// This function computes the field's value again based on the length of the list.
1443     ///
1444     /// # Panics
1445     ///
1446     /// Panics if the value cannot be represented in the target type. This
1447     /// cannot happen with values of the struct received from the X11 server.
num_formats(&self) -> u321448     pub fn num_formats(&self) -> u32 {
1449         self.formats.len()
1450             .try_into().unwrap()
1451     }
1452     /// Get the value of the `num_screens` field.
1453     ///
1454     /// The `num_screens` field is used as the length field of the `screens` field.
1455     /// This function computes the field's value again based on the length of the list.
1456     ///
1457     /// # Panics
1458     ///
1459     /// Panics if the value cannot be represented in the target type. This
1460     /// cannot happen with values of the struct received from the X11 server.
num_screens(&self) -> u321461     pub fn num_screens(&self) -> u32 {
1462         self.screens.len()
1463             .try_into().unwrap()
1464     }
1465     /// Get the value of the `num_subpixel` field.
1466     ///
1467     /// The `num_subpixel` field is used as the length field of the `subpixels` field.
1468     /// This function computes the field's value again based on the length of the list.
1469     ///
1470     /// # Panics
1471     ///
1472     /// Panics if the value cannot be represented in the target type. This
1473     /// cannot happen with values of the struct received from the X11 server.
num_subpixel(&self) -> u321474     pub fn num_subpixel(&self) -> u32 {
1475         self.subpixels.len()
1476             .try_into().unwrap()
1477     }
1478 }
1479 
1480 /// Opcode for the QueryPictIndexValues request
1481 pub const QUERY_PICT_INDEX_VALUES_REQUEST: u8 = 2;
1482 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1483 pub struct QueryPictIndexValuesRequest {
1484     pub format: Pictformat,
1485 }
1486 impl QueryPictIndexValuesRequest {
1487     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1488     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1489     where
1490         Conn: RequestConnection + ?Sized,
1491     {
1492         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1493             .ok_or(ConnectionError::UnsupportedExtension)?;
1494         let length_so_far = 0;
1495         let format_bytes = self.format.serialize();
1496         let mut request0 = vec![
1497             extension_information.major_opcode,
1498             QUERY_PICT_INDEX_VALUES_REQUEST,
1499             0,
1500             0,
1501             format_bytes[0],
1502             format_bytes[1],
1503             format_bytes[2],
1504             format_bytes[3],
1505         ];
1506         let length_so_far = length_so_far + request0.len();
1507         assert_eq!(length_so_far % 4, 0);
1508         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1509         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1510         Ok((vec![request0.into()], vec![]))
1511     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryPictIndexValuesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1512     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryPictIndexValuesReply>, ConnectionError>
1513     where
1514         Conn: RequestConnection + ?Sized,
1515     {
1516         let (bytes, fds) = self.serialize(conn)?;
1517         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1518         conn.send_request_with_reply(&slices, fds)
1519     }
1520     /// 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>1521     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1522         if header.minor_opcode != QUERY_PICT_INDEX_VALUES_REQUEST {
1523             return Err(ParseError::InvalidValue);
1524         }
1525         let (format, remaining) = Pictformat::try_parse(value)?;
1526         let _ = remaining;
1527         Ok(QueryPictIndexValuesRequest {
1528             format,
1529         })
1530     }
1531 }
1532 impl Request for QueryPictIndexValuesRequest {
1533     type Reply = QueryPictIndexValuesReply;
1534 }
query_pict_index_values<Conn>(conn: &Conn, format: Pictformat) -> Result<Cookie<'_, Conn, QueryPictIndexValuesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1535 pub fn query_pict_index_values<Conn>(conn: &Conn, format: Pictformat) -> Result<Cookie<'_, Conn, QueryPictIndexValuesReply>, ConnectionError>
1536 where
1537     Conn: RequestConnection + ?Sized,
1538 {
1539     let request0 = QueryPictIndexValuesRequest {
1540         format,
1541     };
1542     request0.send(conn)
1543 }
1544 
1545 #[derive(Debug, Clone, PartialEq, Eq)]
1546 pub struct QueryPictIndexValuesReply {
1547     pub sequence: u16,
1548     pub length: u32,
1549     pub values: Vec<Indexvalue>,
1550 }
1551 impl TryParse for QueryPictIndexValuesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1552     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1553         let remaining = initial_value;
1554         let (response_type, remaining) = u8::try_parse(remaining)?;
1555         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1556         let (sequence, remaining) = u16::try_parse(remaining)?;
1557         let (length, remaining) = u32::try_parse(remaining)?;
1558         let (num_values, remaining) = u32::try_parse(remaining)?;
1559         let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
1560         let (values, remaining) = crate::x11_utils::parse_list::<Indexvalue>(remaining, num_values.try_to_usize()?)?;
1561         if response_type != 1 {
1562             return Err(ParseError::InvalidValue);
1563         }
1564         let result = QueryPictIndexValuesReply { sequence, length, values };
1565         let _ = remaining;
1566         let remaining = initial_value.get(32 + length as usize * 4..)
1567             .ok_or(ParseError::InsufficientData)?;
1568         Ok((result, remaining))
1569     }
1570 }
1571 impl QueryPictIndexValuesReply {
1572     /// Get the value of the `num_values` field.
1573     ///
1574     /// The `num_values` field is used as the length field of the `values` field.
1575     /// This function computes the field's value again based on the length of the list.
1576     ///
1577     /// # Panics
1578     ///
1579     /// Panics if the value cannot be represented in the target type. This
1580     /// cannot happen with values of the struct received from the X11 server.
num_values(&self) -> u321581     pub fn num_values(&self) -> u32 {
1582         self.values.len()
1583             .try_into().unwrap()
1584     }
1585 }
1586 
1587 /// Auxiliary and optional information for the `create_picture` function
1588 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1589 pub struct CreatePictureAux {
1590     pub repeat: Option<Repeat>,
1591     pub alphamap: Option<Picture>,
1592     pub alphaxorigin: Option<i32>,
1593     pub alphayorigin: Option<i32>,
1594     pub clipxorigin: Option<i32>,
1595     pub clipyorigin: Option<i32>,
1596     pub clipmask: Option<xproto::Pixmap>,
1597     pub graphicsexposure: Option<u32>,
1598     pub subwindowmode: Option<xproto::SubwindowMode>,
1599     pub polyedge: Option<PolyEdge>,
1600     pub polymode: Option<PolyMode>,
1601     pub dither: Option<xproto::Atom>,
1602     pub componentalpha: Option<u32>,
1603 }
1604 impl CreatePictureAux {
try_parse(value: &[u8], value_mask: u32) -> Result<(Self, &[u8]), ParseError>1605     fn try_parse(value: &[u8], value_mask: u32) -> Result<(Self, &[u8]), ParseError> {
1606         let switch_expr = value_mask;
1607         let mut outer_remaining = value;
1608         let repeat = if switch_expr & u32::from(CP::REPEAT) != 0 {
1609             let remaining = outer_remaining;
1610             let (repeat, remaining) = u32::try_parse(remaining)?;
1611             let repeat = repeat.into();
1612             outer_remaining = remaining;
1613             Some(repeat)
1614         } else {
1615             None
1616         };
1617         let alphamap = if switch_expr & u32::from(CP::ALPHA_MAP) != 0 {
1618             let remaining = outer_remaining;
1619             let (alphamap, remaining) = Picture::try_parse(remaining)?;
1620             outer_remaining = remaining;
1621             Some(alphamap)
1622         } else {
1623             None
1624         };
1625         let alphaxorigin = if switch_expr & u32::from(CP::ALPHA_X_ORIGIN) != 0 {
1626             let remaining = outer_remaining;
1627             let (alphaxorigin, remaining) = i32::try_parse(remaining)?;
1628             outer_remaining = remaining;
1629             Some(alphaxorigin)
1630         } else {
1631             None
1632         };
1633         let alphayorigin = if switch_expr & u32::from(CP::ALPHA_Y_ORIGIN) != 0 {
1634             let remaining = outer_remaining;
1635             let (alphayorigin, remaining) = i32::try_parse(remaining)?;
1636             outer_remaining = remaining;
1637             Some(alphayorigin)
1638         } else {
1639             None
1640         };
1641         let clipxorigin = if switch_expr & u32::from(CP::CLIP_X_ORIGIN) != 0 {
1642             let remaining = outer_remaining;
1643             let (clipxorigin, remaining) = i32::try_parse(remaining)?;
1644             outer_remaining = remaining;
1645             Some(clipxorigin)
1646         } else {
1647             None
1648         };
1649         let clipyorigin = if switch_expr & u32::from(CP::CLIP_Y_ORIGIN) != 0 {
1650             let remaining = outer_remaining;
1651             let (clipyorigin, remaining) = i32::try_parse(remaining)?;
1652             outer_remaining = remaining;
1653             Some(clipyorigin)
1654         } else {
1655             None
1656         };
1657         let clipmask = if switch_expr & u32::from(CP::CLIP_MASK) != 0 {
1658             let remaining = outer_remaining;
1659             let (clipmask, remaining) = xproto::Pixmap::try_parse(remaining)?;
1660             outer_remaining = remaining;
1661             Some(clipmask)
1662         } else {
1663             None
1664         };
1665         let graphicsexposure = if switch_expr & u32::from(CP::GRAPHICS_EXPOSURE) != 0 {
1666             let remaining = outer_remaining;
1667             let (graphicsexposure, remaining) = u32::try_parse(remaining)?;
1668             outer_remaining = remaining;
1669             Some(graphicsexposure)
1670         } else {
1671             None
1672         };
1673         let subwindowmode = if switch_expr & u32::from(CP::SUBWINDOW_MODE) != 0 {
1674             let remaining = outer_remaining;
1675             let (subwindowmode, remaining) = u32::try_parse(remaining)?;
1676             let subwindowmode = subwindowmode.into();
1677             outer_remaining = remaining;
1678             Some(subwindowmode)
1679         } else {
1680             None
1681         };
1682         let polyedge = if switch_expr & u32::from(CP::POLY_EDGE) != 0 {
1683             let remaining = outer_remaining;
1684             let (polyedge, remaining) = u32::try_parse(remaining)?;
1685             let polyedge = polyedge.into();
1686             outer_remaining = remaining;
1687             Some(polyedge)
1688         } else {
1689             None
1690         };
1691         let polymode = if switch_expr & u32::from(CP::POLY_MODE) != 0 {
1692             let remaining = outer_remaining;
1693             let (polymode, remaining) = u32::try_parse(remaining)?;
1694             let polymode = polymode.into();
1695             outer_remaining = remaining;
1696             Some(polymode)
1697         } else {
1698             None
1699         };
1700         let dither = if switch_expr & u32::from(CP::DITHER) != 0 {
1701             let remaining = outer_remaining;
1702             let (dither, remaining) = xproto::Atom::try_parse(remaining)?;
1703             outer_remaining = remaining;
1704             Some(dither)
1705         } else {
1706             None
1707         };
1708         let componentalpha = if switch_expr & u32::from(CP::COMPONENT_ALPHA) != 0 {
1709             let remaining = outer_remaining;
1710             let (componentalpha, remaining) = u32::try_parse(remaining)?;
1711             outer_remaining = remaining;
1712             Some(componentalpha)
1713         } else {
1714             None
1715         };
1716         let result = CreatePictureAux { repeat, alphamap, alphaxorigin, alphayorigin, clipxorigin, clipyorigin, clipmask, graphicsexposure, subwindowmode, polyedge, polymode, dither, componentalpha };
1717         Ok((result, outer_remaining))
1718     }
1719 }
1720 impl CreatePictureAux {
1721     #[allow(dead_code)]
serialize(&self, value_mask: u32) -> Vec<u8>1722     fn serialize(&self, value_mask: u32) -> Vec<u8> {
1723         let mut result = Vec::new();
1724         self.serialize_into(&mut result, value_mask);
1725         result
1726     }
serialize_into(&self, bytes: &mut Vec<u8>, value_mask: u32)1727     fn serialize_into(&self, bytes: &mut Vec<u8>, value_mask: u32) {
1728         assert_eq!(self.switch_expr(), value_mask, "switch `value_list` has an inconsistent discriminant");
1729         if let Some(repeat) = self.repeat {
1730             u32::from(repeat).serialize_into(bytes);
1731         }
1732         if let Some(alphamap) = self.alphamap {
1733             alphamap.serialize_into(bytes);
1734         }
1735         if let Some(alphaxorigin) = self.alphaxorigin {
1736             alphaxorigin.serialize_into(bytes);
1737         }
1738         if let Some(alphayorigin) = self.alphayorigin {
1739             alphayorigin.serialize_into(bytes);
1740         }
1741         if let Some(clipxorigin) = self.clipxorigin {
1742             clipxorigin.serialize_into(bytes);
1743         }
1744         if let Some(clipyorigin) = self.clipyorigin {
1745             clipyorigin.serialize_into(bytes);
1746         }
1747         if let Some(clipmask) = self.clipmask {
1748             clipmask.serialize_into(bytes);
1749         }
1750         if let Some(graphicsexposure) = self.graphicsexposure {
1751             graphicsexposure.serialize_into(bytes);
1752         }
1753         if let Some(subwindowmode) = self.subwindowmode {
1754             u32::from(subwindowmode).serialize_into(bytes);
1755         }
1756         if let Some(polyedge) = self.polyedge {
1757             u32::from(polyedge).serialize_into(bytes);
1758         }
1759         if let Some(polymode) = self.polymode {
1760             u32::from(polymode).serialize_into(bytes);
1761         }
1762         if let Some(dither) = self.dither {
1763             dither.serialize_into(bytes);
1764         }
1765         if let Some(componentalpha) = self.componentalpha {
1766             componentalpha.serialize_into(bytes);
1767         }
1768     }
1769 }
1770 impl CreatePictureAux {
switch_expr(&self) -> u321771     fn switch_expr(&self) -> u32 {
1772         let mut expr_value = 0;
1773         if self.repeat.is_some() {
1774             expr_value |= u32::from(CP::REPEAT);
1775         }
1776         if self.alphamap.is_some() {
1777             expr_value |= u32::from(CP::ALPHA_MAP);
1778         }
1779         if self.alphaxorigin.is_some() {
1780             expr_value |= u32::from(CP::ALPHA_X_ORIGIN);
1781         }
1782         if self.alphayorigin.is_some() {
1783             expr_value |= u32::from(CP::ALPHA_Y_ORIGIN);
1784         }
1785         if self.clipxorigin.is_some() {
1786             expr_value |= u32::from(CP::CLIP_X_ORIGIN);
1787         }
1788         if self.clipyorigin.is_some() {
1789             expr_value |= u32::from(CP::CLIP_Y_ORIGIN);
1790         }
1791         if self.clipmask.is_some() {
1792             expr_value |= u32::from(CP::CLIP_MASK);
1793         }
1794         if self.graphicsexposure.is_some() {
1795             expr_value |= u32::from(CP::GRAPHICS_EXPOSURE);
1796         }
1797         if self.subwindowmode.is_some() {
1798             expr_value |= u32::from(CP::SUBWINDOW_MODE);
1799         }
1800         if self.polyedge.is_some() {
1801             expr_value |= u32::from(CP::POLY_EDGE);
1802         }
1803         if self.polymode.is_some() {
1804             expr_value |= u32::from(CP::POLY_MODE);
1805         }
1806         if self.dither.is_some() {
1807             expr_value |= u32::from(CP::DITHER);
1808         }
1809         if self.componentalpha.is_some() {
1810             expr_value |= u32::from(CP::COMPONENT_ALPHA);
1811         }
1812         expr_value
1813     }
1814 }
1815 impl CreatePictureAux {
1816     /// Create a new instance with all fields unset / not present.
new() -> Self1817     pub fn new() -> Self {
1818         Default::default()
1819     }
1820     /// Set the `repeat` field of this structure.
repeat<I>(mut self, value: I) -> Self where I: Into<Option<Repeat>>1821     pub fn repeat<I>(mut self, value: I) -> Self where I: Into<Option<Repeat>> {
1822         self.repeat = value.into();
1823         self
1824     }
1825     /// Set the `alphamap` field of this structure.
alphamap<I>(mut self, value: I) -> Self where I: Into<Option<Picture>>1826     pub fn alphamap<I>(mut self, value: I) -> Self where I: Into<Option<Picture>> {
1827         self.alphamap = value.into();
1828         self
1829     }
1830     /// Set the `alphaxorigin` field of this structure.
alphaxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>1831     pub fn alphaxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
1832         self.alphaxorigin = value.into();
1833         self
1834     }
1835     /// Set the `alphayorigin` field of this structure.
alphayorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>1836     pub fn alphayorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
1837         self.alphayorigin = value.into();
1838         self
1839     }
1840     /// Set the `clipxorigin` field of this structure.
clipxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>1841     pub fn clipxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
1842         self.clipxorigin = value.into();
1843         self
1844     }
1845     /// Set the `clipyorigin` field of this structure.
clipyorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>1846     pub fn clipyorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
1847         self.clipyorigin = value.into();
1848         self
1849     }
1850     /// Set the `clipmask` field of this structure.
clipmask<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Pixmap>>1851     pub fn clipmask<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Pixmap>> {
1852         self.clipmask = value.into();
1853         self
1854     }
1855     /// Set the `graphicsexposure` field of this structure.
graphicsexposure<I>(mut self, value: I) -> Self where I: Into<Option<u32>>1856     pub fn graphicsexposure<I>(mut self, value: I) -> Self where I: Into<Option<u32>> {
1857         self.graphicsexposure = value.into();
1858         self
1859     }
1860     /// Set the `subwindowmode` field of this structure.
subwindowmode<I>(mut self, value: I) -> Self where I: Into<Option<xproto::SubwindowMode>>1861     pub fn subwindowmode<I>(mut self, value: I) -> Self where I: Into<Option<xproto::SubwindowMode>> {
1862         self.subwindowmode = value.into();
1863         self
1864     }
1865     /// Set the `polyedge` field of this structure.
polyedge<I>(mut self, value: I) -> Self where I: Into<Option<PolyEdge>>1866     pub fn polyedge<I>(mut self, value: I) -> Self where I: Into<Option<PolyEdge>> {
1867         self.polyedge = value.into();
1868         self
1869     }
1870     /// Set the `polymode` field of this structure.
polymode<I>(mut self, value: I) -> Self where I: Into<Option<PolyMode>>1871     pub fn polymode<I>(mut self, value: I) -> Self where I: Into<Option<PolyMode>> {
1872         self.polymode = value.into();
1873         self
1874     }
1875     /// Set the `dither` field of this structure.
dither<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Atom>>1876     pub fn dither<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Atom>> {
1877         self.dither = value.into();
1878         self
1879     }
1880     /// Set the `componentalpha` field of this structure.
componentalpha<I>(mut self, value: I) -> Self where I: Into<Option<u32>>1881     pub fn componentalpha<I>(mut self, value: I) -> Self where I: Into<Option<u32>> {
1882         self.componentalpha = value.into();
1883         self
1884     }
1885 }
1886 
1887 /// Opcode for the CreatePicture request
1888 pub const CREATE_PICTURE_REQUEST: u8 = 4;
1889 #[derive(Debug, Clone, PartialEq, Eq)]
1890 pub struct CreatePictureRequest<'input> {
1891     pub pid: Picture,
1892     pub drawable: xproto::Drawable,
1893     pub format: Pictformat,
1894     pub value_list: Cow<'input, CreatePictureAux>,
1895 }
1896 impl<'input> CreatePictureRequest<'input> {
1897     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1898     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1899     where
1900         Conn: RequestConnection + ?Sized,
1901     {
1902         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1903             .ok_or(ConnectionError::UnsupportedExtension)?;
1904         let length_so_far = 0;
1905         let pid_bytes = self.pid.serialize();
1906         let drawable_bytes = self.drawable.serialize();
1907         let format_bytes = self.format.serialize();
1908         let value_mask = self.value_list.switch_expr();
1909         let value_mask_bytes = value_mask.serialize();
1910         let mut request0 = vec![
1911             extension_information.major_opcode,
1912             CREATE_PICTURE_REQUEST,
1913             0,
1914             0,
1915             pid_bytes[0],
1916             pid_bytes[1],
1917             pid_bytes[2],
1918             pid_bytes[3],
1919             drawable_bytes[0],
1920             drawable_bytes[1],
1921             drawable_bytes[2],
1922             drawable_bytes[3],
1923             format_bytes[0],
1924             format_bytes[1],
1925             format_bytes[2],
1926             format_bytes[3],
1927             value_mask_bytes[0],
1928             value_mask_bytes[1],
1929             value_mask_bytes[2],
1930             value_mask_bytes[3],
1931         ];
1932         let length_so_far = length_so_far + request0.len();
1933         let value_list_bytes = self.value_list.serialize(value_mask);
1934         let length_so_far = length_so_far + value_list_bytes.len();
1935         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1936         let length_so_far = length_so_far + padding0.len();
1937         assert_eq!(length_so_far % 4, 0);
1938         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1939         request0[2..4].copy_from_slice(&length.to_ne_bytes());
1940         Ok((vec![request0.into(), value_list_bytes.into(), padding0.into()], vec![]))
1941     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1942     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1943     where
1944         Conn: RequestConnection + ?Sized,
1945     {
1946         let (bytes, fds) = self.serialize(conn)?;
1947         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1948         conn.send_request_without_reply(&slices, fds)
1949     }
1950     /// 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>1951     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1952         if header.minor_opcode != CREATE_PICTURE_REQUEST {
1953             return Err(ParseError::InvalidValue);
1954         }
1955         let (pid, remaining) = Picture::try_parse(value)?;
1956         let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
1957         let (format, remaining) = Pictformat::try_parse(remaining)?;
1958         let (value_mask, remaining) = u32::try_parse(remaining)?;
1959         let (value_list, remaining) = CreatePictureAux::try_parse(remaining, value_mask)?;
1960         let _ = remaining;
1961         Ok(CreatePictureRequest {
1962             pid,
1963             drawable,
1964             format,
1965             value_list: Cow::Owned(value_list),
1966         })
1967     }
1968     /// Clone all borrowed data in this CreatePictureRequest.
into_owned(self) -> CreatePictureRequest<'static>1969     pub fn into_owned(self) -> CreatePictureRequest<'static> {
1970         CreatePictureRequest {
1971             pid: self.pid,
1972             drawable: self.drawable,
1973             format: self.format,
1974             value_list: Cow::Owned(self.value_list.into_owned()),
1975         }
1976     }
1977 }
1978 impl<'input> Request for CreatePictureRequest<'input> {
1979     type Reply = ();
1980 }
create_picture<'c, 'input, Conn>(conn: &'c Conn, pid: Picture, drawable: xproto::Drawable, format: Pictformat, value_list: &'input CreatePictureAux) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1981 pub fn create_picture<'c, 'input, Conn>(conn: &'c Conn, pid: Picture, drawable: xproto::Drawable, format: Pictformat, value_list: &'input CreatePictureAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1982 where
1983     Conn: RequestConnection + ?Sized,
1984 {
1985     let request0 = CreatePictureRequest {
1986         pid,
1987         drawable,
1988         format,
1989         value_list: Cow::Borrowed(value_list),
1990     };
1991     request0.send(conn)
1992 }
1993 
1994 /// Auxiliary and optional information for the `change_picture` function
1995 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
1996 pub struct ChangePictureAux {
1997     pub repeat: Option<Repeat>,
1998     pub alphamap: Option<Picture>,
1999     pub alphaxorigin: Option<i32>,
2000     pub alphayorigin: Option<i32>,
2001     pub clipxorigin: Option<i32>,
2002     pub clipyorigin: Option<i32>,
2003     pub clipmask: Option<xproto::Pixmap>,
2004     pub graphicsexposure: Option<u32>,
2005     pub subwindowmode: Option<xproto::SubwindowMode>,
2006     pub polyedge: Option<PolyEdge>,
2007     pub polymode: Option<PolyMode>,
2008     pub dither: Option<xproto::Atom>,
2009     pub componentalpha: Option<u32>,
2010 }
2011 impl ChangePictureAux {
try_parse(value: &[u8], value_mask: u32) -> Result<(Self, &[u8]), ParseError>2012     fn try_parse(value: &[u8], value_mask: u32) -> Result<(Self, &[u8]), ParseError> {
2013         let switch_expr = value_mask;
2014         let mut outer_remaining = value;
2015         let repeat = if switch_expr & u32::from(CP::REPEAT) != 0 {
2016             let remaining = outer_remaining;
2017             let (repeat, remaining) = u32::try_parse(remaining)?;
2018             let repeat = repeat.into();
2019             outer_remaining = remaining;
2020             Some(repeat)
2021         } else {
2022             None
2023         };
2024         let alphamap = if switch_expr & u32::from(CP::ALPHA_MAP) != 0 {
2025             let remaining = outer_remaining;
2026             let (alphamap, remaining) = Picture::try_parse(remaining)?;
2027             outer_remaining = remaining;
2028             Some(alphamap)
2029         } else {
2030             None
2031         };
2032         let alphaxorigin = if switch_expr & u32::from(CP::ALPHA_X_ORIGIN) != 0 {
2033             let remaining = outer_remaining;
2034             let (alphaxorigin, remaining) = i32::try_parse(remaining)?;
2035             outer_remaining = remaining;
2036             Some(alphaxorigin)
2037         } else {
2038             None
2039         };
2040         let alphayorigin = if switch_expr & u32::from(CP::ALPHA_Y_ORIGIN) != 0 {
2041             let remaining = outer_remaining;
2042             let (alphayorigin, remaining) = i32::try_parse(remaining)?;
2043             outer_remaining = remaining;
2044             Some(alphayorigin)
2045         } else {
2046             None
2047         };
2048         let clipxorigin = if switch_expr & u32::from(CP::CLIP_X_ORIGIN) != 0 {
2049             let remaining = outer_remaining;
2050             let (clipxorigin, remaining) = i32::try_parse(remaining)?;
2051             outer_remaining = remaining;
2052             Some(clipxorigin)
2053         } else {
2054             None
2055         };
2056         let clipyorigin = if switch_expr & u32::from(CP::CLIP_Y_ORIGIN) != 0 {
2057             let remaining = outer_remaining;
2058             let (clipyorigin, remaining) = i32::try_parse(remaining)?;
2059             outer_remaining = remaining;
2060             Some(clipyorigin)
2061         } else {
2062             None
2063         };
2064         let clipmask = if switch_expr & u32::from(CP::CLIP_MASK) != 0 {
2065             let remaining = outer_remaining;
2066             let (clipmask, remaining) = xproto::Pixmap::try_parse(remaining)?;
2067             outer_remaining = remaining;
2068             Some(clipmask)
2069         } else {
2070             None
2071         };
2072         let graphicsexposure = if switch_expr & u32::from(CP::GRAPHICS_EXPOSURE) != 0 {
2073             let remaining = outer_remaining;
2074             let (graphicsexposure, remaining) = u32::try_parse(remaining)?;
2075             outer_remaining = remaining;
2076             Some(graphicsexposure)
2077         } else {
2078             None
2079         };
2080         let subwindowmode = if switch_expr & u32::from(CP::SUBWINDOW_MODE) != 0 {
2081             let remaining = outer_remaining;
2082             let (subwindowmode, remaining) = u32::try_parse(remaining)?;
2083             let subwindowmode = subwindowmode.into();
2084             outer_remaining = remaining;
2085             Some(subwindowmode)
2086         } else {
2087             None
2088         };
2089         let polyedge = if switch_expr & u32::from(CP::POLY_EDGE) != 0 {
2090             let remaining = outer_remaining;
2091             let (polyedge, remaining) = u32::try_parse(remaining)?;
2092             let polyedge = polyedge.into();
2093             outer_remaining = remaining;
2094             Some(polyedge)
2095         } else {
2096             None
2097         };
2098         let polymode = if switch_expr & u32::from(CP::POLY_MODE) != 0 {
2099             let remaining = outer_remaining;
2100             let (polymode, remaining) = u32::try_parse(remaining)?;
2101             let polymode = polymode.into();
2102             outer_remaining = remaining;
2103             Some(polymode)
2104         } else {
2105             None
2106         };
2107         let dither = if switch_expr & u32::from(CP::DITHER) != 0 {
2108             let remaining = outer_remaining;
2109             let (dither, remaining) = xproto::Atom::try_parse(remaining)?;
2110             outer_remaining = remaining;
2111             Some(dither)
2112         } else {
2113             None
2114         };
2115         let componentalpha = if switch_expr & u32::from(CP::COMPONENT_ALPHA) != 0 {
2116             let remaining = outer_remaining;
2117             let (componentalpha, remaining) = u32::try_parse(remaining)?;
2118             outer_remaining = remaining;
2119             Some(componentalpha)
2120         } else {
2121             None
2122         };
2123         let result = ChangePictureAux { repeat, alphamap, alphaxorigin, alphayorigin, clipxorigin, clipyorigin, clipmask, graphicsexposure, subwindowmode, polyedge, polymode, dither, componentalpha };
2124         Ok((result, outer_remaining))
2125     }
2126 }
2127 impl ChangePictureAux {
2128     #[allow(dead_code)]
serialize(&self, value_mask: u32) -> Vec<u8>2129     fn serialize(&self, value_mask: u32) -> Vec<u8> {
2130         let mut result = Vec::new();
2131         self.serialize_into(&mut result, value_mask);
2132         result
2133     }
serialize_into(&self, bytes: &mut Vec<u8>, value_mask: u32)2134     fn serialize_into(&self, bytes: &mut Vec<u8>, value_mask: u32) {
2135         assert_eq!(self.switch_expr(), value_mask, "switch `value_list` has an inconsistent discriminant");
2136         if let Some(repeat) = self.repeat {
2137             u32::from(repeat).serialize_into(bytes);
2138         }
2139         if let Some(alphamap) = self.alphamap {
2140             alphamap.serialize_into(bytes);
2141         }
2142         if let Some(alphaxorigin) = self.alphaxorigin {
2143             alphaxorigin.serialize_into(bytes);
2144         }
2145         if let Some(alphayorigin) = self.alphayorigin {
2146             alphayorigin.serialize_into(bytes);
2147         }
2148         if let Some(clipxorigin) = self.clipxorigin {
2149             clipxorigin.serialize_into(bytes);
2150         }
2151         if let Some(clipyorigin) = self.clipyorigin {
2152             clipyorigin.serialize_into(bytes);
2153         }
2154         if let Some(clipmask) = self.clipmask {
2155             clipmask.serialize_into(bytes);
2156         }
2157         if let Some(graphicsexposure) = self.graphicsexposure {
2158             graphicsexposure.serialize_into(bytes);
2159         }
2160         if let Some(subwindowmode) = self.subwindowmode {
2161             u32::from(subwindowmode).serialize_into(bytes);
2162         }
2163         if let Some(polyedge) = self.polyedge {
2164             u32::from(polyedge).serialize_into(bytes);
2165         }
2166         if let Some(polymode) = self.polymode {
2167             u32::from(polymode).serialize_into(bytes);
2168         }
2169         if let Some(dither) = self.dither {
2170             dither.serialize_into(bytes);
2171         }
2172         if let Some(componentalpha) = self.componentalpha {
2173             componentalpha.serialize_into(bytes);
2174         }
2175     }
2176 }
2177 impl ChangePictureAux {
switch_expr(&self) -> u322178     fn switch_expr(&self) -> u32 {
2179         let mut expr_value = 0;
2180         if self.repeat.is_some() {
2181             expr_value |= u32::from(CP::REPEAT);
2182         }
2183         if self.alphamap.is_some() {
2184             expr_value |= u32::from(CP::ALPHA_MAP);
2185         }
2186         if self.alphaxorigin.is_some() {
2187             expr_value |= u32::from(CP::ALPHA_X_ORIGIN);
2188         }
2189         if self.alphayorigin.is_some() {
2190             expr_value |= u32::from(CP::ALPHA_Y_ORIGIN);
2191         }
2192         if self.clipxorigin.is_some() {
2193             expr_value |= u32::from(CP::CLIP_X_ORIGIN);
2194         }
2195         if self.clipyorigin.is_some() {
2196             expr_value |= u32::from(CP::CLIP_Y_ORIGIN);
2197         }
2198         if self.clipmask.is_some() {
2199             expr_value |= u32::from(CP::CLIP_MASK);
2200         }
2201         if self.graphicsexposure.is_some() {
2202             expr_value |= u32::from(CP::GRAPHICS_EXPOSURE);
2203         }
2204         if self.subwindowmode.is_some() {
2205             expr_value |= u32::from(CP::SUBWINDOW_MODE);
2206         }
2207         if self.polyedge.is_some() {
2208             expr_value |= u32::from(CP::POLY_EDGE);
2209         }
2210         if self.polymode.is_some() {
2211             expr_value |= u32::from(CP::POLY_MODE);
2212         }
2213         if self.dither.is_some() {
2214             expr_value |= u32::from(CP::DITHER);
2215         }
2216         if self.componentalpha.is_some() {
2217             expr_value |= u32::from(CP::COMPONENT_ALPHA);
2218         }
2219         expr_value
2220     }
2221 }
2222 impl ChangePictureAux {
2223     /// Create a new instance with all fields unset / not present.
new() -> Self2224     pub fn new() -> Self {
2225         Default::default()
2226     }
2227     /// Set the `repeat` field of this structure.
repeat<I>(mut self, value: I) -> Self where I: Into<Option<Repeat>>2228     pub fn repeat<I>(mut self, value: I) -> Self where I: Into<Option<Repeat>> {
2229         self.repeat = value.into();
2230         self
2231     }
2232     /// Set the `alphamap` field of this structure.
alphamap<I>(mut self, value: I) -> Self where I: Into<Option<Picture>>2233     pub fn alphamap<I>(mut self, value: I) -> Self where I: Into<Option<Picture>> {
2234         self.alphamap = value.into();
2235         self
2236     }
2237     /// Set the `alphaxorigin` field of this structure.
alphaxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>2238     pub fn alphaxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
2239         self.alphaxorigin = value.into();
2240         self
2241     }
2242     /// Set the `alphayorigin` field of this structure.
alphayorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>2243     pub fn alphayorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
2244         self.alphayorigin = value.into();
2245         self
2246     }
2247     /// Set the `clipxorigin` field of this structure.
clipxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>2248     pub fn clipxorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
2249         self.clipxorigin = value.into();
2250         self
2251     }
2252     /// Set the `clipyorigin` field of this structure.
clipyorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>>2253     pub fn clipyorigin<I>(mut self, value: I) -> Self where I: Into<Option<i32>> {
2254         self.clipyorigin = value.into();
2255         self
2256     }
2257     /// Set the `clipmask` field of this structure.
clipmask<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Pixmap>>2258     pub fn clipmask<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Pixmap>> {
2259         self.clipmask = value.into();
2260         self
2261     }
2262     /// Set the `graphicsexposure` field of this structure.
graphicsexposure<I>(mut self, value: I) -> Self where I: Into<Option<u32>>2263     pub fn graphicsexposure<I>(mut self, value: I) -> Self where I: Into<Option<u32>> {
2264         self.graphicsexposure = value.into();
2265         self
2266     }
2267     /// Set the `subwindowmode` field of this structure.
subwindowmode<I>(mut self, value: I) -> Self where I: Into<Option<xproto::SubwindowMode>>2268     pub fn subwindowmode<I>(mut self, value: I) -> Self where I: Into<Option<xproto::SubwindowMode>> {
2269         self.subwindowmode = value.into();
2270         self
2271     }
2272     /// Set the `polyedge` field of this structure.
polyedge<I>(mut self, value: I) -> Self where I: Into<Option<PolyEdge>>2273     pub fn polyedge<I>(mut self, value: I) -> Self where I: Into<Option<PolyEdge>> {
2274         self.polyedge = value.into();
2275         self
2276     }
2277     /// Set the `polymode` field of this structure.
polymode<I>(mut self, value: I) -> Self where I: Into<Option<PolyMode>>2278     pub fn polymode<I>(mut self, value: I) -> Self where I: Into<Option<PolyMode>> {
2279         self.polymode = value.into();
2280         self
2281     }
2282     /// Set the `dither` field of this structure.
dither<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Atom>>2283     pub fn dither<I>(mut self, value: I) -> Self where I: Into<Option<xproto::Atom>> {
2284         self.dither = value.into();
2285         self
2286     }
2287     /// Set the `componentalpha` field of this structure.
componentalpha<I>(mut self, value: I) -> Self where I: Into<Option<u32>>2288     pub fn componentalpha<I>(mut self, value: I) -> Self where I: Into<Option<u32>> {
2289         self.componentalpha = value.into();
2290         self
2291     }
2292 }
2293 
2294 /// Opcode for the ChangePicture request
2295 pub const CHANGE_PICTURE_REQUEST: u8 = 5;
2296 #[derive(Debug, Clone, PartialEq, Eq)]
2297 pub struct ChangePictureRequest<'input> {
2298     pub picture: Picture,
2299     pub value_list: Cow<'input, ChangePictureAux>,
2300 }
2301 impl<'input> ChangePictureRequest<'input> {
2302     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2303     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2304     where
2305         Conn: RequestConnection + ?Sized,
2306     {
2307         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2308             .ok_or(ConnectionError::UnsupportedExtension)?;
2309         let length_so_far = 0;
2310         let picture_bytes = self.picture.serialize();
2311         let value_mask = self.value_list.switch_expr();
2312         let value_mask_bytes = value_mask.serialize();
2313         let mut request0 = vec![
2314             extension_information.major_opcode,
2315             CHANGE_PICTURE_REQUEST,
2316             0,
2317             0,
2318             picture_bytes[0],
2319             picture_bytes[1],
2320             picture_bytes[2],
2321             picture_bytes[3],
2322             value_mask_bytes[0],
2323             value_mask_bytes[1],
2324             value_mask_bytes[2],
2325             value_mask_bytes[3],
2326         ];
2327         let length_so_far = length_so_far + request0.len();
2328         let value_list_bytes = self.value_list.serialize(value_mask);
2329         let length_so_far = length_so_far + value_list_bytes.len();
2330         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2331         let length_so_far = length_so_far + padding0.len();
2332         assert_eq!(length_so_far % 4, 0);
2333         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2334         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2335         Ok((vec![request0.into(), value_list_bytes.into(), padding0.into()], vec![]))
2336     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2337     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2338     where
2339         Conn: RequestConnection + ?Sized,
2340     {
2341         let (bytes, fds) = self.serialize(conn)?;
2342         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2343         conn.send_request_without_reply(&slices, fds)
2344     }
2345     /// 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>2346     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2347         if header.minor_opcode != CHANGE_PICTURE_REQUEST {
2348             return Err(ParseError::InvalidValue);
2349         }
2350         let (picture, remaining) = Picture::try_parse(value)?;
2351         let (value_mask, remaining) = u32::try_parse(remaining)?;
2352         let (value_list, remaining) = ChangePictureAux::try_parse(remaining, value_mask)?;
2353         let _ = remaining;
2354         Ok(ChangePictureRequest {
2355             picture,
2356             value_list: Cow::Owned(value_list),
2357         })
2358     }
2359     /// Clone all borrowed data in this ChangePictureRequest.
into_owned(self) -> ChangePictureRequest<'static>2360     pub fn into_owned(self) -> ChangePictureRequest<'static> {
2361         ChangePictureRequest {
2362             picture: self.picture,
2363             value_list: Cow::Owned(self.value_list.into_owned()),
2364         }
2365     }
2366 }
2367 impl<'input> Request for ChangePictureRequest<'input> {
2368     type Reply = ();
2369 }
change_picture<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, value_list: &'input ChangePictureAux) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2370 pub fn change_picture<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, value_list: &'input ChangePictureAux) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2371 where
2372     Conn: RequestConnection + ?Sized,
2373 {
2374     let request0 = ChangePictureRequest {
2375         picture,
2376         value_list: Cow::Borrowed(value_list),
2377     };
2378     request0.send(conn)
2379 }
2380 
2381 /// Opcode for the SetPictureClipRectangles request
2382 pub const SET_PICTURE_CLIP_RECTANGLES_REQUEST: u8 = 6;
2383 #[derive(Debug, Clone, PartialEq, Eq)]
2384 pub struct SetPictureClipRectanglesRequest<'input> {
2385     pub picture: Picture,
2386     pub clip_x_origin: i16,
2387     pub clip_y_origin: i16,
2388     pub rectangles: Cow<'input, [xproto::Rectangle]>,
2389 }
2390 impl<'input> SetPictureClipRectanglesRequest<'input> {
2391     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2392     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2393     where
2394         Conn: RequestConnection + ?Sized,
2395     {
2396         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2397             .ok_or(ConnectionError::UnsupportedExtension)?;
2398         let length_so_far = 0;
2399         let picture_bytes = self.picture.serialize();
2400         let clip_x_origin_bytes = self.clip_x_origin.serialize();
2401         let clip_y_origin_bytes = self.clip_y_origin.serialize();
2402         let mut request0 = vec![
2403             extension_information.major_opcode,
2404             SET_PICTURE_CLIP_RECTANGLES_REQUEST,
2405             0,
2406             0,
2407             picture_bytes[0],
2408             picture_bytes[1],
2409             picture_bytes[2],
2410             picture_bytes[3],
2411             clip_x_origin_bytes[0],
2412             clip_x_origin_bytes[1],
2413             clip_y_origin_bytes[0],
2414             clip_y_origin_bytes[1],
2415         ];
2416         let length_so_far = length_so_far + request0.len();
2417         let rectangles_bytes = self.rectangles.serialize();
2418         let length_so_far = length_so_far + rectangles_bytes.len();
2419         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2420         let length_so_far = length_so_far + padding0.len();
2421         assert_eq!(length_so_far % 4, 0);
2422         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2423         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2424         Ok((vec![request0.into(), rectangles_bytes.into(), padding0.into()], vec![]))
2425     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2426     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2427     where
2428         Conn: RequestConnection + ?Sized,
2429     {
2430         let (bytes, fds) = self.serialize(conn)?;
2431         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2432         conn.send_request_without_reply(&slices, fds)
2433     }
2434     /// 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>2435     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2436         if header.minor_opcode != SET_PICTURE_CLIP_RECTANGLES_REQUEST {
2437             return Err(ParseError::InvalidValue);
2438         }
2439         let (picture, remaining) = Picture::try_parse(value)?;
2440         let (clip_x_origin, remaining) = i16::try_parse(remaining)?;
2441         let (clip_y_origin, remaining) = i16::try_parse(remaining)?;
2442         let mut remaining = remaining;
2443         // Length is 'everything left in the input'
2444         let mut rectangles = Vec::new();
2445         while !remaining.is_empty() {
2446             let (v, new_remaining) = xproto::Rectangle::try_parse(remaining)?;
2447             remaining = new_remaining;
2448             rectangles.push(v);
2449         }
2450         let _ = remaining;
2451         Ok(SetPictureClipRectanglesRequest {
2452             picture,
2453             clip_x_origin,
2454             clip_y_origin,
2455             rectangles: Cow::Owned(rectangles),
2456         })
2457     }
2458     /// Clone all borrowed data in this SetPictureClipRectanglesRequest.
into_owned(self) -> SetPictureClipRectanglesRequest<'static>2459     pub fn into_owned(self) -> SetPictureClipRectanglesRequest<'static> {
2460         SetPictureClipRectanglesRequest {
2461             picture: self.picture,
2462             clip_x_origin: self.clip_x_origin,
2463             clip_y_origin: self.clip_y_origin,
2464             rectangles: Cow::Owned(self.rectangles.into_owned()),
2465         }
2466     }
2467 }
2468 impl<'input> Request for SetPictureClipRectanglesRequest<'input> {
2469     type Reply = ();
2470 }
set_picture_clip_rectangles<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2471 pub fn set_picture_clip_rectangles<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2472 where
2473     Conn: RequestConnection + ?Sized,
2474 {
2475     let request0 = SetPictureClipRectanglesRequest {
2476         picture,
2477         clip_x_origin,
2478         clip_y_origin,
2479         rectangles: Cow::Borrowed(rectangles),
2480     };
2481     request0.send(conn)
2482 }
2483 
2484 /// Opcode for the FreePicture request
2485 pub const FREE_PICTURE_REQUEST: u8 = 7;
2486 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2487 pub struct FreePictureRequest {
2488     pub picture: Picture,
2489 }
2490 impl FreePictureRequest {
2491     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2492     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2493     where
2494         Conn: RequestConnection + ?Sized,
2495     {
2496         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2497             .ok_or(ConnectionError::UnsupportedExtension)?;
2498         let length_so_far = 0;
2499         let picture_bytes = self.picture.serialize();
2500         let mut request0 = vec![
2501             extension_information.major_opcode,
2502             FREE_PICTURE_REQUEST,
2503             0,
2504             0,
2505             picture_bytes[0],
2506             picture_bytes[1],
2507             picture_bytes[2],
2508             picture_bytes[3],
2509         ];
2510         let length_so_far = length_so_far + request0.len();
2511         assert_eq!(length_so_far % 4, 0);
2512         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2513         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2514         Ok((vec![request0.into()], vec![]))
2515     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2516     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2517     where
2518         Conn: RequestConnection + ?Sized,
2519     {
2520         let (bytes, fds) = self.serialize(conn)?;
2521         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2522         conn.send_request_without_reply(&slices, fds)
2523     }
2524     /// 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>2525     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2526         if header.minor_opcode != FREE_PICTURE_REQUEST {
2527             return Err(ParseError::InvalidValue);
2528         }
2529         let (picture, remaining) = Picture::try_parse(value)?;
2530         let _ = remaining;
2531         Ok(FreePictureRequest {
2532             picture,
2533         })
2534     }
2535 }
2536 impl Request for FreePictureRequest {
2537     type Reply = ();
2538 }
free_picture<Conn>(conn: &Conn, picture: Picture) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2539 pub fn free_picture<Conn>(conn: &Conn, picture: Picture) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2540 where
2541     Conn: RequestConnection + ?Sized,
2542 {
2543     let request0 = FreePictureRequest {
2544         picture,
2545     };
2546     request0.send(conn)
2547 }
2548 
2549 /// Opcode for the Composite request
2550 pub const COMPOSITE_REQUEST: u8 = 8;
2551 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2552 pub struct CompositeRequest {
2553     pub op: PictOp,
2554     pub src: Picture,
2555     pub mask: Picture,
2556     pub dst: Picture,
2557     pub src_x: i16,
2558     pub src_y: i16,
2559     pub mask_x: i16,
2560     pub mask_y: i16,
2561     pub dst_x: i16,
2562     pub dst_y: i16,
2563     pub width: u16,
2564     pub height: u16,
2565 }
2566 impl CompositeRequest {
2567     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2568     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2569     where
2570         Conn: RequestConnection + ?Sized,
2571     {
2572         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2573             .ok_or(ConnectionError::UnsupportedExtension)?;
2574         let length_so_far = 0;
2575         let op_bytes = u8::from(self.op).serialize();
2576         let src_bytes = self.src.serialize();
2577         let mask_bytes = self.mask.serialize();
2578         let dst_bytes = self.dst.serialize();
2579         let src_x_bytes = self.src_x.serialize();
2580         let src_y_bytes = self.src_y.serialize();
2581         let mask_x_bytes = self.mask_x.serialize();
2582         let mask_y_bytes = self.mask_y.serialize();
2583         let dst_x_bytes = self.dst_x.serialize();
2584         let dst_y_bytes = self.dst_y.serialize();
2585         let width_bytes = self.width.serialize();
2586         let height_bytes = self.height.serialize();
2587         let mut request0 = vec![
2588             extension_information.major_opcode,
2589             COMPOSITE_REQUEST,
2590             0,
2591             0,
2592             op_bytes[0],
2593             0,
2594             0,
2595             0,
2596             src_bytes[0],
2597             src_bytes[1],
2598             src_bytes[2],
2599             src_bytes[3],
2600             mask_bytes[0],
2601             mask_bytes[1],
2602             mask_bytes[2],
2603             mask_bytes[3],
2604             dst_bytes[0],
2605             dst_bytes[1],
2606             dst_bytes[2],
2607             dst_bytes[3],
2608             src_x_bytes[0],
2609             src_x_bytes[1],
2610             src_y_bytes[0],
2611             src_y_bytes[1],
2612             mask_x_bytes[0],
2613             mask_x_bytes[1],
2614             mask_y_bytes[0],
2615             mask_y_bytes[1],
2616             dst_x_bytes[0],
2617             dst_x_bytes[1],
2618             dst_y_bytes[0],
2619             dst_y_bytes[1],
2620             width_bytes[0],
2621             width_bytes[1],
2622             height_bytes[0],
2623             height_bytes[1],
2624         ];
2625         let length_so_far = length_so_far + request0.len();
2626         assert_eq!(length_so_far % 4, 0);
2627         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2628         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2629         Ok((vec![request0.into()], vec![]))
2630     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2631     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2632     where
2633         Conn: RequestConnection + ?Sized,
2634     {
2635         let (bytes, fds) = self.serialize(conn)?;
2636         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2637         conn.send_request_without_reply(&slices, fds)
2638     }
2639     /// 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>2640     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2641         if header.minor_opcode != COMPOSITE_REQUEST {
2642             return Err(ParseError::InvalidValue);
2643         }
2644         let (op, remaining) = u8::try_parse(value)?;
2645         let op = op.into();
2646         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2647         let (src, remaining) = Picture::try_parse(remaining)?;
2648         let (mask, remaining) = Picture::try_parse(remaining)?;
2649         let (dst, remaining) = Picture::try_parse(remaining)?;
2650         let (src_x, remaining) = i16::try_parse(remaining)?;
2651         let (src_y, remaining) = i16::try_parse(remaining)?;
2652         let (mask_x, remaining) = i16::try_parse(remaining)?;
2653         let (mask_y, remaining) = i16::try_parse(remaining)?;
2654         let (dst_x, remaining) = i16::try_parse(remaining)?;
2655         let (dst_y, remaining) = i16::try_parse(remaining)?;
2656         let (width, remaining) = u16::try_parse(remaining)?;
2657         let (height, remaining) = u16::try_parse(remaining)?;
2658         let _ = remaining;
2659         Ok(CompositeRequest {
2660             op,
2661             src,
2662             mask,
2663             dst,
2664             src_x,
2665             src_y,
2666             mask_x,
2667             mask_y,
2668             dst_x,
2669             dst_y,
2670             width,
2671             height,
2672         })
2673     }
2674 }
2675 impl Request for CompositeRequest {
2676     type Reply = ();
2677 }
composite<Conn, A>(conn: &Conn, op: PictOp, src: Picture, mask: A, dst: Picture, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized, A: Into<Picture>,2678 pub fn composite<Conn, A>(conn: &Conn, op: PictOp, src: Picture, mask: A, dst: Picture, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2679 where
2680     Conn: RequestConnection + ?Sized,
2681     A: Into<Picture>,
2682 {
2683     let mask: Picture = mask.into();
2684     let request0 = CompositeRequest {
2685         op,
2686         src,
2687         mask,
2688         dst,
2689         src_x,
2690         src_y,
2691         mask_x,
2692         mask_y,
2693         dst_x,
2694         dst_y,
2695         width,
2696         height,
2697     };
2698     request0.send(conn)
2699 }
2700 
2701 /// Opcode for the Trapezoids request
2702 pub const TRAPEZOIDS_REQUEST: u8 = 10;
2703 #[derive(Debug, Clone, PartialEq, Eq)]
2704 pub struct TrapezoidsRequest<'input> {
2705     pub op: PictOp,
2706     pub src: Picture,
2707     pub dst: Picture,
2708     pub mask_format: Pictformat,
2709     pub src_x: i16,
2710     pub src_y: i16,
2711     pub traps: Cow<'input, [Trapezoid]>,
2712 }
2713 impl<'input> TrapezoidsRequest<'input> {
2714     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2715     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2716     where
2717         Conn: RequestConnection + ?Sized,
2718     {
2719         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2720             .ok_or(ConnectionError::UnsupportedExtension)?;
2721         let length_so_far = 0;
2722         let op_bytes = u8::from(self.op).serialize();
2723         let src_bytes = self.src.serialize();
2724         let dst_bytes = self.dst.serialize();
2725         let mask_format_bytes = self.mask_format.serialize();
2726         let src_x_bytes = self.src_x.serialize();
2727         let src_y_bytes = self.src_y.serialize();
2728         let mut request0 = vec![
2729             extension_information.major_opcode,
2730             TRAPEZOIDS_REQUEST,
2731             0,
2732             0,
2733             op_bytes[0],
2734             0,
2735             0,
2736             0,
2737             src_bytes[0],
2738             src_bytes[1],
2739             src_bytes[2],
2740             src_bytes[3],
2741             dst_bytes[0],
2742             dst_bytes[1],
2743             dst_bytes[2],
2744             dst_bytes[3],
2745             mask_format_bytes[0],
2746             mask_format_bytes[1],
2747             mask_format_bytes[2],
2748             mask_format_bytes[3],
2749             src_x_bytes[0],
2750             src_x_bytes[1],
2751             src_y_bytes[0],
2752             src_y_bytes[1],
2753         ];
2754         let length_so_far = length_so_far + request0.len();
2755         let traps_bytes = self.traps.serialize();
2756         let length_so_far = length_so_far + traps_bytes.len();
2757         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2758         let length_so_far = length_so_far + padding0.len();
2759         assert_eq!(length_so_far % 4, 0);
2760         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2761         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2762         Ok((vec![request0.into(), traps_bytes.into(), padding0.into()], vec![]))
2763     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2764     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2765     where
2766         Conn: RequestConnection + ?Sized,
2767     {
2768         let (bytes, fds) = self.serialize(conn)?;
2769         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2770         conn.send_request_without_reply(&slices, fds)
2771     }
2772     /// 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>2773     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2774         if header.minor_opcode != TRAPEZOIDS_REQUEST {
2775             return Err(ParseError::InvalidValue);
2776         }
2777         let (op, remaining) = u8::try_parse(value)?;
2778         let op = op.into();
2779         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2780         let (src, remaining) = Picture::try_parse(remaining)?;
2781         let (dst, remaining) = Picture::try_parse(remaining)?;
2782         let (mask_format, remaining) = Pictformat::try_parse(remaining)?;
2783         let (src_x, remaining) = i16::try_parse(remaining)?;
2784         let (src_y, remaining) = i16::try_parse(remaining)?;
2785         let mut remaining = remaining;
2786         // Length is 'everything left in the input'
2787         let mut traps = Vec::new();
2788         while !remaining.is_empty() {
2789             let (v, new_remaining) = Trapezoid::try_parse(remaining)?;
2790             remaining = new_remaining;
2791             traps.push(v);
2792         }
2793         let _ = remaining;
2794         Ok(TrapezoidsRequest {
2795             op,
2796             src,
2797             dst,
2798             mask_format,
2799             src_x,
2800             src_y,
2801             traps: Cow::Owned(traps),
2802         })
2803     }
2804     /// Clone all borrowed data in this TrapezoidsRequest.
into_owned(self) -> TrapezoidsRequest<'static>2805     pub fn into_owned(self) -> TrapezoidsRequest<'static> {
2806         TrapezoidsRequest {
2807             op: self.op,
2808             src: self.src,
2809             dst: self.dst,
2810             mask_format: self.mask_format,
2811             src_x: self.src_x,
2812             src_y: self.src_y,
2813             traps: Cow::Owned(self.traps.into_owned()),
2814         }
2815     }
2816 }
2817 impl<'input> Request for TrapezoidsRequest<'input> {
2818     type Reply = ();
2819 }
trapezoids<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, traps: &'input [Trapezoid]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2820 pub fn trapezoids<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, traps: &'input [Trapezoid]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2821 where
2822     Conn: RequestConnection + ?Sized,
2823 {
2824     let request0 = TrapezoidsRequest {
2825         op,
2826         src,
2827         dst,
2828         mask_format,
2829         src_x,
2830         src_y,
2831         traps: Cow::Borrowed(traps),
2832     };
2833     request0.send(conn)
2834 }
2835 
2836 /// Opcode for the Triangles request
2837 pub const TRIANGLES_REQUEST: u8 = 11;
2838 #[derive(Debug, Clone, PartialEq, Eq)]
2839 pub struct TrianglesRequest<'input> {
2840     pub op: PictOp,
2841     pub src: Picture,
2842     pub dst: Picture,
2843     pub mask_format: Pictformat,
2844     pub src_x: i16,
2845     pub src_y: i16,
2846     pub triangles: Cow<'input, [Triangle]>,
2847 }
2848 impl<'input> TrianglesRequest<'input> {
2849     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2850     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2851     where
2852         Conn: RequestConnection + ?Sized,
2853     {
2854         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2855             .ok_or(ConnectionError::UnsupportedExtension)?;
2856         let length_so_far = 0;
2857         let op_bytes = u8::from(self.op).serialize();
2858         let src_bytes = self.src.serialize();
2859         let dst_bytes = self.dst.serialize();
2860         let mask_format_bytes = self.mask_format.serialize();
2861         let src_x_bytes = self.src_x.serialize();
2862         let src_y_bytes = self.src_y.serialize();
2863         let mut request0 = vec![
2864             extension_information.major_opcode,
2865             TRIANGLES_REQUEST,
2866             0,
2867             0,
2868             op_bytes[0],
2869             0,
2870             0,
2871             0,
2872             src_bytes[0],
2873             src_bytes[1],
2874             src_bytes[2],
2875             src_bytes[3],
2876             dst_bytes[0],
2877             dst_bytes[1],
2878             dst_bytes[2],
2879             dst_bytes[3],
2880             mask_format_bytes[0],
2881             mask_format_bytes[1],
2882             mask_format_bytes[2],
2883             mask_format_bytes[3],
2884             src_x_bytes[0],
2885             src_x_bytes[1],
2886             src_y_bytes[0],
2887             src_y_bytes[1],
2888         ];
2889         let length_so_far = length_so_far + request0.len();
2890         let triangles_bytes = self.triangles.serialize();
2891         let length_so_far = length_so_far + triangles_bytes.len();
2892         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2893         let length_so_far = length_so_far + padding0.len();
2894         assert_eq!(length_so_far % 4, 0);
2895         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2896         request0[2..4].copy_from_slice(&length.to_ne_bytes());
2897         Ok((vec![request0.into(), triangles_bytes.into(), padding0.into()], vec![]))
2898     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2899     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2900     where
2901         Conn: RequestConnection + ?Sized,
2902     {
2903         let (bytes, fds) = self.serialize(conn)?;
2904         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2905         conn.send_request_without_reply(&slices, fds)
2906     }
2907     /// 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>2908     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2909         if header.minor_opcode != TRIANGLES_REQUEST {
2910             return Err(ParseError::InvalidValue);
2911         }
2912         let (op, remaining) = u8::try_parse(value)?;
2913         let op = op.into();
2914         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2915         let (src, remaining) = Picture::try_parse(remaining)?;
2916         let (dst, remaining) = Picture::try_parse(remaining)?;
2917         let (mask_format, remaining) = Pictformat::try_parse(remaining)?;
2918         let (src_x, remaining) = i16::try_parse(remaining)?;
2919         let (src_y, remaining) = i16::try_parse(remaining)?;
2920         let mut remaining = remaining;
2921         // Length is 'everything left in the input'
2922         let mut triangles = Vec::new();
2923         while !remaining.is_empty() {
2924             let (v, new_remaining) = Triangle::try_parse(remaining)?;
2925             remaining = new_remaining;
2926             triangles.push(v);
2927         }
2928         let _ = remaining;
2929         Ok(TrianglesRequest {
2930             op,
2931             src,
2932             dst,
2933             mask_format,
2934             src_x,
2935             src_y,
2936             triangles: Cow::Owned(triangles),
2937         })
2938     }
2939     /// Clone all borrowed data in this TrianglesRequest.
into_owned(self) -> TrianglesRequest<'static>2940     pub fn into_owned(self) -> TrianglesRequest<'static> {
2941         TrianglesRequest {
2942             op: self.op,
2943             src: self.src,
2944             dst: self.dst,
2945             mask_format: self.mask_format,
2946             src_x: self.src_x,
2947             src_y: self.src_y,
2948             triangles: Cow::Owned(self.triangles.into_owned()),
2949         }
2950     }
2951 }
2952 impl<'input> Request for TrianglesRequest<'input> {
2953     type Reply = ();
2954 }
triangles<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, triangles: &'input [Triangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2955 pub fn triangles<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, triangles: &'input [Triangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2956 where
2957     Conn: RequestConnection + ?Sized,
2958 {
2959     let request0 = TrianglesRequest {
2960         op,
2961         src,
2962         dst,
2963         mask_format,
2964         src_x,
2965         src_y,
2966         triangles: Cow::Borrowed(triangles),
2967     };
2968     request0.send(conn)
2969 }
2970 
2971 /// Opcode for the TriStrip request
2972 pub const TRI_STRIP_REQUEST: u8 = 12;
2973 #[derive(Debug, Clone, PartialEq, Eq)]
2974 pub struct TriStripRequest<'input> {
2975     pub op: PictOp,
2976     pub src: Picture,
2977     pub dst: Picture,
2978     pub mask_format: Pictformat,
2979     pub src_x: i16,
2980     pub src_y: i16,
2981     pub points: Cow<'input, [Pointfix]>,
2982 }
2983 impl<'input> TriStripRequest<'input> {
2984     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2985     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2986     where
2987         Conn: RequestConnection + ?Sized,
2988     {
2989         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2990             .ok_or(ConnectionError::UnsupportedExtension)?;
2991         let length_so_far = 0;
2992         let op_bytes = u8::from(self.op).serialize();
2993         let src_bytes = self.src.serialize();
2994         let dst_bytes = self.dst.serialize();
2995         let mask_format_bytes = self.mask_format.serialize();
2996         let src_x_bytes = self.src_x.serialize();
2997         let src_y_bytes = self.src_y.serialize();
2998         let mut request0 = vec![
2999             extension_information.major_opcode,
3000             TRI_STRIP_REQUEST,
3001             0,
3002             0,
3003             op_bytes[0],
3004             0,
3005             0,
3006             0,
3007             src_bytes[0],
3008             src_bytes[1],
3009             src_bytes[2],
3010             src_bytes[3],
3011             dst_bytes[0],
3012             dst_bytes[1],
3013             dst_bytes[2],
3014             dst_bytes[3],
3015             mask_format_bytes[0],
3016             mask_format_bytes[1],
3017             mask_format_bytes[2],
3018             mask_format_bytes[3],
3019             src_x_bytes[0],
3020             src_x_bytes[1],
3021             src_y_bytes[0],
3022             src_y_bytes[1],
3023         ];
3024         let length_so_far = length_so_far + request0.len();
3025         let points_bytes = self.points.serialize();
3026         let length_so_far = length_so_far + points_bytes.len();
3027         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3028         let length_so_far = length_so_far + padding0.len();
3029         assert_eq!(length_so_far % 4, 0);
3030         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3031         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3032         Ok((vec![request0.into(), points_bytes.into(), padding0.into()], vec![]))
3033     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3034     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3035     where
3036         Conn: RequestConnection + ?Sized,
3037     {
3038         let (bytes, fds) = self.serialize(conn)?;
3039         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3040         conn.send_request_without_reply(&slices, fds)
3041     }
3042     /// 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>3043     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3044         if header.minor_opcode != TRI_STRIP_REQUEST {
3045             return Err(ParseError::InvalidValue);
3046         }
3047         let (op, remaining) = u8::try_parse(value)?;
3048         let op = op.into();
3049         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
3050         let (src, remaining) = Picture::try_parse(remaining)?;
3051         let (dst, remaining) = Picture::try_parse(remaining)?;
3052         let (mask_format, remaining) = Pictformat::try_parse(remaining)?;
3053         let (src_x, remaining) = i16::try_parse(remaining)?;
3054         let (src_y, remaining) = i16::try_parse(remaining)?;
3055         let mut remaining = remaining;
3056         // Length is 'everything left in the input'
3057         let mut points = Vec::new();
3058         while !remaining.is_empty() {
3059             let (v, new_remaining) = Pointfix::try_parse(remaining)?;
3060             remaining = new_remaining;
3061             points.push(v);
3062         }
3063         let _ = remaining;
3064         Ok(TriStripRequest {
3065             op,
3066             src,
3067             dst,
3068             mask_format,
3069             src_x,
3070             src_y,
3071             points: Cow::Owned(points),
3072         })
3073     }
3074     /// Clone all borrowed data in this TriStripRequest.
into_owned(self) -> TriStripRequest<'static>3075     pub fn into_owned(self) -> TriStripRequest<'static> {
3076         TriStripRequest {
3077             op: self.op,
3078             src: self.src,
3079             dst: self.dst,
3080             mask_format: self.mask_format,
3081             src_x: self.src_x,
3082             src_y: self.src_y,
3083             points: Cow::Owned(self.points.into_owned()),
3084         }
3085     }
3086 }
3087 impl<'input> Request for TriStripRequest<'input> {
3088     type Reply = ();
3089 }
tri_strip<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3090 pub fn tri_strip<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3091 where
3092     Conn: RequestConnection + ?Sized,
3093 {
3094     let request0 = TriStripRequest {
3095         op,
3096         src,
3097         dst,
3098         mask_format,
3099         src_x,
3100         src_y,
3101         points: Cow::Borrowed(points),
3102     };
3103     request0.send(conn)
3104 }
3105 
3106 /// Opcode for the TriFan request
3107 pub const TRI_FAN_REQUEST: u8 = 13;
3108 #[derive(Debug, Clone, PartialEq, Eq)]
3109 pub struct TriFanRequest<'input> {
3110     pub op: PictOp,
3111     pub src: Picture,
3112     pub dst: Picture,
3113     pub mask_format: Pictformat,
3114     pub src_x: i16,
3115     pub src_y: i16,
3116     pub points: Cow<'input, [Pointfix]>,
3117 }
3118 impl<'input> TriFanRequest<'input> {
3119     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3120     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3121     where
3122         Conn: RequestConnection + ?Sized,
3123     {
3124         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3125             .ok_or(ConnectionError::UnsupportedExtension)?;
3126         let length_so_far = 0;
3127         let op_bytes = u8::from(self.op).serialize();
3128         let src_bytes = self.src.serialize();
3129         let dst_bytes = self.dst.serialize();
3130         let mask_format_bytes = self.mask_format.serialize();
3131         let src_x_bytes = self.src_x.serialize();
3132         let src_y_bytes = self.src_y.serialize();
3133         let mut request0 = vec![
3134             extension_information.major_opcode,
3135             TRI_FAN_REQUEST,
3136             0,
3137             0,
3138             op_bytes[0],
3139             0,
3140             0,
3141             0,
3142             src_bytes[0],
3143             src_bytes[1],
3144             src_bytes[2],
3145             src_bytes[3],
3146             dst_bytes[0],
3147             dst_bytes[1],
3148             dst_bytes[2],
3149             dst_bytes[3],
3150             mask_format_bytes[0],
3151             mask_format_bytes[1],
3152             mask_format_bytes[2],
3153             mask_format_bytes[3],
3154             src_x_bytes[0],
3155             src_x_bytes[1],
3156             src_y_bytes[0],
3157             src_y_bytes[1],
3158         ];
3159         let length_so_far = length_so_far + request0.len();
3160         let points_bytes = self.points.serialize();
3161         let length_so_far = length_so_far + points_bytes.len();
3162         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3163         let length_so_far = length_so_far + padding0.len();
3164         assert_eq!(length_so_far % 4, 0);
3165         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3166         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3167         Ok((vec![request0.into(), points_bytes.into(), padding0.into()], vec![]))
3168     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3169     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3170     where
3171         Conn: RequestConnection + ?Sized,
3172     {
3173         let (bytes, fds) = self.serialize(conn)?;
3174         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3175         conn.send_request_without_reply(&slices, fds)
3176     }
3177     /// 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>3178     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3179         if header.minor_opcode != TRI_FAN_REQUEST {
3180             return Err(ParseError::InvalidValue);
3181         }
3182         let (op, remaining) = u8::try_parse(value)?;
3183         let op = op.into();
3184         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
3185         let (src, remaining) = Picture::try_parse(remaining)?;
3186         let (dst, remaining) = Picture::try_parse(remaining)?;
3187         let (mask_format, remaining) = Pictformat::try_parse(remaining)?;
3188         let (src_x, remaining) = i16::try_parse(remaining)?;
3189         let (src_y, remaining) = i16::try_parse(remaining)?;
3190         let mut remaining = remaining;
3191         // Length is 'everything left in the input'
3192         let mut points = Vec::new();
3193         while !remaining.is_empty() {
3194             let (v, new_remaining) = Pointfix::try_parse(remaining)?;
3195             remaining = new_remaining;
3196             points.push(v);
3197         }
3198         let _ = remaining;
3199         Ok(TriFanRequest {
3200             op,
3201             src,
3202             dst,
3203             mask_format,
3204             src_x,
3205             src_y,
3206             points: Cow::Owned(points),
3207         })
3208     }
3209     /// Clone all borrowed data in this TriFanRequest.
into_owned(self) -> TriFanRequest<'static>3210     pub fn into_owned(self) -> TriFanRequest<'static> {
3211         TriFanRequest {
3212             op: self.op,
3213             src: self.src,
3214             dst: self.dst,
3215             mask_format: self.mask_format,
3216             src_x: self.src_x,
3217             src_y: self.src_y,
3218             points: Cow::Owned(self.points.into_owned()),
3219         }
3220     }
3221 }
3222 impl<'input> Request for TriFanRequest<'input> {
3223     type Reply = ();
3224 }
tri_fan<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3225 pub fn tri_fan<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3226 where
3227     Conn: RequestConnection + ?Sized,
3228 {
3229     let request0 = TriFanRequest {
3230         op,
3231         src,
3232         dst,
3233         mask_format,
3234         src_x,
3235         src_y,
3236         points: Cow::Borrowed(points),
3237     };
3238     request0.send(conn)
3239 }
3240 
3241 /// Opcode for the CreateGlyphSet request
3242 pub const CREATE_GLYPH_SET_REQUEST: u8 = 17;
3243 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3244 pub struct CreateGlyphSetRequest {
3245     pub gsid: Glyphset,
3246     pub format: Pictformat,
3247 }
3248 impl CreateGlyphSetRequest {
3249     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3250     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3251     where
3252         Conn: RequestConnection + ?Sized,
3253     {
3254         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3255             .ok_or(ConnectionError::UnsupportedExtension)?;
3256         let length_so_far = 0;
3257         let gsid_bytes = self.gsid.serialize();
3258         let format_bytes = self.format.serialize();
3259         let mut request0 = vec![
3260             extension_information.major_opcode,
3261             CREATE_GLYPH_SET_REQUEST,
3262             0,
3263             0,
3264             gsid_bytes[0],
3265             gsid_bytes[1],
3266             gsid_bytes[2],
3267             gsid_bytes[3],
3268             format_bytes[0],
3269             format_bytes[1],
3270             format_bytes[2],
3271             format_bytes[3],
3272         ];
3273         let length_so_far = length_so_far + request0.len();
3274         assert_eq!(length_so_far % 4, 0);
3275         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3276         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3277         Ok((vec![request0.into()], vec![]))
3278     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3279     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3280     where
3281         Conn: RequestConnection + ?Sized,
3282     {
3283         let (bytes, fds) = self.serialize(conn)?;
3284         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3285         conn.send_request_without_reply(&slices, fds)
3286     }
3287     /// 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>3288     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3289         if header.minor_opcode != CREATE_GLYPH_SET_REQUEST {
3290             return Err(ParseError::InvalidValue);
3291         }
3292         let (gsid, remaining) = Glyphset::try_parse(value)?;
3293         let (format, remaining) = Pictformat::try_parse(remaining)?;
3294         let _ = remaining;
3295         Ok(CreateGlyphSetRequest {
3296             gsid,
3297             format,
3298         })
3299     }
3300 }
3301 impl Request for CreateGlyphSetRequest {
3302     type Reply = ();
3303 }
create_glyph_set<Conn>(conn: &Conn, gsid: Glyphset, format: Pictformat) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3304 pub fn create_glyph_set<Conn>(conn: &Conn, gsid: Glyphset, format: Pictformat) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3305 where
3306     Conn: RequestConnection + ?Sized,
3307 {
3308     let request0 = CreateGlyphSetRequest {
3309         gsid,
3310         format,
3311     };
3312     request0.send(conn)
3313 }
3314 
3315 /// Opcode for the ReferenceGlyphSet request
3316 pub const REFERENCE_GLYPH_SET_REQUEST: u8 = 18;
3317 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3318 pub struct ReferenceGlyphSetRequest {
3319     pub gsid: Glyphset,
3320     pub existing: Glyphset,
3321 }
3322 impl ReferenceGlyphSetRequest {
3323     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3324     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3325     where
3326         Conn: RequestConnection + ?Sized,
3327     {
3328         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3329             .ok_or(ConnectionError::UnsupportedExtension)?;
3330         let length_so_far = 0;
3331         let gsid_bytes = self.gsid.serialize();
3332         let existing_bytes = self.existing.serialize();
3333         let mut request0 = vec![
3334             extension_information.major_opcode,
3335             REFERENCE_GLYPH_SET_REQUEST,
3336             0,
3337             0,
3338             gsid_bytes[0],
3339             gsid_bytes[1],
3340             gsid_bytes[2],
3341             gsid_bytes[3],
3342             existing_bytes[0],
3343             existing_bytes[1],
3344             existing_bytes[2],
3345             existing_bytes[3],
3346         ];
3347         let length_so_far = length_so_far + request0.len();
3348         assert_eq!(length_so_far % 4, 0);
3349         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3350         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3351         Ok((vec![request0.into()], vec![]))
3352     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3353     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3354     where
3355         Conn: RequestConnection + ?Sized,
3356     {
3357         let (bytes, fds) = self.serialize(conn)?;
3358         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3359         conn.send_request_without_reply(&slices, fds)
3360     }
3361     /// 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>3362     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3363         if header.minor_opcode != REFERENCE_GLYPH_SET_REQUEST {
3364             return Err(ParseError::InvalidValue);
3365         }
3366         let (gsid, remaining) = Glyphset::try_parse(value)?;
3367         let (existing, remaining) = Glyphset::try_parse(remaining)?;
3368         let _ = remaining;
3369         Ok(ReferenceGlyphSetRequest {
3370             gsid,
3371             existing,
3372         })
3373     }
3374 }
3375 impl Request for ReferenceGlyphSetRequest {
3376     type Reply = ();
3377 }
reference_glyph_set<Conn>(conn: &Conn, gsid: Glyphset, existing: Glyphset) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3378 pub fn reference_glyph_set<Conn>(conn: &Conn, gsid: Glyphset, existing: Glyphset) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3379 where
3380     Conn: RequestConnection + ?Sized,
3381 {
3382     let request0 = ReferenceGlyphSetRequest {
3383         gsid,
3384         existing,
3385     };
3386     request0.send(conn)
3387 }
3388 
3389 /// Opcode for the FreeGlyphSet request
3390 pub const FREE_GLYPH_SET_REQUEST: u8 = 19;
3391 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3392 pub struct FreeGlyphSetRequest {
3393     pub glyphset: Glyphset,
3394 }
3395 impl FreeGlyphSetRequest {
3396     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3397     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3398     where
3399         Conn: RequestConnection + ?Sized,
3400     {
3401         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3402             .ok_or(ConnectionError::UnsupportedExtension)?;
3403         let length_so_far = 0;
3404         let glyphset_bytes = self.glyphset.serialize();
3405         let mut request0 = vec![
3406             extension_information.major_opcode,
3407             FREE_GLYPH_SET_REQUEST,
3408             0,
3409             0,
3410             glyphset_bytes[0],
3411             glyphset_bytes[1],
3412             glyphset_bytes[2],
3413             glyphset_bytes[3],
3414         ];
3415         let length_so_far = length_so_far + request0.len();
3416         assert_eq!(length_so_far % 4, 0);
3417         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3418         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3419         Ok((vec![request0.into()], vec![]))
3420     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3421     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3422     where
3423         Conn: RequestConnection + ?Sized,
3424     {
3425         let (bytes, fds) = self.serialize(conn)?;
3426         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3427         conn.send_request_without_reply(&slices, fds)
3428     }
3429     /// 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>3430     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3431         if header.minor_opcode != FREE_GLYPH_SET_REQUEST {
3432             return Err(ParseError::InvalidValue);
3433         }
3434         let (glyphset, remaining) = Glyphset::try_parse(value)?;
3435         let _ = remaining;
3436         Ok(FreeGlyphSetRequest {
3437             glyphset,
3438         })
3439     }
3440 }
3441 impl Request for FreeGlyphSetRequest {
3442     type Reply = ();
3443 }
free_glyph_set<Conn>(conn: &Conn, glyphset: Glyphset) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3444 pub fn free_glyph_set<Conn>(conn: &Conn, glyphset: Glyphset) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3445 where
3446     Conn: RequestConnection + ?Sized,
3447 {
3448     let request0 = FreeGlyphSetRequest {
3449         glyphset,
3450     };
3451     request0.send(conn)
3452 }
3453 
3454 /// Opcode for the AddGlyphs request
3455 pub const ADD_GLYPHS_REQUEST: u8 = 20;
3456 #[derive(Debug, Clone, PartialEq, Eq)]
3457 pub struct AddGlyphsRequest<'input> {
3458     pub glyphset: Glyphset,
3459     pub glyphids: Cow<'input, [u32]>,
3460     pub glyphs: Cow<'input, [Glyphinfo]>,
3461     pub data: Cow<'input, [u8]>,
3462 }
3463 impl<'input> AddGlyphsRequest<'input> {
3464     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3465     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3466     where
3467         Conn: RequestConnection + ?Sized,
3468     {
3469         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3470             .ok_or(ConnectionError::UnsupportedExtension)?;
3471         let length_so_far = 0;
3472         let glyphset_bytes = self.glyphset.serialize();
3473         let glyphs_len = u32::try_from(self.glyphids.len()).expect("`glyphids` has too many elements");
3474         let glyphs_len_bytes = glyphs_len.serialize();
3475         let mut request0 = vec![
3476             extension_information.major_opcode,
3477             ADD_GLYPHS_REQUEST,
3478             0,
3479             0,
3480             glyphset_bytes[0],
3481             glyphset_bytes[1],
3482             glyphset_bytes[2],
3483             glyphset_bytes[3],
3484             glyphs_len_bytes[0],
3485             glyphs_len_bytes[1],
3486             glyphs_len_bytes[2],
3487             glyphs_len_bytes[3],
3488         ];
3489         let length_so_far = length_so_far + request0.len();
3490         let glyphids_bytes = self.glyphids.serialize();
3491         let length_so_far = length_so_far + glyphids_bytes.len();
3492         assert_eq!(self.glyphs.len(), usize::try_from(glyphs_len).unwrap(), "`glyphs` has an incorrect length");
3493         let glyphs_bytes = self.glyphs.serialize();
3494         let length_so_far = length_so_far + glyphs_bytes.len();
3495         let length_so_far = length_so_far + self.data.len();
3496         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3497         let length_so_far = length_so_far + padding0.len();
3498         assert_eq!(length_so_far % 4, 0);
3499         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3500         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3501         Ok((vec![request0.into(), glyphids_bytes.into(), glyphs_bytes.into(), self.data, padding0.into()], vec![]))
3502     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3503     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3504     where
3505         Conn: RequestConnection + ?Sized,
3506     {
3507         let (bytes, fds) = self.serialize(conn)?;
3508         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3509         conn.send_request_without_reply(&slices, fds)
3510     }
3511     /// 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>3512     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3513         if header.minor_opcode != ADD_GLYPHS_REQUEST {
3514             return Err(ParseError::InvalidValue);
3515         }
3516         let (glyphset, remaining) = Glyphset::try_parse(value)?;
3517         let (glyphs_len, remaining) = u32::try_parse(remaining)?;
3518         let (glyphids, remaining) = crate::x11_utils::parse_list::<u32>(remaining, glyphs_len.try_to_usize()?)?;
3519         let (glyphs, remaining) = crate::x11_utils::parse_list::<Glyphinfo>(remaining, glyphs_len.try_to_usize()?)?;
3520         let (data, remaining) = remaining.split_at(remaining.len());
3521         let _ = remaining;
3522         Ok(AddGlyphsRequest {
3523             glyphset,
3524             glyphids: Cow::Owned(glyphids),
3525             glyphs: Cow::Owned(glyphs),
3526             data: Cow::Borrowed(data),
3527         })
3528     }
3529     /// Clone all borrowed data in this AddGlyphsRequest.
into_owned(self) -> AddGlyphsRequest<'static>3530     pub fn into_owned(self) -> AddGlyphsRequest<'static> {
3531         AddGlyphsRequest {
3532             glyphset: self.glyphset,
3533             glyphids: Cow::Owned(self.glyphids.into_owned()),
3534             glyphs: Cow::Owned(self.glyphs.into_owned()),
3535             data: Cow::Owned(self.data.into_owned()),
3536         }
3537     }
3538 }
3539 impl<'input> Request for AddGlyphsRequest<'input> {
3540     type Reply = ();
3541 }
add_glyphs<'c, 'input, Conn>(conn: &'c Conn, glyphset: Glyphset, glyphids: &'input [u32], glyphs: &'input [Glyphinfo], data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3542 pub fn add_glyphs<'c, 'input, Conn>(conn: &'c Conn, glyphset: Glyphset, glyphids: &'input [u32], glyphs: &'input [Glyphinfo], data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3543 where
3544     Conn: RequestConnection + ?Sized,
3545 {
3546     let request0 = AddGlyphsRequest {
3547         glyphset,
3548         glyphids: Cow::Borrowed(glyphids),
3549         glyphs: Cow::Borrowed(glyphs),
3550         data: Cow::Borrowed(data),
3551     };
3552     request0.send(conn)
3553 }
3554 
3555 /// Opcode for the FreeGlyphs request
3556 pub const FREE_GLYPHS_REQUEST: u8 = 22;
3557 #[derive(Debug, Clone, PartialEq, Eq)]
3558 pub struct FreeGlyphsRequest<'input> {
3559     pub glyphset: Glyphset,
3560     pub glyphs: Cow<'input, [Glyph]>,
3561 }
3562 impl<'input> FreeGlyphsRequest<'input> {
3563     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3564     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3565     where
3566         Conn: RequestConnection + ?Sized,
3567     {
3568         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3569             .ok_or(ConnectionError::UnsupportedExtension)?;
3570         let length_so_far = 0;
3571         let glyphset_bytes = self.glyphset.serialize();
3572         let mut request0 = vec![
3573             extension_information.major_opcode,
3574             FREE_GLYPHS_REQUEST,
3575             0,
3576             0,
3577             glyphset_bytes[0],
3578             glyphset_bytes[1],
3579             glyphset_bytes[2],
3580             glyphset_bytes[3],
3581         ];
3582         let length_so_far = length_so_far + request0.len();
3583         let glyphs_bytes = self.glyphs.serialize();
3584         let length_so_far = length_so_far + glyphs_bytes.len();
3585         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3586         let length_so_far = length_so_far + padding0.len();
3587         assert_eq!(length_so_far % 4, 0);
3588         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3589         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3590         Ok((vec![request0.into(), glyphs_bytes.into(), padding0.into()], vec![]))
3591     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3592     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3593     where
3594         Conn: RequestConnection + ?Sized,
3595     {
3596         let (bytes, fds) = self.serialize(conn)?;
3597         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3598         conn.send_request_without_reply(&slices, fds)
3599     }
3600     /// 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>3601     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3602         if header.minor_opcode != FREE_GLYPHS_REQUEST {
3603             return Err(ParseError::InvalidValue);
3604         }
3605         let (glyphset, remaining) = Glyphset::try_parse(value)?;
3606         let mut remaining = remaining;
3607         // Length is 'everything left in the input'
3608         let mut glyphs = Vec::new();
3609         while !remaining.is_empty() {
3610             let (v, new_remaining) = Glyph::try_parse(remaining)?;
3611             remaining = new_remaining;
3612             glyphs.push(v);
3613         }
3614         let _ = remaining;
3615         Ok(FreeGlyphsRequest {
3616             glyphset,
3617             glyphs: Cow::Owned(glyphs),
3618         })
3619     }
3620     /// Clone all borrowed data in this FreeGlyphsRequest.
into_owned(self) -> FreeGlyphsRequest<'static>3621     pub fn into_owned(self) -> FreeGlyphsRequest<'static> {
3622         FreeGlyphsRequest {
3623             glyphset: self.glyphset,
3624             glyphs: Cow::Owned(self.glyphs.into_owned()),
3625         }
3626     }
3627 }
3628 impl<'input> Request for FreeGlyphsRequest<'input> {
3629     type Reply = ();
3630 }
free_glyphs<'c, 'input, Conn>(conn: &'c Conn, glyphset: Glyphset, glyphs: &'input [Glyph]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3631 pub fn free_glyphs<'c, 'input, Conn>(conn: &'c Conn, glyphset: Glyphset, glyphs: &'input [Glyph]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3632 where
3633     Conn: RequestConnection + ?Sized,
3634 {
3635     let request0 = FreeGlyphsRequest {
3636         glyphset,
3637         glyphs: Cow::Borrowed(glyphs),
3638     };
3639     request0.send(conn)
3640 }
3641 
3642 /// Opcode for the CompositeGlyphs8 request
3643 pub const COMPOSITE_GLYPHS8_REQUEST: u8 = 23;
3644 #[derive(Debug, Clone, PartialEq, Eq)]
3645 pub struct CompositeGlyphs8Request<'input> {
3646     pub op: PictOp,
3647     pub src: Picture,
3648     pub dst: Picture,
3649     pub mask_format: Pictformat,
3650     pub glyphset: Glyphset,
3651     pub src_x: i16,
3652     pub src_y: i16,
3653     pub glyphcmds: Cow<'input, [u8]>,
3654 }
3655 impl<'input> CompositeGlyphs8Request<'input> {
3656     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3657     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3658     where
3659         Conn: RequestConnection + ?Sized,
3660     {
3661         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3662             .ok_or(ConnectionError::UnsupportedExtension)?;
3663         let length_so_far = 0;
3664         let op_bytes = u8::from(self.op).serialize();
3665         let src_bytes = self.src.serialize();
3666         let dst_bytes = self.dst.serialize();
3667         let mask_format_bytes = self.mask_format.serialize();
3668         let glyphset_bytes = self.glyphset.serialize();
3669         let src_x_bytes = self.src_x.serialize();
3670         let src_y_bytes = self.src_y.serialize();
3671         let mut request0 = vec![
3672             extension_information.major_opcode,
3673             COMPOSITE_GLYPHS8_REQUEST,
3674             0,
3675             0,
3676             op_bytes[0],
3677             0,
3678             0,
3679             0,
3680             src_bytes[0],
3681             src_bytes[1],
3682             src_bytes[2],
3683             src_bytes[3],
3684             dst_bytes[0],
3685             dst_bytes[1],
3686             dst_bytes[2],
3687             dst_bytes[3],
3688             mask_format_bytes[0],
3689             mask_format_bytes[1],
3690             mask_format_bytes[2],
3691             mask_format_bytes[3],
3692             glyphset_bytes[0],
3693             glyphset_bytes[1],
3694             glyphset_bytes[2],
3695             glyphset_bytes[3],
3696             src_x_bytes[0],
3697             src_x_bytes[1],
3698             src_y_bytes[0],
3699             src_y_bytes[1],
3700         ];
3701         let length_so_far = length_so_far + request0.len();
3702         let length_so_far = length_so_far + self.glyphcmds.len();
3703         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3704         let length_so_far = length_so_far + padding0.len();
3705         assert_eq!(length_so_far % 4, 0);
3706         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3707         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3708         Ok((vec![request0.into(), self.glyphcmds, padding0.into()], vec![]))
3709     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3710     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3711     where
3712         Conn: RequestConnection + ?Sized,
3713     {
3714         let (bytes, fds) = self.serialize(conn)?;
3715         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3716         conn.send_request_without_reply(&slices, fds)
3717     }
3718     /// 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>3719     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3720         if header.minor_opcode != COMPOSITE_GLYPHS8_REQUEST {
3721             return Err(ParseError::InvalidValue);
3722         }
3723         let (op, remaining) = u8::try_parse(value)?;
3724         let op = op.into();
3725         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
3726         let (src, remaining) = Picture::try_parse(remaining)?;
3727         let (dst, remaining) = Picture::try_parse(remaining)?;
3728         let (mask_format, remaining) = Pictformat::try_parse(remaining)?;
3729         let (glyphset, remaining) = Glyphset::try_parse(remaining)?;
3730         let (src_x, remaining) = i16::try_parse(remaining)?;
3731         let (src_y, remaining) = i16::try_parse(remaining)?;
3732         let (glyphcmds, remaining) = remaining.split_at(remaining.len());
3733         let _ = remaining;
3734         Ok(CompositeGlyphs8Request {
3735             op,
3736             src,
3737             dst,
3738             mask_format,
3739             glyphset,
3740             src_x,
3741             src_y,
3742             glyphcmds: Cow::Borrowed(glyphcmds),
3743         })
3744     }
3745     /// Clone all borrowed data in this CompositeGlyphs8Request.
into_owned(self) -> CompositeGlyphs8Request<'static>3746     pub fn into_owned(self) -> CompositeGlyphs8Request<'static> {
3747         CompositeGlyphs8Request {
3748             op: self.op,
3749             src: self.src,
3750             dst: self.dst,
3751             mask_format: self.mask_format,
3752             glyphset: self.glyphset,
3753             src_x: self.src_x,
3754             src_y: self.src_y,
3755             glyphcmds: Cow::Owned(self.glyphcmds.into_owned()),
3756         }
3757     }
3758 }
3759 impl<'input> Request for CompositeGlyphs8Request<'input> {
3760     type Reply = ();
3761 }
composite_glyphs8<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3762 pub fn composite_glyphs8<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3763 where
3764     Conn: RequestConnection + ?Sized,
3765 {
3766     let request0 = CompositeGlyphs8Request {
3767         op,
3768         src,
3769         dst,
3770         mask_format,
3771         glyphset,
3772         src_x,
3773         src_y,
3774         glyphcmds: Cow::Borrowed(glyphcmds),
3775     };
3776     request0.send(conn)
3777 }
3778 
3779 /// Opcode for the CompositeGlyphs16 request
3780 pub const COMPOSITE_GLYPHS16_REQUEST: u8 = 24;
3781 #[derive(Debug, Clone, PartialEq, Eq)]
3782 pub struct CompositeGlyphs16Request<'input> {
3783     pub op: PictOp,
3784     pub src: Picture,
3785     pub dst: Picture,
3786     pub mask_format: Pictformat,
3787     pub glyphset: Glyphset,
3788     pub src_x: i16,
3789     pub src_y: i16,
3790     pub glyphcmds: Cow<'input, [u8]>,
3791 }
3792 impl<'input> CompositeGlyphs16Request<'input> {
3793     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3794     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3795     where
3796         Conn: RequestConnection + ?Sized,
3797     {
3798         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3799             .ok_or(ConnectionError::UnsupportedExtension)?;
3800         let length_so_far = 0;
3801         let op_bytes = u8::from(self.op).serialize();
3802         let src_bytes = self.src.serialize();
3803         let dst_bytes = self.dst.serialize();
3804         let mask_format_bytes = self.mask_format.serialize();
3805         let glyphset_bytes = self.glyphset.serialize();
3806         let src_x_bytes = self.src_x.serialize();
3807         let src_y_bytes = self.src_y.serialize();
3808         let mut request0 = vec![
3809             extension_information.major_opcode,
3810             COMPOSITE_GLYPHS16_REQUEST,
3811             0,
3812             0,
3813             op_bytes[0],
3814             0,
3815             0,
3816             0,
3817             src_bytes[0],
3818             src_bytes[1],
3819             src_bytes[2],
3820             src_bytes[3],
3821             dst_bytes[0],
3822             dst_bytes[1],
3823             dst_bytes[2],
3824             dst_bytes[3],
3825             mask_format_bytes[0],
3826             mask_format_bytes[1],
3827             mask_format_bytes[2],
3828             mask_format_bytes[3],
3829             glyphset_bytes[0],
3830             glyphset_bytes[1],
3831             glyphset_bytes[2],
3832             glyphset_bytes[3],
3833             src_x_bytes[0],
3834             src_x_bytes[1],
3835             src_y_bytes[0],
3836             src_y_bytes[1],
3837         ];
3838         let length_so_far = length_so_far + request0.len();
3839         let length_so_far = length_so_far + self.glyphcmds.len();
3840         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3841         let length_so_far = length_so_far + padding0.len();
3842         assert_eq!(length_so_far % 4, 0);
3843         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3844         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3845         Ok((vec![request0.into(), self.glyphcmds, padding0.into()], vec![]))
3846     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3847     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3848     where
3849         Conn: RequestConnection + ?Sized,
3850     {
3851         let (bytes, fds) = self.serialize(conn)?;
3852         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3853         conn.send_request_without_reply(&slices, fds)
3854     }
3855     /// 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>3856     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3857         if header.minor_opcode != COMPOSITE_GLYPHS16_REQUEST {
3858             return Err(ParseError::InvalidValue);
3859         }
3860         let (op, remaining) = u8::try_parse(value)?;
3861         let op = op.into();
3862         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
3863         let (src, remaining) = Picture::try_parse(remaining)?;
3864         let (dst, remaining) = Picture::try_parse(remaining)?;
3865         let (mask_format, remaining) = Pictformat::try_parse(remaining)?;
3866         let (glyphset, remaining) = Glyphset::try_parse(remaining)?;
3867         let (src_x, remaining) = i16::try_parse(remaining)?;
3868         let (src_y, remaining) = i16::try_parse(remaining)?;
3869         let (glyphcmds, remaining) = remaining.split_at(remaining.len());
3870         let _ = remaining;
3871         Ok(CompositeGlyphs16Request {
3872             op,
3873             src,
3874             dst,
3875             mask_format,
3876             glyphset,
3877             src_x,
3878             src_y,
3879             glyphcmds: Cow::Borrowed(glyphcmds),
3880         })
3881     }
3882     /// Clone all borrowed data in this CompositeGlyphs16Request.
into_owned(self) -> CompositeGlyphs16Request<'static>3883     pub fn into_owned(self) -> CompositeGlyphs16Request<'static> {
3884         CompositeGlyphs16Request {
3885             op: self.op,
3886             src: self.src,
3887             dst: self.dst,
3888             mask_format: self.mask_format,
3889             glyphset: self.glyphset,
3890             src_x: self.src_x,
3891             src_y: self.src_y,
3892             glyphcmds: Cow::Owned(self.glyphcmds.into_owned()),
3893         }
3894     }
3895 }
3896 impl<'input> Request for CompositeGlyphs16Request<'input> {
3897     type Reply = ();
3898 }
composite_glyphs16<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3899 pub fn composite_glyphs16<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3900 where
3901     Conn: RequestConnection + ?Sized,
3902 {
3903     let request0 = CompositeGlyphs16Request {
3904         op,
3905         src,
3906         dst,
3907         mask_format,
3908         glyphset,
3909         src_x,
3910         src_y,
3911         glyphcmds: Cow::Borrowed(glyphcmds),
3912     };
3913     request0.send(conn)
3914 }
3915 
3916 /// Opcode for the CompositeGlyphs32 request
3917 pub const COMPOSITE_GLYPHS32_REQUEST: u8 = 25;
3918 #[derive(Debug, Clone, PartialEq, Eq)]
3919 pub struct CompositeGlyphs32Request<'input> {
3920     pub op: PictOp,
3921     pub src: Picture,
3922     pub dst: Picture,
3923     pub mask_format: Pictformat,
3924     pub glyphset: Glyphset,
3925     pub src_x: i16,
3926     pub src_y: i16,
3927     pub glyphcmds: Cow<'input, [u8]>,
3928 }
3929 impl<'input> CompositeGlyphs32Request<'input> {
3930     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3931     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3932     where
3933         Conn: RequestConnection + ?Sized,
3934     {
3935         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3936             .ok_or(ConnectionError::UnsupportedExtension)?;
3937         let length_so_far = 0;
3938         let op_bytes = u8::from(self.op).serialize();
3939         let src_bytes = self.src.serialize();
3940         let dst_bytes = self.dst.serialize();
3941         let mask_format_bytes = self.mask_format.serialize();
3942         let glyphset_bytes = self.glyphset.serialize();
3943         let src_x_bytes = self.src_x.serialize();
3944         let src_y_bytes = self.src_y.serialize();
3945         let mut request0 = vec![
3946             extension_information.major_opcode,
3947             COMPOSITE_GLYPHS32_REQUEST,
3948             0,
3949             0,
3950             op_bytes[0],
3951             0,
3952             0,
3953             0,
3954             src_bytes[0],
3955             src_bytes[1],
3956             src_bytes[2],
3957             src_bytes[3],
3958             dst_bytes[0],
3959             dst_bytes[1],
3960             dst_bytes[2],
3961             dst_bytes[3],
3962             mask_format_bytes[0],
3963             mask_format_bytes[1],
3964             mask_format_bytes[2],
3965             mask_format_bytes[3],
3966             glyphset_bytes[0],
3967             glyphset_bytes[1],
3968             glyphset_bytes[2],
3969             glyphset_bytes[3],
3970             src_x_bytes[0],
3971             src_x_bytes[1],
3972             src_y_bytes[0],
3973             src_y_bytes[1],
3974         ];
3975         let length_so_far = length_so_far + request0.len();
3976         let length_so_far = length_so_far + self.glyphcmds.len();
3977         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3978         let length_so_far = length_so_far + padding0.len();
3979         assert_eq!(length_so_far % 4, 0);
3980         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3981         request0[2..4].copy_from_slice(&length.to_ne_bytes());
3982         Ok((vec![request0.into(), self.glyphcmds, padding0.into()], vec![]))
3983     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3984     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3985     where
3986         Conn: RequestConnection + ?Sized,
3987     {
3988         let (bytes, fds) = self.serialize(conn)?;
3989         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3990         conn.send_request_without_reply(&slices, fds)
3991     }
3992     /// 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>3993     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3994         if header.minor_opcode != COMPOSITE_GLYPHS32_REQUEST {
3995             return Err(ParseError::InvalidValue);
3996         }
3997         let (op, remaining) = u8::try_parse(value)?;
3998         let op = op.into();
3999         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
4000         let (src, remaining) = Picture::try_parse(remaining)?;
4001         let (dst, remaining) = Picture::try_parse(remaining)?;
4002         let (mask_format, remaining) = Pictformat::try_parse(remaining)?;
4003         let (glyphset, remaining) = Glyphset::try_parse(remaining)?;
4004         let (src_x, remaining) = i16::try_parse(remaining)?;
4005         let (src_y, remaining) = i16::try_parse(remaining)?;
4006         let (glyphcmds, remaining) = remaining.split_at(remaining.len());
4007         let _ = remaining;
4008         Ok(CompositeGlyphs32Request {
4009             op,
4010             src,
4011             dst,
4012             mask_format,
4013             glyphset,
4014             src_x,
4015             src_y,
4016             glyphcmds: Cow::Borrowed(glyphcmds),
4017         })
4018     }
4019     /// Clone all borrowed data in this CompositeGlyphs32Request.
into_owned(self) -> CompositeGlyphs32Request<'static>4020     pub fn into_owned(self) -> CompositeGlyphs32Request<'static> {
4021         CompositeGlyphs32Request {
4022             op: self.op,
4023             src: self.src,
4024             dst: self.dst,
4025             mask_format: self.mask_format,
4026             glyphset: self.glyphset,
4027             src_x: self.src_x,
4028             src_y: self.src_y,
4029             glyphcmds: Cow::Owned(self.glyphcmds.into_owned()),
4030         }
4031     }
4032 }
4033 impl<'input> Request for CompositeGlyphs32Request<'input> {
4034     type Reply = ();
4035 }
composite_glyphs32<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4036 pub fn composite_glyphs32<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
4037 where
4038     Conn: RequestConnection + ?Sized,
4039 {
4040     let request0 = CompositeGlyphs32Request {
4041         op,
4042         src,
4043         dst,
4044         mask_format,
4045         glyphset,
4046         src_x,
4047         src_y,
4048         glyphcmds: Cow::Borrowed(glyphcmds),
4049     };
4050     request0.send(conn)
4051 }
4052 
4053 /// Opcode for the FillRectangles request
4054 pub const FILL_RECTANGLES_REQUEST: u8 = 26;
4055 #[derive(Debug, Clone, PartialEq, Eq)]
4056 pub struct FillRectanglesRequest<'input> {
4057     pub op: PictOp,
4058     pub dst: Picture,
4059     pub color: Color,
4060     pub rects: Cow<'input, [xproto::Rectangle]>,
4061 }
4062 impl<'input> FillRectanglesRequest<'input> {
4063     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4064     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4065     where
4066         Conn: RequestConnection + ?Sized,
4067     {
4068         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4069             .ok_or(ConnectionError::UnsupportedExtension)?;
4070         let length_so_far = 0;
4071         let op_bytes = u8::from(self.op).serialize();
4072         let dst_bytes = self.dst.serialize();
4073         let color_bytes = self.color.serialize();
4074         let mut request0 = vec![
4075             extension_information.major_opcode,
4076             FILL_RECTANGLES_REQUEST,
4077             0,
4078             0,
4079             op_bytes[0],
4080             0,
4081             0,
4082             0,
4083             dst_bytes[0],
4084             dst_bytes[1],
4085             dst_bytes[2],
4086             dst_bytes[3],
4087             color_bytes[0],
4088             color_bytes[1],
4089             color_bytes[2],
4090             color_bytes[3],
4091             color_bytes[4],
4092             color_bytes[5],
4093             color_bytes[6],
4094             color_bytes[7],
4095         ];
4096         let length_so_far = length_so_far + request0.len();
4097         let rects_bytes = self.rects.serialize();
4098         let length_so_far = length_so_far + rects_bytes.len();
4099         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
4100         let length_so_far = length_so_far + padding0.len();
4101         assert_eq!(length_so_far % 4, 0);
4102         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4103         request0[2..4].copy_from_slice(&length.to_ne_bytes());
4104         Ok((vec![request0.into(), rects_bytes.into(), padding0.into()], vec![]))
4105     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4106     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4107     where
4108         Conn: RequestConnection + ?Sized,
4109     {
4110         let (bytes, fds) = self.serialize(conn)?;
4111         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4112         conn.send_request_without_reply(&slices, fds)
4113     }
4114     /// 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>4115     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
4116         if header.minor_opcode != FILL_RECTANGLES_REQUEST {
4117             return Err(ParseError::InvalidValue);
4118         }
4119         let (op, remaining) = u8::try_parse(value)?;
4120         let op = op.into();
4121         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
4122         let (dst, remaining) = Picture::try_parse(remaining)?;
4123         let (color, remaining) = Color::try_parse(remaining)?;
4124         let mut remaining = remaining;
4125         // Length is 'everything left in the input'
4126         let mut rects = Vec::new();
4127         while !remaining.is_empty() {
4128             let (v, new_remaining) = xproto::Rectangle::try_parse(remaining)?;
4129             remaining = new_remaining;
4130             rects.push(v);
4131         }
4132         let _ = remaining;
4133         Ok(FillRectanglesRequest {
4134             op,
4135             dst,
4136             color,
4137             rects: Cow::Owned(rects),
4138         })
4139     }
4140     /// Clone all borrowed data in this FillRectanglesRequest.
into_owned(self) -> FillRectanglesRequest<'static>4141     pub fn into_owned(self) -> FillRectanglesRequest<'static> {
4142         FillRectanglesRequest {
4143             op: self.op,
4144             dst: self.dst,
4145             color: self.color,
4146             rects: Cow::Owned(self.rects.into_owned()),
4147         }
4148     }
4149 }
4150 impl<'input> Request for FillRectanglesRequest<'input> {
4151     type Reply = ();
4152 }
fill_rectangles<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, dst: Picture, color: Color, rects: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4153 pub fn fill_rectangles<'c, 'input, Conn>(conn: &'c Conn, op: PictOp, dst: Picture, color: Color, rects: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
4154 where
4155     Conn: RequestConnection + ?Sized,
4156 {
4157     let request0 = FillRectanglesRequest {
4158         op,
4159         dst,
4160         color,
4161         rects: Cow::Borrowed(rects),
4162     };
4163     request0.send(conn)
4164 }
4165 
4166 /// Opcode for the CreateCursor request
4167 pub const CREATE_CURSOR_REQUEST: u8 = 27;
4168 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4169 pub struct CreateCursorRequest {
4170     pub cid: xproto::Cursor,
4171     pub source: Picture,
4172     pub x: u16,
4173     pub y: u16,
4174 }
4175 impl CreateCursorRequest {
4176     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4177     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4178     where
4179         Conn: RequestConnection + ?Sized,
4180     {
4181         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4182             .ok_or(ConnectionError::UnsupportedExtension)?;
4183         let length_so_far = 0;
4184         let cid_bytes = self.cid.serialize();
4185         let source_bytes = self.source.serialize();
4186         let x_bytes = self.x.serialize();
4187         let y_bytes = self.y.serialize();
4188         let mut request0 = vec![
4189             extension_information.major_opcode,
4190             CREATE_CURSOR_REQUEST,
4191             0,
4192             0,
4193             cid_bytes[0],
4194             cid_bytes[1],
4195             cid_bytes[2],
4196             cid_bytes[3],
4197             source_bytes[0],
4198             source_bytes[1],
4199             source_bytes[2],
4200             source_bytes[3],
4201             x_bytes[0],
4202             x_bytes[1],
4203             y_bytes[0],
4204             y_bytes[1],
4205         ];
4206         let length_so_far = length_so_far + request0.len();
4207         assert_eq!(length_so_far % 4, 0);
4208         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4209         request0[2..4].copy_from_slice(&length.to_ne_bytes());
4210         Ok((vec![request0.into()], vec![]))
4211     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4212     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4213     where
4214         Conn: RequestConnection + ?Sized,
4215     {
4216         let (bytes, fds) = self.serialize(conn)?;
4217         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4218         conn.send_request_without_reply(&slices, fds)
4219     }
4220     /// 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>4221     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4222         if header.minor_opcode != CREATE_CURSOR_REQUEST {
4223             return Err(ParseError::InvalidValue);
4224         }
4225         let (cid, remaining) = xproto::Cursor::try_parse(value)?;
4226         let (source, remaining) = Picture::try_parse(remaining)?;
4227         let (x, remaining) = u16::try_parse(remaining)?;
4228         let (y, remaining) = u16::try_parse(remaining)?;
4229         let _ = remaining;
4230         Ok(CreateCursorRequest {
4231             cid,
4232             source,
4233             x,
4234             y,
4235         })
4236     }
4237 }
4238 impl Request for CreateCursorRequest {
4239     type Reply = ();
4240 }
create_cursor<Conn>(conn: &Conn, cid: xproto::Cursor, source: Picture, x: u16, y: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4241 pub fn create_cursor<Conn>(conn: &Conn, cid: xproto::Cursor, source: Picture, x: u16, y: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4242 where
4243     Conn: RequestConnection + ?Sized,
4244 {
4245     let request0 = CreateCursorRequest {
4246         cid,
4247         source,
4248         x,
4249         y,
4250     };
4251     request0.send(conn)
4252 }
4253 
4254 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4255 pub struct Transform {
4256     pub matrix11: Fixed,
4257     pub matrix12: Fixed,
4258     pub matrix13: Fixed,
4259     pub matrix21: Fixed,
4260     pub matrix22: Fixed,
4261     pub matrix23: Fixed,
4262     pub matrix31: Fixed,
4263     pub matrix32: Fixed,
4264     pub matrix33: Fixed,
4265 }
4266 impl TryParse for Transform {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>4267     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4268         let (matrix11, remaining) = Fixed::try_parse(remaining)?;
4269         let (matrix12, remaining) = Fixed::try_parse(remaining)?;
4270         let (matrix13, remaining) = Fixed::try_parse(remaining)?;
4271         let (matrix21, remaining) = Fixed::try_parse(remaining)?;
4272         let (matrix22, remaining) = Fixed::try_parse(remaining)?;
4273         let (matrix23, remaining) = Fixed::try_parse(remaining)?;
4274         let (matrix31, remaining) = Fixed::try_parse(remaining)?;
4275         let (matrix32, remaining) = Fixed::try_parse(remaining)?;
4276         let (matrix33, remaining) = Fixed::try_parse(remaining)?;
4277         let result = Transform { matrix11, matrix12, matrix13, matrix21, matrix22, matrix23, matrix31, matrix32, matrix33 };
4278         Ok((result, remaining))
4279     }
4280 }
4281 impl Serialize for Transform {
4282     type Bytes = [u8; 36];
serialize(&self) -> [u8; 36]4283     fn serialize(&self) -> [u8; 36] {
4284         let matrix11_bytes = self.matrix11.serialize();
4285         let matrix12_bytes = self.matrix12.serialize();
4286         let matrix13_bytes = self.matrix13.serialize();
4287         let matrix21_bytes = self.matrix21.serialize();
4288         let matrix22_bytes = self.matrix22.serialize();
4289         let matrix23_bytes = self.matrix23.serialize();
4290         let matrix31_bytes = self.matrix31.serialize();
4291         let matrix32_bytes = self.matrix32.serialize();
4292         let matrix33_bytes = self.matrix33.serialize();
4293         [
4294             matrix11_bytes[0],
4295             matrix11_bytes[1],
4296             matrix11_bytes[2],
4297             matrix11_bytes[3],
4298             matrix12_bytes[0],
4299             matrix12_bytes[1],
4300             matrix12_bytes[2],
4301             matrix12_bytes[3],
4302             matrix13_bytes[0],
4303             matrix13_bytes[1],
4304             matrix13_bytes[2],
4305             matrix13_bytes[3],
4306             matrix21_bytes[0],
4307             matrix21_bytes[1],
4308             matrix21_bytes[2],
4309             matrix21_bytes[3],
4310             matrix22_bytes[0],
4311             matrix22_bytes[1],
4312             matrix22_bytes[2],
4313             matrix22_bytes[3],
4314             matrix23_bytes[0],
4315             matrix23_bytes[1],
4316             matrix23_bytes[2],
4317             matrix23_bytes[3],
4318             matrix31_bytes[0],
4319             matrix31_bytes[1],
4320             matrix31_bytes[2],
4321             matrix31_bytes[3],
4322             matrix32_bytes[0],
4323             matrix32_bytes[1],
4324             matrix32_bytes[2],
4325             matrix32_bytes[3],
4326             matrix33_bytes[0],
4327             matrix33_bytes[1],
4328             matrix33_bytes[2],
4329             matrix33_bytes[3],
4330         ]
4331     }
serialize_into(&self, bytes: &mut Vec<u8>)4332     fn serialize_into(&self, bytes: &mut Vec<u8>) {
4333         bytes.reserve(36);
4334         self.matrix11.serialize_into(bytes);
4335         self.matrix12.serialize_into(bytes);
4336         self.matrix13.serialize_into(bytes);
4337         self.matrix21.serialize_into(bytes);
4338         self.matrix22.serialize_into(bytes);
4339         self.matrix23.serialize_into(bytes);
4340         self.matrix31.serialize_into(bytes);
4341         self.matrix32.serialize_into(bytes);
4342         self.matrix33.serialize_into(bytes);
4343     }
4344 }
4345 
4346 /// Opcode for the SetPictureTransform request
4347 pub const SET_PICTURE_TRANSFORM_REQUEST: u8 = 28;
4348 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4349 pub struct SetPictureTransformRequest {
4350     pub picture: Picture,
4351     pub transform: Transform,
4352 }
4353 impl SetPictureTransformRequest {
4354     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4355     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4356     where
4357         Conn: RequestConnection + ?Sized,
4358     {
4359         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4360             .ok_or(ConnectionError::UnsupportedExtension)?;
4361         let length_so_far = 0;
4362         let picture_bytes = self.picture.serialize();
4363         let transform_bytes = self.transform.serialize();
4364         let mut request0 = vec![
4365             extension_information.major_opcode,
4366             SET_PICTURE_TRANSFORM_REQUEST,
4367             0,
4368             0,
4369             picture_bytes[0],
4370             picture_bytes[1],
4371             picture_bytes[2],
4372             picture_bytes[3],
4373             transform_bytes[0],
4374             transform_bytes[1],
4375             transform_bytes[2],
4376             transform_bytes[3],
4377             transform_bytes[4],
4378             transform_bytes[5],
4379             transform_bytes[6],
4380             transform_bytes[7],
4381             transform_bytes[8],
4382             transform_bytes[9],
4383             transform_bytes[10],
4384             transform_bytes[11],
4385             transform_bytes[12],
4386             transform_bytes[13],
4387             transform_bytes[14],
4388             transform_bytes[15],
4389             transform_bytes[16],
4390             transform_bytes[17],
4391             transform_bytes[18],
4392             transform_bytes[19],
4393             transform_bytes[20],
4394             transform_bytes[21],
4395             transform_bytes[22],
4396             transform_bytes[23],
4397             transform_bytes[24],
4398             transform_bytes[25],
4399             transform_bytes[26],
4400             transform_bytes[27],
4401             transform_bytes[28],
4402             transform_bytes[29],
4403             transform_bytes[30],
4404             transform_bytes[31],
4405             transform_bytes[32],
4406             transform_bytes[33],
4407             transform_bytes[34],
4408             transform_bytes[35],
4409         ];
4410         let length_so_far = length_so_far + request0.len();
4411         assert_eq!(length_so_far % 4, 0);
4412         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4413         request0[2..4].copy_from_slice(&length.to_ne_bytes());
4414         Ok((vec![request0.into()], vec![]))
4415     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4416     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4417     where
4418         Conn: RequestConnection + ?Sized,
4419     {
4420         let (bytes, fds) = self.serialize(conn)?;
4421         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4422         conn.send_request_without_reply(&slices, fds)
4423     }
4424     /// 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>4425     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4426         if header.minor_opcode != SET_PICTURE_TRANSFORM_REQUEST {
4427             return Err(ParseError::InvalidValue);
4428         }
4429         let (picture, remaining) = Picture::try_parse(value)?;
4430         let (transform, remaining) = Transform::try_parse(remaining)?;
4431         let _ = remaining;
4432         Ok(SetPictureTransformRequest {
4433             picture,
4434             transform,
4435         })
4436     }
4437 }
4438 impl Request for SetPictureTransformRequest {
4439     type Reply = ();
4440 }
set_picture_transform<Conn>(conn: &Conn, picture: Picture, transform: Transform) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4441 pub fn set_picture_transform<Conn>(conn: &Conn, picture: Picture, transform: Transform) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4442 where
4443     Conn: RequestConnection + ?Sized,
4444 {
4445     let request0 = SetPictureTransformRequest {
4446         picture,
4447         transform,
4448     };
4449     request0.send(conn)
4450 }
4451 
4452 /// Opcode for the QueryFilters request
4453 pub const QUERY_FILTERS_REQUEST: u8 = 29;
4454 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4455 pub struct QueryFiltersRequest {
4456     pub drawable: xproto::Drawable,
4457 }
4458 impl QueryFiltersRequest {
4459     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4460     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4461     where
4462         Conn: RequestConnection + ?Sized,
4463     {
4464         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4465             .ok_or(ConnectionError::UnsupportedExtension)?;
4466         let length_so_far = 0;
4467         let drawable_bytes = self.drawable.serialize();
4468         let mut request0 = vec![
4469             extension_information.major_opcode,
4470             QUERY_FILTERS_REQUEST,
4471             0,
4472             0,
4473             drawable_bytes[0],
4474             drawable_bytes[1],
4475             drawable_bytes[2],
4476             drawable_bytes[3],
4477         ];
4478         let length_so_far = length_so_far + request0.len();
4479         assert_eq!(length_so_far % 4, 0);
4480         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4481         request0[2..4].copy_from_slice(&length.to_ne_bytes());
4482         Ok((vec![request0.into()], vec![]))
4483     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryFiltersReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4484     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryFiltersReply>, ConnectionError>
4485     where
4486         Conn: RequestConnection + ?Sized,
4487     {
4488         let (bytes, fds) = self.serialize(conn)?;
4489         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4490         conn.send_request_with_reply(&slices, fds)
4491     }
4492     /// 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>4493     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4494         if header.minor_opcode != QUERY_FILTERS_REQUEST {
4495             return Err(ParseError::InvalidValue);
4496         }
4497         let (drawable, remaining) = xproto::Drawable::try_parse(value)?;
4498         let _ = remaining;
4499         Ok(QueryFiltersRequest {
4500             drawable,
4501         })
4502     }
4503 }
4504 impl Request for QueryFiltersRequest {
4505     type Reply = QueryFiltersReply;
4506 }
query_filters<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<Cookie<'_, Conn, QueryFiltersReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4507 pub fn query_filters<Conn>(conn: &Conn, drawable: xproto::Drawable) -> Result<Cookie<'_, Conn, QueryFiltersReply>, ConnectionError>
4508 where
4509     Conn: RequestConnection + ?Sized,
4510 {
4511     let request0 = QueryFiltersRequest {
4512         drawable,
4513     };
4514     request0.send(conn)
4515 }
4516 
4517 #[derive(Debug, Clone, PartialEq, Eq)]
4518 pub struct QueryFiltersReply {
4519     pub sequence: u16,
4520     pub length: u32,
4521     pub aliases: Vec<u16>,
4522     pub filters: Vec<xproto::Str>,
4523 }
4524 impl TryParse for QueryFiltersReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>4525     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4526         let remaining = initial_value;
4527         let (response_type, remaining) = u8::try_parse(remaining)?;
4528         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4529         let (sequence, remaining) = u16::try_parse(remaining)?;
4530         let (length, remaining) = u32::try_parse(remaining)?;
4531         let (num_aliases, remaining) = u32::try_parse(remaining)?;
4532         let (num_filters, remaining) = u32::try_parse(remaining)?;
4533         let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
4534         let (aliases, remaining) = crate::x11_utils::parse_list::<u16>(remaining, num_aliases.try_to_usize()?)?;
4535         let (filters, remaining) = crate::x11_utils::parse_list::<xproto::Str>(remaining, num_filters.try_to_usize()?)?;
4536         if response_type != 1 {
4537             return Err(ParseError::InvalidValue);
4538         }
4539         let result = QueryFiltersReply { sequence, length, aliases, filters };
4540         let _ = remaining;
4541         let remaining = initial_value.get(32 + length as usize * 4..)
4542             .ok_or(ParseError::InsufficientData)?;
4543         Ok((result, remaining))
4544     }
4545 }
4546 impl QueryFiltersReply {
4547     /// Get the value of the `num_aliases` field.
4548     ///
4549     /// The `num_aliases` field is used as the length field of the `aliases` field.
4550     /// This function computes the field's value again based on the length of the list.
4551     ///
4552     /// # Panics
4553     ///
4554     /// Panics if the value cannot be represented in the target type. This
4555     /// cannot happen with values of the struct received from the X11 server.
num_aliases(&self) -> u324556     pub fn num_aliases(&self) -> u32 {
4557         self.aliases.len()
4558             .try_into().unwrap()
4559     }
4560     /// Get the value of the `num_filters` field.
4561     ///
4562     /// The `num_filters` field is used as the length field of the `filters` field.
4563     /// This function computes the field's value again based on the length of the list.
4564     ///
4565     /// # Panics
4566     ///
4567     /// Panics if the value cannot be represented in the target type. This
4568     /// cannot happen with values of the struct received from the X11 server.
num_filters(&self) -> u324569     pub fn num_filters(&self) -> u32 {
4570         self.filters.len()
4571             .try_into().unwrap()
4572     }
4573 }
4574 
4575 /// Opcode for the SetPictureFilter request
4576 pub const SET_PICTURE_FILTER_REQUEST: u8 = 30;
4577 #[derive(Debug, Clone, PartialEq, Eq)]
4578 pub struct SetPictureFilterRequest<'input> {
4579     pub picture: Picture,
4580     pub filter: Cow<'input, [u8]>,
4581     pub values: Cow<'input, [Fixed]>,
4582 }
4583 impl<'input> SetPictureFilterRequest<'input> {
4584     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4585     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4586     where
4587         Conn: RequestConnection + ?Sized,
4588     {
4589         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4590             .ok_or(ConnectionError::UnsupportedExtension)?;
4591         let length_so_far = 0;
4592         let picture_bytes = self.picture.serialize();
4593         let filter_len = u16::try_from(self.filter.len()).expect("`filter` has too many elements");
4594         let filter_len_bytes = filter_len.serialize();
4595         let mut request0 = vec![
4596             extension_information.major_opcode,
4597             SET_PICTURE_FILTER_REQUEST,
4598             0,
4599             0,
4600             picture_bytes[0],
4601             picture_bytes[1],
4602             picture_bytes[2],
4603             picture_bytes[3],
4604             filter_len_bytes[0],
4605             filter_len_bytes[1],
4606             0,
4607             0,
4608         ];
4609         let length_so_far = length_so_far + request0.len();
4610         let length_so_far = length_so_far + self.filter.len();
4611         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
4612         let length_so_far = length_so_far + padding0.len();
4613         let values_bytes = self.values.serialize();
4614         let length_so_far = length_so_far + values_bytes.len();
4615         let padding1 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
4616         let length_so_far = length_so_far + padding1.len();
4617         assert_eq!(length_so_far % 4, 0);
4618         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4619         request0[2..4].copy_from_slice(&length.to_ne_bytes());
4620         Ok((vec![request0.into(), self.filter, padding0.into(), values_bytes.into(), padding1.into()], vec![]))
4621     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4622     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4623     where
4624         Conn: RequestConnection + ?Sized,
4625     {
4626         let (bytes, fds) = self.serialize(conn)?;
4627         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4628         conn.send_request_without_reply(&slices, fds)
4629     }
4630     /// 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>4631     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
4632         if header.minor_opcode != SET_PICTURE_FILTER_REQUEST {
4633             return Err(ParseError::InvalidValue);
4634         }
4635         let (picture, remaining) = Picture::try_parse(value)?;
4636         let (filter_len, remaining) = u16::try_parse(remaining)?;
4637         let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
4638         let (filter, remaining) = crate::x11_utils::parse_u8_list(remaining, filter_len.try_to_usize()?)?;
4639         // Align offset to multiple of 4
4640         let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
4641         let misalignment = (4 - (offset % 4)) % 4;
4642         let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
4643         let mut remaining = remaining;
4644         // Length is 'everything left in the input'
4645         let mut values = Vec::new();
4646         while !remaining.is_empty() {
4647             let (v, new_remaining) = Fixed::try_parse(remaining)?;
4648             remaining = new_remaining;
4649             values.push(v);
4650         }
4651         let _ = remaining;
4652         Ok(SetPictureFilterRequest {
4653             picture,
4654             filter: Cow::Borrowed(filter),
4655             values: Cow::Owned(values),
4656         })
4657     }
4658     /// Clone all borrowed data in this SetPictureFilterRequest.
into_owned(self) -> SetPictureFilterRequest<'static>4659     pub fn into_owned(self) -> SetPictureFilterRequest<'static> {
4660         SetPictureFilterRequest {
4661             picture: self.picture,
4662             filter: Cow::Owned(self.filter.into_owned()),
4663             values: Cow::Owned(self.values.into_owned()),
4664         }
4665     }
4666 }
4667 impl<'input> Request for SetPictureFilterRequest<'input> {
4668     type Reply = ();
4669 }
set_picture_filter<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, filter: &'input [u8], values: &'input [Fixed]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4670 pub fn set_picture_filter<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, filter: &'input [u8], values: &'input [Fixed]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
4671 where
4672     Conn: RequestConnection + ?Sized,
4673 {
4674     let request0 = SetPictureFilterRequest {
4675         picture,
4676         filter: Cow::Borrowed(filter),
4677         values: Cow::Borrowed(values),
4678     };
4679     request0.send(conn)
4680 }
4681 
4682 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4683 pub struct Animcursorelt {
4684     pub cursor: xproto::Cursor,
4685     pub delay: u32,
4686 }
4687 impl TryParse for Animcursorelt {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>4688     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4689         let (cursor, remaining) = xproto::Cursor::try_parse(remaining)?;
4690         let (delay, remaining) = u32::try_parse(remaining)?;
4691         let result = Animcursorelt { cursor, delay };
4692         Ok((result, remaining))
4693     }
4694 }
4695 impl Serialize for Animcursorelt {
4696     type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]4697     fn serialize(&self) -> [u8; 8] {
4698         let cursor_bytes = self.cursor.serialize();
4699         let delay_bytes = self.delay.serialize();
4700         [
4701             cursor_bytes[0],
4702             cursor_bytes[1],
4703             cursor_bytes[2],
4704             cursor_bytes[3],
4705             delay_bytes[0],
4706             delay_bytes[1],
4707             delay_bytes[2],
4708             delay_bytes[3],
4709         ]
4710     }
serialize_into(&self, bytes: &mut Vec<u8>)4711     fn serialize_into(&self, bytes: &mut Vec<u8>) {
4712         bytes.reserve(8);
4713         self.cursor.serialize_into(bytes);
4714         self.delay.serialize_into(bytes);
4715     }
4716 }
4717 
4718 /// Opcode for the CreateAnimCursor request
4719 pub const CREATE_ANIM_CURSOR_REQUEST: u8 = 31;
4720 #[derive(Debug, Clone, PartialEq, Eq)]
4721 pub struct CreateAnimCursorRequest<'input> {
4722     pub cid: xproto::Cursor,
4723     pub cursors: Cow<'input, [Animcursorelt]>,
4724 }
4725 impl<'input> CreateAnimCursorRequest<'input> {
4726     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4727     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4728     where
4729         Conn: RequestConnection + ?Sized,
4730     {
4731         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4732             .ok_or(ConnectionError::UnsupportedExtension)?;
4733         let length_so_far = 0;
4734         let cid_bytes = self.cid.serialize();
4735         let mut request0 = vec![
4736             extension_information.major_opcode,
4737             CREATE_ANIM_CURSOR_REQUEST,
4738             0,
4739             0,
4740             cid_bytes[0],
4741             cid_bytes[1],
4742             cid_bytes[2],
4743             cid_bytes[3],
4744         ];
4745         let length_so_far = length_so_far + request0.len();
4746         let cursors_bytes = self.cursors.serialize();
4747         let length_so_far = length_so_far + cursors_bytes.len();
4748         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
4749         let length_so_far = length_so_far + padding0.len();
4750         assert_eq!(length_so_far % 4, 0);
4751         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4752         request0[2..4].copy_from_slice(&length.to_ne_bytes());
4753         Ok((vec![request0.into(), cursors_bytes.into(), padding0.into()], vec![]))
4754     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4755     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4756     where
4757         Conn: RequestConnection + ?Sized,
4758     {
4759         let (bytes, fds) = self.serialize(conn)?;
4760         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4761         conn.send_request_without_reply(&slices, fds)
4762     }
4763     /// 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>4764     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
4765         if header.minor_opcode != CREATE_ANIM_CURSOR_REQUEST {
4766             return Err(ParseError::InvalidValue);
4767         }
4768         let (cid, remaining) = xproto::Cursor::try_parse(value)?;
4769         let mut remaining = remaining;
4770         // Length is 'everything left in the input'
4771         let mut cursors = Vec::new();
4772         while !remaining.is_empty() {
4773             let (v, new_remaining) = Animcursorelt::try_parse(remaining)?;
4774             remaining = new_remaining;
4775             cursors.push(v);
4776         }
4777         let _ = remaining;
4778         Ok(CreateAnimCursorRequest {
4779             cid,
4780             cursors: Cow::Owned(cursors),
4781         })
4782     }
4783     /// Clone all borrowed data in this CreateAnimCursorRequest.
into_owned(self) -> CreateAnimCursorRequest<'static>4784     pub fn into_owned(self) -> CreateAnimCursorRequest<'static> {
4785         CreateAnimCursorRequest {
4786             cid: self.cid,
4787             cursors: Cow::Owned(self.cursors.into_owned()),
4788         }
4789     }
4790 }
4791 impl<'input> Request for CreateAnimCursorRequest<'input> {
4792     type Reply = ();
4793 }
create_anim_cursor<'c, 'input, Conn>(conn: &'c Conn, cid: xproto::Cursor, cursors: &'input [Animcursorelt]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4794 pub fn create_anim_cursor<'c, 'input, Conn>(conn: &'c Conn, cid: xproto::Cursor, cursors: &'input [Animcursorelt]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
4795 where
4796     Conn: RequestConnection + ?Sized,
4797 {
4798     let request0 = CreateAnimCursorRequest {
4799         cid,
4800         cursors: Cow::Borrowed(cursors),
4801     };
4802     request0.send(conn)
4803 }
4804 
4805 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4806 pub struct Spanfix {
4807     pub l: Fixed,
4808     pub r: Fixed,
4809     pub y: Fixed,
4810 }
4811 impl TryParse for Spanfix {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>4812     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4813         let (l, remaining) = Fixed::try_parse(remaining)?;
4814         let (r, remaining) = Fixed::try_parse(remaining)?;
4815         let (y, remaining) = Fixed::try_parse(remaining)?;
4816         let result = Spanfix { l, r, y };
4817         Ok((result, remaining))
4818     }
4819 }
4820 impl Serialize for Spanfix {
4821     type Bytes = [u8; 12];
serialize(&self) -> [u8; 12]4822     fn serialize(&self) -> [u8; 12] {
4823         let l_bytes = self.l.serialize();
4824         let r_bytes = self.r.serialize();
4825         let y_bytes = self.y.serialize();
4826         [
4827             l_bytes[0],
4828             l_bytes[1],
4829             l_bytes[2],
4830             l_bytes[3],
4831             r_bytes[0],
4832             r_bytes[1],
4833             r_bytes[2],
4834             r_bytes[3],
4835             y_bytes[0],
4836             y_bytes[1],
4837             y_bytes[2],
4838             y_bytes[3],
4839         ]
4840     }
serialize_into(&self, bytes: &mut Vec<u8>)4841     fn serialize_into(&self, bytes: &mut Vec<u8>) {
4842         bytes.reserve(12);
4843         self.l.serialize_into(bytes);
4844         self.r.serialize_into(bytes);
4845         self.y.serialize_into(bytes);
4846     }
4847 }
4848 
4849 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4850 pub struct Trap {
4851     pub top: Spanfix,
4852     pub bot: Spanfix,
4853 }
4854 impl TryParse for Trap {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>4855     fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4856         let (top, remaining) = Spanfix::try_parse(remaining)?;
4857         let (bot, remaining) = Spanfix::try_parse(remaining)?;
4858         let result = Trap { top, bot };
4859         Ok((result, remaining))
4860     }
4861 }
4862 impl Serialize for Trap {
4863     type Bytes = [u8; 24];
serialize(&self) -> [u8; 24]4864     fn serialize(&self) -> [u8; 24] {
4865         let top_bytes = self.top.serialize();
4866         let bot_bytes = self.bot.serialize();
4867         [
4868             top_bytes[0],
4869             top_bytes[1],
4870             top_bytes[2],
4871             top_bytes[3],
4872             top_bytes[4],
4873             top_bytes[5],
4874             top_bytes[6],
4875             top_bytes[7],
4876             top_bytes[8],
4877             top_bytes[9],
4878             top_bytes[10],
4879             top_bytes[11],
4880             bot_bytes[0],
4881             bot_bytes[1],
4882             bot_bytes[2],
4883             bot_bytes[3],
4884             bot_bytes[4],
4885             bot_bytes[5],
4886             bot_bytes[6],
4887             bot_bytes[7],
4888             bot_bytes[8],
4889             bot_bytes[9],
4890             bot_bytes[10],
4891             bot_bytes[11],
4892         ]
4893     }
serialize_into(&self, bytes: &mut Vec<u8>)4894     fn serialize_into(&self, bytes: &mut Vec<u8>) {
4895         bytes.reserve(24);
4896         self.top.serialize_into(bytes);
4897         self.bot.serialize_into(bytes);
4898     }
4899 }
4900 
4901 /// Opcode for the AddTraps request
4902 pub const ADD_TRAPS_REQUEST: u8 = 32;
4903 #[derive(Debug, Clone, PartialEq, Eq)]
4904 pub struct AddTrapsRequest<'input> {
4905     pub picture: Picture,
4906     pub x_off: i16,
4907     pub y_off: i16,
4908     pub traps: Cow<'input, [Trap]>,
4909 }
4910 impl<'input> AddTrapsRequest<'input> {
4911     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4912     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4913     where
4914         Conn: RequestConnection + ?Sized,
4915     {
4916         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4917             .ok_or(ConnectionError::UnsupportedExtension)?;
4918         let length_so_far = 0;
4919         let picture_bytes = self.picture.serialize();
4920         let x_off_bytes = self.x_off.serialize();
4921         let y_off_bytes = self.y_off.serialize();
4922         let mut request0 = vec![
4923             extension_information.major_opcode,
4924             ADD_TRAPS_REQUEST,
4925             0,
4926             0,
4927             picture_bytes[0],
4928             picture_bytes[1],
4929             picture_bytes[2],
4930             picture_bytes[3],
4931             x_off_bytes[0],
4932             x_off_bytes[1],
4933             y_off_bytes[0],
4934             y_off_bytes[1],
4935         ];
4936         let length_so_far = length_so_far + request0.len();
4937         let traps_bytes = self.traps.serialize();
4938         let length_so_far = length_so_far + traps_bytes.len();
4939         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
4940         let length_so_far = length_so_far + padding0.len();
4941         assert_eq!(length_so_far % 4, 0);
4942         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4943         request0[2..4].copy_from_slice(&length.to_ne_bytes());
4944         Ok((vec![request0.into(), traps_bytes.into(), padding0.into()], vec![]))
4945     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4946     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4947     where
4948         Conn: RequestConnection + ?Sized,
4949     {
4950         let (bytes, fds) = self.serialize(conn)?;
4951         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4952         conn.send_request_without_reply(&slices, fds)
4953     }
4954     /// 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>4955     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
4956         if header.minor_opcode != ADD_TRAPS_REQUEST {
4957             return Err(ParseError::InvalidValue);
4958         }
4959         let (picture, remaining) = Picture::try_parse(value)?;
4960         let (x_off, remaining) = i16::try_parse(remaining)?;
4961         let (y_off, remaining) = i16::try_parse(remaining)?;
4962         let mut remaining = remaining;
4963         // Length is 'everything left in the input'
4964         let mut traps = Vec::new();
4965         while !remaining.is_empty() {
4966             let (v, new_remaining) = Trap::try_parse(remaining)?;
4967             remaining = new_remaining;
4968             traps.push(v);
4969         }
4970         let _ = remaining;
4971         Ok(AddTrapsRequest {
4972             picture,
4973             x_off,
4974             y_off,
4975             traps: Cow::Owned(traps),
4976         })
4977     }
4978     /// Clone all borrowed data in this AddTrapsRequest.
into_owned(self) -> AddTrapsRequest<'static>4979     pub fn into_owned(self) -> AddTrapsRequest<'static> {
4980         AddTrapsRequest {
4981             picture: self.picture,
4982             x_off: self.x_off,
4983             y_off: self.y_off,
4984             traps: Cow::Owned(self.traps.into_owned()),
4985         }
4986     }
4987 }
4988 impl<'input> Request for AddTrapsRequest<'input> {
4989     type Reply = ();
4990 }
add_traps<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, x_off: i16, y_off: i16, traps: &'input [Trap]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4991 pub fn add_traps<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, x_off: i16, y_off: i16, traps: &'input [Trap]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
4992 where
4993     Conn: RequestConnection + ?Sized,
4994 {
4995     let request0 = AddTrapsRequest {
4996         picture,
4997         x_off,
4998         y_off,
4999         traps: Cow::Borrowed(traps),
5000     };
5001     request0.send(conn)
5002 }
5003 
5004 /// Opcode for the CreateSolidFill request
5005 pub const CREATE_SOLID_FILL_REQUEST: u8 = 33;
5006 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5007 pub struct CreateSolidFillRequest {
5008     pub picture: Picture,
5009     pub color: Color,
5010 }
5011 impl CreateSolidFillRequest {
5012     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5013     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5014     where
5015         Conn: RequestConnection + ?Sized,
5016     {
5017         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5018             .ok_or(ConnectionError::UnsupportedExtension)?;
5019         let length_so_far = 0;
5020         let picture_bytes = self.picture.serialize();
5021         let color_bytes = self.color.serialize();
5022         let mut request0 = vec![
5023             extension_information.major_opcode,
5024             CREATE_SOLID_FILL_REQUEST,
5025             0,
5026             0,
5027             picture_bytes[0],
5028             picture_bytes[1],
5029             picture_bytes[2],
5030             picture_bytes[3],
5031             color_bytes[0],
5032             color_bytes[1],
5033             color_bytes[2],
5034             color_bytes[3],
5035             color_bytes[4],
5036             color_bytes[5],
5037             color_bytes[6],
5038             color_bytes[7],
5039         ];
5040         let length_so_far = length_so_far + request0.len();
5041         assert_eq!(length_so_far % 4, 0);
5042         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5043         request0[2..4].copy_from_slice(&length.to_ne_bytes());
5044         Ok((vec![request0.into()], vec![]))
5045     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5046     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
5047     where
5048         Conn: RequestConnection + ?Sized,
5049     {
5050         let (bytes, fds) = self.serialize(conn)?;
5051         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5052         conn.send_request_without_reply(&slices, fds)
5053     }
5054     /// 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>5055     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5056         if header.minor_opcode != CREATE_SOLID_FILL_REQUEST {
5057             return Err(ParseError::InvalidValue);
5058         }
5059         let (picture, remaining) = Picture::try_parse(value)?;
5060         let (color, remaining) = Color::try_parse(remaining)?;
5061         let _ = remaining;
5062         Ok(CreateSolidFillRequest {
5063             picture,
5064             color,
5065         })
5066     }
5067 }
5068 impl Request for CreateSolidFillRequest {
5069     type Reply = ();
5070 }
create_solid_fill<Conn>(conn: &Conn, picture: Picture, color: Color) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5071 pub fn create_solid_fill<Conn>(conn: &Conn, picture: Picture, color: Color) -> Result<VoidCookie<'_, Conn>, ConnectionError>
5072 where
5073     Conn: RequestConnection + ?Sized,
5074 {
5075     let request0 = CreateSolidFillRequest {
5076         picture,
5077         color,
5078     };
5079     request0.send(conn)
5080 }
5081 
5082 /// Opcode for the CreateLinearGradient request
5083 pub const CREATE_LINEAR_GRADIENT_REQUEST: u8 = 34;
5084 #[derive(Debug, Clone, PartialEq, Eq)]
5085 pub struct CreateLinearGradientRequest<'input> {
5086     pub picture: Picture,
5087     pub p1: Pointfix,
5088     pub p2: Pointfix,
5089     pub stops: Cow<'input, [Fixed]>,
5090     pub colors: Cow<'input, [Color]>,
5091 }
5092 impl<'input> CreateLinearGradientRequest<'input> {
5093     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5094     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5095     where
5096         Conn: RequestConnection + ?Sized,
5097     {
5098         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5099             .ok_or(ConnectionError::UnsupportedExtension)?;
5100         let length_so_far = 0;
5101         let picture_bytes = self.picture.serialize();
5102         let p1_bytes = self.p1.serialize();
5103         let p2_bytes = self.p2.serialize();
5104         let num_stops = u32::try_from(self.stops.len()).expect("`stops` has too many elements");
5105         let num_stops_bytes = num_stops.serialize();
5106         let mut request0 = vec![
5107             extension_information.major_opcode,
5108             CREATE_LINEAR_GRADIENT_REQUEST,
5109             0,
5110             0,
5111             picture_bytes[0],
5112             picture_bytes[1],
5113             picture_bytes[2],
5114             picture_bytes[3],
5115             p1_bytes[0],
5116             p1_bytes[1],
5117             p1_bytes[2],
5118             p1_bytes[3],
5119             p1_bytes[4],
5120             p1_bytes[5],
5121             p1_bytes[6],
5122             p1_bytes[7],
5123             p2_bytes[0],
5124             p2_bytes[1],
5125             p2_bytes[2],
5126             p2_bytes[3],
5127             p2_bytes[4],
5128             p2_bytes[5],
5129             p2_bytes[6],
5130             p2_bytes[7],
5131             num_stops_bytes[0],
5132             num_stops_bytes[1],
5133             num_stops_bytes[2],
5134             num_stops_bytes[3],
5135         ];
5136         let length_so_far = length_so_far + request0.len();
5137         let stops_bytes = self.stops.serialize();
5138         let length_so_far = length_so_far + stops_bytes.len();
5139         assert_eq!(self.colors.len(), usize::try_from(num_stops).unwrap(), "`colors` has an incorrect length");
5140         let colors_bytes = self.colors.serialize();
5141         let length_so_far = length_so_far + colors_bytes.len();
5142         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
5143         let length_so_far = length_so_far + padding0.len();
5144         assert_eq!(length_so_far % 4, 0);
5145         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5146         request0[2..4].copy_from_slice(&length.to_ne_bytes());
5147         Ok((vec![request0.into(), stops_bytes.into(), colors_bytes.into(), padding0.into()], vec![]))
5148     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5149     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
5150     where
5151         Conn: RequestConnection + ?Sized,
5152     {
5153         let (bytes, fds) = self.serialize(conn)?;
5154         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5155         conn.send_request_without_reply(&slices, fds)
5156     }
5157     /// 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>5158     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
5159         if header.minor_opcode != CREATE_LINEAR_GRADIENT_REQUEST {
5160             return Err(ParseError::InvalidValue);
5161         }
5162         let (picture, remaining) = Picture::try_parse(value)?;
5163         let (p1, remaining) = Pointfix::try_parse(remaining)?;
5164         let (p2, remaining) = Pointfix::try_parse(remaining)?;
5165         let (num_stops, remaining) = u32::try_parse(remaining)?;
5166         let (stops, remaining) = crate::x11_utils::parse_list::<Fixed>(remaining, num_stops.try_to_usize()?)?;
5167         let (colors, remaining) = crate::x11_utils::parse_list::<Color>(remaining, num_stops.try_to_usize()?)?;
5168         let _ = remaining;
5169         Ok(CreateLinearGradientRequest {
5170             picture,
5171             p1,
5172             p2,
5173             stops: Cow::Owned(stops),
5174             colors: Cow::Owned(colors),
5175         })
5176     }
5177     /// Clone all borrowed data in this CreateLinearGradientRequest.
into_owned(self) -> CreateLinearGradientRequest<'static>5178     pub fn into_owned(self) -> CreateLinearGradientRequest<'static> {
5179         CreateLinearGradientRequest {
5180             picture: self.picture,
5181             p1: self.p1,
5182             p2: self.p2,
5183             stops: Cow::Owned(self.stops.into_owned()),
5184             colors: Cow::Owned(self.colors.into_owned()),
5185         }
5186     }
5187 }
5188 impl<'input> Request for CreateLinearGradientRequest<'input> {
5189     type Reply = ();
5190 }
create_linear_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, p1: Pointfix, p2: Pointfix, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5191 pub fn create_linear_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, p1: Pointfix, p2: Pointfix, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
5192 where
5193     Conn: RequestConnection + ?Sized,
5194 {
5195     let request0 = CreateLinearGradientRequest {
5196         picture,
5197         p1,
5198         p2,
5199         stops: Cow::Borrowed(stops),
5200         colors: Cow::Borrowed(colors),
5201     };
5202     request0.send(conn)
5203 }
5204 
5205 /// Opcode for the CreateRadialGradient request
5206 pub const CREATE_RADIAL_GRADIENT_REQUEST: u8 = 35;
5207 #[derive(Debug, Clone, PartialEq, Eq)]
5208 pub struct CreateRadialGradientRequest<'input> {
5209     pub picture: Picture,
5210     pub inner: Pointfix,
5211     pub outer: Pointfix,
5212     pub inner_radius: Fixed,
5213     pub outer_radius: Fixed,
5214     pub stops: Cow<'input, [Fixed]>,
5215     pub colors: Cow<'input, [Color]>,
5216 }
5217 impl<'input> CreateRadialGradientRequest<'input> {
5218     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5219     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5220     where
5221         Conn: RequestConnection + ?Sized,
5222     {
5223         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5224             .ok_or(ConnectionError::UnsupportedExtension)?;
5225         let length_so_far = 0;
5226         let picture_bytes = self.picture.serialize();
5227         let inner_bytes = self.inner.serialize();
5228         let outer_bytes = self.outer.serialize();
5229         let inner_radius_bytes = self.inner_radius.serialize();
5230         let outer_radius_bytes = self.outer_radius.serialize();
5231         let num_stops = u32::try_from(self.stops.len()).expect("`stops` has too many elements");
5232         let num_stops_bytes = num_stops.serialize();
5233         let mut request0 = vec![
5234             extension_information.major_opcode,
5235             CREATE_RADIAL_GRADIENT_REQUEST,
5236             0,
5237             0,
5238             picture_bytes[0],
5239             picture_bytes[1],
5240             picture_bytes[2],
5241             picture_bytes[3],
5242             inner_bytes[0],
5243             inner_bytes[1],
5244             inner_bytes[2],
5245             inner_bytes[3],
5246             inner_bytes[4],
5247             inner_bytes[5],
5248             inner_bytes[6],
5249             inner_bytes[7],
5250             outer_bytes[0],
5251             outer_bytes[1],
5252             outer_bytes[2],
5253             outer_bytes[3],
5254             outer_bytes[4],
5255             outer_bytes[5],
5256             outer_bytes[6],
5257             outer_bytes[7],
5258             inner_radius_bytes[0],
5259             inner_radius_bytes[1],
5260             inner_radius_bytes[2],
5261             inner_radius_bytes[3],
5262             outer_radius_bytes[0],
5263             outer_radius_bytes[1],
5264             outer_radius_bytes[2],
5265             outer_radius_bytes[3],
5266             num_stops_bytes[0],
5267             num_stops_bytes[1],
5268             num_stops_bytes[2],
5269             num_stops_bytes[3],
5270         ];
5271         let length_so_far = length_so_far + request0.len();
5272         let stops_bytes = self.stops.serialize();
5273         let length_so_far = length_so_far + stops_bytes.len();
5274         assert_eq!(self.colors.len(), usize::try_from(num_stops).unwrap(), "`colors` has an incorrect length");
5275         let colors_bytes = self.colors.serialize();
5276         let length_so_far = length_so_far + colors_bytes.len();
5277         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
5278         let length_so_far = length_so_far + padding0.len();
5279         assert_eq!(length_so_far % 4, 0);
5280         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5281         request0[2..4].copy_from_slice(&length.to_ne_bytes());
5282         Ok((vec![request0.into(), stops_bytes.into(), colors_bytes.into(), padding0.into()], vec![]))
5283     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5284     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
5285     where
5286         Conn: RequestConnection + ?Sized,
5287     {
5288         let (bytes, fds) = self.serialize(conn)?;
5289         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5290         conn.send_request_without_reply(&slices, fds)
5291     }
5292     /// 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>5293     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
5294         if header.minor_opcode != CREATE_RADIAL_GRADIENT_REQUEST {
5295             return Err(ParseError::InvalidValue);
5296         }
5297         let (picture, remaining) = Picture::try_parse(value)?;
5298         let (inner, remaining) = Pointfix::try_parse(remaining)?;
5299         let (outer, remaining) = Pointfix::try_parse(remaining)?;
5300         let (inner_radius, remaining) = Fixed::try_parse(remaining)?;
5301         let (outer_radius, remaining) = Fixed::try_parse(remaining)?;
5302         let (num_stops, remaining) = u32::try_parse(remaining)?;
5303         let (stops, remaining) = crate::x11_utils::parse_list::<Fixed>(remaining, num_stops.try_to_usize()?)?;
5304         let (colors, remaining) = crate::x11_utils::parse_list::<Color>(remaining, num_stops.try_to_usize()?)?;
5305         let _ = remaining;
5306         Ok(CreateRadialGradientRequest {
5307             picture,
5308             inner,
5309             outer,
5310             inner_radius,
5311             outer_radius,
5312             stops: Cow::Owned(stops),
5313             colors: Cow::Owned(colors),
5314         })
5315     }
5316     /// Clone all borrowed data in this CreateRadialGradientRequest.
into_owned(self) -> CreateRadialGradientRequest<'static>5317     pub fn into_owned(self) -> CreateRadialGradientRequest<'static> {
5318         CreateRadialGradientRequest {
5319             picture: self.picture,
5320             inner: self.inner,
5321             outer: self.outer,
5322             inner_radius: self.inner_radius,
5323             outer_radius: self.outer_radius,
5324             stops: Cow::Owned(self.stops.into_owned()),
5325             colors: Cow::Owned(self.colors.into_owned()),
5326         }
5327     }
5328 }
5329 impl<'input> Request for CreateRadialGradientRequest<'input> {
5330     type Reply = ();
5331 }
create_radial_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5332 pub fn create_radial_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
5333 where
5334     Conn: RequestConnection + ?Sized,
5335 {
5336     let request0 = CreateRadialGradientRequest {
5337         picture,
5338         inner,
5339         outer,
5340         inner_radius,
5341         outer_radius,
5342         stops: Cow::Borrowed(stops),
5343         colors: Cow::Borrowed(colors),
5344     };
5345     request0.send(conn)
5346 }
5347 
5348 /// Opcode for the CreateConicalGradient request
5349 pub const CREATE_CONICAL_GRADIENT_REQUEST: u8 = 36;
5350 #[derive(Debug, Clone, PartialEq, Eq)]
5351 pub struct CreateConicalGradientRequest<'input> {
5352     pub picture: Picture,
5353     pub center: Pointfix,
5354     pub angle: Fixed,
5355     pub stops: Cow<'input, [Fixed]>,
5356     pub colors: Cow<'input, [Color]>,
5357 }
5358 impl<'input> CreateConicalGradientRequest<'input> {
5359     /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5360     fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5361     where
5362         Conn: RequestConnection + ?Sized,
5363     {
5364         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5365             .ok_or(ConnectionError::UnsupportedExtension)?;
5366         let length_so_far = 0;
5367         let picture_bytes = self.picture.serialize();
5368         let center_bytes = self.center.serialize();
5369         let angle_bytes = self.angle.serialize();
5370         let num_stops = u32::try_from(self.stops.len()).expect("`stops` has too many elements");
5371         let num_stops_bytes = num_stops.serialize();
5372         let mut request0 = vec![
5373             extension_information.major_opcode,
5374             CREATE_CONICAL_GRADIENT_REQUEST,
5375             0,
5376             0,
5377             picture_bytes[0],
5378             picture_bytes[1],
5379             picture_bytes[2],
5380             picture_bytes[3],
5381             center_bytes[0],
5382             center_bytes[1],
5383             center_bytes[2],
5384             center_bytes[3],
5385             center_bytes[4],
5386             center_bytes[5],
5387             center_bytes[6],
5388             center_bytes[7],
5389             angle_bytes[0],
5390             angle_bytes[1],
5391             angle_bytes[2],
5392             angle_bytes[3],
5393             num_stops_bytes[0],
5394             num_stops_bytes[1],
5395             num_stops_bytes[2],
5396             num_stops_bytes[3],
5397         ];
5398         let length_so_far = length_so_far + request0.len();
5399         let stops_bytes = self.stops.serialize();
5400         let length_so_far = length_so_far + stops_bytes.len();
5401         assert_eq!(self.colors.len(), usize::try_from(num_stops).unwrap(), "`colors` has an incorrect length");
5402         let colors_bytes = self.colors.serialize();
5403         let length_so_far = length_so_far + colors_bytes.len();
5404         let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
5405         let length_so_far = length_so_far + padding0.len();
5406         assert_eq!(length_so_far % 4, 0);
5407         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5408         request0[2..4].copy_from_slice(&length.to_ne_bytes());
5409         Ok((vec![request0.into(), stops_bytes.into(), colors_bytes.into(), padding0.into()], vec![]))
5410     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5411     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
5412     where
5413         Conn: RequestConnection + ?Sized,
5414     {
5415         let (bytes, fds) = self.serialize(conn)?;
5416         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5417         conn.send_request_without_reply(&slices, fds)
5418     }
5419     /// 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>5420     pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
5421         if header.minor_opcode != CREATE_CONICAL_GRADIENT_REQUEST {
5422             return Err(ParseError::InvalidValue);
5423         }
5424         let (picture, remaining) = Picture::try_parse(value)?;
5425         let (center, remaining) = Pointfix::try_parse(remaining)?;
5426         let (angle, remaining) = Fixed::try_parse(remaining)?;
5427         let (num_stops, remaining) = u32::try_parse(remaining)?;
5428         let (stops, remaining) = crate::x11_utils::parse_list::<Fixed>(remaining, num_stops.try_to_usize()?)?;
5429         let (colors, remaining) = crate::x11_utils::parse_list::<Color>(remaining, num_stops.try_to_usize()?)?;
5430         let _ = remaining;
5431         Ok(CreateConicalGradientRequest {
5432             picture,
5433             center,
5434             angle,
5435             stops: Cow::Owned(stops),
5436             colors: Cow::Owned(colors),
5437         })
5438     }
5439     /// Clone all borrowed data in this CreateConicalGradientRequest.
into_owned(self) -> CreateConicalGradientRequest<'static>5440     pub fn into_owned(self) -> CreateConicalGradientRequest<'static> {
5441         CreateConicalGradientRequest {
5442             picture: self.picture,
5443             center: self.center,
5444             angle: self.angle,
5445             stops: Cow::Owned(self.stops.into_owned()),
5446             colors: Cow::Owned(self.colors.into_owned()),
5447         }
5448     }
5449 }
5450 impl<'input> Request for CreateConicalGradientRequest<'input> {
5451     type Reply = ();
5452 }
create_conical_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, center: Pointfix, angle: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,5453 pub fn create_conical_gradient<'c, 'input, Conn>(conn: &'c Conn, picture: Picture, center: Pointfix, angle: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
5454 where
5455     Conn: RequestConnection + ?Sized,
5456 {
5457     let request0 = CreateConicalGradientRequest {
5458         picture,
5459         center,
5460         angle,
5461         stops: Cow::Borrowed(stops),
5462         colors: Cow::Borrowed(colors),
5463     };
5464     request0.send(conn)
5465 }
5466 
5467 /// Extension trait defining the requests of this extension.
5468 pub trait ConnectionExt: RequestConnection {
render_query_version(&self, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>5469     fn render_query_version(&self, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>
5470     {
5471         query_version(self, client_major_version, client_minor_version)
5472     }
render_query_pict_formats(&self) -> Result<Cookie<'_, Self, QueryPictFormatsReply>, ConnectionError>5473     fn render_query_pict_formats(&self) -> Result<Cookie<'_, Self, QueryPictFormatsReply>, ConnectionError>
5474     {
5475         query_pict_formats(self)
5476     }
render_query_pict_index_values(&self, format: Pictformat) -> Result<Cookie<'_, Self, QueryPictIndexValuesReply>, ConnectionError>5477     fn render_query_pict_index_values(&self, format: Pictformat) -> Result<Cookie<'_, Self, QueryPictIndexValuesReply>, ConnectionError>
5478     {
5479         query_pict_index_values(self, format)
5480     }
render_create_picture<'c, 'input>(&'c self, pid: Picture, drawable: xproto::Drawable, format: Pictformat, value_list: &'input CreatePictureAux) -> Result<VoidCookie<'c, Self>, ConnectionError>5481     fn render_create_picture<'c, 'input>(&'c self, pid: Picture, drawable: xproto::Drawable, format: Pictformat, value_list: &'input CreatePictureAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
5482     {
5483         create_picture(self, pid, drawable, format, value_list)
5484     }
render_change_picture<'c, 'input>(&'c self, picture: Picture, value_list: &'input ChangePictureAux) -> Result<VoidCookie<'c, Self>, ConnectionError>5485     fn render_change_picture<'c, 'input>(&'c self, picture: Picture, value_list: &'input ChangePictureAux) -> Result<VoidCookie<'c, Self>, ConnectionError>
5486     {
5487         change_picture(self, picture, value_list)
5488     }
render_set_picture_clip_rectangles<'c, 'input>(&'c self, picture: Picture, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>5489     fn render_set_picture_clip_rectangles<'c, 'input>(&'c self, picture: Picture, clip_x_origin: i16, clip_y_origin: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5490     {
5491         set_picture_clip_rectangles(self, picture, clip_x_origin, clip_y_origin, rectangles)
5492     }
render_free_picture(&self, picture: Picture) -> Result<VoidCookie<'_, Self>, ConnectionError>5493     fn render_free_picture(&self, picture: Picture) -> Result<VoidCookie<'_, Self>, ConnectionError>
5494     {
5495         free_picture(self, picture)
5496     }
render_composite<A>(&self, op: PictOp, src: Picture, mask: A, dst: Picture, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Self>, ConnectionError> where A: Into<Picture>,5497     fn render_composite<A>(&self, op: PictOp, src: Picture, mask: A, dst: Picture, src_x: i16, src_y: i16, mask_x: i16, mask_y: i16, dst_x: i16, dst_y: i16, width: u16, height: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
5498     where
5499         A: Into<Picture>,
5500     {
5501         composite(self, op, src, mask, dst, src_x, src_y, mask_x, mask_y, dst_x, dst_y, width, height)
5502     }
render_trapezoids<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, traps: &'input [Trapezoid]) -> Result<VoidCookie<'c, Self>, ConnectionError>5503     fn render_trapezoids<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, traps: &'input [Trapezoid]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5504     {
5505         trapezoids(self, op, src, dst, mask_format, src_x, src_y, traps)
5506     }
render_triangles<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, triangles: &'input [Triangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>5507     fn render_triangles<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, triangles: &'input [Triangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5508     {
5509         self::triangles(self, op, src, dst, mask_format, src_x, src_y, triangles)
5510     }
render_tri_strip<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Self>, ConnectionError>5511     fn render_tri_strip<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5512     {
5513         tri_strip(self, op, src, dst, mask_format, src_x, src_y, points)
5514     }
render_tri_fan<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Self>, ConnectionError>5515     fn render_tri_fan<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, src_x: i16, src_y: i16, points: &'input [Pointfix]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5516     {
5517         tri_fan(self, op, src, dst, mask_format, src_x, src_y, points)
5518     }
render_create_glyph_set(&self, gsid: Glyphset, format: Pictformat) -> Result<VoidCookie<'_, Self>, ConnectionError>5519     fn render_create_glyph_set(&self, gsid: Glyphset, format: Pictformat) -> Result<VoidCookie<'_, Self>, ConnectionError>
5520     {
5521         create_glyph_set(self, gsid, format)
5522     }
render_reference_glyph_set(&self, gsid: Glyphset, existing: Glyphset) -> Result<VoidCookie<'_, Self>, ConnectionError>5523     fn render_reference_glyph_set(&self, gsid: Glyphset, existing: Glyphset) -> Result<VoidCookie<'_, Self>, ConnectionError>
5524     {
5525         reference_glyph_set(self, gsid, existing)
5526     }
render_free_glyph_set(&self, glyphset: Glyphset) -> Result<VoidCookie<'_, Self>, ConnectionError>5527     fn render_free_glyph_set(&self, glyphset: Glyphset) -> Result<VoidCookie<'_, Self>, ConnectionError>
5528     {
5529         free_glyph_set(self, glyphset)
5530     }
render_add_glyphs<'c, 'input>(&'c self, glyphset: Glyphset, glyphids: &'input [u32], glyphs: &'input [Glyphinfo], data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>5531     fn render_add_glyphs<'c, 'input>(&'c self, glyphset: Glyphset, glyphids: &'input [u32], glyphs: &'input [Glyphinfo], data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5532     {
5533         add_glyphs(self, glyphset, glyphids, glyphs, data)
5534     }
render_free_glyphs<'c, 'input>(&'c self, glyphset: Glyphset, glyphs: &'input [Glyph]) -> Result<VoidCookie<'c, Self>, ConnectionError>5535     fn render_free_glyphs<'c, 'input>(&'c self, glyphset: Glyphset, glyphs: &'input [Glyph]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5536     {
5537         free_glyphs(self, glyphset, glyphs)
5538     }
render_composite_glyphs8<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>5539     fn render_composite_glyphs8<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5540     {
5541         composite_glyphs8(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds)
5542     }
render_composite_glyphs16<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>5543     fn render_composite_glyphs16<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5544     {
5545         composite_glyphs16(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds)
5546     }
render_composite_glyphs32<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>5547     fn render_composite_glyphs32<'c, 'input>(&'c self, op: PictOp, src: Picture, dst: Picture, mask_format: Pictformat, glyphset: Glyphset, src_x: i16, src_y: i16, glyphcmds: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5548     {
5549         composite_glyphs32(self, op, src, dst, mask_format, glyphset, src_x, src_y, glyphcmds)
5550     }
render_fill_rectangles<'c, 'input>(&'c self, op: PictOp, dst: Picture, color: Color, rects: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>5551     fn render_fill_rectangles<'c, 'input>(&'c self, op: PictOp, dst: Picture, color: Color, rects: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5552     {
5553         fill_rectangles(self, op, dst, color, rects)
5554     }
render_create_cursor(&self, cid: xproto::Cursor, source: Picture, x: u16, y: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>5555     fn render_create_cursor(&self, cid: xproto::Cursor, source: Picture, x: u16, y: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
5556     {
5557         create_cursor(self, cid, source, x, y)
5558     }
render_set_picture_transform(&self, picture: Picture, transform: Transform) -> Result<VoidCookie<'_, Self>, ConnectionError>5559     fn render_set_picture_transform(&self, picture: Picture, transform: Transform) -> Result<VoidCookie<'_, Self>, ConnectionError>
5560     {
5561         set_picture_transform(self, picture, transform)
5562     }
render_query_filters(&self, drawable: xproto::Drawable) -> Result<Cookie<'_, Self, QueryFiltersReply>, ConnectionError>5563     fn render_query_filters(&self, drawable: xproto::Drawable) -> Result<Cookie<'_, Self, QueryFiltersReply>, ConnectionError>
5564     {
5565         query_filters(self, drawable)
5566     }
render_set_picture_filter<'c, 'input>(&'c self, picture: Picture, filter: &'input [u8], values: &'input [Fixed]) -> Result<VoidCookie<'c, Self>, ConnectionError>5567     fn render_set_picture_filter<'c, 'input>(&'c self, picture: Picture, filter: &'input [u8], values: &'input [Fixed]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5568     {
5569         set_picture_filter(self, picture, filter, values)
5570     }
render_create_anim_cursor<'c, 'input>(&'c self, cid: xproto::Cursor, cursors: &'input [Animcursorelt]) -> Result<VoidCookie<'c, Self>, ConnectionError>5571     fn render_create_anim_cursor<'c, 'input>(&'c self, cid: xproto::Cursor, cursors: &'input [Animcursorelt]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5572     {
5573         create_anim_cursor(self, cid, cursors)
5574     }
render_add_traps<'c, 'input>(&'c self, picture: Picture, x_off: i16, y_off: i16, traps: &'input [Trap]) -> Result<VoidCookie<'c, Self>, ConnectionError>5575     fn render_add_traps<'c, 'input>(&'c self, picture: Picture, x_off: i16, y_off: i16, traps: &'input [Trap]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5576     {
5577         add_traps(self, picture, x_off, y_off, traps)
5578     }
render_create_solid_fill(&self, picture: Picture, color: Color) -> Result<VoidCookie<'_, Self>, ConnectionError>5579     fn render_create_solid_fill(&self, picture: Picture, color: Color) -> Result<VoidCookie<'_, Self>, ConnectionError>
5580     {
5581         create_solid_fill(self, picture, color)
5582     }
render_create_linear_gradient<'c, 'input>(&'c self, picture: Picture, p1: Pointfix, p2: Pointfix, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>5583     fn render_create_linear_gradient<'c, 'input>(&'c self, picture: Picture, p1: Pointfix, p2: Pointfix, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5584     {
5585         create_linear_gradient(self, picture, p1, p2, stops, colors)
5586     }
render_create_radial_gradient<'c, 'input>(&'c self, picture: Picture, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>5587     fn render_create_radial_gradient<'c, 'input>(&'c self, picture: Picture, inner: Pointfix, outer: Pointfix, inner_radius: Fixed, outer_radius: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5588     {
5589         create_radial_gradient(self, picture, inner, outer, inner_radius, outer_radius, stops, colors)
5590     }
render_create_conical_gradient<'c, 'input>(&'c self, picture: Picture, center: Pointfix, angle: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>5591     fn render_create_conical_gradient<'c, 'input>(&'c self, picture: Picture, center: Pointfix, angle: Fixed, stops: &'input [Fixed], colors: &'input [Color]) -> Result<VoidCookie<'c, Self>, ConnectionError>
5592     {
5593         create_conical_gradient(self, picture, center, angle, stops, colors)
5594     }
5595 }
5596 
5597 impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
5598