x11rb_protocol/protocol/
render.rs

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