x11rb_protocol/protocol/
glx.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Glx` 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 = "GLX";
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) = (1, 4);
38
39pub type Pixmap = u32;
40
41pub type Context = u32;
42
43pub type Pbuffer = u32;
44
45pub type Window = u32;
46
47pub type Fbconfig = u32;
48
49pub type Drawable = u32;
50
51pub type Float32 = f32;
52
53pub type Float64 = f64;
54
55pub type Bool32 = u32;
56
57pub type ContextTag = u32;
58
59
60/// Opcode for the BadContext error
61pub const BAD_CONTEXT_ERROR: u8 = 0;
62
63/// Opcode for the BadContextState error
64pub const BAD_CONTEXT_STATE_ERROR: u8 = 1;
65
66/// Opcode for the BadDrawable error
67pub const BAD_DRAWABLE_ERROR: u8 = 2;
68
69/// Opcode for the BadPixmap error
70pub const BAD_PIXMAP_ERROR: u8 = 3;
71
72/// Opcode for the BadContextTag error
73pub const BAD_CONTEXT_TAG_ERROR: u8 = 4;
74
75/// Opcode for the BadCurrentWindow error
76pub const BAD_CURRENT_WINDOW_ERROR: u8 = 5;
77
78/// Opcode for the BadRenderRequest error
79pub const BAD_RENDER_REQUEST_ERROR: u8 = 6;
80
81/// Opcode for the BadLargeRequest error
82pub const BAD_LARGE_REQUEST_ERROR: u8 = 7;
83
84/// Opcode for the UnsupportedPrivateRequest error
85pub const UNSUPPORTED_PRIVATE_REQUEST_ERROR: u8 = 8;
86
87/// Opcode for the BadFBConfig error
88pub const BAD_FB_CONFIG_ERROR: u8 = 9;
89
90/// Opcode for the BadPbuffer error
91pub const BAD_PBUFFER_ERROR: u8 = 10;
92
93/// Opcode for the BadCurrentDrawable error
94pub const BAD_CURRENT_DRAWABLE_ERROR: u8 = 11;
95
96/// Opcode for the BadWindow error
97pub const BAD_WINDOW_ERROR: u8 = 12;
98
99/// Opcode for the GLXBadProfileARB error
100pub const GLX_BAD_PROFILE_ARB_ERROR: u8 = 13;
101
102/// Opcode for the PbufferClobber event
103pub const PBUFFER_CLOBBER_EVENT: u8 = 0;
104#[derive(Clone, Copy, Default)]
105#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
106#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
107pub struct PbufferClobberEvent {
108    pub response_type: u8,
109    pub sequence: u16,
110    pub event_type: u16,
111    pub draw_type: u16,
112    pub drawable: Drawable,
113    pub b_mask: u32,
114    pub aux_buffer: u16,
115    pub x: u16,
116    pub y: u16,
117    pub width: u16,
118    pub height: u16,
119    pub count: u16,
120}
121impl_debug_if_no_extra_traits!(PbufferClobberEvent, "PbufferClobberEvent");
122impl TryParse for PbufferClobberEvent {
123    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
124        let remaining = initial_value;
125        let (response_type, remaining) = u8::try_parse(remaining)?;
126        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
127        let (sequence, remaining) = u16::try_parse(remaining)?;
128        let (event_type, remaining) = u16::try_parse(remaining)?;
129        let (draw_type, remaining) = u16::try_parse(remaining)?;
130        let (drawable, remaining) = Drawable::try_parse(remaining)?;
131        let (b_mask, remaining) = u32::try_parse(remaining)?;
132        let (aux_buffer, remaining) = u16::try_parse(remaining)?;
133        let (x, remaining) = u16::try_parse(remaining)?;
134        let (y, remaining) = u16::try_parse(remaining)?;
135        let (width, remaining) = u16::try_parse(remaining)?;
136        let (height, remaining) = u16::try_parse(remaining)?;
137        let (count, remaining) = u16::try_parse(remaining)?;
138        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
139        let result = PbufferClobberEvent { response_type, sequence, event_type, draw_type, drawable, b_mask, aux_buffer, x, y, width, height, count };
140        let _ = remaining;
141        let remaining = initial_value.get(32..)
142            .ok_or(ParseError::InsufficientData)?;
143        Ok((result, remaining))
144    }
145}
146impl Serialize for PbufferClobberEvent {
147    type Bytes = [u8; 32];
148    fn serialize(&self) -> [u8; 32] {
149        let response_type_bytes = self.response_type.serialize();
150        let sequence_bytes = self.sequence.serialize();
151        let event_type_bytes = self.event_type.serialize();
152        let draw_type_bytes = self.draw_type.serialize();
153        let drawable_bytes = self.drawable.serialize();
154        let b_mask_bytes = self.b_mask.serialize();
155        let aux_buffer_bytes = self.aux_buffer.serialize();
156        let x_bytes = self.x.serialize();
157        let y_bytes = self.y.serialize();
158        let width_bytes = self.width.serialize();
159        let height_bytes = self.height.serialize();
160        let count_bytes = self.count.serialize();
161        [
162            response_type_bytes[0],
163            0,
164            sequence_bytes[0],
165            sequence_bytes[1],
166            event_type_bytes[0],
167            event_type_bytes[1],
168            draw_type_bytes[0],
169            draw_type_bytes[1],
170            drawable_bytes[0],
171            drawable_bytes[1],
172            drawable_bytes[2],
173            drawable_bytes[3],
174            b_mask_bytes[0],
175            b_mask_bytes[1],
176            b_mask_bytes[2],
177            b_mask_bytes[3],
178            aux_buffer_bytes[0],
179            aux_buffer_bytes[1],
180            x_bytes[0],
181            x_bytes[1],
182            y_bytes[0],
183            y_bytes[1],
184            width_bytes[0],
185            width_bytes[1],
186            height_bytes[0],
187            height_bytes[1],
188            count_bytes[0],
189            count_bytes[1],
190            0,
191            0,
192            0,
193            0,
194        ]
195    }
196    fn serialize_into(&self, bytes: &mut Vec<u8>) {
197        bytes.reserve(32);
198        self.response_type.serialize_into(bytes);
199        bytes.extend_from_slice(&[0; 1]);
200        self.sequence.serialize_into(bytes);
201        self.event_type.serialize_into(bytes);
202        self.draw_type.serialize_into(bytes);
203        self.drawable.serialize_into(bytes);
204        self.b_mask.serialize_into(bytes);
205        self.aux_buffer.serialize_into(bytes);
206        self.x.serialize_into(bytes);
207        self.y.serialize_into(bytes);
208        self.width.serialize_into(bytes);
209        self.height.serialize_into(bytes);
210        self.count.serialize_into(bytes);
211        bytes.extend_from_slice(&[0; 4]);
212    }
213}
214impl From<&PbufferClobberEvent> for [u8; 32] {
215    fn from(input: &PbufferClobberEvent) -> Self {
216        let response_type_bytes = input.response_type.serialize();
217        let sequence_bytes = input.sequence.serialize();
218        let event_type_bytes = input.event_type.serialize();
219        let draw_type_bytes = input.draw_type.serialize();
220        let drawable_bytes = input.drawable.serialize();
221        let b_mask_bytes = input.b_mask.serialize();
222        let aux_buffer_bytes = input.aux_buffer.serialize();
223        let x_bytes = input.x.serialize();
224        let y_bytes = input.y.serialize();
225        let width_bytes = input.width.serialize();
226        let height_bytes = input.height.serialize();
227        let count_bytes = input.count.serialize();
228        [
229            response_type_bytes[0],
230            0,
231            sequence_bytes[0],
232            sequence_bytes[1],
233            event_type_bytes[0],
234            event_type_bytes[1],
235            draw_type_bytes[0],
236            draw_type_bytes[1],
237            drawable_bytes[0],
238            drawable_bytes[1],
239            drawable_bytes[2],
240            drawable_bytes[3],
241            b_mask_bytes[0],
242            b_mask_bytes[1],
243            b_mask_bytes[2],
244            b_mask_bytes[3],
245            aux_buffer_bytes[0],
246            aux_buffer_bytes[1],
247            x_bytes[0],
248            x_bytes[1],
249            y_bytes[0],
250            y_bytes[1],
251            width_bytes[0],
252            width_bytes[1],
253            height_bytes[0],
254            height_bytes[1],
255            count_bytes[0],
256            count_bytes[1],
257            0,
258            0,
259            0,
260            0,
261        ]
262    }
263}
264impl From<PbufferClobberEvent> for [u8; 32] {
265    fn from(input: PbufferClobberEvent) -> Self {
266        Self::from(&input)
267    }
268}
269
270/// Opcode for the BufferSwapComplete event
271pub const BUFFER_SWAP_COMPLETE_EVENT: u8 = 1;
272#[derive(Clone, Copy, Default)]
273#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
274#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
275pub struct BufferSwapCompleteEvent {
276    pub response_type: u8,
277    pub sequence: u16,
278    pub event_type: u16,
279    pub drawable: Drawable,
280    pub ust_hi: u32,
281    pub ust_lo: u32,
282    pub msc_hi: u32,
283    pub msc_lo: u32,
284    pub sbc: u32,
285}
286impl_debug_if_no_extra_traits!(BufferSwapCompleteEvent, "BufferSwapCompleteEvent");
287impl TryParse for BufferSwapCompleteEvent {
288    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
289        let remaining = initial_value;
290        let (response_type, remaining) = u8::try_parse(remaining)?;
291        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
292        let (sequence, remaining) = u16::try_parse(remaining)?;
293        let (event_type, remaining) = u16::try_parse(remaining)?;
294        let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
295        let (drawable, remaining) = Drawable::try_parse(remaining)?;
296        let (ust_hi, remaining) = u32::try_parse(remaining)?;
297        let (ust_lo, remaining) = u32::try_parse(remaining)?;
298        let (msc_hi, remaining) = u32::try_parse(remaining)?;
299        let (msc_lo, remaining) = u32::try_parse(remaining)?;
300        let (sbc, remaining) = u32::try_parse(remaining)?;
301        let result = BufferSwapCompleteEvent { response_type, sequence, event_type, drawable, ust_hi, ust_lo, msc_hi, msc_lo, sbc };
302        let _ = remaining;
303        let remaining = initial_value.get(32..)
304            .ok_or(ParseError::InsufficientData)?;
305        Ok((result, remaining))
306    }
307}
308impl Serialize for BufferSwapCompleteEvent {
309    type Bytes = [u8; 32];
310    fn serialize(&self) -> [u8; 32] {
311        let response_type_bytes = self.response_type.serialize();
312        let sequence_bytes = self.sequence.serialize();
313        let event_type_bytes = self.event_type.serialize();
314        let drawable_bytes = self.drawable.serialize();
315        let ust_hi_bytes = self.ust_hi.serialize();
316        let ust_lo_bytes = self.ust_lo.serialize();
317        let msc_hi_bytes = self.msc_hi.serialize();
318        let msc_lo_bytes = self.msc_lo.serialize();
319        let sbc_bytes = self.sbc.serialize();
320        [
321            response_type_bytes[0],
322            0,
323            sequence_bytes[0],
324            sequence_bytes[1],
325            event_type_bytes[0],
326            event_type_bytes[1],
327            0,
328            0,
329            drawable_bytes[0],
330            drawable_bytes[1],
331            drawable_bytes[2],
332            drawable_bytes[3],
333            ust_hi_bytes[0],
334            ust_hi_bytes[1],
335            ust_hi_bytes[2],
336            ust_hi_bytes[3],
337            ust_lo_bytes[0],
338            ust_lo_bytes[1],
339            ust_lo_bytes[2],
340            ust_lo_bytes[3],
341            msc_hi_bytes[0],
342            msc_hi_bytes[1],
343            msc_hi_bytes[2],
344            msc_hi_bytes[3],
345            msc_lo_bytes[0],
346            msc_lo_bytes[1],
347            msc_lo_bytes[2],
348            msc_lo_bytes[3],
349            sbc_bytes[0],
350            sbc_bytes[1],
351            sbc_bytes[2],
352            sbc_bytes[3],
353        ]
354    }
355    fn serialize_into(&self, bytes: &mut Vec<u8>) {
356        bytes.reserve(32);
357        self.response_type.serialize_into(bytes);
358        bytes.extend_from_slice(&[0; 1]);
359        self.sequence.serialize_into(bytes);
360        self.event_type.serialize_into(bytes);
361        bytes.extend_from_slice(&[0; 2]);
362        self.drawable.serialize_into(bytes);
363        self.ust_hi.serialize_into(bytes);
364        self.ust_lo.serialize_into(bytes);
365        self.msc_hi.serialize_into(bytes);
366        self.msc_lo.serialize_into(bytes);
367        self.sbc.serialize_into(bytes);
368    }
369}
370impl From<&BufferSwapCompleteEvent> for [u8; 32] {
371    fn from(input: &BufferSwapCompleteEvent) -> Self {
372        let response_type_bytes = input.response_type.serialize();
373        let sequence_bytes = input.sequence.serialize();
374        let event_type_bytes = input.event_type.serialize();
375        let drawable_bytes = input.drawable.serialize();
376        let ust_hi_bytes = input.ust_hi.serialize();
377        let ust_lo_bytes = input.ust_lo.serialize();
378        let msc_hi_bytes = input.msc_hi.serialize();
379        let msc_lo_bytes = input.msc_lo.serialize();
380        let sbc_bytes = input.sbc.serialize();
381        [
382            response_type_bytes[0],
383            0,
384            sequence_bytes[0],
385            sequence_bytes[1],
386            event_type_bytes[0],
387            event_type_bytes[1],
388            0,
389            0,
390            drawable_bytes[0],
391            drawable_bytes[1],
392            drawable_bytes[2],
393            drawable_bytes[3],
394            ust_hi_bytes[0],
395            ust_hi_bytes[1],
396            ust_hi_bytes[2],
397            ust_hi_bytes[3],
398            ust_lo_bytes[0],
399            ust_lo_bytes[1],
400            ust_lo_bytes[2],
401            ust_lo_bytes[3],
402            msc_hi_bytes[0],
403            msc_hi_bytes[1],
404            msc_hi_bytes[2],
405            msc_hi_bytes[3],
406            msc_lo_bytes[0],
407            msc_lo_bytes[1],
408            msc_lo_bytes[2],
409            msc_lo_bytes[3],
410            sbc_bytes[0],
411            sbc_bytes[1],
412            sbc_bytes[2],
413            sbc_bytes[3],
414        ]
415    }
416}
417impl From<BufferSwapCompleteEvent> for [u8; 32] {
418    fn from(input: BufferSwapCompleteEvent) -> Self {
419        Self::from(&input)
420    }
421}
422
423#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
424#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
425pub struct PBCET(u16);
426impl PBCET {
427    pub const DAMAGED: Self = Self(32791);
428    pub const SAVED: Self = Self(32792);
429}
430impl From<PBCET> for u16 {
431    #[inline]
432    fn from(input: PBCET) -> Self {
433        input.0
434    }
435}
436impl From<PBCET> for Option<u16> {
437    #[inline]
438    fn from(input: PBCET) -> Self {
439        Some(input.0)
440    }
441}
442impl From<PBCET> for u32 {
443    #[inline]
444    fn from(input: PBCET) -> Self {
445        u32::from(input.0)
446    }
447}
448impl From<PBCET> for Option<u32> {
449    #[inline]
450    fn from(input: PBCET) -> Self {
451        Some(u32::from(input.0))
452    }
453}
454impl From<u8> for PBCET {
455    #[inline]
456    fn from(value: u8) -> Self {
457        Self(value.into())
458    }
459}
460impl From<u16> for PBCET {
461    #[inline]
462    fn from(value: u16) -> Self {
463        Self(value)
464    }
465}
466impl core::fmt::Debug for PBCET  {
467    fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
468        let variants = [
469            (Self::DAMAGED.0.into(), "DAMAGED", "Damaged"),
470            (Self::SAVED.0.into(), "SAVED", "Saved"),
471        ];
472        pretty_print_enum(fmt, self.0.into(), &variants)
473    }
474}
475
476#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
477#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
478pub struct PBCDT(u16);
479impl PBCDT {
480    pub const WINDOW: Self = Self(32793);
481    pub const PBUFFER: Self = Self(32794);
482}
483impl From<PBCDT> for u16 {
484    #[inline]
485    fn from(input: PBCDT) -> Self {
486        input.0
487    }
488}
489impl From<PBCDT> for Option<u16> {
490    #[inline]
491    fn from(input: PBCDT) -> Self {
492        Some(input.0)
493    }
494}
495impl From<PBCDT> for u32 {
496    #[inline]
497    fn from(input: PBCDT) -> Self {
498        u32::from(input.0)
499    }
500}
501impl From<PBCDT> for Option<u32> {
502    #[inline]
503    fn from(input: PBCDT) -> Self {
504        Some(u32::from(input.0))
505    }
506}
507impl From<u8> for PBCDT {
508    #[inline]
509    fn from(value: u8) -> Self {
510        Self(value.into())
511    }
512}
513impl From<u16> for PBCDT {
514    #[inline]
515    fn from(value: u16) -> Self {
516        Self(value)
517    }
518}
519impl core::fmt::Debug for PBCDT  {
520    fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
521        let variants = [
522            (Self::WINDOW.0.into(), "WINDOW", "Window"),
523            (Self::PBUFFER.0.into(), "PBUFFER", "Pbuffer"),
524        ];
525        pretty_print_enum(fmt, self.0.into(), &variants)
526    }
527}
528
529/// Opcode for the Render request
530pub const RENDER_REQUEST: u8 = 1;
531#[derive(Clone, Default)]
532#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
533#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
534pub struct RenderRequest<'input> {
535    pub context_tag: ContextTag,
536    pub data: Cow<'input, [u8]>,
537}
538impl_debug_if_no_extra_traits!(RenderRequest<'_>, "RenderRequest");
539impl<'input> RenderRequest<'input> {
540    /// Serialize this request into bytes for the provided connection
541    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
542        let length_so_far = 0;
543        let context_tag_bytes = self.context_tag.serialize();
544        let mut request0 = vec![
545            major_opcode,
546            RENDER_REQUEST,
547            0,
548            0,
549            context_tag_bytes[0],
550            context_tag_bytes[1],
551            context_tag_bytes[2],
552            context_tag_bytes[3],
553        ];
554        let length_so_far = length_so_far + request0.len();
555        let length_so_far = length_so_far + self.data.len();
556        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
557        let length_so_far = length_so_far + padding0.len();
558        assert_eq!(length_so_far % 4, 0);
559        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
560        request0[2..4].copy_from_slice(&length.to_ne_bytes());
561        ([request0.into(), self.data, padding0.into()], vec![])
562    }
563    /// Parse this request given its header, its body, and any fds that go along with it
564    #[cfg(feature = "request-parsing")]
565    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
566        if header.minor_opcode != RENDER_REQUEST {
567            return Err(ParseError::InvalidValue);
568        }
569        let (context_tag, remaining) = ContextTag::try_parse(value)?;
570        let (data, remaining) = remaining.split_at(remaining.len());
571        let _ = remaining;
572        Ok(RenderRequest {
573            context_tag,
574            data: Cow::Borrowed(data),
575        })
576    }
577    /// Clone all borrowed data in this RenderRequest.
578    pub fn into_owned(self) -> RenderRequest<'static> {
579        RenderRequest {
580            context_tag: self.context_tag,
581            data: Cow::Owned(self.data.into_owned()),
582        }
583    }
584}
585impl<'input> Request for RenderRequest<'input> {
586    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
587
588    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
589        let (bufs, fds) = self.serialize(major_opcode);
590        // Flatten the buffers into a single vector
591        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
592        (buf, fds)
593    }
594}
595impl<'input> crate::x11_utils::VoidRequest for RenderRequest<'input> {
596}
597
598/// Opcode for the RenderLarge request
599pub const RENDER_LARGE_REQUEST: u8 = 2;
600#[derive(Clone, Default)]
601#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
602#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
603pub struct RenderLargeRequest<'input> {
604    pub context_tag: ContextTag,
605    pub request_num: u16,
606    pub request_total: u16,
607    pub data: Cow<'input, [u8]>,
608}
609impl_debug_if_no_extra_traits!(RenderLargeRequest<'_>, "RenderLargeRequest");
610impl<'input> RenderLargeRequest<'input> {
611    /// Serialize this request into bytes for the provided connection
612    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
613        let length_so_far = 0;
614        let context_tag_bytes = self.context_tag.serialize();
615        let request_num_bytes = self.request_num.serialize();
616        let request_total_bytes = self.request_total.serialize();
617        let data_len = u32::try_from(self.data.len()).expect("`data` has too many elements");
618        let data_len_bytes = data_len.serialize();
619        let mut request0 = vec![
620            major_opcode,
621            RENDER_LARGE_REQUEST,
622            0,
623            0,
624            context_tag_bytes[0],
625            context_tag_bytes[1],
626            context_tag_bytes[2],
627            context_tag_bytes[3],
628            request_num_bytes[0],
629            request_num_bytes[1],
630            request_total_bytes[0],
631            request_total_bytes[1],
632            data_len_bytes[0],
633            data_len_bytes[1],
634            data_len_bytes[2],
635            data_len_bytes[3],
636        ];
637        let length_so_far = length_so_far + request0.len();
638        let length_so_far = length_so_far + self.data.len();
639        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
640        let length_so_far = length_so_far + padding0.len();
641        assert_eq!(length_so_far % 4, 0);
642        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
643        request0[2..4].copy_from_slice(&length.to_ne_bytes());
644        ([request0.into(), self.data, padding0.into()], vec![])
645    }
646    /// Parse this request given its header, its body, and any fds that go along with it
647    #[cfg(feature = "request-parsing")]
648    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
649        if header.minor_opcode != RENDER_LARGE_REQUEST {
650            return Err(ParseError::InvalidValue);
651        }
652        let (context_tag, remaining) = ContextTag::try_parse(value)?;
653        let (request_num, remaining) = u16::try_parse(remaining)?;
654        let (request_total, remaining) = u16::try_parse(remaining)?;
655        let (data_len, remaining) = u32::try_parse(remaining)?;
656        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, data_len.try_to_usize()?)?;
657        let _ = remaining;
658        Ok(RenderLargeRequest {
659            context_tag,
660            request_num,
661            request_total,
662            data: Cow::Borrowed(data),
663        })
664    }
665    /// Clone all borrowed data in this RenderLargeRequest.
666    pub fn into_owned(self) -> RenderLargeRequest<'static> {
667        RenderLargeRequest {
668            context_tag: self.context_tag,
669            request_num: self.request_num,
670            request_total: self.request_total,
671            data: Cow::Owned(self.data.into_owned()),
672        }
673    }
674}
675impl<'input> Request for RenderLargeRequest<'input> {
676    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
677
678    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
679        let (bufs, fds) = self.serialize(major_opcode);
680        // Flatten the buffers into a single vector
681        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
682        (buf, fds)
683    }
684}
685impl<'input> crate::x11_utils::VoidRequest for RenderLargeRequest<'input> {
686}
687
688/// Opcode for the CreateContext request
689pub const CREATE_CONTEXT_REQUEST: u8 = 3;
690#[derive(Clone, Copy, Default)]
691#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
692#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
693pub struct CreateContextRequest {
694    pub context: Context,
695    pub visual: xproto::Visualid,
696    pub screen: u32,
697    pub share_list: Context,
698    pub is_direct: bool,
699}
700impl_debug_if_no_extra_traits!(CreateContextRequest, "CreateContextRequest");
701impl CreateContextRequest {
702    /// Serialize this request into bytes for the provided connection
703    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
704        let length_so_far = 0;
705        let context_bytes = self.context.serialize();
706        let visual_bytes = self.visual.serialize();
707        let screen_bytes = self.screen.serialize();
708        let share_list_bytes = self.share_list.serialize();
709        let is_direct_bytes = self.is_direct.serialize();
710        let mut request0 = vec![
711            major_opcode,
712            CREATE_CONTEXT_REQUEST,
713            0,
714            0,
715            context_bytes[0],
716            context_bytes[1],
717            context_bytes[2],
718            context_bytes[3],
719            visual_bytes[0],
720            visual_bytes[1],
721            visual_bytes[2],
722            visual_bytes[3],
723            screen_bytes[0],
724            screen_bytes[1],
725            screen_bytes[2],
726            screen_bytes[3],
727            share_list_bytes[0],
728            share_list_bytes[1],
729            share_list_bytes[2],
730            share_list_bytes[3],
731            is_direct_bytes[0],
732            0,
733            0,
734            0,
735        ];
736        let length_so_far = length_so_far + request0.len();
737        assert_eq!(length_so_far % 4, 0);
738        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
739        request0[2..4].copy_from_slice(&length.to_ne_bytes());
740        ([request0.into()], vec![])
741    }
742    /// Parse this request given its header, its body, and any fds that go along with it
743    #[cfg(feature = "request-parsing")]
744    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
745        if header.minor_opcode != CREATE_CONTEXT_REQUEST {
746            return Err(ParseError::InvalidValue);
747        }
748        let (context, remaining) = Context::try_parse(value)?;
749        let (visual, remaining) = xproto::Visualid::try_parse(remaining)?;
750        let (screen, remaining) = u32::try_parse(remaining)?;
751        let (share_list, remaining) = Context::try_parse(remaining)?;
752        let (is_direct, remaining) = bool::try_parse(remaining)?;
753        let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
754        let _ = remaining;
755        Ok(CreateContextRequest {
756            context,
757            visual,
758            screen,
759            share_list,
760            is_direct,
761        })
762    }
763}
764impl Request for CreateContextRequest {
765    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
766
767    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
768        let (bufs, fds) = self.serialize(major_opcode);
769        // Flatten the buffers into a single vector
770        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
771        (buf, fds)
772    }
773}
774impl crate::x11_utils::VoidRequest for CreateContextRequest {
775}
776
777/// Opcode for the DestroyContext request
778pub const DESTROY_CONTEXT_REQUEST: u8 = 4;
779#[derive(Clone, Copy, Default)]
780#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
781#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
782pub struct DestroyContextRequest {
783    pub context: Context,
784}
785impl_debug_if_no_extra_traits!(DestroyContextRequest, "DestroyContextRequest");
786impl DestroyContextRequest {
787    /// Serialize this request into bytes for the provided connection
788    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
789        let length_so_far = 0;
790        let context_bytes = self.context.serialize();
791        let mut request0 = vec![
792            major_opcode,
793            DESTROY_CONTEXT_REQUEST,
794            0,
795            0,
796            context_bytes[0],
797            context_bytes[1],
798            context_bytes[2],
799            context_bytes[3],
800        ];
801        let length_so_far = length_so_far + request0.len();
802        assert_eq!(length_so_far % 4, 0);
803        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
804        request0[2..4].copy_from_slice(&length.to_ne_bytes());
805        ([request0.into()], vec![])
806    }
807    /// Parse this request given its header, its body, and any fds that go along with it
808    #[cfg(feature = "request-parsing")]
809    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
810        if header.minor_opcode != DESTROY_CONTEXT_REQUEST {
811            return Err(ParseError::InvalidValue);
812        }
813        let (context, remaining) = Context::try_parse(value)?;
814        let _ = remaining;
815        Ok(DestroyContextRequest {
816            context,
817        })
818    }
819}
820impl Request for DestroyContextRequest {
821    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
822
823    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
824        let (bufs, fds) = self.serialize(major_opcode);
825        // Flatten the buffers into a single vector
826        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
827        (buf, fds)
828    }
829}
830impl crate::x11_utils::VoidRequest for DestroyContextRequest {
831}
832
833/// Opcode for the MakeCurrent request
834pub const MAKE_CURRENT_REQUEST: u8 = 5;
835#[derive(Clone, Copy, Default)]
836#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
837#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
838pub struct MakeCurrentRequest {
839    pub drawable: Drawable,
840    pub context: Context,
841    pub old_context_tag: ContextTag,
842}
843impl_debug_if_no_extra_traits!(MakeCurrentRequest, "MakeCurrentRequest");
844impl MakeCurrentRequest {
845    /// Serialize this request into bytes for the provided connection
846    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
847        let length_so_far = 0;
848        let drawable_bytes = self.drawable.serialize();
849        let context_bytes = self.context.serialize();
850        let old_context_tag_bytes = self.old_context_tag.serialize();
851        let mut request0 = vec![
852            major_opcode,
853            MAKE_CURRENT_REQUEST,
854            0,
855            0,
856            drawable_bytes[0],
857            drawable_bytes[1],
858            drawable_bytes[2],
859            drawable_bytes[3],
860            context_bytes[0],
861            context_bytes[1],
862            context_bytes[2],
863            context_bytes[3],
864            old_context_tag_bytes[0],
865            old_context_tag_bytes[1],
866            old_context_tag_bytes[2],
867            old_context_tag_bytes[3],
868        ];
869        let length_so_far = length_so_far + request0.len();
870        assert_eq!(length_so_far % 4, 0);
871        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
872        request0[2..4].copy_from_slice(&length.to_ne_bytes());
873        ([request0.into()], vec![])
874    }
875    /// Parse this request given its header, its body, and any fds that go along with it
876    #[cfg(feature = "request-parsing")]
877    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
878        if header.minor_opcode != MAKE_CURRENT_REQUEST {
879            return Err(ParseError::InvalidValue);
880        }
881        let (drawable, remaining) = Drawable::try_parse(value)?;
882        let (context, remaining) = Context::try_parse(remaining)?;
883        let (old_context_tag, remaining) = ContextTag::try_parse(remaining)?;
884        let _ = remaining;
885        Ok(MakeCurrentRequest {
886            drawable,
887            context,
888            old_context_tag,
889        })
890    }
891}
892impl Request for MakeCurrentRequest {
893    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
894
895    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
896        let (bufs, fds) = self.serialize(major_opcode);
897        // Flatten the buffers into a single vector
898        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
899        (buf, fds)
900    }
901}
902impl crate::x11_utils::ReplyRequest for MakeCurrentRequest {
903    type Reply = MakeCurrentReply;
904}
905
906#[derive(Clone, Copy, Default)]
907#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
908#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
909pub struct MakeCurrentReply {
910    pub sequence: u16,
911    pub length: u32,
912    pub context_tag: ContextTag,
913}
914impl_debug_if_no_extra_traits!(MakeCurrentReply, "MakeCurrentReply");
915impl TryParse for MakeCurrentReply {
916    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
917        let remaining = initial_value;
918        let (response_type, remaining) = u8::try_parse(remaining)?;
919        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
920        let (sequence, remaining) = u16::try_parse(remaining)?;
921        let (length, remaining) = u32::try_parse(remaining)?;
922        let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
923        let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
924        if response_type != 1 {
925            return Err(ParseError::InvalidValue);
926        }
927        let result = MakeCurrentReply { sequence, length, context_tag };
928        let _ = remaining;
929        let remaining = initial_value.get(32 + length as usize * 4..)
930            .ok_or(ParseError::InsufficientData)?;
931        Ok((result, remaining))
932    }
933}
934impl Serialize for MakeCurrentReply {
935    type Bytes = [u8; 32];
936    fn serialize(&self) -> [u8; 32] {
937        let response_type_bytes = &[1];
938        let sequence_bytes = self.sequence.serialize();
939        let length_bytes = self.length.serialize();
940        let context_tag_bytes = self.context_tag.serialize();
941        [
942            response_type_bytes[0],
943            0,
944            sequence_bytes[0],
945            sequence_bytes[1],
946            length_bytes[0],
947            length_bytes[1],
948            length_bytes[2],
949            length_bytes[3],
950            context_tag_bytes[0],
951            context_tag_bytes[1],
952            context_tag_bytes[2],
953            context_tag_bytes[3],
954            0,
955            0,
956            0,
957            0,
958            0,
959            0,
960            0,
961            0,
962            0,
963            0,
964            0,
965            0,
966            0,
967            0,
968            0,
969            0,
970            0,
971            0,
972            0,
973            0,
974        ]
975    }
976    fn serialize_into(&self, bytes: &mut Vec<u8>) {
977        bytes.reserve(32);
978        let response_type_bytes = &[1];
979        bytes.push(response_type_bytes[0]);
980        bytes.extend_from_slice(&[0; 1]);
981        self.sequence.serialize_into(bytes);
982        self.length.serialize_into(bytes);
983        self.context_tag.serialize_into(bytes);
984        bytes.extend_from_slice(&[0; 20]);
985    }
986}
987
988/// Opcode for the IsDirect request
989pub const IS_DIRECT_REQUEST: u8 = 6;
990#[derive(Clone, Copy, Default)]
991#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
992#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
993pub struct IsDirectRequest {
994    pub context: Context,
995}
996impl_debug_if_no_extra_traits!(IsDirectRequest, "IsDirectRequest");
997impl IsDirectRequest {
998    /// Serialize this request into bytes for the provided connection
999    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1000        let length_so_far = 0;
1001        let context_bytes = self.context.serialize();
1002        let mut request0 = vec![
1003            major_opcode,
1004            IS_DIRECT_REQUEST,
1005            0,
1006            0,
1007            context_bytes[0],
1008            context_bytes[1],
1009            context_bytes[2],
1010            context_bytes[3],
1011        ];
1012        let length_so_far = length_so_far + request0.len();
1013        assert_eq!(length_so_far % 4, 0);
1014        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1015        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1016        ([request0.into()], vec![])
1017    }
1018    /// Parse this request given its header, its body, and any fds that go along with it
1019    #[cfg(feature = "request-parsing")]
1020    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1021        if header.minor_opcode != IS_DIRECT_REQUEST {
1022            return Err(ParseError::InvalidValue);
1023        }
1024        let (context, remaining) = Context::try_parse(value)?;
1025        let _ = remaining;
1026        Ok(IsDirectRequest {
1027            context,
1028        })
1029    }
1030}
1031impl Request for IsDirectRequest {
1032    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1033
1034    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1035        let (bufs, fds) = self.serialize(major_opcode);
1036        // Flatten the buffers into a single vector
1037        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1038        (buf, fds)
1039    }
1040}
1041impl crate::x11_utils::ReplyRequest for IsDirectRequest {
1042    type Reply = IsDirectReply;
1043}
1044
1045#[derive(Clone, Copy, Default)]
1046#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1047#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1048pub struct IsDirectReply {
1049    pub sequence: u16,
1050    pub length: u32,
1051    pub is_direct: bool,
1052}
1053impl_debug_if_no_extra_traits!(IsDirectReply, "IsDirectReply");
1054impl TryParse for IsDirectReply {
1055    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1056        let remaining = initial_value;
1057        let (response_type, remaining) = u8::try_parse(remaining)?;
1058        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1059        let (sequence, remaining) = u16::try_parse(remaining)?;
1060        let (length, remaining) = u32::try_parse(remaining)?;
1061        let (is_direct, remaining) = bool::try_parse(remaining)?;
1062        let remaining = remaining.get(23..).ok_or(ParseError::InsufficientData)?;
1063        if response_type != 1 {
1064            return Err(ParseError::InvalidValue);
1065        }
1066        let result = IsDirectReply { sequence, length, is_direct };
1067        let _ = remaining;
1068        let remaining = initial_value.get(32 + length as usize * 4..)
1069            .ok_or(ParseError::InsufficientData)?;
1070        Ok((result, remaining))
1071    }
1072}
1073impl Serialize for IsDirectReply {
1074    type Bytes = [u8; 32];
1075    fn serialize(&self) -> [u8; 32] {
1076        let response_type_bytes = &[1];
1077        let sequence_bytes = self.sequence.serialize();
1078        let length_bytes = self.length.serialize();
1079        let is_direct_bytes = self.is_direct.serialize();
1080        [
1081            response_type_bytes[0],
1082            0,
1083            sequence_bytes[0],
1084            sequence_bytes[1],
1085            length_bytes[0],
1086            length_bytes[1],
1087            length_bytes[2],
1088            length_bytes[3],
1089            is_direct_bytes[0],
1090            0,
1091            0,
1092            0,
1093            0,
1094            0,
1095            0,
1096            0,
1097            0,
1098            0,
1099            0,
1100            0,
1101            0,
1102            0,
1103            0,
1104            0,
1105            0,
1106            0,
1107            0,
1108            0,
1109            0,
1110            0,
1111            0,
1112            0,
1113        ]
1114    }
1115    fn serialize_into(&self, bytes: &mut Vec<u8>) {
1116        bytes.reserve(32);
1117        let response_type_bytes = &[1];
1118        bytes.push(response_type_bytes[0]);
1119        bytes.extend_from_slice(&[0; 1]);
1120        self.sequence.serialize_into(bytes);
1121        self.length.serialize_into(bytes);
1122        self.is_direct.serialize_into(bytes);
1123        bytes.extend_from_slice(&[0; 23]);
1124    }
1125}
1126
1127/// Opcode for the QueryVersion request
1128pub const QUERY_VERSION_REQUEST: u8 = 7;
1129#[derive(Clone, Copy, Default)]
1130#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1131#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1132pub struct QueryVersionRequest {
1133    pub major_version: u32,
1134    pub minor_version: u32,
1135}
1136impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest");
1137impl QueryVersionRequest {
1138    /// Serialize this request into bytes for the provided connection
1139    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1140        let length_so_far = 0;
1141        let major_version_bytes = self.major_version.serialize();
1142        let minor_version_bytes = self.minor_version.serialize();
1143        let mut request0 = vec![
1144            major_opcode,
1145            QUERY_VERSION_REQUEST,
1146            0,
1147            0,
1148            major_version_bytes[0],
1149            major_version_bytes[1],
1150            major_version_bytes[2],
1151            major_version_bytes[3],
1152            minor_version_bytes[0],
1153            minor_version_bytes[1],
1154            minor_version_bytes[2],
1155            minor_version_bytes[3],
1156        ];
1157        let length_so_far = length_so_far + request0.len();
1158        assert_eq!(length_so_far % 4, 0);
1159        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1160        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1161        ([request0.into()], vec![])
1162    }
1163    /// Parse this request given its header, its body, and any fds that go along with it
1164    #[cfg(feature = "request-parsing")]
1165    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1166        if header.minor_opcode != QUERY_VERSION_REQUEST {
1167            return Err(ParseError::InvalidValue);
1168        }
1169        let (major_version, remaining) = u32::try_parse(value)?;
1170        let (minor_version, remaining) = u32::try_parse(remaining)?;
1171        let _ = remaining;
1172        Ok(QueryVersionRequest {
1173            major_version,
1174            minor_version,
1175        })
1176    }
1177}
1178impl Request for QueryVersionRequest {
1179    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1180
1181    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1182        let (bufs, fds) = self.serialize(major_opcode);
1183        // Flatten the buffers into a single vector
1184        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1185        (buf, fds)
1186    }
1187}
1188impl crate::x11_utils::ReplyRequest for QueryVersionRequest {
1189    type Reply = QueryVersionReply;
1190}
1191
1192#[derive(Clone, Copy, Default)]
1193#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1194#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1195pub struct QueryVersionReply {
1196    pub sequence: u16,
1197    pub length: u32,
1198    pub major_version: u32,
1199    pub minor_version: u32,
1200}
1201impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply");
1202impl TryParse for QueryVersionReply {
1203    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1204        let remaining = initial_value;
1205        let (response_type, remaining) = u8::try_parse(remaining)?;
1206        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1207        let (sequence, remaining) = u16::try_parse(remaining)?;
1208        let (length, remaining) = u32::try_parse(remaining)?;
1209        let (major_version, remaining) = u32::try_parse(remaining)?;
1210        let (minor_version, remaining) = u32::try_parse(remaining)?;
1211        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
1212        if response_type != 1 {
1213            return Err(ParseError::InvalidValue);
1214        }
1215        let result = QueryVersionReply { sequence, length, major_version, minor_version };
1216        let _ = remaining;
1217        let remaining = initial_value.get(32 + length as usize * 4..)
1218            .ok_or(ParseError::InsufficientData)?;
1219        Ok((result, remaining))
1220    }
1221}
1222impl Serialize for QueryVersionReply {
1223    type Bytes = [u8; 32];
1224    fn serialize(&self) -> [u8; 32] {
1225        let response_type_bytes = &[1];
1226        let sequence_bytes = self.sequence.serialize();
1227        let length_bytes = self.length.serialize();
1228        let major_version_bytes = self.major_version.serialize();
1229        let minor_version_bytes = self.minor_version.serialize();
1230        [
1231            response_type_bytes[0],
1232            0,
1233            sequence_bytes[0],
1234            sequence_bytes[1],
1235            length_bytes[0],
1236            length_bytes[1],
1237            length_bytes[2],
1238            length_bytes[3],
1239            major_version_bytes[0],
1240            major_version_bytes[1],
1241            major_version_bytes[2],
1242            major_version_bytes[3],
1243            minor_version_bytes[0],
1244            minor_version_bytes[1],
1245            minor_version_bytes[2],
1246            minor_version_bytes[3],
1247            0,
1248            0,
1249            0,
1250            0,
1251            0,
1252            0,
1253            0,
1254            0,
1255            0,
1256            0,
1257            0,
1258            0,
1259            0,
1260            0,
1261            0,
1262            0,
1263        ]
1264    }
1265    fn serialize_into(&self, bytes: &mut Vec<u8>) {
1266        bytes.reserve(32);
1267        let response_type_bytes = &[1];
1268        bytes.push(response_type_bytes[0]);
1269        bytes.extend_from_slice(&[0; 1]);
1270        self.sequence.serialize_into(bytes);
1271        self.length.serialize_into(bytes);
1272        self.major_version.serialize_into(bytes);
1273        self.minor_version.serialize_into(bytes);
1274        bytes.extend_from_slice(&[0; 16]);
1275    }
1276}
1277
1278/// Opcode for the WaitGL request
1279pub const WAIT_GL_REQUEST: u8 = 8;
1280#[derive(Clone, Copy, Default)]
1281#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1282#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1283pub struct WaitGLRequest {
1284    pub context_tag: ContextTag,
1285}
1286impl_debug_if_no_extra_traits!(WaitGLRequest, "WaitGLRequest");
1287impl WaitGLRequest {
1288    /// Serialize this request into bytes for the provided connection
1289    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1290        let length_so_far = 0;
1291        let context_tag_bytes = self.context_tag.serialize();
1292        let mut request0 = vec![
1293            major_opcode,
1294            WAIT_GL_REQUEST,
1295            0,
1296            0,
1297            context_tag_bytes[0],
1298            context_tag_bytes[1],
1299            context_tag_bytes[2],
1300            context_tag_bytes[3],
1301        ];
1302        let length_so_far = length_so_far + request0.len();
1303        assert_eq!(length_so_far % 4, 0);
1304        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1305        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1306        ([request0.into()], vec![])
1307    }
1308    /// Parse this request given its header, its body, and any fds that go along with it
1309    #[cfg(feature = "request-parsing")]
1310    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1311        if header.minor_opcode != WAIT_GL_REQUEST {
1312            return Err(ParseError::InvalidValue);
1313        }
1314        let (context_tag, remaining) = ContextTag::try_parse(value)?;
1315        let _ = remaining;
1316        Ok(WaitGLRequest {
1317            context_tag,
1318        })
1319    }
1320}
1321impl Request for WaitGLRequest {
1322    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1323
1324    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1325        let (bufs, fds) = self.serialize(major_opcode);
1326        // Flatten the buffers into a single vector
1327        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1328        (buf, fds)
1329    }
1330}
1331impl crate::x11_utils::VoidRequest for WaitGLRequest {
1332}
1333
1334/// Opcode for the WaitX request
1335pub const WAIT_X_REQUEST: u8 = 9;
1336#[derive(Clone, Copy, Default)]
1337#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1338#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1339pub struct WaitXRequest {
1340    pub context_tag: ContextTag,
1341}
1342impl_debug_if_no_extra_traits!(WaitXRequest, "WaitXRequest");
1343impl WaitXRequest {
1344    /// Serialize this request into bytes for the provided connection
1345    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1346        let length_so_far = 0;
1347        let context_tag_bytes = self.context_tag.serialize();
1348        let mut request0 = vec![
1349            major_opcode,
1350            WAIT_X_REQUEST,
1351            0,
1352            0,
1353            context_tag_bytes[0],
1354            context_tag_bytes[1],
1355            context_tag_bytes[2],
1356            context_tag_bytes[3],
1357        ];
1358        let length_so_far = length_so_far + request0.len();
1359        assert_eq!(length_so_far % 4, 0);
1360        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1361        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1362        ([request0.into()], vec![])
1363    }
1364    /// Parse this request given its header, its body, and any fds that go along with it
1365    #[cfg(feature = "request-parsing")]
1366    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1367        if header.minor_opcode != WAIT_X_REQUEST {
1368            return Err(ParseError::InvalidValue);
1369        }
1370        let (context_tag, remaining) = ContextTag::try_parse(value)?;
1371        let _ = remaining;
1372        Ok(WaitXRequest {
1373            context_tag,
1374        })
1375    }
1376}
1377impl Request for WaitXRequest {
1378    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1379
1380    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1381        let (bufs, fds) = self.serialize(major_opcode);
1382        // Flatten the buffers into a single vector
1383        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1384        (buf, fds)
1385    }
1386}
1387impl crate::x11_utils::VoidRequest for WaitXRequest {
1388}
1389
1390/// Opcode for the CopyContext request
1391pub const COPY_CONTEXT_REQUEST: u8 = 10;
1392#[derive(Clone, Copy, Default)]
1393#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1394#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1395pub struct CopyContextRequest {
1396    pub src: Context,
1397    pub dest: Context,
1398    pub mask: u32,
1399    pub src_context_tag: ContextTag,
1400}
1401impl_debug_if_no_extra_traits!(CopyContextRequest, "CopyContextRequest");
1402impl CopyContextRequest {
1403    /// Serialize this request into bytes for the provided connection
1404    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1405        let length_so_far = 0;
1406        let src_bytes = self.src.serialize();
1407        let dest_bytes = self.dest.serialize();
1408        let mask_bytes = self.mask.serialize();
1409        let src_context_tag_bytes = self.src_context_tag.serialize();
1410        let mut request0 = vec![
1411            major_opcode,
1412            COPY_CONTEXT_REQUEST,
1413            0,
1414            0,
1415            src_bytes[0],
1416            src_bytes[1],
1417            src_bytes[2],
1418            src_bytes[3],
1419            dest_bytes[0],
1420            dest_bytes[1],
1421            dest_bytes[2],
1422            dest_bytes[3],
1423            mask_bytes[0],
1424            mask_bytes[1],
1425            mask_bytes[2],
1426            mask_bytes[3],
1427            src_context_tag_bytes[0],
1428            src_context_tag_bytes[1],
1429            src_context_tag_bytes[2],
1430            src_context_tag_bytes[3],
1431        ];
1432        let length_so_far = length_so_far + request0.len();
1433        assert_eq!(length_so_far % 4, 0);
1434        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1435        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1436        ([request0.into()], vec![])
1437    }
1438    /// Parse this request given its header, its body, and any fds that go along with it
1439    #[cfg(feature = "request-parsing")]
1440    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1441        if header.minor_opcode != COPY_CONTEXT_REQUEST {
1442            return Err(ParseError::InvalidValue);
1443        }
1444        let (src, remaining) = Context::try_parse(value)?;
1445        let (dest, remaining) = Context::try_parse(remaining)?;
1446        let (mask, remaining) = u32::try_parse(remaining)?;
1447        let (src_context_tag, remaining) = ContextTag::try_parse(remaining)?;
1448        let _ = remaining;
1449        Ok(CopyContextRequest {
1450            src,
1451            dest,
1452            mask,
1453            src_context_tag,
1454        })
1455    }
1456}
1457impl Request for CopyContextRequest {
1458    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1459
1460    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1461        let (bufs, fds) = self.serialize(major_opcode);
1462        // Flatten the buffers into a single vector
1463        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1464        (buf, fds)
1465    }
1466}
1467impl crate::x11_utils::VoidRequest for CopyContextRequest {
1468}
1469
1470#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1471#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1472pub struct GC(u32);
1473impl GC {
1474    pub const GL_CURRENT_BIT: Self = Self(1 << 0);
1475    pub const GL_POINT_BIT: Self = Self(1 << 1);
1476    pub const GL_LINE_BIT: Self = Self(1 << 2);
1477    pub const GL_POLYGON_BIT: Self = Self(1 << 3);
1478    pub const GL_POLYGON_STIPPLE_BIT: Self = Self(1 << 4);
1479    pub const GL_PIXEL_MODE_BIT: Self = Self(1 << 5);
1480    pub const GL_LIGHTING_BIT: Self = Self(1 << 6);
1481    pub const GL_FOG_BIT: Self = Self(1 << 7);
1482    pub const GL_DEPTH_BUFFER_BIT: Self = Self(1 << 8);
1483    pub const GL_ACCUM_BUFFER_BIT: Self = Self(1 << 9);
1484    pub const GL_STENCIL_BUFFER_BIT: Self = Self(1 << 10);
1485    pub const GL_VIEWPORT_BIT: Self = Self(1 << 11);
1486    pub const GL_TRANSFORM_BIT: Self = Self(1 << 12);
1487    pub const GL_ENABLE_BIT: Self = Self(1 << 13);
1488    pub const GL_COLOR_BUFFER_BIT: Self = Self(1 << 14);
1489    pub const GL_HINT_BIT: Self = Self(1 << 15);
1490    pub const GL_EVAL_BIT: Self = Self(1 << 16);
1491    pub const GL_LIST_BIT: Self = Self(1 << 17);
1492    pub const GL_TEXTURE_BIT: Self = Self(1 << 18);
1493    pub const GL_SCISSOR_BIT: Self = Self(1 << 19);
1494    pub const GL_ALL_ATTRIB_BITS: Self = Self(16_777_215);
1495}
1496impl From<GC> for u32 {
1497    #[inline]
1498    fn from(input: GC) -> Self {
1499        input.0
1500    }
1501}
1502impl From<GC> for Option<u32> {
1503    #[inline]
1504    fn from(input: GC) -> Self {
1505        Some(input.0)
1506    }
1507}
1508impl From<u8> for GC {
1509    #[inline]
1510    fn from(value: u8) -> Self {
1511        Self(value.into())
1512    }
1513}
1514impl From<u16> for GC {
1515    #[inline]
1516    fn from(value: u16) -> Self {
1517        Self(value.into())
1518    }
1519}
1520impl From<u32> for GC {
1521    #[inline]
1522    fn from(value: u32) -> Self {
1523        Self(value)
1524    }
1525}
1526impl core::fmt::Debug for GC  {
1527    fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1528        let variants = [
1529            (Self::GL_CURRENT_BIT.0, "GL_CURRENT_BIT", "GL_CURRENT_BIT"),
1530            (Self::GL_POINT_BIT.0, "GL_POINT_BIT", "GL_POINT_BIT"),
1531            (Self::GL_LINE_BIT.0, "GL_LINE_BIT", "GL_LINE_BIT"),
1532            (Self::GL_POLYGON_BIT.0, "GL_POLYGON_BIT", "GL_POLYGON_BIT"),
1533            (Self::GL_POLYGON_STIPPLE_BIT.0, "GL_POLYGON_STIPPLE_BIT", "GL_POLYGON_STIPPLE_BIT"),
1534            (Self::GL_PIXEL_MODE_BIT.0, "GL_PIXEL_MODE_BIT", "GL_PIXEL_MODE_BIT"),
1535            (Self::GL_LIGHTING_BIT.0, "GL_LIGHTING_BIT", "GL_LIGHTING_BIT"),
1536            (Self::GL_FOG_BIT.0, "GL_FOG_BIT", "GL_FOG_BIT"),
1537            (Self::GL_DEPTH_BUFFER_BIT.0, "GL_DEPTH_BUFFER_BIT", "GL_DEPTH_BUFFER_BIT"),
1538            (Self::GL_ACCUM_BUFFER_BIT.0, "GL_ACCUM_BUFFER_BIT", "GL_ACCUM_BUFFER_BIT"),
1539            (Self::GL_STENCIL_BUFFER_BIT.0, "GL_STENCIL_BUFFER_BIT", "GL_STENCIL_BUFFER_BIT"),
1540            (Self::GL_VIEWPORT_BIT.0, "GL_VIEWPORT_BIT", "GL_VIEWPORT_BIT"),
1541            (Self::GL_TRANSFORM_BIT.0, "GL_TRANSFORM_BIT", "GL_TRANSFORM_BIT"),
1542            (Self::GL_ENABLE_BIT.0, "GL_ENABLE_BIT", "GL_ENABLE_BIT"),
1543            (Self::GL_COLOR_BUFFER_BIT.0, "GL_COLOR_BUFFER_BIT", "GL_COLOR_BUFFER_BIT"),
1544            (Self::GL_HINT_BIT.0, "GL_HINT_BIT", "GL_HINT_BIT"),
1545            (Self::GL_EVAL_BIT.0, "GL_EVAL_BIT", "GL_EVAL_BIT"),
1546            (Self::GL_LIST_BIT.0, "GL_LIST_BIT", "GL_LIST_BIT"),
1547            (Self::GL_TEXTURE_BIT.0, "GL_TEXTURE_BIT", "GL_TEXTURE_BIT"),
1548            (Self::GL_SCISSOR_BIT.0, "GL_SCISSOR_BIT", "GL_SCISSOR_BIT"),
1549            (Self::GL_ALL_ATTRIB_BITS.0, "GL_ALL_ATTRIB_BITS", "GL_ALL_ATTRIB_BITS"),
1550        ];
1551        pretty_print_enum(fmt, self.0, &variants)
1552    }
1553}
1554
1555/// Opcode for the SwapBuffers request
1556pub const SWAP_BUFFERS_REQUEST: u8 = 11;
1557#[derive(Clone, Copy, Default)]
1558#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1559#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1560pub struct SwapBuffersRequest {
1561    pub context_tag: ContextTag,
1562    pub drawable: Drawable,
1563}
1564impl_debug_if_no_extra_traits!(SwapBuffersRequest, "SwapBuffersRequest");
1565impl SwapBuffersRequest {
1566    /// Serialize this request into bytes for the provided connection
1567    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1568        let length_so_far = 0;
1569        let context_tag_bytes = self.context_tag.serialize();
1570        let drawable_bytes = self.drawable.serialize();
1571        let mut request0 = vec![
1572            major_opcode,
1573            SWAP_BUFFERS_REQUEST,
1574            0,
1575            0,
1576            context_tag_bytes[0],
1577            context_tag_bytes[1],
1578            context_tag_bytes[2],
1579            context_tag_bytes[3],
1580            drawable_bytes[0],
1581            drawable_bytes[1],
1582            drawable_bytes[2],
1583            drawable_bytes[3],
1584        ];
1585        let length_so_far = length_so_far + request0.len();
1586        assert_eq!(length_so_far % 4, 0);
1587        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1588        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1589        ([request0.into()], vec![])
1590    }
1591    /// Parse this request given its header, its body, and any fds that go along with it
1592    #[cfg(feature = "request-parsing")]
1593    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1594        if header.minor_opcode != SWAP_BUFFERS_REQUEST {
1595            return Err(ParseError::InvalidValue);
1596        }
1597        let (context_tag, remaining) = ContextTag::try_parse(value)?;
1598        let (drawable, remaining) = Drawable::try_parse(remaining)?;
1599        let _ = remaining;
1600        Ok(SwapBuffersRequest {
1601            context_tag,
1602            drawable,
1603        })
1604    }
1605}
1606impl Request for SwapBuffersRequest {
1607    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1608
1609    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1610        let (bufs, fds) = self.serialize(major_opcode);
1611        // Flatten the buffers into a single vector
1612        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1613        (buf, fds)
1614    }
1615}
1616impl crate::x11_utils::VoidRequest for SwapBuffersRequest {
1617}
1618
1619/// Opcode for the UseXFont request
1620pub const USE_X_FONT_REQUEST: u8 = 12;
1621#[derive(Clone, Copy, Default)]
1622#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1623#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1624pub struct UseXFontRequest {
1625    pub context_tag: ContextTag,
1626    pub font: xproto::Font,
1627    pub first: u32,
1628    pub count: u32,
1629    pub list_base: u32,
1630}
1631impl_debug_if_no_extra_traits!(UseXFontRequest, "UseXFontRequest");
1632impl UseXFontRequest {
1633    /// Serialize this request into bytes for the provided connection
1634    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1635        let length_so_far = 0;
1636        let context_tag_bytes = self.context_tag.serialize();
1637        let font_bytes = self.font.serialize();
1638        let first_bytes = self.first.serialize();
1639        let count_bytes = self.count.serialize();
1640        let list_base_bytes = self.list_base.serialize();
1641        let mut request0 = vec![
1642            major_opcode,
1643            USE_X_FONT_REQUEST,
1644            0,
1645            0,
1646            context_tag_bytes[0],
1647            context_tag_bytes[1],
1648            context_tag_bytes[2],
1649            context_tag_bytes[3],
1650            font_bytes[0],
1651            font_bytes[1],
1652            font_bytes[2],
1653            font_bytes[3],
1654            first_bytes[0],
1655            first_bytes[1],
1656            first_bytes[2],
1657            first_bytes[3],
1658            count_bytes[0],
1659            count_bytes[1],
1660            count_bytes[2],
1661            count_bytes[3],
1662            list_base_bytes[0],
1663            list_base_bytes[1],
1664            list_base_bytes[2],
1665            list_base_bytes[3],
1666        ];
1667        let length_so_far = length_so_far + request0.len();
1668        assert_eq!(length_so_far % 4, 0);
1669        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1670        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1671        ([request0.into()], vec![])
1672    }
1673    /// Parse this request given its header, its body, and any fds that go along with it
1674    #[cfg(feature = "request-parsing")]
1675    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1676        if header.minor_opcode != USE_X_FONT_REQUEST {
1677            return Err(ParseError::InvalidValue);
1678        }
1679        let (context_tag, remaining) = ContextTag::try_parse(value)?;
1680        let (font, remaining) = xproto::Font::try_parse(remaining)?;
1681        let (first, remaining) = u32::try_parse(remaining)?;
1682        let (count, remaining) = u32::try_parse(remaining)?;
1683        let (list_base, remaining) = u32::try_parse(remaining)?;
1684        let _ = remaining;
1685        Ok(UseXFontRequest {
1686            context_tag,
1687            font,
1688            first,
1689            count,
1690            list_base,
1691        })
1692    }
1693}
1694impl Request for UseXFontRequest {
1695    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1696
1697    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1698        let (bufs, fds) = self.serialize(major_opcode);
1699        // Flatten the buffers into a single vector
1700        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1701        (buf, fds)
1702    }
1703}
1704impl crate::x11_utils::VoidRequest for UseXFontRequest {
1705}
1706
1707/// Opcode for the CreateGLXPixmap request
1708pub const CREATE_GLX_PIXMAP_REQUEST: u8 = 13;
1709#[derive(Clone, Copy, Default)]
1710#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1711#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1712pub struct CreateGLXPixmapRequest {
1713    pub screen: u32,
1714    pub visual: xproto::Visualid,
1715    pub pixmap: xproto::Pixmap,
1716    pub glx_pixmap: Pixmap,
1717}
1718impl_debug_if_no_extra_traits!(CreateGLXPixmapRequest, "CreateGLXPixmapRequest");
1719impl CreateGLXPixmapRequest {
1720    /// Serialize this request into bytes for the provided connection
1721    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1722        let length_so_far = 0;
1723        let screen_bytes = self.screen.serialize();
1724        let visual_bytes = self.visual.serialize();
1725        let pixmap_bytes = self.pixmap.serialize();
1726        let glx_pixmap_bytes = self.glx_pixmap.serialize();
1727        let mut request0 = vec![
1728            major_opcode,
1729            CREATE_GLX_PIXMAP_REQUEST,
1730            0,
1731            0,
1732            screen_bytes[0],
1733            screen_bytes[1],
1734            screen_bytes[2],
1735            screen_bytes[3],
1736            visual_bytes[0],
1737            visual_bytes[1],
1738            visual_bytes[2],
1739            visual_bytes[3],
1740            pixmap_bytes[0],
1741            pixmap_bytes[1],
1742            pixmap_bytes[2],
1743            pixmap_bytes[3],
1744            glx_pixmap_bytes[0],
1745            glx_pixmap_bytes[1],
1746            glx_pixmap_bytes[2],
1747            glx_pixmap_bytes[3],
1748        ];
1749        let length_so_far = length_so_far + request0.len();
1750        assert_eq!(length_so_far % 4, 0);
1751        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1752        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1753        ([request0.into()], vec![])
1754    }
1755    /// Parse this request given its header, its body, and any fds that go along with it
1756    #[cfg(feature = "request-parsing")]
1757    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1758        if header.minor_opcode != CREATE_GLX_PIXMAP_REQUEST {
1759            return Err(ParseError::InvalidValue);
1760        }
1761        let (screen, remaining) = u32::try_parse(value)?;
1762        let (visual, remaining) = xproto::Visualid::try_parse(remaining)?;
1763        let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?;
1764        let (glx_pixmap, remaining) = Pixmap::try_parse(remaining)?;
1765        let _ = remaining;
1766        Ok(CreateGLXPixmapRequest {
1767            screen,
1768            visual,
1769            pixmap,
1770            glx_pixmap,
1771        })
1772    }
1773}
1774impl Request for CreateGLXPixmapRequest {
1775    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1776
1777    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1778        let (bufs, fds) = self.serialize(major_opcode);
1779        // Flatten the buffers into a single vector
1780        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1781        (buf, fds)
1782    }
1783}
1784impl crate::x11_utils::VoidRequest for CreateGLXPixmapRequest {
1785}
1786
1787/// Opcode for the GetVisualConfigs request
1788pub const GET_VISUAL_CONFIGS_REQUEST: u8 = 14;
1789#[derive(Clone, Copy, Default)]
1790#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1791#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1792pub struct GetVisualConfigsRequest {
1793    pub screen: u32,
1794}
1795impl_debug_if_no_extra_traits!(GetVisualConfigsRequest, "GetVisualConfigsRequest");
1796impl GetVisualConfigsRequest {
1797    /// Serialize this request into bytes for the provided connection
1798    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1799        let length_so_far = 0;
1800        let screen_bytes = self.screen.serialize();
1801        let mut request0 = vec![
1802            major_opcode,
1803            GET_VISUAL_CONFIGS_REQUEST,
1804            0,
1805            0,
1806            screen_bytes[0],
1807            screen_bytes[1],
1808            screen_bytes[2],
1809            screen_bytes[3],
1810        ];
1811        let length_so_far = length_so_far + request0.len();
1812        assert_eq!(length_so_far % 4, 0);
1813        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1814        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1815        ([request0.into()], vec![])
1816    }
1817    /// Parse this request given its header, its body, and any fds that go along with it
1818    #[cfg(feature = "request-parsing")]
1819    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1820        if header.minor_opcode != GET_VISUAL_CONFIGS_REQUEST {
1821            return Err(ParseError::InvalidValue);
1822        }
1823        let (screen, remaining) = u32::try_parse(value)?;
1824        let _ = remaining;
1825        Ok(GetVisualConfigsRequest {
1826            screen,
1827        })
1828    }
1829}
1830impl Request for GetVisualConfigsRequest {
1831    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1832
1833    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1834        let (bufs, fds) = self.serialize(major_opcode);
1835        // Flatten the buffers into a single vector
1836        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1837        (buf, fds)
1838    }
1839}
1840impl crate::x11_utils::ReplyRequest for GetVisualConfigsRequest {
1841    type Reply = GetVisualConfigsReply;
1842}
1843
1844#[derive(Clone, Default)]
1845#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1846#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1847pub struct GetVisualConfigsReply {
1848    pub sequence: u16,
1849    pub num_visuals: u32,
1850    pub num_properties: u32,
1851    pub property_list: Vec<u32>,
1852}
1853impl_debug_if_no_extra_traits!(GetVisualConfigsReply, "GetVisualConfigsReply");
1854impl TryParse for GetVisualConfigsReply {
1855    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1856        let remaining = initial_value;
1857        let (response_type, remaining) = u8::try_parse(remaining)?;
1858        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1859        let (sequence, remaining) = u16::try_parse(remaining)?;
1860        let (length, remaining) = u32::try_parse(remaining)?;
1861        let (num_visuals, remaining) = u32::try_parse(remaining)?;
1862        let (num_properties, remaining) = u32::try_parse(remaining)?;
1863        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
1864        let (property_list, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
1865        if response_type != 1 {
1866            return Err(ParseError::InvalidValue);
1867        }
1868        let result = GetVisualConfigsReply { sequence, num_visuals, num_properties, property_list };
1869        let _ = remaining;
1870        let remaining = initial_value.get(32 + length as usize * 4..)
1871            .ok_or(ParseError::InsufficientData)?;
1872        Ok((result, remaining))
1873    }
1874}
1875impl Serialize for GetVisualConfigsReply {
1876    type Bytes = Vec<u8>;
1877    fn serialize(&self) -> Vec<u8> {
1878        let mut result = Vec::new();
1879        self.serialize_into(&mut result);
1880        result
1881    }
1882    fn serialize_into(&self, bytes: &mut Vec<u8>) {
1883        bytes.reserve(32);
1884        let response_type_bytes = &[1];
1885        bytes.push(response_type_bytes[0]);
1886        bytes.extend_from_slice(&[0; 1]);
1887        self.sequence.serialize_into(bytes);
1888        let length = u32::try_from(self.property_list.len()).expect("`property_list` has too many elements");
1889        length.serialize_into(bytes);
1890        self.num_visuals.serialize_into(bytes);
1891        self.num_properties.serialize_into(bytes);
1892        bytes.extend_from_slice(&[0; 16]);
1893        self.property_list.serialize_into(bytes);
1894    }
1895}
1896impl GetVisualConfigsReply {
1897    /// Get the value of the `length` field.
1898    ///
1899    /// The `length` field is used as the length field of the `property_list` field.
1900    /// This function computes the field's value again based on the length of the list.
1901    ///
1902    /// # Panics
1903    ///
1904    /// Panics if the value cannot be represented in the target type. This
1905    /// cannot happen with values of the struct received from the X11 server.
1906    pub fn length(&self) -> u32 {
1907        self.property_list.len()
1908            .try_into().unwrap()
1909    }
1910}
1911
1912/// Opcode for the DestroyGLXPixmap request
1913pub const DESTROY_GLX_PIXMAP_REQUEST: u8 = 15;
1914#[derive(Clone, Copy, Default)]
1915#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1916#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1917pub struct DestroyGLXPixmapRequest {
1918    pub glx_pixmap: Pixmap,
1919}
1920impl_debug_if_no_extra_traits!(DestroyGLXPixmapRequest, "DestroyGLXPixmapRequest");
1921impl DestroyGLXPixmapRequest {
1922    /// Serialize this request into bytes for the provided connection
1923    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
1924        let length_so_far = 0;
1925        let glx_pixmap_bytes = self.glx_pixmap.serialize();
1926        let mut request0 = vec![
1927            major_opcode,
1928            DESTROY_GLX_PIXMAP_REQUEST,
1929            0,
1930            0,
1931            glx_pixmap_bytes[0],
1932            glx_pixmap_bytes[1],
1933            glx_pixmap_bytes[2],
1934            glx_pixmap_bytes[3],
1935        ];
1936        let length_so_far = length_so_far + request0.len();
1937        assert_eq!(length_so_far % 4, 0);
1938        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1939        request0[2..4].copy_from_slice(&length.to_ne_bytes());
1940        ([request0.into()], vec![])
1941    }
1942    /// Parse this request given its header, its body, and any fds that go along with it
1943    #[cfg(feature = "request-parsing")]
1944    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1945        if header.minor_opcode != DESTROY_GLX_PIXMAP_REQUEST {
1946            return Err(ParseError::InvalidValue);
1947        }
1948        let (glx_pixmap, remaining) = Pixmap::try_parse(value)?;
1949        let _ = remaining;
1950        Ok(DestroyGLXPixmapRequest {
1951            glx_pixmap,
1952        })
1953    }
1954}
1955impl Request for DestroyGLXPixmapRequest {
1956    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
1957
1958    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
1959        let (bufs, fds) = self.serialize(major_opcode);
1960        // Flatten the buffers into a single vector
1961        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
1962        (buf, fds)
1963    }
1964}
1965impl crate::x11_utils::VoidRequest for DestroyGLXPixmapRequest {
1966}
1967
1968/// Opcode for the VendorPrivate request
1969pub const VENDOR_PRIVATE_REQUEST: u8 = 16;
1970#[derive(Clone, Default)]
1971#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
1972#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1973pub struct VendorPrivateRequest<'input> {
1974    pub vendor_code: u32,
1975    pub context_tag: ContextTag,
1976    pub data: Cow<'input, [u8]>,
1977}
1978impl_debug_if_no_extra_traits!(VendorPrivateRequest<'_>, "VendorPrivateRequest");
1979impl<'input> VendorPrivateRequest<'input> {
1980    /// Serialize this request into bytes for the provided connection
1981    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
1982        let length_so_far = 0;
1983        let vendor_code_bytes = self.vendor_code.serialize();
1984        let context_tag_bytes = self.context_tag.serialize();
1985        let mut request0 = vec![
1986            major_opcode,
1987            VENDOR_PRIVATE_REQUEST,
1988            0,
1989            0,
1990            vendor_code_bytes[0],
1991            vendor_code_bytes[1],
1992            vendor_code_bytes[2],
1993            vendor_code_bytes[3],
1994            context_tag_bytes[0],
1995            context_tag_bytes[1],
1996            context_tag_bytes[2],
1997            context_tag_bytes[3],
1998        ];
1999        let length_so_far = length_so_far + request0.len();
2000        let length_so_far = length_so_far + self.data.len();
2001        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2002        let length_so_far = length_so_far + padding0.len();
2003        assert_eq!(length_so_far % 4, 0);
2004        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2005        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2006        ([request0.into(), self.data, padding0.into()], vec![])
2007    }
2008    /// Parse this request given its header, its body, and any fds that go along with it
2009    #[cfg(feature = "request-parsing")]
2010    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2011        if header.minor_opcode != VENDOR_PRIVATE_REQUEST {
2012            return Err(ParseError::InvalidValue);
2013        }
2014        let (vendor_code, remaining) = u32::try_parse(value)?;
2015        let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
2016        let (data, remaining) = remaining.split_at(remaining.len());
2017        let _ = remaining;
2018        Ok(VendorPrivateRequest {
2019            vendor_code,
2020            context_tag,
2021            data: Cow::Borrowed(data),
2022        })
2023    }
2024    /// Clone all borrowed data in this VendorPrivateRequest.
2025    pub fn into_owned(self) -> VendorPrivateRequest<'static> {
2026        VendorPrivateRequest {
2027            vendor_code: self.vendor_code,
2028            context_tag: self.context_tag,
2029            data: Cow::Owned(self.data.into_owned()),
2030        }
2031    }
2032}
2033impl<'input> Request for VendorPrivateRequest<'input> {
2034    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2035
2036    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2037        let (bufs, fds) = self.serialize(major_opcode);
2038        // Flatten the buffers into a single vector
2039        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2040        (buf, fds)
2041    }
2042}
2043impl<'input> crate::x11_utils::VoidRequest for VendorPrivateRequest<'input> {
2044}
2045
2046/// Opcode for the VendorPrivateWithReply request
2047pub const VENDOR_PRIVATE_WITH_REPLY_REQUEST: u8 = 17;
2048#[derive(Clone, Default)]
2049#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2050#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2051pub struct VendorPrivateWithReplyRequest<'input> {
2052    pub vendor_code: u32,
2053    pub context_tag: ContextTag,
2054    pub data: Cow<'input, [u8]>,
2055}
2056impl_debug_if_no_extra_traits!(VendorPrivateWithReplyRequest<'_>, "VendorPrivateWithReplyRequest");
2057impl<'input> VendorPrivateWithReplyRequest<'input> {
2058    /// Serialize this request into bytes for the provided connection
2059    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
2060        let length_so_far = 0;
2061        let vendor_code_bytes = self.vendor_code.serialize();
2062        let context_tag_bytes = self.context_tag.serialize();
2063        let mut request0 = vec![
2064            major_opcode,
2065            VENDOR_PRIVATE_WITH_REPLY_REQUEST,
2066            0,
2067            0,
2068            vendor_code_bytes[0],
2069            vendor_code_bytes[1],
2070            vendor_code_bytes[2],
2071            vendor_code_bytes[3],
2072            context_tag_bytes[0],
2073            context_tag_bytes[1],
2074            context_tag_bytes[2],
2075            context_tag_bytes[3],
2076        ];
2077        let length_so_far = length_so_far + request0.len();
2078        let length_so_far = length_so_far + self.data.len();
2079        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2080        let length_so_far = length_so_far + padding0.len();
2081        assert_eq!(length_so_far % 4, 0);
2082        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2083        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2084        ([request0.into(), self.data, padding0.into()], vec![])
2085    }
2086    /// Parse this request given its header, its body, and any fds that go along with it
2087    #[cfg(feature = "request-parsing")]
2088    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2089        if header.minor_opcode != VENDOR_PRIVATE_WITH_REPLY_REQUEST {
2090            return Err(ParseError::InvalidValue);
2091        }
2092        let (vendor_code, remaining) = u32::try_parse(value)?;
2093        let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
2094        let (data, remaining) = remaining.split_at(remaining.len());
2095        let _ = remaining;
2096        Ok(VendorPrivateWithReplyRequest {
2097            vendor_code,
2098            context_tag,
2099            data: Cow::Borrowed(data),
2100        })
2101    }
2102    /// Clone all borrowed data in this VendorPrivateWithReplyRequest.
2103    pub fn into_owned(self) -> VendorPrivateWithReplyRequest<'static> {
2104        VendorPrivateWithReplyRequest {
2105            vendor_code: self.vendor_code,
2106            context_tag: self.context_tag,
2107            data: Cow::Owned(self.data.into_owned()),
2108        }
2109    }
2110}
2111impl<'input> Request for VendorPrivateWithReplyRequest<'input> {
2112    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2113
2114    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2115        let (bufs, fds) = self.serialize(major_opcode);
2116        // Flatten the buffers into a single vector
2117        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2118        (buf, fds)
2119    }
2120}
2121impl<'input> crate::x11_utils::ReplyRequest for VendorPrivateWithReplyRequest<'input> {
2122    type Reply = VendorPrivateWithReplyReply;
2123}
2124
2125#[derive(Clone, Default)]
2126#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2127#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2128pub struct VendorPrivateWithReplyReply {
2129    pub sequence: u16,
2130    pub retval: u32,
2131    pub data1: [u8; 24],
2132    pub data2: Vec<u8>,
2133}
2134impl_debug_if_no_extra_traits!(VendorPrivateWithReplyReply, "VendorPrivateWithReplyReply");
2135impl TryParse for VendorPrivateWithReplyReply {
2136    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2137        let remaining = initial_value;
2138        let (response_type, remaining) = u8::try_parse(remaining)?;
2139        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2140        let (sequence, remaining) = u16::try_parse(remaining)?;
2141        let (length, remaining) = u32::try_parse(remaining)?;
2142        let (retval, remaining) = u32::try_parse(remaining)?;
2143        let (data1, remaining) = crate::x11_utils::parse_u8_array::<24>(remaining)?;
2144        let (data2, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
2145        let data2 = data2.to_vec();
2146        if response_type != 1 {
2147            return Err(ParseError::InvalidValue);
2148        }
2149        let result = VendorPrivateWithReplyReply { sequence, retval, data1, data2 };
2150        let _ = remaining;
2151        let remaining = initial_value.get(32 + length as usize * 4..)
2152            .ok_or(ParseError::InsufficientData)?;
2153        Ok((result, remaining))
2154    }
2155}
2156impl Serialize for VendorPrivateWithReplyReply {
2157    type Bytes = Vec<u8>;
2158    fn serialize(&self) -> Vec<u8> {
2159        let mut result = Vec::new();
2160        self.serialize_into(&mut result);
2161        result
2162    }
2163    fn serialize_into(&self, bytes: &mut Vec<u8>) {
2164        bytes.reserve(36);
2165        let response_type_bytes = &[1];
2166        bytes.push(response_type_bytes[0]);
2167        bytes.extend_from_slice(&[0; 1]);
2168        self.sequence.serialize_into(bytes);
2169        assert_eq!(self.data2.len() % 4, 0, "`data2` has an incorrect length, must be a multiple of 4");
2170        let length = u32::try_from(self.data2.len() / 4).expect("`data2` has too many elements");
2171        length.serialize_into(bytes);
2172        self.retval.serialize_into(bytes);
2173        bytes.extend_from_slice(&self.data1);
2174        bytes.extend_from_slice(&self.data2);
2175    }
2176}
2177impl VendorPrivateWithReplyReply {
2178    /// Get the value of the `length` field.
2179    ///
2180    /// The `length` field is used as the length field of the `data2` field.
2181    /// This function computes the field's value again based on the length of the list.
2182    ///
2183    /// # Panics
2184    ///
2185    /// Panics if the value cannot be represented in the target type. This
2186    /// cannot happen with values of the struct received from the X11 server.
2187    pub fn length(&self) -> u32 {
2188        self.data2.len()
2189            .checked_div(4).unwrap()
2190            .try_into().unwrap()
2191    }
2192}
2193
2194/// Opcode for the QueryExtensionsString request
2195pub const QUERY_EXTENSIONS_STRING_REQUEST: u8 = 18;
2196#[derive(Clone, Copy, Default)]
2197#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2198#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2199pub struct QueryExtensionsStringRequest {
2200    pub screen: u32,
2201}
2202impl_debug_if_no_extra_traits!(QueryExtensionsStringRequest, "QueryExtensionsStringRequest");
2203impl QueryExtensionsStringRequest {
2204    /// Serialize this request into bytes for the provided connection
2205    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
2206        let length_so_far = 0;
2207        let screen_bytes = self.screen.serialize();
2208        let mut request0 = vec![
2209            major_opcode,
2210            QUERY_EXTENSIONS_STRING_REQUEST,
2211            0,
2212            0,
2213            screen_bytes[0],
2214            screen_bytes[1],
2215            screen_bytes[2],
2216            screen_bytes[3],
2217        ];
2218        let length_so_far = length_so_far + request0.len();
2219        assert_eq!(length_so_far % 4, 0);
2220        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2221        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2222        ([request0.into()], vec![])
2223    }
2224    /// Parse this request given its header, its body, and any fds that go along with it
2225    #[cfg(feature = "request-parsing")]
2226    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2227        if header.minor_opcode != QUERY_EXTENSIONS_STRING_REQUEST {
2228            return Err(ParseError::InvalidValue);
2229        }
2230        let (screen, remaining) = u32::try_parse(value)?;
2231        let _ = remaining;
2232        Ok(QueryExtensionsStringRequest {
2233            screen,
2234        })
2235    }
2236}
2237impl Request for QueryExtensionsStringRequest {
2238    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2239
2240    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2241        let (bufs, fds) = self.serialize(major_opcode);
2242        // Flatten the buffers into a single vector
2243        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2244        (buf, fds)
2245    }
2246}
2247impl crate::x11_utils::ReplyRequest for QueryExtensionsStringRequest {
2248    type Reply = QueryExtensionsStringReply;
2249}
2250
2251#[derive(Clone, Copy, Default)]
2252#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2253#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2254pub struct QueryExtensionsStringReply {
2255    pub sequence: u16,
2256    pub length: u32,
2257    pub n: u32,
2258}
2259impl_debug_if_no_extra_traits!(QueryExtensionsStringReply, "QueryExtensionsStringReply");
2260impl TryParse for QueryExtensionsStringReply {
2261    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2262        let remaining = initial_value;
2263        let (response_type, remaining) = u8::try_parse(remaining)?;
2264        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2265        let (sequence, remaining) = u16::try_parse(remaining)?;
2266        let (length, remaining) = u32::try_parse(remaining)?;
2267        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
2268        let (n, remaining) = u32::try_parse(remaining)?;
2269        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
2270        if response_type != 1 {
2271            return Err(ParseError::InvalidValue);
2272        }
2273        let result = QueryExtensionsStringReply { sequence, length, n };
2274        let _ = remaining;
2275        let remaining = initial_value.get(32 + length as usize * 4..)
2276            .ok_or(ParseError::InsufficientData)?;
2277        Ok((result, remaining))
2278    }
2279}
2280impl Serialize for QueryExtensionsStringReply {
2281    type Bytes = [u8; 32];
2282    fn serialize(&self) -> [u8; 32] {
2283        let response_type_bytes = &[1];
2284        let sequence_bytes = self.sequence.serialize();
2285        let length_bytes = self.length.serialize();
2286        let n_bytes = self.n.serialize();
2287        [
2288            response_type_bytes[0],
2289            0,
2290            sequence_bytes[0],
2291            sequence_bytes[1],
2292            length_bytes[0],
2293            length_bytes[1],
2294            length_bytes[2],
2295            length_bytes[3],
2296            0,
2297            0,
2298            0,
2299            0,
2300            n_bytes[0],
2301            n_bytes[1],
2302            n_bytes[2],
2303            n_bytes[3],
2304            0,
2305            0,
2306            0,
2307            0,
2308            0,
2309            0,
2310            0,
2311            0,
2312            0,
2313            0,
2314            0,
2315            0,
2316            0,
2317            0,
2318            0,
2319            0,
2320        ]
2321    }
2322    fn serialize_into(&self, bytes: &mut Vec<u8>) {
2323        bytes.reserve(32);
2324        let response_type_bytes = &[1];
2325        bytes.push(response_type_bytes[0]);
2326        bytes.extend_from_slice(&[0; 1]);
2327        self.sequence.serialize_into(bytes);
2328        self.length.serialize_into(bytes);
2329        bytes.extend_from_slice(&[0; 4]);
2330        self.n.serialize_into(bytes);
2331        bytes.extend_from_slice(&[0; 16]);
2332    }
2333}
2334
2335/// Opcode for the QueryServerString request
2336pub const QUERY_SERVER_STRING_REQUEST: u8 = 19;
2337#[derive(Clone, Copy, Default)]
2338#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2339#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2340pub struct QueryServerStringRequest {
2341    pub screen: u32,
2342    pub name: u32,
2343}
2344impl_debug_if_no_extra_traits!(QueryServerStringRequest, "QueryServerStringRequest");
2345impl QueryServerStringRequest {
2346    /// Serialize this request into bytes for the provided connection
2347    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
2348        let length_so_far = 0;
2349        let screen_bytes = self.screen.serialize();
2350        let name_bytes = self.name.serialize();
2351        let mut request0 = vec![
2352            major_opcode,
2353            QUERY_SERVER_STRING_REQUEST,
2354            0,
2355            0,
2356            screen_bytes[0],
2357            screen_bytes[1],
2358            screen_bytes[2],
2359            screen_bytes[3],
2360            name_bytes[0],
2361            name_bytes[1],
2362            name_bytes[2],
2363            name_bytes[3],
2364        ];
2365        let length_so_far = length_so_far + request0.len();
2366        assert_eq!(length_so_far % 4, 0);
2367        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2368        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2369        ([request0.into()], vec![])
2370    }
2371    /// Parse this request given its header, its body, and any fds that go along with it
2372    #[cfg(feature = "request-parsing")]
2373    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2374        if header.minor_opcode != QUERY_SERVER_STRING_REQUEST {
2375            return Err(ParseError::InvalidValue);
2376        }
2377        let (screen, remaining) = u32::try_parse(value)?;
2378        let (name, remaining) = u32::try_parse(remaining)?;
2379        let _ = remaining;
2380        Ok(QueryServerStringRequest {
2381            screen,
2382            name,
2383        })
2384    }
2385}
2386impl Request for QueryServerStringRequest {
2387    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2388
2389    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2390        let (bufs, fds) = self.serialize(major_opcode);
2391        // Flatten the buffers into a single vector
2392        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2393        (buf, fds)
2394    }
2395}
2396impl crate::x11_utils::ReplyRequest for QueryServerStringRequest {
2397    type Reply = QueryServerStringReply;
2398}
2399
2400#[derive(Clone, Default)]
2401#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2402#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2403pub struct QueryServerStringReply {
2404    pub sequence: u16,
2405    pub length: u32,
2406    pub string: Vec<u8>,
2407}
2408impl_debug_if_no_extra_traits!(QueryServerStringReply, "QueryServerStringReply");
2409impl TryParse for QueryServerStringReply {
2410    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2411        let remaining = initial_value;
2412        let (response_type, remaining) = u8::try_parse(remaining)?;
2413        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2414        let (sequence, remaining) = u16::try_parse(remaining)?;
2415        let (length, remaining) = u32::try_parse(remaining)?;
2416        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
2417        let (str_len, remaining) = u32::try_parse(remaining)?;
2418        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
2419        let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, str_len.try_to_usize()?)?;
2420        let string = string.to_vec();
2421        if response_type != 1 {
2422            return Err(ParseError::InvalidValue);
2423        }
2424        let result = QueryServerStringReply { sequence, length, string };
2425        let _ = remaining;
2426        let remaining = initial_value.get(32 + length as usize * 4..)
2427            .ok_or(ParseError::InsufficientData)?;
2428        Ok((result, remaining))
2429    }
2430}
2431impl Serialize for QueryServerStringReply {
2432    type Bytes = Vec<u8>;
2433    fn serialize(&self) -> Vec<u8> {
2434        let mut result = Vec::new();
2435        self.serialize_into(&mut result);
2436        result
2437    }
2438    fn serialize_into(&self, bytes: &mut Vec<u8>) {
2439        bytes.reserve(32);
2440        let response_type_bytes = &[1];
2441        bytes.push(response_type_bytes[0]);
2442        bytes.extend_from_slice(&[0; 1]);
2443        self.sequence.serialize_into(bytes);
2444        self.length.serialize_into(bytes);
2445        bytes.extend_from_slice(&[0; 4]);
2446        let str_len = u32::try_from(self.string.len()).expect("`string` has too many elements");
2447        str_len.serialize_into(bytes);
2448        bytes.extend_from_slice(&[0; 16]);
2449        bytes.extend_from_slice(&self.string);
2450    }
2451}
2452impl QueryServerStringReply {
2453    /// Get the value of the `str_len` field.
2454    ///
2455    /// The `str_len` field is used as the length field of the `string` field.
2456    /// This function computes the field's value again based on the length of the list.
2457    ///
2458    /// # Panics
2459    ///
2460    /// Panics if the value cannot be represented in the target type. This
2461    /// cannot happen with values of the struct received from the X11 server.
2462    pub fn str_len(&self) -> u32 {
2463        self.string.len()
2464            .try_into().unwrap()
2465    }
2466}
2467
2468/// Opcode for the ClientInfo request
2469pub const CLIENT_INFO_REQUEST: u8 = 20;
2470#[derive(Clone, Default)]
2471#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2472#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2473pub struct ClientInfoRequest<'input> {
2474    pub major_version: u32,
2475    pub minor_version: u32,
2476    pub string: Cow<'input, [u8]>,
2477}
2478impl_debug_if_no_extra_traits!(ClientInfoRequest<'_>, "ClientInfoRequest");
2479impl<'input> ClientInfoRequest<'input> {
2480    /// Serialize this request into bytes for the provided connection
2481    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
2482        let length_so_far = 0;
2483        let major_version_bytes = self.major_version.serialize();
2484        let minor_version_bytes = self.minor_version.serialize();
2485        let str_len = u32::try_from(self.string.len()).expect("`string` has too many elements");
2486        let str_len_bytes = str_len.serialize();
2487        let mut request0 = vec![
2488            major_opcode,
2489            CLIENT_INFO_REQUEST,
2490            0,
2491            0,
2492            major_version_bytes[0],
2493            major_version_bytes[1],
2494            major_version_bytes[2],
2495            major_version_bytes[3],
2496            minor_version_bytes[0],
2497            minor_version_bytes[1],
2498            minor_version_bytes[2],
2499            minor_version_bytes[3],
2500            str_len_bytes[0],
2501            str_len_bytes[1],
2502            str_len_bytes[2],
2503            str_len_bytes[3],
2504        ];
2505        let length_so_far = length_so_far + request0.len();
2506        let length_so_far = length_so_far + self.string.len();
2507        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2508        let length_so_far = length_so_far + padding0.len();
2509        assert_eq!(length_so_far % 4, 0);
2510        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2511        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2512        ([request0.into(), self.string, padding0.into()], vec![])
2513    }
2514    /// Parse this request given its header, its body, and any fds that go along with it
2515    #[cfg(feature = "request-parsing")]
2516    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2517        if header.minor_opcode != CLIENT_INFO_REQUEST {
2518            return Err(ParseError::InvalidValue);
2519        }
2520        let (major_version, remaining) = u32::try_parse(value)?;
2521        let (minor_version, remaining) = u32::try_parse(remaining)?;
2522        let (str_len, remaining) = u32::try_parse(remaining)?;
2523        let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, str_len.try_to_usize()?)?;
2524        let _ = remaining;
2525        Ok(ClientInfoRequest {
2526            major_version,
2527            minor_version,
2528            string: Cow::Borrowed(string),
2529        })
2530    }
2531    /// Clone all borrowed data in this ClientInfoRequest.
2532    pub fn into_owned(self) -> ClientInfoRequest<'static> {
2533        ClientInfoRequest {
2534            major_version: self.major_version,
2535            minor_version: self.minor_version,
2536            string: Cow::Owned(self.string.into_owned()),
2537        }
2538    }
2539}
2540impl<'input> Request for ClientInfoRequest<'input> {
2541    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2542
2543    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2544        let (bufs, fds) = self.serialize(major_opcode);
2545        // Flatten the buffers into a single vector
2546        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2547        (buf, fds)
2548    }
2549}
2550impl<'input> crate::x11_utils::VoidRequest for ClientInfoRequest<'input> {
2551}
2552
2553/// Opcode for the GetFBConfigs request
2554pub const GET_FB_CONFIGS_REQUEST: u8 = 21;
2555#[derive(Clone, Copy, Default)]
2556#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2557#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2558pub struct GetFBConfigsRequest {
2559    pub screen: u32,
2560}
2561impl_debug_if_no_extra_traits!(GetFBConfigsRequest, "GetFBConfigsRequest");
2562impl GetFBConfigsRequest {
2563    /// Serialize this request into bytes for the provided connection
2564    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
2565        let length_so_far = 0;
2566        let screen_bytes = self.screen.serialize();
2567        let mut request0 = vec![
2568            major_opcode,
2569            GET_FB_CONFIGS_REQUEST,
2570            0,
2571            0,
2572            screen_bytes[0],
2573            screen_bytes[1],
2574            screen_bytes[2],
2575            screen_bytes[3],
2576        ];
2577        let length_so_far = length_so_far + request0.len();
2578        assert_eq!(length_so_far % 4, 0);
2579        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2580        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2581        ([request0.into()], vec![])
2582    }
2583    /// Parse this request given its header, its body, and any fds that go along with it
2584    #[cfg(feature = "request-parsing")]
2585    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2586        if header.minor_opcode != GET_FB_CONFIGS_REQUEST {
2587            return Err(ParseError::InvalidValue);
2588        }
2589        let (screen, remaining) = u32::try_parse(value)?;
2590        let _ = remaining;
2591        Ok(GetFBConfigsRequest {
2592            screen,
2593        })
2594    }
2595}
2596impl Request for GetFBConfigsRequest {
2597    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2598
2599    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2600        let (bufs, fds) = self.serialize(major_opcode);
2601        // Flatten the buffers into a single vector
2602        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2603        (buf, fds)
2604    }
2605}
2606impl crate::x11_utils::ReplyRequest for GetFBConfigsRequest {
2607    type Reply = GetFBConfigsReply;
2608}
2609
2610#[derive(Clone, Default)]
2611#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2612#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2613pub struct GetFBConfigsReply {
2614    pub sequence: u16,
2615    pub num_fb_configs: u32,
2616    pub num_properties: u32,
2617    pub property_list: Vec<u32>,
2618}
2619impl_debug_if_no_extra_traits!(GetFBConfigsReply, "GetFBConfigsReply");
2620impl TryParse for GetFBConfigsReply {
2621    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2622        let remaining = initial_value;
2623        let (response_type, remaining) = u8::try_parse(remaining)?;
2624        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2625        let (sequence, remaining) = u16::try_parse(remaining)?;
2626        let (length, remaining) = u32::try_parse(remaining)?;
2627        let (num_fb_configs, remaining) = u32::try_parse(remaining)?;
2628        let (num_properties, remaining) = u32::try_parse(remaining)?;
2629        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
2630        let (property_list, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
2631        if response_type != 1 {
2632            return Err(ParseError::InvalidValue);
2633        }
2634        let result = GetFBConfigsReply { sequence, num_fb_configs, num_properties, property_list };
2635        let _ = remaining;
2636        let remaining = initial_value.get(32 + length as usize * 4..)
2637            .ok_or(ParseError::InsufficientData)?;
2638        Ok((result, remaining))
2639    }
2640}
2641impl Serialize for GetFBConfigsReply {
2642    type Bytes = Vec<u8>;
2643    fn serialize(&self) -> Vec<u8> {
2644        let mut result = Vec::new();
2645        self.serialize_into(&mut result);
2646        result
2647    }
2648    fn serialize_into(&self, bytes: &mut Vec<u8>) {
2649        bytes.reserve(32);
2650        let response_type_bytes = &[1];
2651        bytes.push(response_type_bytes[0]);
2652        bytes.extend_from_slice(&[0; 1]);
2653        self.sequence.serialize_into(bytes);
2654        let length = u32::try_from(self.property_list.len()).expect("`property_list` has too many elements");
2655        length.serialize_into(bytes);
2656        self.num_fb_configs.serialize_into(bytes);
2657        self.num_properties.serialize_into(bytes);
2658        bytes.extend_from_slice(&[0; 16]);
2659        self.property_list.serialize_into(bytes);
2660    }
2661}
2662impl GetFBConfigsReply {
2663    /// Get the value of the `length` field.
2664    ///
2665    /// The `length` field is used as the length field of the `property_list` field.
2666    /// This function computes the field's value again based on the length of the list.
2667    ///
2668    /// # Panics
2669    ///
2670    /// Panics if the value cannot be represented in the target type. This
2671    /// cannot happen with values of the struct received from the X11 server.
2672    pub fn length(&self) -> u32 {
2673        self.property_list.len()
2674            .try_into().unwrap()
2675    }
2676}
2677
2678/// Opcode for the CreatePixmap request
2679pub const CREATE_PIXMAP_REQUEST: u8 = 22;
2680#[derive(Clone, Default)]
2681#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2682#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2683pub struct CreatePixmapRequest<'input> {
2684    pub screen: u32,
2685    pub fbconfig: Fbconfig,
2686    pub pixmap: xproto::Pixmap,
2687    pub glx_pixmap: Pixmap,
2688    pub attribs: Cow<'input, [u32]>,
2689}
2690impl_debug_if_no_extra_traits!(CreatePixmapRequest<'_>, "CreatePixmapRequest");
2691impl<'input> CreatePixmapRequest<'input> {
2692    /// Serialize this request into bytes for the provided connection
2693    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
2694        let length_so_far = 0;
2695        let screen_bytes = self.screen.serialize();
2696        let fbconfig_bytes = self.fbconfig.serialize();
2697        let pixmap_bytes = self.pixmap.serialize();
2698        let glx_pixmap_bytes = self.glx_pixmap.serialize();
2699        assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
2700        let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
2701        let num_attribs_bytes = num_attribs.serialize();
2702        let mut request0 = vec![
2703            major_opcode,
2704            CREATE_PIXMAP_REQUEST,
2705            0,
2706            0,
2707            screen_bytes[0],
2708            screen_bytes[1],
2709            screen_bytes[2],
2710            screen_bytes[3],
2711            fbconfig_bytes[0],
2712            fbconfig_bytes[1],
2713            fbconfig_bytes[2],
2714            fbconfig_bytes[3],
2715            pixmap_bytes[0],
2716            pixmap_bytes[1],
2717            pixmap_bytes[2],
2718            pixmap_bytes[3],
2719            glx_pixmap_bytes[0],
2720            glx_pixmap_bytes[1],
2721            glx_pixmap_bytes[2],
2722            glx_pixmap_bytes[3],
2723            num_attribs_bytes[0],
2724            num_attribs_bytes[1],
2725            num_attribs_bytes[2],
2726            num_attribs_bytes[3],
2727        ];
2728        let length_so_far = length_so_far + request0.len();
2729        let attribs_bytes = self.attribs.serialize();
2730        let length_so_far = length_so_far + attribs_bytes.len();
2731        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2732        let length_so_far = length_so_far + padding0.len();
2733        assert_eq!(length_so_far % 4, 0);
2734        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2735        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2736        ([request0.into(), attribs_bytes.into(), padding0.into()], vec![])
2737    }
2738    /// Parse this request given its header, its body, and any fds that go along with it
2739    #[cfg(feature = "request-parsing")]
2740    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2741        if header.minor_opcode != CREATE_PIXMAP_REQUEST {
2742            return Err(ParseError::InvalidValue);
2743        }
2744        let (screen, remaining) = u32::try_parse(value)?;
2745        let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
2746        let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?;
2747        let (glx_pixmap, remaining) = Pixmap::try_parse(remaining)?;
2748        let (num_attribs, remaining) = u32::try_parse(remaining)?;
2749        let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
2750        let _ = remaining;
2751        Ok(CreatePixmapRequest {
2752            screen,
2753            fbconfig,
2754            pixmap,
2755            glx_pixmap,
2756            attribs: Cow::Owned(attribs),
2757        })
2758    }
2759    /// Clone all borrowed data in this CreatePixmapRequest.
2760    pub fn into_owned(self) -> CreatePixmapRequest<'static> {
2761        CreatePixmapRequest {
2762            screen: self.screen,
2763            fbconfig: self.fbconfig,
2764            pixmap: self.pixmap,
2765            glx_pixmap: self.glx_pixmap,
2766            attribs: Cow::Owned(self.attribs.into_owned()),
2767        }
2768    }
2769}
2770impl<'input> Request for CreatePixmapRequest<'input> {
2771    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2772
2773    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2774        let (bufs, fds) = self.serialize(major_opcode);
2775        // Flatten the buffers into a single vector
2776        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2777        (buf, fds)
2778    }
2779}
2780impl<'input> crate::x11_utils::VoidRequest for CreatePixmapRequest<'input> {
2781}
2782
2783/// Opcode for the DestroyPixmap request
2784pub const DESTROY_PIXMAP_REQUEST: u8 = 23;
2785#[derive(Clone, Copy, Default)]
2786#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2787#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2788pub struct DestroyPixmapRequest {
2789    pub glx_pixmap: Pixmap,
2790}
2791impl_debug_if_no_extra_traits!(DestroyPixmapRequest, "DestroyPixmapRequest");
2792impl DestroyPixmapRequest {
2793    /// Serialize this request into bytes for the provided connection
2794    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
2795        let length_so_far = 0;
2796        let glx_pixmap_bytes = self.glx_pixmap.serialize();
2797        let mut request0 = vec![
2798            major_opcode,
2799            DESTROY_PIXMAP_REQUEST,
2800            0,
2801            0,
2802            glx_pixmap_bytes[0],
2803            glx_pixmap_bytes[1],
2804            glx_pixmap_bytes[2],
2805            glx_pixmap_bytes[3],
2806        ];
2807        let length_so_far = length_so_far + request0.len();
2808        assert_eq!(length_so_far % 4, 0);
2809        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2810        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2811        ([request0.into()], vec![])
2812    }
2813    /// Parse this request given its header, its body, and any fds that go along with it
2814    #[cfg(feature = "request-parsing")]
2815    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2816        if header.minor_opcode != DESTROY_PIXMAP_REQUEST {
2817            return Err(ParseError::InvalidValue);
2818        }
2819        let (glx_pixmap, remaining) = Pixmap::try_parse(value)?;
2820        let _ = remaining;
2821        Ok(DestroyPixmapRequest {
2822            glx_pixmap,
2823        })
2824    }
2825}
2826impl Request for DestroyPixmapRequest {
2827    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2828
2829    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2830        let (bufs, fds) = self.serialize(major_opcode);
2831        // Flatten the buffers into a single vector
2832        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2833        (buf, fds)
2834    }
2835}
2836impl crate::x11_utils::VoidRequest for DestroyPixmapRequest {
2837}
2838
2839/// Opcode for the CreateNewContext request
2840pub const CREATE_NEW_CONTEXT_REQUEST: u8 = 24;
2841#[derive(Clone, Copy, Default)]
2842#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2843#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2844pub struct CreateNewContextRequest {
2845    pub context: Context,
2846    pub fbconfig: Fbconfig,
2847    pub screen: u32,
2848    pub render_type: u32,
2849    pub share_list: Context,
2850    pub is_direct: bool,
2851}
2852impl_debug_if_no_extra_traits!(CreateNewContextRequest, "CreateNewContextRequest");
2853impl CreateNewContextRequest {
2854    /// Serialize this request into bytes for the provided connection
2855    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
2856        let length_so_far = 0;
2857        let context_bytes = self.context.serialize();
2858        let fbconfig_bytes = self.fbconfig.serialize();
2859        let screen_bytes = self.screen.serialize();
2860        let render_type_bytes = self.render_type.serialize();
2861        let share_list_bytes = self.share_list.serialize();
2862        let is_direct_bytes = self.is_direct.serialize();
2863        let mut request0 = vec![
2864            major_opcode,
2865            CREATE_NEW_CONTEXT_REQUEST,
2866            0,
2867            0,
2868            context_bytes[0],
2869            context_bytes[1],
2870            context_bytes[2],
2871            context_bytes[3],
2872            fbconfig_bytes[0],
2873            fbconfig_bytes[1],
2874            fbconfig_bytes[2],
2875            fbconfig_bytes[3],
2876            screen_bytes[0],
2877            screen_bytes[1],
2878            screen_bytes[2],
2879            screen_bytes[3],
2880            render_type_bytes[0],
2881            render_type_bytes[1],
2882            render_type_bytes[2],
2883            render_type_bytes[3],
2884            share_list_bytes[0],
2885            share_list_bytes[1],
2886            share_list_bytes[2],
2887            share_list_bytes[3],
2888            is_direct_bytes[0],
2889            0,
2890            0,
2891            0,
2892        ];
2893        let length_so_far = length_so_far + request0.len();
2894        assert_eq!(length_so_far % 4, 0);
2895        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2896        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2897        ([request0.into()], vec![])
2898    }
2899    /// Parse this request given its header, its body, and any fds that go along with it
2900    #[cfg(feature = "request-parsing")]
2901    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2902        if header.minor_opcode != CREATE_NEW_CONTEXT_REQUEST {
2903            return Err(ParseError::InvalidValue);
2904        }
2905        let (context, remaining) = Context::try_parse(value)?;
2906        let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
2907        let (screen, remaining) = u32::try_parse(remaining)?;
2908        let (render_type, remaining) = u32::try_parse(remaining)?;
2909        let (share_list, remaining) = Context::try_parse(remaining)?;
2910        let (is_direct, remaining) = bool::try_parse(remaining)?;
2911        let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2912        let _ = remaining;
2913        Ok(CreateNewContextRequest {
2914            context,
2915            fbconfig,
2916            screen,
2917            render_type,
2918            share_list,
2919            is_direct,
2920        })
2921    }
2922}
2923impl Request for CreateNewContextRequest {
2924    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2925
2926    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2927        let (bufs, fds) = self.serialize(major_opcode);
2928        // Flatten the buffers into a single vector
2929        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2930        (buf, fds)
2931    }
2932}
2933impl crate::x11_utils::VoidRequest for CreateNewContextRequest {
2934}
2935
2936/// Opcode for the QueryContext request
2937pub const QUERY_CONTEXT_REQUEST: u8 = 25;
2938#[derive(Clone, Copy, Default)]
2939#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2940#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2941pub struct QueryContextRequest {
2942    pub context: Context,
2943}
2944impl_debug_if_no_extra_traits!(QueryContextRequest, "QueryContextRequest");
2945impl QueryContextRequest {
2946    /// Serialize this request into bytes for the provided connection
2947    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
2948        let length_so_far = 0;
2949        let context_bytes = self.context.serialize();
2950        let mut request0 = vec![
2951            major_opcode,
2952            QUERY_CONTEXT_REQUEST,
2953            0,
2954            0,
2955            context_bytes[0],
2956            context_bytes[1],
2957            context_bytes[2],
2958            context_bytes[3],
2959        ];
2960        let length_so_far = length_so_far + request0.len();
2961        assert_eq!(length_so_far % 4, 0);
2962        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2963        request0[2..4].copy_from_slice(&length.to_ne_bytes());
2964        ([request0.into()], vec![])
2965    }
2966    /// Parse this request given its header, its body, and any fds that go along with it
2967    #[cfg(feature = "request-parsing")]
2968    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2969        if header.minor_opcode != QUERY_CONTEXT_REQUEST {
2970            return Err(ParseError::InvalidValue);
2971        }
2972        let (context, remaining) = Context::try_parse(value)?;
2973        let _ = remaining;
2974        Ok(QueryContextRequest {
2975            context,
2976        })
2977    }
2978}
2979impl Request for QueryContextRequest {
2980    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
2981
2982    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
2983        let (bufs, fds) = self.serialize(major_opcode);
2984        // Flatten the buffers into a single vector
2985        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
2986        (buf, fds)
2987    }
2988}
2989impl crate::x11_utils::ReplyRequest for QueryContextRequest {
2990    type Reply = QueryContextReply;
2991}
2992
2993#[derive(Clone, Default)]
2994#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
2995#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2996pub struct QueryContextReply {
2997    pub sequence: u16,
2998    pub length: u32,
2999    pub attribs: Vec<u32>,
3000}
3001impl_debug_if_no_extra_traits!(QueryContextReply, "QueryContextReply");
3002impl TryParse for QueryContextReply {
3003    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
3004        let remaining = initial_value;
3005        let (response_type, remaining) = u8::try_parse(remaining)?;
3006        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
3007        let (sequence, remaining) = u16::try_parse(remaining)?;
3008        let (length, remaining) = u32::try_parse(remaining)?;
3009        let (num_attribs, remaining) = u32::try_parse(remaining)?;
3010        let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
3011        let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3012        if response_type != 1 {
3013            return Err(ParseError::InvalidValue);
3014        }
3015        let result = QueryContextReply { sequence, length, attribs };
3016        let _ = remaining;
3017        let remaining = initial_value.get(32 + length as usize * 4..)
3018            .ok_or(ParseError::InsufficientData)?;
3019        Ok((result, remaining))
3020    }
3021}
3022impl Serialize for QueryContextReply {
3023    type Bytes = Vec<u8>;
3024    fn serialize(&self) -> Vec<u8> {
3025        let mut result = Vec::new();
3026        self.serialize_into(&mut result);
3027        result
3028    }
3029    fn serialize_into(&self, bytes: &mut Vec<u8>) {
3030        bytes.reserve(32);
3031        let response_type_bytes = &[1];
3032        bytes.push(response_type_bytes[0]);
3033        bytes.extend_from_slice(&[0; 1]);
3034        self.sequence.serialize_into(bytes);
3035        self.length.serialize_into(bytes);
3036        assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3037        let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3038        num_attribs.serialize_into(bytes);
3039        bytes.extend_from_slice(&[0; 20]);
3040        self.attribs.serialize_into(bytes);
3041    }
3042}
3043impl QueryContextReply {
3044    /// Get the value of the `num_attribs` field.
3045    ///
3046    /// The `num_attribs` field is used as the length field of the `attribs` field.
3047    /// This function computes the field's value again based on the length of the list.
3048    ///
3049    /// # Panics
3050    ///
3051    /// Panics if the value cannot be represented in the target type. This
3052    /// cannot happen with values of the struct received from the X11 server.
3053    pub fn num_attribs(&self) -> u32 {
3054        self.attribs.len()
3055            .checked_div(2).unwrap()
3056            .try_into().unwrap()
3057    }
3058}
3059
3060/// Opcode for the MakeContextCurrent request
3061pub const MAKE_CONTEXT_CURRENT_REQUEST: u8 = 26;
3062#[derive(Clone, Copy, Default)]
3063#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3064#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3065pub struct MakeContextCurrentRequest {
3066    pub old_context_tag: ContextTag,
3067    pub drawable: Drawable,
3068    pub read_drawable: Drawable,
3069    pub context: Context,
3070}
3071impl_debug_if_no_extra_traits!(MakeContextCurrentRequest, "MakeContextCurrentRequest");
3072impl MakeContextCurrentRequest {
3073    /// Serialize this request into bytes for the provided connection
3074    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
3075        let length_so_far = 0;
3076        let old_context_tag_bytes = self.old_context_tag.serialize();
3077        let drawable_bytes = self.drawable.serialize();
3078        let read_drawable_bytes = self.read_drawable.serialize();
3079        let context_bytes = self.context.serialize();
3080        let mut request0 = vec![
3081            major_opcode,
3082            MAKE_CONTEXT_CURRENT_REQUEST,
3083            0,
3084            0,
3085            old_context_tag_bytes[0],
3086            old_context_tag_bytes[1],
3087            old_context_tag_bytes[2],
3088            old_context_tag_bytes[3],
3089            drawable_bytes[0],
3090            drawable_bytes[1],
3091            drawable_bytes[2],
3092            drawable_bytes[3],
3093            read_drawable_bytes[0],
3094            read_drawable_bytes[1],
3095            read_drawable_bytes[2],
3096            read_drawable_bytes[3],
3097            context_bytes[0],
3098            context_bytes[1],
3099            context_bytes[2],
3100            context_bytes[3],
3101        ];
3102        let length_so_far = length_so_far + request0.len();
3103        assert_eq!(length_so_far % 4, 0);
3104        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3105        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3106        ([request0.into()], vec![])
3107    }
3108    /// Parse this request given its header, its body, and any fds that go along with it
3109    #[cfg(feature = "request-parsing")]
3110    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3111        if header.minor_opcode != MAKE_CONTEXT_CURRENT_REQUEST {
3112            return Err(ParseError::InvalidValue);
3113        }
3114        let (old_context_tag, remaining) = ContextTag::try_parse(value)?;
3115        let (drawable, remaining) = Drawable::try_parse(remaining)?;
3116        let (read_drawable, remaining) = Drawable::try_parse(remaining)?;
3117        let (context, remaining) = Context::try_parse(remaining)?;
3118        let _ = remaining;
3119        Ok(MakeContextCurrentRequest {
3120            old_context_tag,
3121            drawable,
3122            read_drawable,
3123            context,
3124        })
3125    }
3126}
3127impl Request for MakeContextCurrentRequest {
3128    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3129
3130    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3131        let (bufs, fds) = self.serialize(major_opcode);
3132        // Flatten the buffers into a single vector
3133        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3134        (buf, fds)
3135    }
3136}
3137impl crate::x11_utils::ReplyRequest for MakeContextCurrentRequest {
3138    type Reply = MakeContextCurrentReply;
3139}
3140
3141#[derive(Clone, Copy, Default)]
3142#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3143#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3144pub struct MakeContextCurrentReply {
3145    pub sequence: u16,
3146    pub length: u32,
3147    pub context_tag: ContextTag,
3148}
3149impl_debug_if_no_extra_traits!(MakeContextCurrentReply, "MakeContextCurrentReply");
3150impl TryParse for MakeContextCurrentReply {
3151    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
3152        let remaining = initial_value;
3153        let (response_type, remaining) = u8::try_parse(remaining)?;
3154        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
3155        let (sequence, remaining) = u16::try_parse(remaining)?;
3156        let (length, remaining) = u32::try_parse(remaining)?;
3157        let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
3158        let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
3159        if response_type != 1 {
3160            return Err(ParseError::InvalidValue);
3161        }
3162        let result = MakeContextCurrentReply { sequence, length, context_tag };
3163        let _ = remaining;
3164        let remaining = initial_value.get(32 + length as usize * 4..)
3165            .ok_or(ParseError::InsufficientData)?;
3166        Ok((result, remaining))
3167    }
3168}
3169impl Serialize for MakeContextCurrentReply {
3170    type Bytes = [u8; 32];
3171    fn serialize(&self) -> [u8; 32] {
3172        let response_type_bytes = &[1];
3173        let sequence_bytes = self.sequence.serialize();
3174        let length_bytes = self.length.serialize();
3175        let context_tag_bytes = self.context_tag.serialize();
3176        [
3177            response_type_bytes[0],
3178            0,
3179            sequence_bytes[0],
3180            sequence_bytes[1],
3181            length_bytes[0],
3182            length_bytes[1],
3183            length_bytes[2],
3184            length_bytes[3],
3185            context_tag_bytes[0],
3186            context_tag_bytes[1],
3187            context_tag_bytes[2],
3188            context_tag_bytes[3],
3189            0,
3190            0,
3191            0,
3192            0,
3193            0,
3194            0,
3195            0,
3196            0,
3197            0,
3198            0,
3199            0,
3200            0,
3201            0,
3202            0,
3203            0,
3204            0,
3205            0,
3206            0,
3207            0,
3208            0,
3209        ]
3210    }
3211    fn serialize_into(&self, bytes: &mut Vec<u8>) {
3212        bytes.reserve(32);
3213        let response_type_bytes = &[1];
3214        bytes.push(response_type_bytes[0]);
3215        bytes.extend_from_slice(&[0; 1]);
3216        self.sequence.serialize_into(bytes);
3217        self.length.serialize_into(bytes);
3218        self.context_tag.serialize_into(bytes);
3219        bytes.extend_from_slice(&[0; 20]);
3220    }
3221}
3222
3223/// Opcode for the CreatePbuffer request
3224pub const CREATE_PBUFFER_REQUEST: u8 = 27;
3225#[derive(Clone, Default)]
3226#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3227#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3228pub struct CreatePbufferRequest<'input> {
3229    pub screen: u32,
3230    pub fbconfig: Fbconfig,
3231    pub pbuffer: Pbuffer,
3232    pub attribs: Cow<'input, [u32]>,
3233}
3234impl_debug_if_no_extra_traits!(CreatePbufferRequest<'_>, "CreatePbufferRequest");
3235impl<'input> CreatePbufferRequest<'input> {
3236    /// Serialize this request into bytes for the provided connection
3237    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
3238        let length_so_far = 0;
3239        let screen_bytes = self.screen.serialize();
3240        let fbconfig_bytes = self.fbconfig.serialize();
3241        let pbuffer_bytes = self.pbuffer.serialize();
3242        assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3243        let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3244        let num_attribs_bytes = num_attribs.serialize();
3245        let mut request0 = vec![
3246            major_opcode,
3247            CREATE_PBUFFER_REQUEST,
3248            0,
3249            0,
3250            screen_bytes[0],
3251            screen_bytes[1],
3252            screen_bytes[2],
3253            screen_bytes[3],
3254            fbconfig_bytes[0],
3255            fbconfig_bytes[1],
3256            fbconfig_bytes[2],
3257            fbconfig_bytes[3],
3258            pbuffer_bytes[0],
3259            pbuffer_bytes[1],
3260            pbuffer_bytes[2],
3261            pbuffer_bytes[3],
3262            num_attribs_bytes[0],
3263            num_attribs_bytes[1],
3264            num_attribs_bytes[2],
3265            num_attribs_bytes[3],
3266        ];
3267        let length_so_far = length_so_far + request0.len();
3268        let attribs_bytes = self.attribs.serialize();
3269        let length_so_far = length_so_far + attribs_bytes.len();
3270        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3271        let length_so_far = length_so_far + padding0.len();
3272        assert_eq!(length_so_far % 4, 0);
3273        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3274        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3275        ([request0.into(), attribs_bytes.into(), padding0.into()], vec![])
3276    }
3277    /// Parse this request given its header, its body, and any fds that go along with it
3278    #[cfg(feature = "request-parsing")]
3279    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3280        if header.minor_opcode != CREATE_PBUFFER_REQUEST {
3281            return Err(ParseError::InvalidValue);
3282        }
3283        let (screen, remaining) = u32::try_parse(value)?;
3284        let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
3285        let (pbuffer, remaining) = Pbuffer::try_parse(remaining)?;
3286        let (num_attribs, remaining) = u32::try_parse(remaining)?;
3287        let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3288        let _ = remaining;
3289        Ok(CreatePbufferRequest {
3290            screen,
3291            fbconfig,
3292            pbuffer,
3293            attribs: Cow::Owned(attribs),
3294        })
3295    }
3296    /// Clone all borrowed data in this CreatePbufferRequest.
3297    pub fn into_owned(self) -> CreatePbufferRequest<'static> {
3298        CreatePbufferRequest {
3299            screen: self.screen,
3300            fbconfig: self.fbconfig,
3301            pbuffer: self.pbuffer,
3302            attribs: Cow::Owned(self.attribs.into_owned()),
3303        }
3304    }
3305}
3306impl<'input> Request for CreatePbufferRequest<'input> {
3307    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3308
3309    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3310        let (bufs, fds) = self.serialize(major_opcode);
3311        // Flatten the buffers into a single vector
3312        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3313        (buf, fds)
3314    }
3315}
3316impl<'input> crate::x11_utils::VoidRequest for CreatePbufferRequest<'input> {
3317}
3318
3319/// Opcode for the DestroyPbuffer request
3320pub const DESTROY_PBUFFER_REQUEST: u8 = 28;
3321#[derive(Clone, Copy, Default)]
3322#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3323#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3324pub struct DestroyPbufferRequest {
3325    pub pbuffer: Pbuffer,
3326}
3327impl_debug_if_no_extra_traits!(DestroyPbufferRequest, "DestroyPbufferRequest");
3328impl DestroyPbufferRequest {
3329    /// Serialize this request into bytes for the provided connection
3330    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
3331        let length_so_far = 0;
3332        let pbuffer_bytes = self.pbuffer.serialize();
3333        let mut request0 = vec![
3334            major_opcode,
3335            DESTROY_PBUFFER_REQUEST,
3336            0,
3337            0,
3338            pbuffer_bytes[0],
3339            pbuffer_bytes[1],
3340            pbuffer_bytes[2],
3341            pbuffer_bytes[3],
3342        ];
3343        let length_so_far = length_so_far + request0.len();
3344        assert_eq!(length_so_far % 4, 0);
3345        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3346        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3347        ([request0.into()], vec![])
3348    }
3349    /// Parse this request given its header, its body, and any fds that go along with it
3350    #[cfg(feature = "request-parsing")]
3351    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3352        if header.minor_opcode != DESTROY_PBUFFER_REQUEST {
3353            return Err(ParseError::InvalidValue);
3354        }
3355        let (pbuffer, remaining) = Pbuffer::try_parse(value)?;
3356        let _ = remaining;
3357        Ok(DestroyPbufferRequest {
3358            pbuffer,
3359        })
3360    }
3361}
3362impl Request for DestroyPbufferRequest {
3363    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3364
3365    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3366        let (bufs, fds) = self.serialize(major_opcode);
3367        // Flatten the buffers into a single vector
3368        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3369        (buf, fds)
3370    }
3371}
3372impl crate::x11_utils::VoidRequest for DestroyPbufferRequest {
3373}
3374
3375/// Opcode for the GetDrawableAttributes request
3376pub const GET_DRAWABLE_ATTRIBUTES_REQUEST: u8 = 29;
3377#[derive(Clone, Copy, Default)]
3378#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3379#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3380pub struct GetDrawableAttributesRequest {
3381    pub drawable: Drawable,
3382}
3383impl_debug_if_no_extra_traits!(GetDrawableAttributesRequest, "GetDrawableAttributesRequest");
3384impl GetDrawableAttributesRequest {
3385    /// Serialize this request into bytes for the provided connection
3386    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
3387        let length_so_far = 0;
3388        let drawable_bytes = self.drawable.serialize();
3389        let mut request0 = vec![
3390            major_opcode,
3391            GET_DRAWABLE_ATTRIBUTES_REQUEST,
3392            0,
3393            0,
3394            drawable_bytes[0],
3395            drawable_bytes[1],
3396            drawable_bytes[2],
3397            drawable_bytes[3],
3398        ];
3399        let length_so_far = length_so_far + request0.len();
3400        assert_eq!(length_so_far % 4, 0);
3401        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3402        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3403        ([request0.into()], vec![])
3404    }
3405    /// Parse this request given its header, its body, and any fds that go along with it
3406    #[cfg(feature = "request-parsing")]
3407    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3408        if header.minor_opcode != GET_DRAWABLE_ATTRIBUTES_REQUEST {
3409            return Err(ParseError::InvalidValue);
3410        }
3411        let (drawable, remaining) = Drawable::try_parse(value)?;
3412        let _ = remaining;
3413        Ok(GetDrawableAttributesRequest {
3414            drawable,
3415        })
3416    }
3417}
3418impl Request for GetDrawableAttributesRequest {
3419    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3420
3421    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3422        let (bufs, fds) = self.serialize(major_opcode);
3423        // Flatten the buffers into a single vector
3424        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3425        (buf, fds)
3426    }
3427}
3428impl crate::x11_utils::ReplyRequest for GetDrawableAttributesRequest {
3429    type Reply = GetDrawableAttributesReply;
3430}
3431
3432#[derive(Clone, Default)]
3433#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3434#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3435pub struct GetDrawableAttributesReply {
3436    pub sequence: u16,
3437    pub length: u32,
3438    pub attribs: Vec<u32>,
3439}
3440impl_debug_if_no_extra_traits!(GetDrawableAttributesReply, "GetDrawableAttributesReply");
3441impl TryParse for GetDrawableAttributesReply {
3442    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
3443        let remaining = initial_value;
3444        let (response_type, remaining) = u8::try_parse(remaining)?;
3445        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
3446        let (sequence, remaining) = u16::try_parse(remaining)?;
3447        let (length, remaining) = u32::try_parse(remaining)?;
3448        let (num_attribs, remaining) = u32::try_parse(remaining)?;
3449        let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
3450        let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3451        if response_type != 1 {
3452            return Err(ParseError::InvalidValue);
3453        }
3454        let result = GetDrawableAttributesReply { sequence, length, attribs };
3455        let _ = remaining;
3456        let remaining = initial_value.get(32 + length as usize * 4..)
3457            .ok_or(ParseError::InsufficientData)?;
3458        Ok((result, remaining))
3459    }
3460}
3461impl Serialize for GetDrawableAttributesReply {
3462    type Bytes = Vec<u8>;
3463    fn serialize(&self) -> Vec<u8> {
3464        let mut result = Vec::new();
3465        self.serialize_into(&mut result);
3466        result
3467    }
3468    fn serialize_into(&self, bytes: &mut Vec<u8>) {
3469        bytes.reserve(32);
3470        let response_type_bytes = &[1];
3471        bytes.push(response_type_bytes[0]);
3472        bytes.extend_from_slice(&[0; 1]);
3473        self.sequence.serialize_into(bytes);
3474        self.length.serialize_into(bytes);
3475        assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3476        let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3477        num_attribs.serialize_into(bytes);
3478        bytes.extend_from_slice(&[0; 20]);
3479        self.attribs.serialize_into(bytes);
3480    }
3481}
3482impl GetDrawableAttributesReply {
3483    /// Get the value of the `num_attribs` field.
3484    ///
3485    /// The `num_attribs` field is used as the length field of the `attribs` field.
3486    /// This function computes the field's value again based on the length of the list.
3487    ///
3488    /// # Panics
3489    ///
3490    /// Panics if the value cannot be represented in the target type. This
3491    /// cannot happen with values of the struct received from the X11 server.
3492    pub fn num_attribs(&self) -> u32 {
3493        self.attribs.len()
3494            .checked_div(2).unwrap()
3495            .try_into().unwrap()
3496    }
3497}
3498
3499/// Opcode for the ChangeDrawableAttributes request
3500pub const CHANGE_DRAWABLE_ATTRIBUTES_REQUEST: u8 = 30;
3501#[derive(Clone, Default)]
3502#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3503#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3504pub struct ChangeDrawableAttributesRequest<'input> {
3505    pub drawable: Drawable,
3506    pub attribs: Cow<'input, [u32]>,
3507}
3508impl_debug_if_no_extra_traits!(ChangeDrawableAttributesRequest<'_>, "ChangeDrawableAttributesRequest");
3509impl<'input> ChangeDrawableAttributesRequest<'input> {
3510    /// Serialize this request into bytes for the provided connection
3511    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
3512        let length_so_far = 0;
3513        let drawable_bytes = self.drawable.serialize();
3514        assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3515        let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3516        let num_attribs_bytes = num_attribs.serialize();
3517        let mut request0 = vec![
3518            major_opcode,
3519            CHANGE_DRAWABLE_ATTRIBUTES_REQUEST,
3520            0,
3521            0,
3522            drawable_bytes[0],
3523            drawable_bytes[1],
3524            drawable_bytes[2],
3525            drawable_bytes[3],
3526            num_attribs_bytes[0],
3527            num_attribs_bytes[1],
3528            num_attribs_bytes[2],
3529            num_attribs_bytes[3],
3530        ];
3531        let length_so_far = length_so_far + request0.len();
3532        let attribs_bytes = self.attribs.serialize();
3533        let length_so_far = length_so_far + attribs_bytes.len();
3534        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3535        let length_so_far = length_so_far + padding0.len();
3536        assert_eq!(length_so_far % 4, 0);
3537        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3538        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3539        ([request0.into(), attribs_bytes.into(), padding0.into()], vec![])
3540    }
3541    /// Parse this request given its header, its body, and any fds that go along with it
3542    #[cfg(feature = "request-parsing")]
3543    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3544        if header.minor_opcode != CHANGE_DRAWABLE_ATTRIBUTES_REQUEST {
3545            return Err(ParseError::InvalidValue);
3546        }
3547        let (drawable, remaining) = Drawable::try_parse(value)?;
3548        let (num_attribs, remaining) = u32::try_parse(remaining)?;
3549        let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3550        let _ = remaining;
3551        Ok(ChangeDrawableAttributesRequest {
3552            drawable,
3553            attribs: Cow::Owned(attribs),
3554        })
3555    }
3556    /// Clone all borrowed data in this ChangeDrawableAttributesRequest.
3557    pub fn into_owned(self) -> ChangeDrawableAttributesRequest<'static> {
3558        ChangeDrawableAttributesRequest {
3559            drawable: self.drawable,
3560            attribs: Cow::Owned(self.attribs.into_owned()),
3561        }
3562    }
3563}
3564impl<'input> Request for ChangeDrawableAttributesRequest<'input> {
3565    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3566
3567    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3568        let (bufs, fds) = self.serialize(major_opcode);
3569        // Flatten the buffers into a single vector
3570        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3571        (buf, fds)
3572    }
3573}
3574impl<'input> crate::x11_utils::VoidRequest for ChangeDrawableAttributesRequest<'input> {
3575}
3576
3577/// Opcode for the CreateWindow request
3578pub const CREATE_WINDOW_REQUEST: u8 = 31;
3579#[derive(Clone, Default)]
3580#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3581#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3582pub struct CreateWindowRequest<'input> {
3583    pub screen: u32,
3584    pub fbconfig: Fbconfig,
3585    pub window: xproto::Window,
3586    pub glx_window: Window,
3587    pub attribs: Cow<'input, [u32]>,
3588}
3589impl_debug_if_no_extra_traits!(CreateWindowRequest<'_>, "CreateWindowRequest");
3590impl<'input> CreateWindowRequest<'input> {
3591    /// Serialize this request into bytes for the provided connection
3592    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
3593        let length_so_far = 0;
3594        let screen_bytes = self.screen.serialize();
3595        let fbconfig_bytes = self.fbconfig.serialize();
3596        let window_bytes = self.window.serialize();
3597        let glx_window_bytes = self.glx_window.serialize();
3598        assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3599        let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3600        let num_attribs_bytes = num_attribs.serialize();
3601        let mut request0 = vec![
3602            major_opcode,
3603            CREATE_WINDOW_REQUEST,
3604            0,
3605            0,
3606            screen_bytes[0],
3607            screen_bytes[1],
3608            screen_bytes[2],
3609            screen_bytes[3],
3610            fbconfig_bytes[0],
3611            fbconfig_bytes[1],
3612            fbconfig_bytes[2],
3613            fbconfig_bytes[3],
3614            window_bytes[0],
3615            window_bytes[1],
3616            window_bytes[2],
3617            window_bytes[3],
3618            glx_window_bytes[0],
3619            glx_window_bytes[1],
3620            glx_window_bytes[2],
3621            glx_window_bytes[3],
3622            num_attribs_bytes[0],
3623            num_attribs_bytes[1],
3624            num_attribs_bytes[2],
3625            num_attribs_bytes[3],
3626        ];
3627        let length_so_far = length_so_far + request0.len();
3628        let attribs_bytes = self.attribs.serialize();
3629        let length_so_far = length_so_far + attribs_bytes.len();
3630        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3631        let length_so_far = length_so_far + padding0.len();
3632        assert_eq!(length_so_far % 4, 0);
3633        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3634        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3635        ([request0.into(), attribs_bytes.into(), padding0.into()], vec![])
3636    }
3637    /// Parse this request given its header, its body, and any fds that go along with it
3638    #[cfg(feature = "request-parsing")]
3639    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3640        if header.minor_opcode != CREATE_WINDOW_REQUEST {
3641            return Err(ParseError::InvalidValue);
3642        }
3643        let (screen, remaining) = u32::try_parse(value)?;
3644        let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
3645        let (window, remaining) = xproto::Window::try_parse(remaining)?;
3646        let (glx_window, remaining) = Window::try_parse(remaining)?;
3647        let (num_attribs, remaining) = u32::try_parse(remaining)?;
3648        let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3649        let _ = remaining;
3650        Ok(CreateWindowRequest {
3651            screen,
3652            fbconfig,
3653            window,
3654            glx_window,
3655            attribs: Cow::Owned(attribs),
3656        })
3657    }
3658    /// Clone all borrowed data in this CreateWindowRequest.
3659    pub fn into_owned(self) -> CreateWindowRequest<'static> {
3660        CreateWindowRequest {
3661            screen: self.screen,
3662            fbconfig: self.fbconfig,
3663            window: self.window,
3664            glx_window: self.glx_window,
3665            attribs: Cow::Owned(self.attribs.into_owned()),
3666        }
3667    }
3668}
3669impl<'input> Request for CreateWindowRequest<'input> {
3670    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3671
3672    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3673        let (bufs, fds) = self.serialize(major_opcode);
3674        // Flatten the buffers into a single vector
3675        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3676        (buf, fds)
3677    }
3678}
3679impl<'input> crate::x11_utils::VoidRequest for CreateWindowRequest<'input> {
3680}
3681
3682/// Opcode for the DeleteWindow request
3683pub const DELETE_WINDOW_REQUEST: u8 = 32;
3684#[derive(Clone, Copy, Default)]
3685#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3686#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3687pub struct DeleteWindowRequest {
3688    pub glxwindow: Window,
3689}
3690impl_debug_if_no_extra_traits!(DeleteWindowRequest, "DeleteWindowRequest");
3691impl DeleteWindowRequest {
3692    /// Serialize this request into bytes for the provided connection
3693    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
3694        let length_so_far = 0;
3695        let glxwindow_bytes = self.glxwindow.serialize();
3696        let mut request0 = vec![
3697            major_opcode,
3698            DELETE_WINDOW_REQUEST,
3699            0,
3700            0,
3701            glxwindow_bytes[0],
3702            glxwindow_bytes[1],
3703            glxwindow_bytes[2],
3704            glxwindow_bytes[3],
3705        ];
3706        let length_so_far = length_so_far + request0.len();
3707        assert_eq!(length_so_far % 4, 0);
3708        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3709        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3710        ([request0.into()], vec![])
3711    }
3712    /// Parse this request given its header, its body, and any fds that go along with it
3713    #[cfg(feature = "request-parsing")]
3714    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3715        if header.minor_opcode != DELETE_WINDOW_REQUEST {
3716            return Err(ParseError::InvalidValue);
3717        }
3718        let (glxwindow, remaining) = Window::try_parse(value)?;
3719        let _ = remaining;
3720        Ok(DeleteWindowRequest {
3721            glxwindow,
3722        })
3723    }
3724}
3725impl Request for DeleteWindowRequest {
3726    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3727
3728    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3729        let (bufs, fds) = self.serialize(major_opcode);
3730        // Flatten the buffers into a single vector
3731        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3732        (buf, fds)
3733    }
3734}
3735impl crate::x11_utils::VoidRequest for DeleteWindowRequest {
3736}
3737
3738/// Opcode for the SetClientInfoARB request
3739pub const SET_CLIENT_INFO_ARB_REQUEST: u8 = 33;
3740#[derive(Clone, Default)]
3741#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3742#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3743pub struct SetClientInfoARBRequest<'input> {
3744    pub major_version: u32,
3745    pub minor_version: u32,
3746    pub gl_versions: Cow<'input, [u32]>,
3747    pub gl_extension_string: Cow<'input, [u8]>,
3748    pub glx_extension_string: Cow<'input, [u8]>,
3749}
3750impl_debug_if_no_extra_traits!(SetClientInfoARBRequest<'_>, "SetClientInfoARBRequest");
3751impl<'input> SetClientInfoARBRequest<'input> {
3752    /// Serialize this request into bytes for the provided connection
3753    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 6]> {
3754        let length_so_far = 0;
3755        let major_version_bytes = self.major_version.serialize();
3756        let minor_version_bytes = self.minor_version.serialize();
3757        assert_eq!(self.gl_versions.len() % 2, 0, "`gl_versions` has an incorrect length, must be a multiple of 2");
3758        let num_versions = u32::try_from(self.gl_versions.len() / 2).expect("`gl_versions` has too many elements");
3759        let num_versions_bytes = num_versions.serialize();
3760        let gl_str_len = u32::try_from(self.gl_extension_string.len()).expect("`gl_extension_string` has too many elements");
3761        let gl_str_len_bytes = gl_str_len.serialize();
3762        let glx_str_len = u32::try_from(self.glx_extension_string.len()).expect("`glx_extension_string` has too many elements");
3763        let glx_str_len_bytes = glx_str_len.serialize();
3764        let mut request0 = vec![
3765            major_opcode,
3766            SET_CLIENT_INFO_ARB_REQUEST,
3767            0,
3768            0,
3769            major_version_bytes[0],
3770            major_version_bytes[1],
3771            major_version_bytes[2],
3772            major_version_bytes[3],
3773            minor_version_bytes[0],
3774            minor_version_bytes[1],
3775            minor_version_bytes[2],
3776            minor_version_bytes[3],
3777            num_versions_bytes[0],
3778            num_versions_bytes[1],
3779            num_versions_bytes[2],
3780            num_versions_bytes[3],
3781            gl_str_len_bytes[0],
3782            gl_str_len_bytes[1],
3783            gl_str_len_bytes[2],
3784            gl_str_len_bytes[3],
3785            glx_str_len_bytes[0],
3786            glx_str_len_bytes[1],
3787            glx_str_len_bytes[2],
3788            glx_str_len_bytes[3],
3789        ];
3790        let length_so_far = length_so_far + request0.len();
3791        let gl_versions_bytes = self.gl_versions.serialize();
3792        let length_so_far = length_so_far + gl_versions_bytes.len();
3793        let length_so_far = length_so_far + self.gl_extension_string.len();
3794        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3795        let length_so_far = length_so_far + padding0.len();
3796        let length_so_far = length_so_far + self.glx_extension_string.len();
3797        let padding1 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3798        let length_so_far = length_so_far + padding1.len();
3799        assert_eq!(length_so_far % 4, 0);
3800        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3801        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3802        ([request0.into(), gl_versions_bytes.into(), self.gl_extension_string, padding0.into(), self.glx_extension_string, padding1.into()], vec![])
3803    }
3804    /// Parse this request given its header, its body, and any fds that go along with it
3805    #[cfg(feature = "request-parsing")]
3806    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3807        if header.minor_opcode != SET_CLIENT_INFO_ARB_REQUEST {
3808            return Err(ParseError::InvalidValue);
3809        }
3810        let (major_version, remaining) = u32::try_parse(value)?;
3811        let (minor_version, remaining) = u32::try_parse(remaining)?;
3812        let (num_versions, remaining) = u32::try_parse(remaining)?;
3813        let (gl_str_len, remaining) = u32::try_parse(remaining)?;
3814        let (glx_str_len, remaining) = u32::try_parse(remaining)?;
3815        let (gl_versions, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_versions).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3816        let (gl_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, gl_str_len.try_to_usize()?)?;
3817        // Align offset to multiple of 4
3818        let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
3819        let misalignment = (4 - (offset % 4)) % 4;
3820        let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
3821        let (glx_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, glx_str_len.try_to_usize()?)?;
3822        let _ = remaining;
3823        Ok(SetClientInfoARBRequest {
3824            major_version,
3825            minor_version,
3826            gl_versions: Cow::Owned(gl_versions),
3827            gl_extension_string: Cow::Borrowed(gl_extension_string),
3828            glx_extension_string: Cow::Borrowed(glx_extension_string),
3829        })
3830    }
3831    /// Clone all borrowed data in this SetClientInfoARBRequest.
3832    pub fn into_owned(self) -> SetClientInfoARBRequest<'static> {
3833        SetClientInfoARBRequest {
3834            major_version: self.major_version,
3835            minor_version: self.minor_version,
3836            gl_versions: Cow::Owned(self.gl_versions.into_owned()),
3837            gl_extension_string: Cow::Owned(self.gl_extension_string.into_owned()),
3838            glx_extension_string: Cow::Owned(self.glx_extension_string.into_owned()),
3839        }
3840    }
3841}
3842impl<'input> Request for SetClientInfoARBRequest<'input> {
3843    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3844
3845    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3846        let (bufs, fds) = self.serialize(major_opcode);
3847        // Flatten the buffers into a single vector
3848        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3849        (buf, fds)
3850    }
3851}
3852impl<'input> crate::x11_utils::VoidRequest for SetClientInfoARBRequest<'input> {
3853}
3854
3855/// Opcode for the CreateContextAttribsARB request
3856pub const CREATE_CONTEXT_ATTRIBS_ARB_REQUEST: u8 = 34;
3857#[derive(Clone, Default)]
3858#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3859#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3860pub struct CreateContextAttribsARBRequest<'input> {
3861    pub context: Context,
3862    pub fbconfig: Fbconfig,
3863    pub screen: u32,
3864    pub share_list: Context,
3865    pub is_direct: bool,
3866    pub attribs: Cow<'input, [u32]>,
3867}
3868impl_debug_if_no_extra_traits!(CreateContextAttribsARBRequest<'_>, "CreateContextAttribsARBRequest");
3869impl<'input> CreateContextAttribsARBRequest<'input> {
3870    /// Serialize this request into bytes for the provided connection
3871    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
3872        let length_so_far = 0;
3873        let context_bytes = self.context.serialize();
3874        let fbconfig_bytes = self.fbconfig.serialize();
3875        let screen_bytes = self.screen.serialize();
3876        let share_list_bytes = self.share_list.serialize();
3877        let is_direct_bytes = self.is_direct.serialize();
3878        assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3879        let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3880        let num_attribs_bytes = num_attribs.serialize();
3881        let mut request0 = vec![
3882            major_opcode,
3883            CREATE_CONTEXT_ATTRIBS_ARB_REQUEST,
3884            0,
3885            0,
3886            context_bytes[0],
3887            context_bytes[1],
3888            context_bytes[2],
3889            context_bytes[3],
3890            fbconfig_bytes[0],
3891            fbconfig_bytes[1],
3892            fbconfig_bytes[2],
3893            fbconfig_bytes[3],
3894            screen_bytes[0],
3895            screen_bytes[1],
3896            screen_bytes[2],
3897            screen_bytes[3],
3898            share_list_bytes[0],
3899            share_list_bytes[1],
3900            share_list_bytes[2],
3901            share_list_bytes[3],
3902            is_direct_bytes[0],
3903            0,
3904            0,
3905            0,
3906            num_attribs_bytes[0],
3907            num_attribs_bytes[1],
3908            num_attribs_bytes[2],
3909            num_attribs_bytes[3],
3910        ];
3911        let length_so_far = length_so_far + request0.len();
3912        let attribs_bytes = self.attribs.serialize();
3913        let length_so_far = length_so_far + attribs_bytes.len();
3914        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3915        let length_so_far = length_so_far + padding0.len();
3916        assert_eq!(length_so_far % 4, 0);
3917        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3918        request0[2..4].copy_from_slice(&length.to_ne_bytes());
3919        ([request0.into(), attribs_bytes.into(), padding0.into()], vec![])
3920    }
3921    /// Parse this request given its header, its body, and any fds that go along with it
3922    #[cfg(feature = "request-parsing")]
3923    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3924        if header.minor_opcode != CREATE_CONTEXT_ATTRIBS_ARB_REQUEST {
3925            return Err(ParseError::InvalidValue);
3926        }
3927        let (context, remaining) = Context::try_parse(value)?;
3928        let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
3929        let (screen, remaining) = u32::try_parse(remaining)?;
3930        let (share_list, remaining) = Context::try_parse(remaining)?;
3931        let (is_direct, remaining) = bool::try_parse(remaining)?;
3932        let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
3933        let (num_attribs, remaining) = u32::try_parse(remaining)?;
3934        let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3935        let _ = remaining;
3936        Ok(CreateContextAttribsARBRequest {
3937            context,
3938            fbconfig,
3939            screen,
3940            share_list,
3941            is_direct,
3942            attribs: Cow::Owned(attribs),
3943        })
3944    }
3945    /// Clone all borrowed data in this CreateContextAttribsARBRequest.
3946    pub fn into_owned(self) -> CreateContextAttribsARBRequest<'static> {
3947        CreateContextAttribsARBRequest {
3948            context: self.context,
3949            fbconfig: self.fbconfig,
3950            screen: self.screen,
3951            share_list: self.share_list,
3952            is_direct: self.is_direct,
3953            attribs: Cow::Owned(self.attribs.into_owned()),
3954        }
3955    }
3956}
3957impl<'input> Request for CreateContextAttribsARBRequest<'input> {
3958    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
3959
3960    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
3961        let (bufs, fds) = self.serialize(major_opcode);
3962        // Flatten the buffers into a single vector
3963        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
3964        (buf, fds)
3965    }
3966}
3967impl<'input> crate::x11_utils::VoidRequest for CreateContextAttribsARBRequest<'input> {
3968}
3969
3970/// Opcode for the SetClientInfo2ARB request
3971pub const SET_CLIENT_INFO2_ARB_REQUEST: u8 = 35;
3972#[derive(Clone, Default)]
3973#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
3974#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3975pub struct SetClientInfo2ARBRequest<'input> {
3976    pub major_version: u32,
3977    pub minor_version: u32,
3978    pub gl_versions: Cow<'input, [u32]>,
3979    pub gl_extension_string: Cow<'input, [u8]>,
3980    pub glx_extension_string: Cow<'input, [u8]>,
3981}
3982impl_debug_if_no_extra_traits!(SetClientInfo2ARBRequest<'_>, "SetClientInfo2ARBRequest");
3983impl<'input> SetClientInfo2ARBRequest<'input> {
3984    /// Serialize this request into bytes for the provided connection
3985    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 6]> {
3986        let length_so_far = 0;
3987        let major_version_bytes = self.major_version.serialize();
3988        let minor_version_bytes = self.minor_version.serialize();
3989        assert_eq!(self.gl_versions.len() % 3, 0, "`gl_versions` has an incorrect length, must be a multiple of 3");
3990        let num_versions = u32::try_from(self.gl_versions.len() / 3).expect("`gl_versions` has too many elements");
3991        let num_versions_bytes = num_versions.serialize();
3992        let gl_str_len = u32::try_from(self.gl_extension_string.len()).expect("`gl_extension_string` has too many elements");
3993        let gl_str_len_bytes = gl_str_len.serialize();
3994        let glx_str_len = u32::try_from(self.glx_extension_string.len()).expect("`glx_extension_string` has too many elements");
3995        let glx_str_len_bytes = glx_str_len.serialize();
3996        let mut request0 = vec![
3997            major_opcode,
3998            SET_CLIENT_INFO2_ARB_REQUEST,
3999            0,
4000            0,
4001            major_version_bytes[0],
4002            major_version_bytes[1],
4003            major_version_bytes[2],
4004            major_version_bytes[3],
4005            minor_version_bytes[0],
4006            minor_version_bytes[1],
4007            minor_version_bytes[2],
4008            minor_version_bytes[3],
4009            num_versions_bytes[0],
4010            num_versions_bytes[1],
4011            num_versions_bytes[2],
4012            num_versions_bytes[3],
4013            gl_str_len_bytes[0],
4014            gl_str_len_bytes[1],
4015            gl_str_len_bytes[2],
4016            gl_str_len_bytes[3],
4017            glx_str_len_bytes[0],
4018            glx_str_len_bytes[1],
4019            glx_str_len_bytes[2],
4020            glx_str_len_bytes[3],
4021        ];
4022        let length_so_far = length_so_far + request0.len();
4023        let gl_versions_bytes = self.gl_versions.serialize();
4024        let length_so_far = length_so_far + gl_versions_bytes.len();
4025        let length_so_far = length_so_far + self.gl_extension_string.len();
4026        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
4027        let length_so_far = length_so_far + padding0.len();
4028        let length_so_far = length_so_far + self.glx_extension_string.len();
4029        let padding1 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
4030        let length_so_far = length_so_far + padding1.len();
4031        assert_eq!(length_so_far % 4, 0);
4032        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4033        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4034        ([request0.into(), gl_versions_bytes.into(), self.gl_extension_string, padding0.into(), self.glx_extension_string, padding1.into()], vec![])
4035    }
4036    /// Parse this request given its header, its body, and any fds that go along with it
4037    #[cfg(feature = "request-parsing")]
4038    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
4039        if header.minor_opcode != SET_CLIENT_INFO2_ARB_REQUEST {
4040            return Err(ParseError::InvalidValue);
4041        }
4042        let (major_version, remaining) = u32::try_parse(value)?;
4043        let (minor_version, remaining) = u32::try_parse(remaining)?;
4044        let (num_versions, remaining) = u32::try_parse(remaining)?;
4045        let (gl_str_len, remaining) = u32::try_parse(remaining)?;
4046        let (glx_str_len, remaining) = u32::try_parse(remaining)?;
4047        let (gl_versions, remaining) = crate::x11_utils::parse_list::<u32>(remaining, u32::from(num_versions).checked_mul(3u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
4048        let (gl_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, gl_str_len.try_to_usize()?)?;
4049        // Align offset to multiple of 4
4050        let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
4051        let misalignment = (4 - (offset % 4)) % 4;
4052        let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
4053        let (glx_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, glx_str_len.try_to_usize()?)?;
4054        let _ = remaining;
4055        Ok(SetClientInfo2ARBRequest {
4056            major_version,
4057            minor_version,
4058            gl_versions: Cow::Owned(gl_versions),
4059            gl_extension_string: Cow::Borrowed(gl_extension_string),
4060            glx_extension_string: Cow::Borrowed(glx_extension_string),
4061        })
4062    }
4063    /// Clone all borrowed data in this SetClientInfo2ARBRequest.
4064    pub fn into_owned(self) -> SetClientInfo2ARBRequest<'static> {
4065        SetClientInfo2ARBRequest {
4066            major_version: self.major_version,
4067            minor_version: self.minor_version,
4068            gl_versions: Cow::Owned(self.gl_versions.into_owned()),
4069            gl_extension_string: Cow::Owned(self.gl_extension_string.into_owned()),
4070            glx_extension_string: Cow::Owned(self.glx_extension_string.into_owned()),
4071        }
4072    }
4073}
4074impl<'input> Request for SetClientInfo2ARBRequest<'input> {
4075    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4076
4077    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4078        let (bufs, fds) = self.serialize(major_opcode);
4079        // Flatten the buffers into a single vector
4080        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4081        (buf, fds)
4082    }
4083}
4084impl<'input> crate::x11_utils::VoidRequest for SetClientInfo2ARBRequest<'input> {
4085}
4086
4087/// Opcode for the NewList request
4088pub const NEW_LIST_REQUEST: u8 = 101;
4089#[derive(Clone, Copy, Default)]
4090#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4091#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4092pub struct NewListRequest {
4093    pub context_tag: ContextTag,
4094    pub list: u32,
4095    pub mode: u32,
4096}
4097impl_debug_if_no_extra_traits!(NewListRequest, "NewListRequest");
4098impl NewListRequest {
4099    /// Serialize this request into bytes for the provided connection
4100    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4101        let length_so_far = 0;
4102        let context_tag_bytes = self.context_tag.serialize();
4103        let list_bytes = self.list.serialize();
4104        let mode_bytes = self.mode.serialize();
4105        let mut request0 = vec![
4106            major_opcode,
4107            NEW_LIST_REQUEST,
4108            0,
4109            0,
4110            context_tag_bytes[0],
4111            context_tag_bytes[1],
4112            context_tag_bytes[2],
4113            context_tag_bytes[3],
4114            list_bytes[0],
4115            list_bytes[1],
4116            list_bytes[2],
4117            list_bytes[3],
4118            mode_bytes[0],
4119            mode_bytes[1],
4120            mode_bytes[2],
4121            mode_bytes[3],
4122        ];
4123        let length_so_far = length_so_far + request0.len();
4124        assert_eq!(length_so_far % 4, 0);
4125        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4126        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4127        ([request0.into()], vec![])
4128    }
4129    /// Parse this request given its header, its body, and any fds that go along with it
4130    #[cfg(feature = "request-parsing")]
4131    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4132        if header.minor_opcode != NEW_LIST_REQUEST {
4133            return Err(ParseError::InvalidValue);
4134        }
4135        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4136        let (list, remaining) = u32::try_parse(remaining)?;
4137        let (mode, remaining) = u32::try_parse(remaining)?;
4138        let _ = remaining;
4139        Ok(NewListRequest {
4140            context_tag,
4141            list,
4142            mode,
4143        })
4144    }
4145}
4146impl Request for NewListRequest {
4147    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4148
4149    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4150        let (bufs, fds) = self.serialize(major_opcode);
4151        // Flatten the buffers into a single vector
4152        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4153        (buf, fds)
4154    }
4155}
4156impl crate::x11_utils::VoidRequest for NewListRequest {
4157}
4158
4159/// Opcode for the EndList request
4160pub const END_LIST_REQUEST: u8 = 102;
4161#[derive(Clone, Copy, Default)]
4162#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4163#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4164pub struct EndListRequest {
4165    pub context_tag: ContextTag,
4166}
4167impl_debug_if_no_extra_traits!(EndListRequest, "EndListRequest");
4168impl EndListRequest {
4169    /// Serialize this request into bytes for the provided connection
4170    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4171        let length_so_far = 0;
4172        let context_tag_bytes = self.context_tag.serialize();
4173        let mut request0 = vec![
4174            major_opcode,
4175            END_LIST_REQUEST,
4176            0,
4177            0,
4178            context_tag_bytes[0],
4179            context_tag_bytes[1],
4180            context_tag_bytes[2],
4181            context_tag_bytes[3],
4182        ];
4183        let length_so_far = length_so_far + request0.len();
4184        assert_eq!(length_so_far % 4, 0);
4185        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4186        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4187        ([request0.into()], vec![])
4188    }
4189    /// Parse this request given its header, its body, and any fds that go along with it
4190    #[cfg(feature = "request-parsing")]
4191    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4192        if header.minor_opcode != END_LIST_REQUEST {
4193            return Err(ParseError::InvalidValue);
4194        }
4195        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4196        let _ = remaining;
4197        Ok(EndListRequest {
4198            context_tag,
4199        })
4200    }
4201}
4202impl Request for EndListRequest {
4203    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4204
4205    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4206        let (bufs, fds) = self.serialize(major_opcode);
4207        // Flatten the buffers into a single vector
4208        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4209        (buf, fds)
4210    }
4211}
4212impl crate::x11_utils::VoidRequest for EndListRequest {
4213}
4214
4215/// Opcode for the DeleteLists request
4216pub const DELETE_LISTS_REQUEST: u8 = 103;
4217#[derive(Clone, Copy, Default)]
4218#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4219#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4220pub struct DeleteListsRequest {
4221    pub context_tag: ContextTag,
4222    pub list: u32,
4223    pub range: i32,
4224}
4225impl_debug_if_no_extra_traits!(DeleteListsRequest, "DeleteListsRequest");
4226impl DeleteListsRequest {
4227    /// Serialize this request into bytes for the provided connection
4228    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4229        let length_so_far = 0;
4230        let context_tag_bytes = self.context_tag.serialize();
4231        let list_bytes = self.list.serialize();
4232        let range_bytes = self.range.serialize();
4233        let mut request0 = vec![
4234            major_opcode,
4235            DELETE_LISTS_REQUEST,
4236            0,
4237            0,
4238            context_tag_bytes[0],
4239            context_tag_bytes[1],
4240            context_tag_bytes[2],
4241            context_tag_bytes[3],
4242            list_bytes[0],
4243            list_bytes[1],
4244            list_bytes[2],
4245            list_bytes[3],
4246            range_bytes[0],
4247            range_bytes[1],
4248            range_bytes[2],
4249            range_bytes[3],
4250        ];
4251        let length_so_far = length_so_far + request0.len();
4252        assert_eq!(length_so_far % 4, 0);
4253        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4254        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4255        ([request0.into()], vec![])
4256    }
4257    /// Parse this request given its header, its body, and any fds that go along with it
4258    #[cfg(feature = "request-parsing")]
4259    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4260        if header.minor_opcode != DELETE_LISTS_REQUEST {
4261            return Err(ParseError::InvalidValue);
4262        }
4263        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4264        let (list, remaining) = u32::try_parse(remaining)?;
4265        let (range, remaining) = i32::try_parse(remaining)?;
4266        let _ = remaining;
4267        Ok(DeleteListsRequest {
4268            context_tag,
4269            list,
4270            range,
4271        })
4272    }
4273}
4274impl Request for DeleteListsRequest {
4275    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4276
4277    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4278        let (bufs, fds) = self.serialize(major_opcode);
4279        // Flatten the buffers into a single vector
4280        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4281        (buf, fds)
4282    }
4283}
4284impl crate::x11_utils::VoidRequest for DeleteListsRequest {
4285}
4286
4287/// Opcode for the GenLists request
4288pub const GEN_LISTS_REQUEST: u8 = 104;
4289#[derive(Clone, Copy, Default)]
4290#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4291#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4292pub struct GenListsRequest {
4293    pub context_tag: ContextTag,
4294    pub range: i32,
4295}
4296impl_debug_if_no_extra_traits!(GenListsRequest, "GenListsRequest");
4297impl GenListsRequest {
4298    /// Serialize this request into bytes for the provided connection
4299    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4300        let length_so_far = 0;
4301        let context_tag_bytes = self.context_tag.serialize();
4302        let range_bytes = self.range.serialize();
4303        let mut request0 = vec![
4304            major_opcode,
4305            GEN_LISTS_REQUEST,
4306            0,
4307            0,
4308            context_tag_bytes[0],
4309            context_tag_bytes[1],
4310            context_tag_bytes[2],
4311            context_tag_bytes[3],
4312            range_bytes[0],
4313            range_bytes[1],
4314            range_bytes[2],
4315            range_bytes[3],
4316        ];
4317        let length_so_far = length_so_far + request0.len();
4318        assert_eq!(length_so_far % 4, 0);
4319        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4320        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4321        ([request0.into()], vec![])
4322    }
4323    /// Parse this request given its header, its body, and any fds that go along with it
4324    #[cfg(feature = "request-parsing")]
4325    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4326        if header.minor_opcode != GEN_LISTS_REQUEST {
4327            return Err(ParseError::InvalidValue);
4328        }
4329        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4330        let (range, remaining) = i32::try_parse(remaining)?;
4331        let _ = remaining;
4332        Ok(GenListsRequest {
4333            context_tag,
4334            range,
4335        })
4336    }
4337}
4338impl Request for GenListsRequest {
4339    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4340
4341    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4342        let (bufs, fds) = self.serialize(major_opcode);
4343        // Flatten the buffers into a single vector
4344        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4345        (buf, fds)
4346    }
4347}
4348impl crate::x11_utils::ReplyRequest for GenListsRequest {
4349    type Reply = GenListsReply;
4350}
4351
4352#[derive(Clone, Copy, Default)]
4353#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4354#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4355pub struct GenListsReply {
4356    pub sequence: u16,
4357    pub length: u32,
4358    pub ret_val: u32,
4359}
4360impl_debug_if_no_extra_traits!(GenListsReply, "GenListsReply");
4361impl TryParse for GenListsReply {
4362    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4363        let remaining = initial_value;
4364        let (response_type, remaining) = u8::try_parse(remaining)?;
4365        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4366        let (sequence, remaining) = u16::try_parse(remaining)?;
4367        let (length, remaining) = u32::try_parse(remaining)?;
4368        let (ret_val, remaining) = u32::try_parse(remaining)?;
4369        if response_type != 1 {
4370            return Err(ParseError::InvalidValue);
4371        }
4372        let result = GenListsReply { sequence, length, ret_val };
4373        let _ = remaining;
4374        let remaining = initial_value.get(32 + length as usize * 4..)
4375            .ok_or(ParseError::InsufficientData)?;
4376        Ok((result, remaining))
4377    }
4378}
4379impl Serialize for GenListsReply {
4380    type Bytes = [u8; 12];
4381    fn serialize(&self) -> [u8; 12] {
4382        let response_type_bytes = &[1];
4383        let sequence_bytes = self.sequence.serialize();
4384        let length_bytes = self.length.serialize();
4385        let ret_val_bytes = self.ret_val.serialize();
4386        [
4387            response_type_bytes[0],
4388            0,
4389            sequence_bytes[0],
4390            sequence_bytes[1],
4391            length_bytes[0],
4392            length_bytes[1],
4393            length_bytes[2],
4394            length_bytes[3],
4395            ret_val_bytes[0],
4396            ret_val_bytes[1],
4397            ret_val_bytes[2],
4398            ret_val_bytes[3],
4399        ]
4400    }
4401    fn serialize_into(&self, bytes: &mut Vec<u8>) {
4402        bytes.reserve(12);
4403        let response_type_bytes = &[1];
4404        bytes.push(response_type_bytes[0]);
4405        bytes.extend_from_slice(&[0; 1]);
4406        self.sequence.serialize_into(bytes);
4407        self.length.serialize_into(bytes);
4408        self.ret_val.serialize_into(bytes);
4409    }
4410}
4411
4412/// Opcode for the FeedbackBuffer request
4413pub const FEEDBACK_BUFFER_REQUEST: u8 = 105;
4414#[derive(Clone, Copy, Default)]
4415#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4416#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4417pub struct FeedbackBufferRequest {
4418    pub context_tag: ContextTag,
4419    pub size: i32,
4420    pub type_: i32,
4421}
4422impl_debug_if_no_extra_traits!(FeedbackBufferRequest, "FeedbackBufferRequest");
4423impl FeedbackBufferRequest {
4424    /// Serialize this request into bytes for the provided connection
4425    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4426        let length_so_far = 0;
4427        let context_tag_bytes = self.context_tag.serialize();
4428        let size_bytes = self.size.serialize();
4429        let type_bytes = self.type_.serialize();
4430        let mut request0 = vec![
4431            major_opcode,
4432            FEEDBACK_BUFFER_REQUEST,
4433            0,
4434            0,
4435            context_tag_bytes[0],
4436            context_tag_bytes[1],
4437            context_tag_bytes[2],
4438            context_tag_bytes[3],
4439            size_bytes[0],
4440            size_bytes[1],
4441            size_bytes[2],
4442            size_bytes[3],
4443            type_bytes[0],
4444            type_bytes[1],
4445            type_bytes[2],
4446            type_bytes[3],
4447        ];
4448        let length_so_far = length_so_far + request0.len();
4449        assert_eq!(length_so_far % 4, 0);
4450        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4451        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4452        ([request0.into()], vec![])
4453    }
4454    /// Parse this request given its header, its body, and any fds that go along with it
4455    #[cfg(feature = "request-parsing")]
4456    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4457        if header.minor_opcode != FEEDBACK_BUFFER_REQUEST {
4458            return Err(ParseError::InvalidValue);
4459        }
4460        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4461        let (size, remaining) = i32::try_parse(remaining)?;
4462        let (type_, remaining) = i32::try_parse(remaining)?;
4463        let _ = remaining;
4464        Ok(FeedbackBufferRequest {
4465            context_tag,
4466            size,
4467            type_,
4468        })
4469    }
4470}
4471impl Request for FeedbackBufferRequest {
4472    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4473
4474    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4475        let (bufs, fds) = self.serialize(major_opcode);
4476        // Flatten the buffers into a single vector
4477        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4478        (buf, fds)
4479    }
4480}
4481impl crate::x11_utils::VoidRequest for FeedbackBufferRequest {
4482}
4483
4484/// Opcode for the SelectBuffer request
4485pub const SELECT_BUFFER_REQUEST: u8 = 106;
4486#[derive(Clone, Copy, Default)]
4487#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4488#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4489pub struct SelectBufferRequest {
4490    pub context_tag: ContextTag,
4491    pub size: i32,
4492}
4493impl_debug_if_no_extra_traits!(SelectBufferRequest, "SelectBufferRequest");
4494impl SelectBufferRequest {
4495    /// Serialize this request into bytes for the provided connection
4496    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4497        let length_so_far = 0;
4498        let context_tag_bytes = self.context_tag.serialize();
4499        let size_bytes = self.size.serialize();
4500        let mut request0 = vec![
4501            major_opcode,
4502            SELECT_BUFFER_REQUEST,
4503            0,
4504            0,
4505            context_tag_bytes[0],
4506            context_tag_bytes[1],
4507            context_tag_bytes[2],
4508            context_tag_bytes[3],
4509            size_bytes[0],
4510            size_bytes[1],
4511            size_bytes[2],
4512            size_bytes[3],
4513        ];
4514        let length_so_far = length_so_far + request0.len();
4515        assert_eq!(length_so_far % 4, 0);
4516        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4517        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4518        ([request0.into()], vec![])
4519    }
4520    /// Parse this request given its header, its body, and any fds that go along with it
4521    #[cfg(feature = "request-parsing")]
4522    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4523        if header.minor_opcode != SELECT_BUFFER_REQUEST {
4524            return Err(ParseError::InvalidValue);
4525        }
4526        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4527        let (size, remaining) = i32::try_parse(remaining)?;
4528        let _ = remaining;
4529        Ok(SelectBufferRequest {
4530            context_tag,
4531            size,
4532        })
4533    }
4534}
4535impl Request for SelectBufferRequest {
4536    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4537
4538    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4539        let (bufs, fds) = self.serialize(major_opcode);
4540        // Flatten the buffers into a single vector
4541        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4542        (buf, fds)
4543    }
4544}
4545impl crate::x11_utils::VoidRequest for SelectBufferRequest {
4546}
4547
4548/// Opcode for the RenderMode request
4549pub const RENDER_MODE_REQUEST: u8 = 107;
4550#[derive(Clone, Copy, Default)]
4551#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4552#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4553pub struct RenderModeRequest {
4554    pub context_tag: ContextTag,
4555    pub mode: u32,
4556}
4557impl_debug_if_no_extra_traits!(RenderModeRequest, "RenderModeRequest");
4558impl RenderModeRequest {
4559    /// Serialize this request into bytes for the provided connection
4560    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4561        let length_so_far = 0;
4562        let context_tag_bytes = self.context_tag.serialize();
4563        let mode_bytes = self.mode.serialize();
4564        let mut request0 = vec![
4565            major_opcode,
4566            RENDER_MODE_REQUEST,
4567            0,
4568            0,
4569            context_tag_bytes[0],
4570            context_tag_bytes[1],
4571            context_tag_bytes[2],
4572            context_tag_bytes[3],
4573            mode_bytes[0],
4574            mode_bytes[1],
4575            mode_bytes[2],
4576            mode_bytes[3],
4577        ];
4578        let length_so_far = length_so_far + request0.len();
4579        assert_eq!(length_so_far % 4, 0);
4580        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4581        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4582        ([request0.into()], vec![])
4583    }
4584    /// Parse this request given its header, its body, and any fds that go along with it
4585    #[cfg(feature = "request-parsing")]
4586    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4587        if header.minor_opcode != RENDER_MODE_REQUEST {
4588            return Err(ParseError::InvalidValue);
4589        }
4590        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4591        let (mode, remaining) = u32::try_parse(remaining)?;
4592        let _ = remaining;
4593        Ok(RenderModeRequest {
4594            context_tag,
4595            mode,
4596        })
4597    }
4598}
4599impl Request for RenderModeRequest {
4600    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4601
4602    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4603        let (bufs, fds) = self.serialize(major_opcode);
4604        // Flatten the buffers into a single vector
4605        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4606        (buf, fds)
4607    }
4608}
4609impl crate::x11_utils::ReplyRequest for RenderModeRequest {
4610    type Reply = RenderModeReply;
4611}
4612
4613#[derive(Clone, Default)]
4614#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4615#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4616pub struct RenderModeReply {
4617    pub sequence: u16,
4618    pub length: u32,
4619    pub ret_val: u32,
4620    pub new_mode: u32,
4621    pub data: Vec<u32>,
4622}
4623impl_debug_if_no_extra_traits!(RenderModeReply, "RenderModeReply");
4624impl TryParse for RenderModeReply {
4625    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4626        let remaining = initial_value;
4627        let (response_type, remaining) = u8::try_parse(remaining)?;
4628        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4629        let (sequence, remaining) = u16::try_parse(remaining)?;
4630        let (length, remaining) = u32::try_parse(remaining)?;
4631        let (ret_val, remaining) = u32::try_parse(remaining)?;
4632        let (n, remaining) = u32::try_parse(remaining)?;
4633        let (new_mode, remaining) = u32::try_parse(remaining)?;
4634        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
4635        let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
4636        if response_type != 1 {
4637            return Err(ParseError::InvalidValue);
4638        }
4639        let result = RenderModeReply { sequence, length, ret_val, new_mode, data };
4640        let _ = remaining;
4641        let remaining = initial_value.get(32 + length as usize * 4..)
4642            .ok_or(ParseError::InsufficientData)?;
4643        Ok((result, remaining))
4644    }
4645}
4646impl Serialize for RenderModeReply {
4647    type Bytes = Vec<u8>;
4648    fn serialize(&self) -> Vec<u8> {
4649        let mut result = Vec::new();
4650        self.serialize_into(&mut result);
4651        result
4652    }
4653    fn serialize_into(&self, bytes: &mut Vec<u8>) {
4654        bytes.reserve(32);
4655        let response_type_bytes = &[1];
4656        bytes.push(response_type_bytes[0]);
4657        bytes.extend_from_slice(&[0; 1]);
4658        self.sequence.serialize_into(bytes);
4659        self.length.serialize_into(bytes);
4660        self.ret_val.serialize_into(bytes);
4661        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
4662        n.serialize_into(bytes);
4663        self.new_mode.serialize_into(bytes);
4664        bytes.extend_from_slice(&[0; 12]);
4665        self.data.serialize_into(bytes);
4666    }
4667}
4668impl RenderModeReply {
4669    /// Get the value of the `n` field.
4670    ///
4671    /// The `n` field is used as the length field of the `data` field.
4672    /// This function computes the field's value again based on the length of the list.
4673    ///
4674    /// # Panics
4675    ///
4676    /// Panics if the value cannot be represented in the target type. This
4677    /// cannot happen with values of the struct received from the X11 server.
4678    pub fn n(&self) -> u32 {
4679        self.data.len()
4680            .try_into().unwrap()
4681    }
4682}
4683
4684#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4685#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4686pub struct RM(u16);
4687impl RM {
4688    pub const GL_RENDER: Self = Self(7168);
4689    pub const GL_FEEDBACK: Self = Self(7169);
4690    pub const GL_SELECT: Self = Self(7170);
4691}
4692impl From<RM> for u16 {
4693    #[inline]
4694    fn from(input: RM) -> Self {
4695        input.0
4696    }
4697}
4698impl From<RM> for Option<u16> {
4699    #[inline]
4700    fn from(input: RM) -> Self {
4701        Some(input.0)
4702    }
4703}
4704impl From<RM> for u32 {
4705    #[inline]
4706    fn from(input: RM) -> Self {
4707        u32::from(input.0)
4708    }
4709}
4710impl From<RM> for Option<u32> {
4711    #[inline]
4712    fn from(input: RM) -> Self {
4713        Some(u32::from(input.0))
4714    }
4715}
4716impl From<u8> for RM {
4717    #[inline]
4718    fn from(value: u8) -> Self {
4719        Self(value.into())
4720    }
4721}
4722impl From<u16> for RM {
4723    #[inline]
4724    fn from(value: u16) -> Self {
4725        Self(value)
4726    }
4727}
4728impl core::fmt::Debug for RM  {
4729    fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
4730        let variants = [
4731            (Self::GL_RENDER.0.into(), "GL_RENDER", "GL_RENDER"),
4732            (Self::GL_FEEDBACK.0.into(), "GL_FEEDBACK", "GL_FEEDBACK"),
4733            (Self::GL_SELECT.0.into(), "GL_SELECT", "GL_SELECT"),
4734        ];
4735        pretty_print_enum(fmt, self.0.into(), &variants)
4736    }
4737}
4738
4739/// Opcode for the Finish request
4740pub const FINISH_REQUEST: u8 = 108;
4741#[derive(Clone, Copy, Default)]
4742#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4743#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4744pub struct FinishRequest {
4745    pub context_tag: ContextTag,
4746}
4747impl_debug_if_no_extra_traits!(FinishRequest, "FinishRequest");
4748impl FinishRequest {
4749    /// Serialize this request into bytes for the provided connection
4750    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4751        let length_so_far = 0;
4752        let context_tag_bytes = self.context_tag.serialize();
4753        let mut request0 = vec![
4754            major_opcode,
4755            FINISH_REQUEST,
4756            0,
4757            0,
4758            context_tag_bytes[0],
4759            context_tag_bytes[1],
4760            context_tag_bytes[2],
4761            context_tag_bytes[3],
4762        ];
4763        let length_so_far = length_so_far + request0.len();
4764        assert_eq!(length_so_far % 4, 0);
4765        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4766        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4767        ([request0.into()], vec![])
4768    }
4769    /// Parse this request given its header, its body, and any fds that go along with it
4770    #[cfg(feature = "request-parsing")]
4771    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4772        if header.minor_opcode != FINISH_REQUEST {
4773            return Err(ParseError::InvalidValue);
4774        }
4775        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4776        let _ = remaining;
4777        Ok(FinishRequest {
4778            context_tag,
4779        })
4780    }
4781}
4782impl Request for FinishRequest {
4783    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4784
4785    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4786        let (bufs, fds) = self.serialize(major_opcode);
4787        // Flatten the buffers into a single vector
4788        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4789        (buf, fds)
4790    }
4791}
4792impl crate::x11_utils::ReplyRequest for FinishRequest {
4793    type Reply = FinishReply;
4794}
4795
4796#[derive(Clone, Copy, Default)]
4797#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4798#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4799pub struct FinishReply {
4800    pub sequence: u16,
4801    pub length: u32,
4802}
4803impl_debug_if_no_extra_traits!(FinishReply, "FinishReply");
4804impl TryParse for FinishReply {
4805    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4806        let remaining = initial_value;
4807        let (response_type, remaining) = u8::try_parse(remaining)?;
4808        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4809        let (sequence, remaining) = u16::try_parse(remaining)?;
4810        let (length, remaining) = u32::try_parse(remaining)?;
4811        if response_type != 1 {
4812            return Err(ParseError::InvalidValue);
4813        }
4814        let result = FinishReply { sequence, length };
4815        let _ = remaining;
4816        let remaining = initial_value.get(32 + length as usize * 4..)
4817            .ok_or(ParseError::InsufficientData)?;
4818        Ok((result, remaining))
4819    }
4820}
4821impl Serialize for FinishReply {
4822    type Bytes = [u8; 8];
4823    fn serialize(&self) -> [u8; 8] {
4824        let response_type_bytes = &[1];
4825        let sequence_bytes = self.sequence.serialize();
4826        let length_bytes = self.length.serialize();
4827        [
4828            response_type_bytes[0],
4829            0,
4830            sequence_bytes[0],
4831            sequence_bytes[1],
4832            length_bytes[0],
4833            length_bytes[1],
4834            length_bytes[2],
4835            length_bytes[3],
4836        ]
4837    }
4838    fn serialize_into(&self, bytes: &mut Vec<u8>) {
4839        bytes.reserve(8);
4840        let response_type_bytes = &[1];
4841        bytes.push(response_type_bytes[0]);
4842        bytes.extend_from_slice(&[0; 1]);
4843        self.sequence.serialize_into(bytes);
4844        self.length.serialize_into(bytes);
4845    }
4846}
4847
4848/// Opcode for the PixelStoref request
4849pub const PIXEL_STOREF_REQUEST: u8 = 109;
4850#[derive(Clone, Copy, Default)]
4851#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
4852#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4853pub struct PixelStorefRequest {
4854    pub context_tag: ContextTag,
4855    pub pname: u32,
4856    pub datum: Float32,
4857}
4858impl_debug_if_no_extra_traits!(PixelStorefRequest, "PixelStorefRequest");
4859impl PixelStorefRequest {
4860    /// Serialize this request into bytes for the provided connection
4861    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4862        let length_so_far = 0;
4863        let context_tag_bytes = self.context_tag.serialize();
4864        let pname_bytes = self.pname.serialize();
4865        let datum_bytes = self.datum.serialize();
4866        let mut request0 = vec![
4867            major_opcode,
4868            PIXEL_STOREF_REQUEST,
4869            0,
4870            0,
4871            context_tag_bytes[0],
4872            context_tag_bytes[1],
4873            context_tag_bytes[2],
4874            context_tag_bytes[3],
4875            pname_bytes[0],
4876            pname_bytes[1],
4877            pname_bytes[2],
4878            pname_bytes[3],
4879            datum_bytes[0],
4880            datum_bytes[1],
4881            datum_bytes[2],
4882            datum_bytes[3],
4883        ];
4884        let length_so_far = length_so_far + request0.len();
4885        assert_eq!(length_so_far % 4, 0);
4886        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4887        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4888        ([request0.into()], vec![])
4889    }
4890    /// Parse this request given its header, its body, and any fds that go along with it
4891    #[cfg(feature = "request-parsing")]
4892    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4893        if header.minor_opcode != PIXEL_STOREF_REQUEST {
4894            return Err(ParseError::InvalidValue);
4895        }
4896        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4897        let (pname, remaining) = u32::try_parse(remaining)?;
4898        let (datum, remaining) = Float32::try_parse(remaining)?;
4899        let _ = remaining;
4900        Ok(PixelStorefRequest {
4901            context_tag,
4902            pname,
4903            datum,
4904        })
4905    }
4906}
4907impl Request for PixelStorefRequest {
4908    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4909
4910    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4911        let (bufs, fds) = self.serialize(major_opcode);
4912        // Flatten the buffers into a single vector
4913        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4914        (buf, fds)
4915    }
4916}
4917impl crate::x11_utils::VoidRequest for PixelStorefRequest {
4918}
4919
4920/// Opcode for the PixelStorei request
4921pub const PIXEL_STOREI_REQUEST: u8 = 110;
4922#[derive(Clone, Copy, Default)]
4923#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4924#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4925pub struct PixelStoreiRequest {
4926    pub context_tag: ContextTag,
4927    pub pname: u32,
4928    pub datum: i32,
4929}
4930impl_debug_if_no_extra_traits!(PixelStoreiRequest, "PixelStoreiRequest");
4931impl PixelStoreiRequest {
4932    /// Serialize this request into bytes for the provided connection
4933    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
4934        let length_so_far = 0;
4935        let context_tag_bytes = self.context_tag.serialize();
4936        let pname_bytes = self.pname.serialize();
4937        let datum_bytes = self.datum.serialize();
4938        let mut request0 = vec![
4939            major_opcode,
4940            PIXEL_STOREI_REQUEST,
4941            0,
4942            0,
4943            context_tag_bytes[0],
4944            context_tag_bytes[1],
4945            context_tag_bytes[2],
4946            context_tag_bytes[3],
4947            pname_bytes[0],
4948            pname_bytes[1],
4949            pname_bytes[2],
4950            pname_bytes[3],
4951            datum_bytes[0],
4952            datum_bytes[1],
4953            datum_bytes[2],
4954            datum_bytes[3],
4955        ];
4956        let length_so_far = length_so_far + request0.len();
4957        assert_eq!(length_so_far % 4, 0);
4958        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4959        request0[2..4].copy_from_slice(&length.to_ne_bytes());
4960        ([request0.into()], vec![])
4961    }
4962    /// Parse this request given its header, its body, and any fds that go along with it
4963    #[cfg(feature = "request-parsing")]
4964    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4965        if header.minor_opcode != PIXEL_STOREI_REQUEST {
4966            return Err(ParseError::InvalidValue);
4967        }
4968        let (context_tag, remaining) = ContextTag::try_parse(value)?;
4969        let (pname, remaining) = u32::try_parse(remaining)?;
4970        let (datum, remaining) = i32::try_parse(remaining)?;
4971        let _ = remaining;
4972        Ok(PixelStoreiRequest {
4973            context_tag,
4974            pname,
4975            datum,
4976        })
4977    }
4978}
4979impl Request for PixelStoreiRequest {
4980    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
4981
4982    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
4983        let (bufs, fds) = self.serialize(major_opcode);
4984        // Flatten the buffers into a single vector
4985        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
4986        (buf, fds)
4987    }
4988}
4989impl crate::x11_utils::VoidRequest for PixelStoreiRequest {
4990}
4991
4992/// Opcode for the ReadPixels request
4993pub const READ_PIXELS_REQUEST: u8 = 111;
4994#[derive(Clone, Copy, Default)]
4995#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
4996#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4997pub struct ReadPixelsRequest {
4998    pub context_tag: ContextTag,
4999    pub x: i32,
5000    pub y: i32,
5001    pub width: i32,
5002    pub height: i32,
5003    pub format: u32,
5004    pub type_: u32,
5005    pub swap_bytes: bool,
5006    pub lsb_first: bool,
5007}
5008impl_debug_if_no_extra_traits!(ReadPixelsRequest, "ReadPixelsRequest");
5009impl ReadPixelsRequest {
5010    /// Serialize this request into bytes for the provided connection
5011    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5012        let length_so_far = 0;
5013        let context_tag_bytes = self.context_tag.serialize();
5014        let x_bytes = self.x.serialize();
5015        let y_bytes = self.y.serialize();
5016        let width_bytes = self.width.serialize();
5017        let height_bytes = self.height.serialize();
5018        let format_bytes = self.format.serialize();
5019        let type_bytes = self.type_.serialize();
5020        let swap_bytes_bytes = self.swap_bytes.serialize();
5021        let lsb_first_bytes = self.lsb_first.serialize();
5022        let mut request0 = vec![
5023            major_opcode,
5024            READ_PIXELS_REQUEST,
5025            0,
5026            0,
5027            context_tag_bytes[0],
5028            context_tag_bytes[1],
5029            context_tag_bytes[2],
5030            context_tag_bytes[3],
5031            x_bytes[0],
5032            x_bytes[1],
5033            x_bytes[2],
5034            x_bytes[3],
5035            y_bytes[0],
5036            y_bytes[1],
5037            y_bytes[2],
5038            y_bytes[3],
5039            width_bytes[0],
5040            width_bytes[1],
5041            width_bytes[2],
5042            width_bytes[3],
5043            height_bytes[0],
5044            height_bytes[1],
5045            height_bytes[2],
5046            height_bytes[3],
5047            format_bytes[0],
5048            format_bytes[1],
5049            format_bytes[2],
5050            format_bytes[3],
5051            type_bytes[0],
5052            type_bytes[1],
5053            type_bytes[2],
5054            type_bytes[3],
5055            swap_bytes_bytes[0],
5056            lsb_first_bytes[0],
5057            0,
5058            0,
5059        ];
5060        let length_so_far = length_so_far + request0.len();
5061        assert_eq!(length_so_far % 4, 0);
5062        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5063        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5064        ([request0.into()], vec![])
5065    }
5066    /// Parse this request given its header, its body, and any fds that go along with it
5067    #[cfg(feature = "request-parsing")]
5068    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5069        if header.minor_opcode != READ_PIXELS_REQUEST {
5070            return Err(ParseError::InvalidValue);
5071        }
5072        let (context_tag, remaining) = ContextTag::try_parse(value)?;
5073        let (x, remaining) = i32::try_parse(remaining)?;
5074        let (y, remaining) = i32::try_parse(remaining)?;
5075        let (width, remaining) = i32::try_parse(remaining)?;
5076        let (height, remaining) = i32::try_parse(remaining)?;
5077        let (format, remaining) = u32::try_parse(remaining)?;
5078        let (type_, remaining) = u32::try_parse(remaining)?;
5079        let (swap_bytes, remaining) = bool::try_parse(remaining)?;
5080        let (lsb_first, remaining) = bool::try_parse(remaining)?;
5081        let _ = remaining;
5082        Ok(ReadPixelsRequest {
5083            context_tag,
5084            x,
5085            y,
5086            width,
5087            height,
5088            format,
5089            type_,
5090            swap_bytes,
5091            lsb_first,
5092        })
5093    }
5094}
5095impl Request for ReadPixelsRequest {
5096    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
5097
5098    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
5099        let (bufs, fds) = self.serialize(major_opcode);
5100        // Flatten the buffers into a single vector
5101        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
5102        (buf, fds)
5103    }
5104}
5105impl crate::x11_utils::ReplyRequest for ReadPixelsRequest {
5106    type Reply = ReadPixelsReply;
5107}
5108
5109#[derive(Clone, Default)]
5110#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5111#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5112pub struct ReadPixelsReply {
5113    pub sequence: u16,
5114    pub data: Vec<u8>,
5115}
5116impl_debug_if_no_extra_traits!(ReadPixelsReply, "ReadPixelsReply");
5117impl TryParse for ReadPixelsReply {
5118    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5119        let remaining = initial_value;
5120        let (response_type, remaining) = u8::try_parse(remaining)?;
5121        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5122        let (sequence, remaining) = u16::try_parse(remaining)?;
5123        let (length, remaining) = u32::try_parse(remaining)?;
5124        let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
5125        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
5126        let data = data.to_vec();
5127        if response_type != 1 {
5128            return Err(ParseError::InvalidValue);
5129        }
5130        let result = ReadPixelsReply { sequence, data };
5131        let _ = remaining;
5132        let remaining = initial_value.get(32 + length as usize * 4..)
5133            .ok_or(ParseError::InsufficientData)?;
5134        Ok((result, remaining))
5135    }
5136}
5137impl Serialize for ReadPixelsReply {
5138    type Bytes = Vec<u8>;
5139    fn serialize(&self) -> Vec<u8> {
5140        let mut result = Vec::new();
5141        self.serialize_into(&mut result);
5142        result
5143    }
5144    fn serialize_into(&self, bytes: &mut Vec<u8>) {
5145        bytes.reserve(32);
5146        let response_type_bytes = &[1];
5147        bytes.push(response_type_bytes[0]);
5148        bytes.extend_from_slice(&[0; 1]);
5149        self.sequence.serialize_into(bytes);
5150        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
5151        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
5152        length.serialize_into(bytes);
5153        bytes.extend_from_slice(&[0; 24]);
5154        bytes.extend_from_slice(&self.data);
5155    }
5156}
5157impl ReadPixelsReply {
5158    /// Get the value of the `length` field.
5159    ///
5160    /// The `length` field is used as the length field of the `data` field.
5161    /// This function computes the field's value again based on the length of the list.
5162    ///
5163    /// # Panics
5164    ///
5165    /// Panics if the value cannot be represented in the target type. This
5166    /// cannot happen with values of the struct received from the X11 server.
5167    pub fn length(&self) -> u32 {
5168        self.data.len()
5169            .checked_div(4).unwrap()
5170            .try_into().unwrap()
5171    }
5172}
5173
5174/// Opcode for the GetBooleanv request
5175pub const GET_BOOLEANV_REQUEST: u8 = 112;
5176#[derive(Clone, Copy, Default)]
5177#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5178#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5179pub struct GetBooleanvRequest {
5180    pub context_tag: ContextTag,
5181    pub pname: i32,
5182}
5183impl_debug_if_no_extra_traits!(GetBooleanvRequest, "GetBooleanvRequest");
5184impl GetBooleanvRequest {
5185    /// Serialize this request into bytes for the provided connection
5186    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5187        let length_so_far = 0;
5188        let context_tag_bytes = self.context_tag.serialize();
5189        let pname_bytes = self.pname.serialize();
5190        let mut request0 = vec![
5191            major_opcode,
5192            GET_BOOLEANV_REQUEST,
5193            0,
5194            0,
5195            context_tag_bytes[0],
5196            context_tag_bytes[1],
5197            context_tag_bytes[2],
5198            context_tag_bytes[3],
5199            pname_bytes[0],
5200            pname_bytes[1],
5201            pname_bytes[2],
5202            pname_bytes[3],
5203        ];
5204        let length_so_far = length_so_far + request0.len();
5205        assert_eq!(length_so_far % 4, 0);
5206        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5207        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5208        ([request0.into()], vec![])
5209    }
5210    /// Parse this request given its header, its body, and any fds that go along with it
5211    #[cfg(feature = "request-parsing")]
5212    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5213        if header.minor_opcode != GET_BOOLEANV_REQUEST {
5214            return Err(ParseError::InvalidValue);
5215        }
5216        let (context_tag, remaining) = ContextTag::try_parse(value)?;
5217        let (pname, remaining) = i32::try_parse(remaining)?;
5218        let _ = remaining;
5219        Ok(GetBooleanvRequest {
5220            context_tag,
5221            pname,
5222        })
5223    }
5224}
5225impl Request for GetBooleanvRequest {
5226    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
5227
5228    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
5229        let (bufs, fds) = self.serialize(major_opcode);
5230        // Flatten the buffers into a single vector
5231        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
5232        (buf, fds)
5233    }
5234}
5235impl crate::x11_utils::ReplyRequest for GetBooleanvRequest {
5236    type Reply = GetBooleanvReply;
5237}
5238
5239#[derive(Clone, Default)]
5240#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5241#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5242pub struct GetBooleanvReply {
5243    pub sequence: u16,
5244    pub length: u32,
5245    pub datum: bool,
5246    pub data: Vec<bool>,
5247}
5248impl_debug_if_no_extra_traits!(GetBooleanvReply, "GetBooleanvReply");
5249impl TryParse for GetBooleanvReply {
5250    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5251        let remaining = initial_value;
5252        let (response_type, remaining) = u8::try_parse(remaining)?;
5253        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5254        let (sequence, remaining) = u16::try_parse(remaining)?;
5255        let (length, remaining) = u32::try_parse(remaining)?;
5256        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5257        let (n, remaining) = u32::try_parse(remaining)?;
5258        let (datum, remaining) = bool::try_parse(remaining)?;
5259        let remaining = remaining.get(15..).ok_or(ParseError::InsufficientData)?;
5260        let (data, remaining) = crate::x11_utils::parse_list::<bool>(remaining, n.try_to_usize()?)?;
5261        if response_type != 1 {
5262            return Err(ParseError::InvalidValue);
5263        }
5264        let result = GetBooleanvReply { sequence, length, datum, data };
5265        let _ = remaining;
5266        let remaining = initial_value.get(32 + length as usize * 4..)
5267            .ok_or(ParseError::InsufficientData)?;
5268        Ok((result, remaining))
5269    }
5270}
5271impl Serialize for GetBooleanvReply {
5272    type Bytes = Vec<u8>;
5273    fn serialize(&self) -> Vec<u8> {
5274        let mut result = Vec::new();
5275        self.serialize_into(&mut result);
5276        result
5277    }
5278    fn serialize_into(&self, bytes: &mut Vec<u8>) {
5279        bytes.reserve(32);
5280        let response_type_bytes = &[1];
5281        bytes.push(response_type_bytes[0]);
5282        bytes.extend_from_slice(&[0; 1]);
5283        self.sequence.serialize_into(bytes);
5284        self.length.serialize_into(bytes);
5285        bytes.extend_from_slice(&[0; 4]);
5286        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
5287        n.serialize_into(bytes);
5288        self.datum.serialize_into(bytes);
5289        bytes.extend_from_slice(&[0; 15]);
5290        self.data.serialize_into(bytes);
5291    }
5292}
5293impl GetBooleanvReply {
5294    /// Get the value of the `n` field.
5295    ///
5296    /// The `n` field is used as the length field of the `data` field.
5297    /// This function computes the field's value again based on the length of the list.
5298    ///
5299    /// # Panics
5300    ///
5301    /// Panics if the value cannot be represented in the target type. This
5302    /// cannot happen with values of the struct received from the X11 server.
5303    pub fn n(&self) -> u32 {
5304        self.data.len()
5305            .try_into().unwrap()
5306    }
5307}
5308
5309/// Opcode for the GetClipPlane request
5310pub const GET_CLIP_PLANE_REQUEST: u8 = 113;
5311#[derive(Clone, Copy, Default)]
5312#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5313#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5314pub struct GetClipPlaneRequest {
5315    pub context_tag: ContextTag,
5316    pub plane: i32,
5317}
5318impl_debug_if_no_extra_traits!(GetClipPlaneRequest, "GetClipPlaneRequest");
5319impl GetClipPlaneRequest {
5320    /// Serialize this request into bytes for the provided connection
5321    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5322        let length_so_far = 0;
5323        let context_tag_bytes = self.context_tag.serialize();
5324        let plane_bytes = self.plane.serialize();
5325        let mut request0 = vec![
5326            major_opcode,
5327            GET_CLIP_PLANE_REQUEST,
5328            0,
5329            0,
5330            context_tag_bytes[0],
5331            context_tag_bytes[1],
5332            context_tag_bytes[2],
5333            context_tag_bytes[3],
5334            plane_bytes[0],
5335            plane_bytes[1],
5336            plane_bytes[2],
5337            plane_bytes[3],
5338        ];
5339        let length_so_far = length_so_far + request0.len();
5340        assert_eq!(length_so_far % 4, 0);
5341        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5342        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5343        ([request0.into()], vec![])
5344    }
5345    /// Parse this request given its header, its body, and any fds that go along with it
5346    #[cfg(feature = "request-parsing")]
5347    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5348        if header.minor_opcode != GET_CLIP_PLANE_REQUEST {
5349            return Err(ParseError::InvalidValue);
5350        }
5351        let (context_tag, remaining) = ContextTag::try_parse(value)?;
5352        let (plane, remaining) = i32::try_parse(remaining)?;
5353        let _ = remaining;
5354        Ok(GetClipPlaneRequest {
5355            context_tag,
5356            plane,
5357        })
5358    }
5359}
5360impl Request for GetClipPlaneRequest {
5361    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
5362
5363    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
5364        let (bufs, fds) = self.serialize(major_opcode);
5365        // Flatten the buffers into a single vector
5366        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
5367        (buf, fds)
5368    }
5369}
5370impl crate::x11_utils::ReplyRequest for GetClipPlaneRequest {
5371    type Reply = GetClipPlaneReply;
5372}
5373
5374#[derive(Clone, Default)]
5375#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
5376#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5377pub struct GetClipPlaneReply {
5378    pub sequence: u16,
5379    pub data: Vec<Float64>,
5380}
5381impl_debug_if_no_extra_traits!(GetClipPlaneReply, "GetClipPlaneReply");
5382impl TryParse for GetClipPlaneReply {
5383    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5384        let remaining = initial_value;
5385        let (response_type, remaining) = u8::try_parse(remaining)?;
5386        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5387        let (sequence, remaining) = u16::try_parse(remaining)?;
5388        let (length, remaining) = u32::try_parse(remaining)?;
5389        let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
5390        let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, u32::from(length).checked_div(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
5391        if response_type != 1 {
5392            return Err(ParseError::InvalidValue);
5393        }
5394        let result = GetClipPlaneReply { sequence, data };
5395        let _ = remaining;
5396        let remaining = initial_value.get(32 + length as usize * 4..)
5397            .ok_or(ParseError::InsufficientData)?;
5398        Ok((result, remaining))
5399    }
5400}
5401impl Serialize for GetClipPlaneReply {
5402    type Bytes = Vec<u8>;
5403    fn serialize(&self) -> Vec<u8> {
5404        let mut result = Vec::new();
5405        self.serialize_into(&mut result);
5406        result
5407    }
5408    fn serialize_into(&self, bytes: &mut Vec<u8>) {
5409        bytes.reserve(32);
5410        let response_type_bytes = &[1];
5411        bytes.push(response_type_bytes[0]);
5412        bytes.extend_from_slice(&[0; 1]);
5413        self.sequence.serialize_into(bytes);
5414        let length = u32::try_from(self.data.len()).ok().and_then(|len| len.checked_mul(2)).expect("`data` has too many elements");
5415        length.serialize_into(bytes);
5416        bytes.extend_from_slice(&[0; 24]);
5417        self.data.serialize_into(bytes);
5418    }
5419}
5420impl GetClipPlaneReply {
5421    /// Get the value of the `length` field.
5422    ///
5423    /// The `length` field is used as the length field of the `data` field.
5424    /// This function computes the field's value again based on the length of the list.
5425    ///
5426    /// # Panics
5427    ///
5428    /// Panics if the value cannot be represented in the target type. This
5429    /// cannot happen with values of the struct received from the X11 server.
5430    pub fn length(&self) -> u32 {
5431        self.data.len()
5432            .checked_mul(2).unwrap()
5433            .try_into().unwrap()
5434    }
5435}
5436
5437/// Opcode for the GetDoublev request
5438pub const GET_DOUBLEV_REQUEST: u8 = 114;
5439#[derive(Clone, Copy, Default)]
5440#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5441#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5442pub struct GetDoublevRequest {
5443    pub context_tag: ContextTag,
5444    pub pname: u32,
5445}
5446impl_debug_if_no_extra_traits!(GetDoublevRequest, "GetDoublevRequest");
5447impl GetDoublevRequest {
5448    /// Serialize this request into bytes for the provided connection
5449    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5450        let length_so_far = 0;
5451        let context_tag_bytes = self.context_tag.serialize();
5452        let pname_bytes = self.pname.serialize();
5453        let mut request0 = vec![
5454            major_opcode,
5455            GET_DOUBLEV_REQUEST,
5456            0,
5457            0,
5458            context_tag_bytes[0],
5459            context_tag_bytes[1],
5460            context_tag_bytes[2],
5461            context_tag_bytes[3],
5462            pname_bytes[0],
5463            pname_bytes[1],
5464            pname_bytes[2],
5465            pname_bytes[3],
5466        ];
5467        let length_so_far = length_so_far + request0.len();
5468        assert_eq!(length_so_far % 4, 0);
5469        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5470        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5471        ([request0.into()], vec![])
5472    }
5473    /// Parse this request given its header, its body, and any fds that go along with it
5474    #[cfg(feature = "request-parsing")]
5475    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5476        if header.minor_opcode != GET_DOUBLEV_REQUEST {
5477            return Err(ParseError::InvalidValue);
5478        }
5479        let (context_tag, remaining) = ContextTag::try_parse(value)?;
5480        let (pname, remaining) = u32::try_parse(remaining)?;
5481        let _ = remaining;
5482        Ok(GetDoublevRequest {
5483            context_tag,
5484            pname,
5485        })
5486    }
5487}
5488impl Request for GetDoublevRequest {
5489    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
5490
5491    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
5492        let (bufs, fds) = self.serialize(major_opcode);
5493        // Flatten the buffers into a single vector
5494        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
5495        (buf, fds)
5496    }
5497}
5498impl crate::x11_utils::ReplyRequest for GetDoublevRequest {
5499    type Reply = GetDoublevReply;
5500}
5501
5502#[derive(Clone, Default)]
5503#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
5504#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5505pub struct GetDoublevReply {
5506    pub sequence: u16,
5507    pub length: u32,
5508    pub datum: Float64,
5509    pub data: Vec<Float64>,
5510}
5511impl_debug_if_no_extra_traits!(GetDoublevReply, "GetDoublevReply");
5512impl TryParse for GetDoublevReply {
5513    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5514        let remaining = initial_value;
5515        let (response_type, remaining) = u8::try_parse(remaining)?;
5516        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5517        let (sequence, remaining) = u16::try_parse(remaining)?;
5518        let (length, remaining) = u32::try_parse(remaining)?;
5519        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5520        let (n, remaining) = u32::try_parse(remaining)?;
5521        let (datum, remaining) = Float64::try_parse(remaining)?;
5522        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
5523        let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, n.try_to_usize()?)?;
5524        if response_type != 1 {
5525            return Err(ParseError::InvalidValue);
5526        }
5527        let result = GetDoublevReply { sequence, length, datum, data };
5528        let _ = remaining;
5529        let remaining = initial_value.get(32 + length as usize * 4..)
5530            .ok_or(ParseError::InsufficientData)?;
5531        Ok((result, remaining))
5532    }
5533}
5534impl Serialize for GetDoublevReply {
5535    type Bytes = Vec<u8>;
5536    fn serialize(&self) -> Vec<u8> {
5537        let mut result = Vec::new();
5538        self.serialize_into(&mut result);
5539        result
5540    }
5541    fn serialize_into(&self, bytes: &mut Vec<u8>) {
5542        bytes.reserve(32);
5543        let response_type_bytes = &[1];
5544        bytes.push(response_type_bytes[0]);
5545        bytes.extend_from_slice(&[0; 1]);
5546        self.sequence.serialize_into(bytes);
5547        self.length.serialize_into(bytes);
5548        bytes.extend_from_slice(&[0; 4]);
5549        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
5550        n.serialize_into(bytes);
5551        self.datum.serialize_into(bytes);
5552        bytes.extend_from_slice(&[0; 8]);
5553        self.data.serialize_into(bytes);
5554    }
5555}
5556impl GetDoublevReply {
5557    /// Get the value of the `n` field.
5558    ///
5559    /// The `n` field is used as the length field of the `data` field.
5560    /// This function computes the field's value again based on the length of the list.
5561    ///
5562    /// # Panics
5563    ///
5564    /// Panics if the value cannot be represented in the target type. This
5565    /// cannot happen with values of the struct received from the X11 server.
5566    pub fn n(&self) -> u32 {
5567        self.data.len()
5568            .try_into().unwrap()
5569    }
5570}
5571
5572/// Opcode for the GetError request
5573pub const GET_ERROR_REQUEST: u8 = 115;
5574#[derive(Clone, Copy, Default)]
5575#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5576#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5577pub struct GetErrorRequest {
5578    pub context_tag: ContextTag,
5579}
5580impl_debug_if_no_extra_traits!(GetErrorRequest, "GetErrorRequest");
5581impl GetErrorRequest {
5582    /// Serialize this request into bytes for the provided connection
5583    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5584        let length_so_far = 0;
5585        let context_tag_bytes = self.context_tag.serialize();
5586        let mut request0 = vec![
5587            major_opcode,
5588            GET_ERROR_REQUEST,
5589            0,
5590            0,
5591            context_tag_bytes[0],
5592            context_tag_bytes[1],
5593            context_tag_bytes[2],
5594            context_tag_bytes[3],
5595        ];
5596        let length_so_far = length_so_far + request0.len();
5597        assert_eq!(length_so_far % 4, 0);
5598        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5599        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5600        ([request0.into()], vec![])
5601    }
5602    /// Parse this request given its header, its body, and any fds that go along with it
5603    #[cfg(feature = "request-parsing")]
5604    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5605        if header.minor_opcode != GET_ERROR_REQUEST {
5606            return Err(ParseError::InvalidValue);
5607        }
5608        let (context_tag, remaining) = ContextTag::try_parse(value)?;
5609        let _ = remaining;
5610        Ok(GetErrorRequest {
5611            context_tag,
5612        })
5613    }
5614}
5615impl Request for GetErrorRequest {
5616    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
5617
5618    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
5619        let (bufs, fds) = self.serialize(major_opcode);
5620        // Flatten the buffers into a single vector
5621        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
5622        (buf, fds)
5623    }
5624}
5625impl crate::x11_utils::ReplyRequest for GetErrorRequest {
5626    type Reply = GetErrorReply;
5627}
5628
5629#[derive(Clone, Copy, Default)]
5630#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5631#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5632pub struct GetErrorReply {
5633    pub sequence: u16,
5634    pub length: u32,
5635    pub error: i32,
5636}
5637impl_debug_if_no_extra_traits!(GetErrorReply, "GetErrorReply");
5638impl TryParse for GetErrorReply {
5639    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5640        let remaining = initial_value;
5641        let (response_type, remaining) = u8::try_parse(remaining)?;
5642        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5643        let (sequence, remaining) = u16::try_parse(remaining)?;
5644        let (length, remaining) = u32::try_parse(remaining)?;
5645        let (error, remaining) = i32::try_parse(remaining)?;
5646        if response_type != 1 {
5647            return Err(ParseError::InvalidValue);
5648        }
5649        let result = GetErrorReply { sequence, length, error };
5650        let _ = remaining;
5651        let remaining = initial_value.get(32 + length as usize * 4..)
5652            .ok_or(ParseError::InsufficientData)?;
5653        Ok((result, remaining))
5654    }
5655}
5656impl Serialize for GetErrorReply {
5657    type Bytes = [u8; 12];
5658    fn serialize(&self) -> [u8; 12] {
5659        let response_type_bytes = &[1];
5660        let sequence_bytes = self.sequence.serialize();
5661        let length_bytes = self.length.serialize();
5662        let error_bytes = self.error.serialize();
5663        [
5664            response_type_bytes[0],
5665            0,
5666            sequence_bytes[0],
5667            sequence_bytes[1],
5668            length_bytes[0],
5669            length_bytes[1],
5670            length_bytes[2],
5671            length_bytes[3],
5672            error_bytes[0],
5673            error_bytes[1],
5674            error_bytes[2],
5675            error_bytes[3],
5676        ]
5677    }
5678    fn serialize_into(&self, bytes: &mut Vec<u8>) {
5679        bytes.reserve(12);
5680        let response_type_bytes = &[1];
5681        bytes.push(response_type_bytes[0]);
5682        bytes.extend_from_slice(&[0; 1]);
5683        self.sequence.serialize_into(bytes);
5684        self.length.serialize_into(bytes);
5685        self.error.serialize_into(bytes);
5686    }
5687}
5688
5689/// Opcode for the GetFloatv request
5690pub const GET_FLOATV_REQUEST: u8 = 116;
5691#[derive(Clone, Copy, Default)]
5692#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5693#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5694pub struct GetFloatvRequest {
5695    pub context_tag: ContextTag,
5696    pub pname: u32,
5697}
5698impl_debug_if_no_extra_traits!(GetFloatvRequest, "GetFloatvRequest");
5699impl GetFloatvRequest {
5700    /// Serialize this request into bytes for the provided connection
5701    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5702        let length_so_far = 0;
5703        let context_tag_bytes = self.context_tag.serialize();
5704        let pname_bytes = self.pname.serialize();
5705        let mut request0 = vec![
5706            major_opcode,
5707            GET_FLOATV_REQUEST,
5708            0,
5709            0,
5710            context_tag_bytes[0],
5711            context_tag_bytes[1],
5712            context_tag_bytes[2],
5713            context_tag_bytes[3],
5714            pname_bytes[0],
5715            pname_bytes[1],
5716            pname_bytes[2],
5717            pname_bytes[3],
5718        ];
5719        let length_so_far = length_so_far + request0.len();
5720        assert_eq!(length_so_far % 4, 0);
5721        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5722        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5723        ([request0.into()], vec![])
5724    }
5725    /// Parse this request given its header, its body, and any fds that go along with it
5726    #[cfg(feature = "request-parsing")]
5727    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5728        if header.minor_opcode != GET_FLOATV_REQUEST {
5729            return Err(ParseError::InvalidValue);
5730        }
5731        let (context_tag, remaining) = ContextTag::try_parse(value)?;
5732        let (pname, remaining) = u32::try_parse(remaining)?;
5733        let _ = remaining;
5734        Ok(GetFloatvRequest {
5735            context_tag,
5736            pname,
5737        })
5738    }
5739}
5740impl Request for GetFloatvRequest {
5741    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
5742
5743    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
5744        let (bufs, fds) = self.serialize(major_opcode);
5745        // Flatten the buffers into a single vector
5746        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
5747        (buf, fds)
5748    }
5749}
5750impl crate::x11_utils::ReplyRequest for GetFloatvRequest {
5751    type Reply = GetFloatvReply;
5752}
5753
5754#[derive(Clone, Default)]
5755#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
5756#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5757pub struct GetFloatvReply {
5758    pub sequence: u16,
5759    pub length: u32,
5760    pub datum: Float32,
5761    pub data: Vec<Float32>,
5762}
5763impl_debug_if_no_extra_traits!(GetFloatvReply, "GetFloatvReply");
5764impl TryParse for GetFloatvReply {
5765    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5766        let remaining = initial_value;
5767        let (response_type, remaining) = u8::try_parse(remaining)?;
5768        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5769        let (sequence, remaining) = u16::try_parse(remaining)?;
5770        let (length, remaining) = u32::try_parse(remaining)?;
5771        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5772        let (n, remaining) = u32::try_parse(remaining)?;
5773        let (datum, remaining) = Float32::try_parse(remaining)?;
5774        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
5775        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
5776        if response_type != 1 {
5777            return Err(ParseError::InvalidValue);
5778        }
5779        let result = GetFloatvReply { sequence, length, datum, data };
5780        let _ = remaining;
5781        let remaining = initial_value.get(32 + length as usize * 4..)
5782            .ok_or(ParseError::InsufficientData)?;
5783        Ok((result, remaining))
5784    }
5785}
5786impl Serialize for GetFloatvReply {
5787    type Bytes = Vec<u8>;
5788    fn serialize(&self) -> Vec<u8> {
5789        let mut result = Vec::new();
5790        self.serialize_into(&mut result);
5791        result
5792    }
5793    fn serialize_into(&self, bytes: &mut Vec<u8>) {
5794        bytes.reserve(32);
5795        let response_type_bytes = &[1];
5796        bytes.push(response_type_bytes[0]);
5797        bytes.extend_from_slice(&[0; 1]);
5798        self.sequence.serialize_into(bytes);
5799        self.length.serialize_into(bytes);
5800        bytes.extend_from_slice(&[0; 4]);
5801        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
5802        n.serialize_into(bytes);
5803        self.datum.serialize_into(bytes);
5804        bytes.extend_from_slice(&[0; 12]);
5805        self.data.serialize_into(bytes);
5806    }
5807}
5808impl GetFloatvReply {
5809    /// Get the value of the `n` field.
5810    ///
5811    /// The `n` field is used as the length field of the `data` field.
5812    /// This function computes the field's value again based on the length of the list.
5813    ///
5814    /// # Panics
5815    ///
5816    /// Panics if the value cannot be represented in the target type. This
5817    /// cannot happen with values of the struct received from the X11 server.
5818    pub fn n(&self) -> u32 {
5819        self.data.len()
5820            .try_into().unwrap()
5821    }
5822}
5823
5824/// Opcode for the GetIntegerv request
5825pub const GET_INTEGERV_REQUEST: u8 = 117;
5826#[derive(Clone, Copy, Default)]
5827#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5828#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5829pub struct GetIntegervRequest {
5830    pub context_tag: ContextTag,
5831    pub pname: u32,
5832}
5833impl_debug_if_no_extra_traits!(GetIntegervRequest, "GetIntegervRequest");
5834impl GetIntegervRequest {
5835    /// Serialize this request into bytes for the provided connection
5836    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5837        let length_so_far = 0;
5838        let context_tag_bytes = self.context_tag.serialize();
5839        let pname_bytes = self.pname.serialize();
5840        let mut request0 = vec![
5841            major_opcode,
5842            GET_INTEGERV_REQUEST,
5843            0,
5844            0,
5845            context_tag_bytes[0],
5846            context_tag_bytes[1],
5847            context_tag_bytes[2],
5848            context_tag_bytes[3],
5849            pname_bytes[0],
5850            pname_bytes[1],
5851            pname_bytes[2],
5852            pname_bytes[3],
5853        ];
5854        let length_so_far = length_so_far + request0.len();
5855        assert_eq!(length_so_far % 4, 0);
5856        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5857        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5858        ([request0.into()], vec![])
5859    }
5860    /// Parse this request given its header, its body, and any fds that go along with it
5861    #[cfg(feature = "request-parsing")]
5862    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5863        if header.minor_opcode != GET_INTEGERV_REQUEST {
5864            return Err(ParseError::InvalidValue);
5865        }
5866        let (context_tag, remaining) = ContextTag::try_parse(value)?;
5867        let (pname, remaining) = u32::try_parse(remaining)?;
5868        let _ = remaining;
5869        Ok(GetIntegervRequest {
5870            context_tag,
5871            pname,
5872        })
5873    }
5874}
5875impl Request for GetIntegervRequest {
5876    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
5877
5878    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
5879        let (bufs, fds) = self.serialize(major_opcode);
5880        // Flatten the buffers into a single vector
5881        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
5882        (buf, fds)
5883    }
5884}
5885impl crate::x11_utils::ReplyRequest for GetIntegervRequest {
5886    type Reply = GetIntegervReply;
5887}
5888
5889#[derive(Clone, Default)]
5890#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5891#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5892pub struct GetIntegervReply {
5893    pub sequence: u16,
5894    pub length: u32,
5895    pub datum: i32,
5896    pub data: Vec<i32>,
5897}
5898impl_debug_if_no_extra_traits!(GetIntegervReply, "GetIntegervReply");
5899impl TryParse for GetIntegervReply {
5900    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5901        let remaining = initial_value;
5902        let (response_type, remaining) = u8::try_parse(remaining)?;
5903        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5904        let (sequence, remaining) = u16::try_parse(remaining)?;
5905        let (length, remaining) = u32::try_parse(remaining)?;
5906        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5907        let (n, remaining) = u32::try_parse(remaining)?;
5908        let (datum, remaining) = i32::try_parse(remaining)?;
5909        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
5910        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
5911        if response_type != 1 {
5912            return Err(ParseError::InvalidValue);
5913        }
5914        let result = GetIntegervReply { sequence, length, datum, data };
5915        let _ = remaining;
5916        let remaining = initial_value.get(32 + length as usize * 4..)
5917            .ok_or(ParseError::InsufficientData)?;
5918        Ok((result, remaining))
5919    }
5920}
5921impl Serialize for GetIntegervReply {
5922    type Bytes = Vec<u8>;
5923    fn serialize(&self) -> Vec<u8> {
5924        let mut result = Vec::new();
5925        self.serialize_into(&mut result);
5926        result
5927    }
5928    fn serialize_into(&self, bytes: &mut Vec<u8>) {
5929        bytes.reserve(32);
5930        let response_type_bytes = &[1];
5931        bytes.push(response_type_bytes[0]);
5932        bytes.extend_from_slice(&[0; 1]);
5933        self.sequence.serialize_into(bytes);
5934        self.length.serialize_into(bytes);
5935        bytes.extend_from_slice(&[0; 4]);
5936        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
5937        n.serialize_into(bytes);
5938        self.datum.serialize_into(bytes);
5939        bytes.extend_from_slice(&[0; 12]);
5940        self.data.serialize_into(bytes);
5941    }
5942}
5943impl GetIntegervReply {
5944    /// Get the value of the `n` field.
5945    ///
5946    /// The `n` field is used as the length field of the `data` field.
5947    /// This function computes the field's value again based on the length of the list.
5948    ///
5949    /// # Panics
5950    ///
5951    /// Panics if the value cannot be represented in the target type. This
5952    /// cannot happen with values of the struct received from the X11 server.
5953    pub fn n(&self) -> u32 {
5954        self.data.len()
5955            .try_into().unwrap()
5956    }
5957}
5958
5959/// Opcode for the GetLightfv request
5960pub const GET_LIGHTFV_REQUEST: u8 = 118;
5961#[derive(Clone, Copy, Default)]
5962#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
5963#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5964pub struct GetLightfvRequest {
5965    pub context_tag: ContextTag,
5966    pub light: u32,
5967    pub pname: u32,
5968}
5969impl_debug_if_no_extra_traits!(GetLightfvRequest, "GetLightfvRequest");
5970impl GetLightfvRequest {
5971    /// Serialize this request into bytes for the provided connection
5972    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
5973        let length_so_far = 0;
5974        let context_tag_bytes = self.context_tag.serialize();
5975        let light_bytes = self.light.serialize();
5976        let pname_bytes = self.pname.serialize();
5977        let mut request0 = vec![
5978            major_opcode,
5979            GET_LIGHTFV_REQUEST,
5980            0,
5981            0,
5982            context_tag_bytes[0],
5983            context_tag_bytes[1],
5984            context_tag_bytes[2],
5985            context_tag_bytes[3],
5986            light_bytes[0],
5987            light_bytes[1],
5988            light_bytes[2],
5989            light_bytes[3],
5990            pname_bytes[0],
5991            pname_bytes[1],
5992            pname_bytes[2],
5993            pname_bytes[3],
5994        ];
5995        let length_so_far = length_so_far + request0.len();
5996        assert_eq!(length_so_far % 4, 0);
5997        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5998        request0[2..4].copy_from_slice(&length.to_ne_bytes());
5999        ([request0.into()], vec![])
6000    }
6001    /// Parse this request given its header, its body, and any fds that go along with it
6002    #[cfg(feature = "request-parsing")]
6003    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6004        if header.minor_opcode != GET_LIGHTFV_REQUEST {
6005            return Err(ParseError::InvalidValue);
6006        }
6007        let (context_tag, remaining) = ContextTag::try_parse(value)?;
6008        let (light, remaining) = u32::try_parse(remaining)?;
6009        let (pname, remaining) = u32::try_parse(remaining)?;
6010        let _ = remaining;
6011        Ok(GetLightfvRequest {
6012            context_tag,
6013            light,
6014            pname,
6015        })
6016    }
6017}
6018impl Request for GetLightfvRequest {
6019    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
6020
6021    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
6022        let (bufs, fds) = self.serialize(major_opcode);
6023        // Flatten the buffers into a single vector
6024        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
6025        (buf, fds)
6026    }
6027}
6028impl crate::x11_utils::ReplyRequest for GetLightfvRequest {
6029    type Reply = GetLightfvReply;
6030}
6031
6032#[derive(Clone, Default)]
6033#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
6034#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6035pub struct GetLightfvReply {
6036    pub sequence: u16,
6037    pub length: u32,
6038    pub datum: Float32,
6039    pub data: Vec<Float32>,
6040}
6041impl_debug_if_no_extra_traits!(GetLightfvReply, "GetLightfvReply");
6042impl TryParse for GetLightfvReply {
6043    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6044        let remaining = initial_value;
6045        let (response_type, remaining) = u8::try_parse(remaining)?;
6046        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6047        let (sequence, remaining) = u16::try_parse(remaining)?;
6048        let (length, remaining) = u32::try_parse(remaining)?;
6049        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6050        let (n, remaining) = u32::try_parse(remaining)?;
6051        let (datum, remaining) = Float32::try_parse(remaining)?;
6052        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6053        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
6054        if response_type != 1 {
6055            return Err(ParseError::InvalidValue);
6056        }
6057        let result = GetLightfvReply { sequence, length, datum, data };
6058        let _ = remaining;
6059        let remaining = initial_value.get(32 + length as usize * 4..)
6060            .ok_or(ParseError::InsufficientData)?;
6061        Ok((result, remaining))
6062    }
6063}
6064impl Serialize for GetLightfvReply {
6065    type Bytes = Vec<u8>;
6066    fn serialize(&self) -> Vec<u8> {
6067        let mut result = Vec::new();
6068        self.serialize_into(&mut result);
6069        result
6070    }
6071    fn serialize_into(&self, bytes: &mut Vec<u8>) {
6072        bytes.reserve(32);
6073        let response_type_bytes = &[1];
6074        bytes.push(response_type_bytes[0]);
6075        bytes.extend_from_slice(&[0; 1]);
6076        self.sequence.serialize_into(bytes);
6077        self.length.serialize_into(bytes);
6078        bytes.extend_from_slice(&[0; 4]);
6079        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
6080        n.serialize_into(bytes);
6081        self.datum.serialize_into(bytes);
6082        bytes.extend_from_slice(&[0; 12]);
6083        self.data.serialize_into(bytes);
6084    }
6085}
6086impl GetLightfvReply {
6087    /// Get the value of the `n` field.
6088    ///
6089    /// The `n` field is used as the length field of the `data` field.
6090    /// This function computes the field's value again based on the length of the list.
6091    ///
6092    /// # Panics
6093    ///
6094    /// Panics if the value cannot be represented in the target type. This
6095    /// cannot happen with values of the struct received from the X11 server.
6096    pub fn n(&self) -> u32 {
6097        self.data.len()
6098            .try_into().unwrap()
6099    }
6100}
6101
6102/// Opcode for the GetLightiv request
6103pub const GET_LIGHTIV_REQUEST: u8 = 119;
6104#[derive(Clone, Copy, Default)]
6105#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6106#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6107pub struct GetLightivRequest {
6108    pub context_tag: ContextTag,
6109    pub light: u32,
6110    pub pname: u32,
6111}
6112impl_debug_if_no_extra_traits!(GetLightivRequest, "GetLightivRequest");
6113impl GetLightivRequest {
6114    /// Serialize this request into bytes for the provided connection
6115    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
6116        let length_so_far = 0;
6117        let context_tag_bytes = self.context_tag.serialize();
6118        let light_bytes = self.light.serialize();
6119        let pname_bytes = self.pname.serialize();
6120        let mut request0 = vec![
6121            major_opcode,
6122            GET_LIGHTIV_REQUEST,
6123            0,
6124            0,
6125            context_tag_bytes[0],
6126            context_tag_bytes[1],
6127            context_tag_bytes[2],
6128            context_tag_bytes[3],
6129            light_bytes[0],
6130            light_bytes[1],
6131            light_bytes[2],
6132            light_bytes[3],
6133            pname_bytes[0],
6134            pname_bytes[1],
6135            pname_bytes[2],
6136            pname_bytes[3],
6137        ];
6138        let length_so_far = length_so_far + request0.len();
6139        assert_eq!(length_so_far % 4, 0);
6140        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6141        request0[2..4].copy_from_slice(&length.to_ne_bytes());
6142        ([request0.into()], vec![])
6143    }
6144    /// Parse this request given its header, its body, and any fds that go along with it
6145    #[cfg(feature = "request-parsing")]
6146    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6147        if header.minor_opcode != GET_LIGHTIV_REQUEST {
6148            return Err(ParseError::InvalidValue);
6149        }
6150        let (context_tag, remaining) = ContextTag::try_parse(value)?;
6151        let (light, remaining) = u32::try_parse(remaining)?;
6152        let (pname, remaining) = u32::try_parse(remaining)?;
6153        let _ = remaining;
6154        Ok(GetLightivRequest {
6155            context_tag,
6156            light,
6157            pname,
6158        })
6159    }
6160}
6161impl Request for GetLightivRequest {
6162    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
6163
6164    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
6165        let (bufs, fds) = self.serialize(major_opcode);
6166        // Flatten the buffers into a single vector
6167        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
6168        (buf, fds)
6169    }
6170}
6171impl crate::x11_utils::ReplyRequest for GetLightivRequest {
6172    type Reply = GetLightivReply;
6173}
6174
6175#[derive(Clone, Default)]
6176#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6177#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6178pub struct GetLightivReply {
6179    pub sequence: u16,
6180    pub length: u32,
6181    pub datum: i32,
6182    pub data: Vec<i32>,
6183}
6184impl_debug_if_no_extra_traits!(GetLightivReply, "GetLightivReply");
6185impl TryParse for GetLightivReply {
6186    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6187        let remaining = initial_value;
6188        let (response_type, remaining) = u8::try_parse(remaining)?;
6189        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6190        let (sequence, remaining) = u16::try_parse(remaining)?;
6191        let (length, remaining) = u32::try_parse(remaining)?;
6192        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6193        let (n, remaining) = u32::try_parse(remaining)?;
6194        let (datum, remaining) = i32::try_parse(remaining)?;
6195        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6196        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
6197        if response_type != 1 {
6198            return Err(ParseError::InvalidValue);
6199        }
6200        let result = GetLightivReply { sequence, length, datum, data };
6201        let _ = remaining;
6202        let remaining = initial_value.get(32 + length as usize * 4..)
6203            .ok_or(ParseError::InsufficientData)?;
6204        Ok((result, remaining))
6205    }
6206}
6207impl Serialize for GetLightivReply {
6208    type Bytes = Vec<u8>;
6209    fn serialize(&self) -> Vec<u8> {
6210        let mut result = Vec::new();
6211        self.serialize_into(&mut result);
6212        result
6213    }
6214    fn serialize_into(&self, bytes: &mut Vec<u8>) {
6215        bytes.reserve(32);
6216        let response_type_bytes = &[1];
6217        bytes.push(response_type_bytes[0]);
6218        bytes.extend_from_slice(&[0; 1]);
6219        self.sequence.serialize_into(bytes);
6220        self.length.serialize_into(bytes);
6221        bytes.extend_from_slice(&[0; 4]);
6222        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
6223        n.serialize_into(bytes);
6224        self.datum.serialize_into(bytes);
6225        bytes.extend_from_slice(&[0; 12]);
6226        self.data.serialize_into(bytes);
6227    }
6228}
6229impl GetLightivReply {
6230    /// Get the value of the `n` field.
6231    ///
6232    /// The `n` field is used as the length field of the `data` field.
6233    /// This function computes the field's value again based on the length of the list.
6234    ///
6235    /// # Panics
6236    ///
6237    /// Panics if the value cannot be represented in the target type. This
6238    /// cannot happen with values of the struct received from the X11 server.
6239    pub fn n(&self) -> u32 {
6240        self.data.len()
6241            .try_into().unwrap()
6242    }
6243}
6244
6245/// Opcode for the GetMapdv request
6246pub const GET_MAPDV_REQUEST: u8 = 120;
6247#[derive(Clone, Copy, Default)]
6248#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6249#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6250pub struct GetMapdvRequest {
6251    pub context_tag: ContextTag,
6252    pub target: u32,
6253    pub query: u32,
6254}
6255impl_debug_if_no_extra_traits!(GetMapdvRequest, "GetMapdvRequest");
6256impl GetMapdvRequest {
6257    /// Serialize this request into bytes for the provided connection
6258    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
6259        let length_so_far = 0;
6260        let context_tag_bytes = self.context_tag.serialize();
6261        let target_bytes = self.target.serialize();
6262        let query_bytes = self.query.serialize();
6263        let mut request0 = vec![
6264            major_opcode,
6265            GET_MAPDV_REQUEST,
6266            0,
6267            0,
6268            context_tag_bytes[0],
6269            context_tag_bytes[1],
6270            context_tag_bytes[2],
6271            context_tag_bytes[3],
6272            target_bytes[0],
6273            target_bytes[1],
6274            target_bytes[2],
6275            target_bytes[3],
6276            query_bytes[0],
6277            query_bytes[1],
6278            query_bytes[2],
6279            query_bytes[3],
6280        ];
6281        let length_so_far = length_so_far + request0.len();
6282        assert_eq!(length_so_far % 4, 0);
6283        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6284        request0[2..4].copy_from_slice(&length.to_ne_bytes());
6285        ([request0.into()], vec![])
6286    }
6287    /// Parse this request given its header, its body, and any fds that go along with it
6288    #[cfg(feature = "request-parsing")]
6289    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6290        if header.minor_opcode != GET_MAPDV_REQUEST {
6291            return Err(ParseError::InvalidValue);
6292        }
6293        let (context_tag, remaining) = ContextTag::try_parse(value)?;
6294        let (target, remaining) = u32::try_parse(remaining)?;
6295        let (query, remaining) = u32::try_parse(remaining)?;
6296        let _ = remaining;
6297        Ok(GetMapdvRequest {
6298            context_tag,
6299            target,
6300            query,
6301        })
6302    }
6303}
6304impl Request for GetMapdvRequest {
6305    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
6306
6307    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
6308        let (bufs, fds) = self.serialize(major_opcode);
6309        // Flatten the buffers into a single vector
6310        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
6311        (buf, fds)
6312    }
6313}
6314impl crate::x11_utils::ReplyRequest for GetMapdvRequest {
6315    type Reply = GetMapdvReply;
6316}
6317
6318#[derive(Clone, Default)]
6319#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
6320#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6321pub struct GetMapdvReply {
6322    pub sequence: u16,
6323    pub length: u32,
6324    pub datum: Float64,
6325    pub data: Vec<Float64>,
6326}
6327impl_debug_if_no_extra_traits!(GetMapdvReply, "GetMapdvReply");
6328impl TryParse for GetMapdvReply {
6329    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6330        let remaining = initial_value;
6331        let (response_type, remaining) = u8::try_parse(remaining)?;
6332        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6333        let (sequence, remaining) = u16::try_parse(remaining)?;
6334        let (length, remaining) = u32::try_parse(remaining)?;
6335        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6336        let (n, remaining) = u32::try_parse(remaining)?;
6337        let (datum, remaining) = Float64::try_parse(remaining)?;
6338        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
6339        let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, n.try_to_usize()?)?;
6340        if response_type != 1 {
6341            return Err(ParseError::InvalidValue);
6342        }
6343        let result = GetMapdvReply { sequence, length, datum, data };
6344        let _ = remaining;
6345        let remaining = initial_value.get(32 + length as usize * 4..)
6346            .ok_or(ParseError::InsufficientData)?;
6347        Ok((result, remaining))
6348    }
6349}
6350impl Serialize for GetMapdvReply {
6351    type Bytes = Vec<u8>;
6352    fn serialize(&self) -> Vec<u8> {
6353        let mut result = Vec::new();
6354        self.serialize_into(&mut result);
6355        result
6356    }
6357    fn serialize_into(&self, bytes: &mut Vec<u8>) {
6358        bytes.reserve(32);
6359        let response_type_bytes = &[1];
6360        bytes.push(response_type_bytes[0]);
6361        bytes.extend_from_slice(&[0; 1]);
6362        self.sequence.serialize_into(bytes);
6363        self.length.serialize_into(bytes);
6364        bytes.extend_from_slice(&[0; 4]);
6365        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
6366        n.serialize_into(bytes);
6367        self.datum.serialize_into(bytes);
6368        bytes.extend_from_slice(&[0; 8]);
6369        self.data.serialize_into(bytes);
6370    }
6371}
6372impl GetMapdvReply {
6373    /// Get the value of the `n` field.
6374    ///
6375    /// The `n` field is used as the length field of the `data` field.
6376    /// This function computes the field's value again based on the length of the list.
6377    ///
6378    /// # Panics
6379    ///
6380    /// Panics if the value cannot be represented in the target type. This
6381    /// cannot happen with values of the struct received from the X11 server.
6382    pub fn n(&self) -> u32 {
6383        self.data.len()
6384            .try_into().unwrap()
6385    }
6386}
6387
6388/// Opcode for the GetMapfv request
6389pub const GET_MAPFV_REQUEST: u8 = 121;
6390#[derive(Clone, Copy, Default)]
6391#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6392#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6393pub struct GetMapfvRequest {
6394    pub context_tag: ContextTag,
6395    pub target: u32,
6396    pub query: u32,
6397}
6398impl_debug_if_no_extra_traits!(GetMapfvRequest, "GetMapfvRequest");
6399impl GetMapfvRequest {
6400    /// Serialize this request into bytes for the provided connection
6401    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
6402        let length_so_far = 0;
6403        let context_tag_bytes = self.context_tag.serialize();
6404        let target_bytes = self.target.serialize();
6405        let query_bytes = self.query.serialize();
6406        let mut request0 = vec![
6407            major_opcode,
6408            GET_MAPFV_REQUEST,
6409            0,
6410            0,
6411            context_tag_bytes[0],
6412            context_tag_bytes[1],
6413            context_tag_bytes[2],
6414            context_tag_bytes[3],
6415            target_bytes[0],
6416            target_bytes[1],
6417            target_bytes[2],
6418            target_bytes[3],
6419            query_bytes[0],
6420            query_bytes[1],
6421            query_bytes[2],
6422            query_bytes[3],
6423        ];
6424        let length_so_far = length_so_far + request0.len();
6425        assert_eq!(length_so_far % 4, 0);
6426        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6427        request0[2..4].copy_from_slice(&length.to_ne_bytes());
6428        ([request0.into()], vec![])
6429    }
6430    /// Parse this request given its header, its body, and any fds that go along with it
6431    #[cfg(feature = "request-parsing")]
6432    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6433        if header.minor_opcode != GET_MAPFV_REQUEST {
6434            return Err(ParseError::InvalidValue);
6435        }
6436        let (context_tag, remaining) = ContextTag::try_parse(value)?;
6437        let (target, remaining) = u32::try_parse(remaining)?;
6438        let (query, remaining) = u32::try_parse(remaining)?;
6439        let _ = remaining;
6440        Ok(GetMapfvRequest {
6441            context_tag,
6442            target,
6443            query,
6444        })
6445    }
6446}
6447impl Request for GetMapfvRequest {
6448    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
6449
6450    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
6451        let (bufs, fds) = self.serialize(major_opcode);
6452        // Flatten the buffers into a single vector
6453        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
6454        (buf, fds)
6455    }
6456}
6457impl crate::x11_utils::ReplyRequest for GetMapfvRequest {
6458    type Reply = GetMapfvReply;
6459}
6460
6461#[derive(Clone, Default)]
6462#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
6463#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6464pub struct GetMapfvReply {
6465    pub sequence: u16,
6466    pub length: u32,
6467    pub datum: Float32,
6468    pub data: Vec<Float32>,
6469}
6470impl_debug_if_no_extra_traits!(GetMapfvReply, "GetMapfvReply");
6471impl TryParse for GetMapfvReply {
6472    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6473        let remaining = initial_value;
6474        let (response_type, remaining) = u8::try_parse(remaining)?;
6475        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6476        let (sequence, remaining) = u16::try_parse(remaining)?;
6477        let (length, remaining) = u32::try_parse(remaining)?;
6478        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6479        let (n, remaining) = u32::try_parse(remaining)?;
6480        let (datum, remaining) = Float32::try_parse(remaining)?;
6481        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6482        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
6483        if response_type != 1 {
6484            return Err(ParseError::InvalidValue);
6485        }
6486        let result = GetMapfvReply { sequence, length, datum, data };
6487        let _ = remaining;
6488        let remaining = initial_value.get(32 + length as usize * 4..)
6489            .ok_or(ParseError::InsufficientData)?;
6490        Ok((result, remaining))
6491    }
6492}
6493impl Serialize for GetMapfvReply {
6494    type Bytes = Vec<u8>;
6495    fn serialize(&self) -> Vec<u8> {
6496        let mut result = Vec::new();
6497        self.serialize_into(&mut result);
6498        result
6499    }
6500    fn serialize_into(&self, bytes: &mut Vec<u8>) {
6501        bytes.reserve(32);
6502        let response_type_bytes = &[1];
6503        bytes.push(response_type_bytes[0]);
6504        bytes.extend_from_slice(&[0; 1]);
6505        self.sequence.serialize_into(bytes);
6506        self.length.serialize_into(bytes);
6507        bytes.extend_from_slice(&[0; 4]);
6508        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
6509        n.serialize_into(bytes);
6510        self.datum.serialize_into(bytes);
6511        bytes.extend_from_slice(&[0; 12]);
6512        self.data.serialize_into(bytes);
6513    }
6514}
6515impl GetMapfvReply {
6516    /// Get the value of the `n` field.
6517    ///
6518    /// The `n` field is used as the length field of the `data` field.
6519    /// This function computes the field's value again based on the length of the list.
6520    ///
6521    /// # Panics
6522    ///
6523    /// Panics if the value cannot be represented in the target type. This
6524    /// cannot happen with values of the struct received from the X11 server.
6525    pub fn n(&self) -> u32 {
6526        self.data.len()
6527            .try_into().unwrap()
6528    }
6529}
6530
6531/// Opcode for the GetMapiv request
6532pub const GET_MAPIV_REQUEST: u8 = 122;
6533#[derive(Clone, Copy, Default)]
6534#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6535#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6536pub struct GetMapivRequest {
6537    pub context_tag: ContextTag,
6538    pub target: u32,
6539    pub query: u32,
6540}
6541impl_debug_if_no_extra_traits!(GetMapivRequest, "GetMapivRequest");
6542impl GetMapivRequest {
6543    /// Serialize this request into bytes for the provided connection
6544    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
6545        let length_so_far = 0;
6546        let context_tag_bytes = self.context_tag.serialize();
6547        let target_bytes = self.target.serialize();
6548        let query_bytes = self.query.serialize();
6549        let mut request0 = vec![
6550            major_opcode,
6551            GET_MAPIV_REQUEST,
6552            0,
6553            0,
6554            context_tag_bytes[0],
6555            context_tag_bytes[1],
6556            context_tag_bytes[2],
6557            context_tag_bytes[3],
6558            target_bytes[0],
6559            target_bytes[1],
6560            target_bytes[2],
6561            target_bytes[3],
6562            query_bytes[0],
6563            query_bytes[1],
6564            query_bytes[2],
6565            query_bytes[3],
6566        ];
6567        let length_so_far = length_so_far + request0.len();
6568        assert_eq!(length_so_far % 4, 0);
6569        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6570        request0[2..4].copy_from_slice(&length.to_ne_bytes());
6571        ([request0.into()], vec![])
6572    }
6573    /// Parse this request given its header, its body, and any fds that go along with it
6574    #[cfg(feature = "request-parsing")]
6575    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6576        if header.minor_opcode != GET_MAPIV_REQUEST {
6577            return Err(ParseError::InvalidValue);
6578        }
6579        let (context_tag, remaining) = ContextTag::try_parse(value)?;
6580        let (target, remaining) = u32::try_parse(remaining)?;
6581        let (query, remaining) = u32::try_parse(remaining)?;
6582        let _ = remaining;
6583        Ok(GetMapivRequest {
6584            context_tag,
6585            target,
6586            query,
6587        })
6588    }
6589}
6590impl Request for GetMapivRequest {
6591    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
6592
6593    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
6594        let (bufs, fds) = self.serialize(major_opcode);
6595        // Flatten the buffers into a single vector
6596        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
6597        (buf, fds)
6598    }
6599}
6600impl crate::x11_utils::ReplyRequest for GetMapivRequest {
6601    type Reply = GetMapivReply;
6602}
6603
6604#[derive(Clone, Default)]
6605#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6606#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6607pub struct GetMapivReply {
6608    pub sequence: u16,
6609    pub length: u32,
6610    pub datum: i32,
6611    pub data: Vec<i32>,
6612}
6613impl_debug_if_no_extra_traits!(GetMapivReply, "GetMapivReply");
6614impl TryParse for GetMapivReply {
6615    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6616        let remaining = initial_value;
6617        let (response_type, remaining) = u8::try_parse(remaining)?;
6618        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6619        let (sequence, remaining) = u16::try_parse(remaining)?;
6620        let (length, remaining) = u32::try_parse(remaining)?;
6621        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6622        let (n, remaining) = u32::try_parse(remaining)?;
6623        let (datum, remaining) = i32::try_parse(remaining)?;
6624        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6625        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
6626        if response_type != 1 {
6627            return Err(ParseError::InvalidValue);
6628        }
6629        let result = GetMapivReply { sequence, length, datum, data };
6630        let _ = remaining;
6631        let remaining = initial_value.get(32 + length as usize * 4..)
6632            .ok_or(ParseError::InsufficientData)?;
6633        Ok((result, remaining))
6634    }
6635}
6636impl Serialize for GetMapivReply {
6637    type Bytes = Vec<u8>;
6638    fn serialize(&self) -> Vec<u8> {
6639        let mut result = Vec::new();
6640        self.serialize_into(&mut result);
6641        result
6642    }
6643    fn serialize_into(&self, bytes: &mut Vec<u8>) {
6644        bytes.reserve(32);
6645        let response_type_bytes = &[1];
6646        bytes.push(response_type_bytes[0]);
6647        bytes.extend_from_slice(&[0; 1]);
6648        self.sequence.serialize_into(bytes);
6649        self.length.serialize_into(bytes);
6650        bytes.extend_from_slice(&[0; 4]);
6651        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
6652        n.serialize_into(bytes);
6653        self.datum.serialize_into(bytes);
6654        bytes.extend_from_slice(&[0; 12]);
6655        self.data.serialize_into(bytes);
6656    }
6657}
6658impl GetMapivReply {
6659    /// Get the value of the `n` field.
6660    ///
6661    /// The `n` field is used as the length field of the `data` field.
6662    /// This function computes the field's value again based on the length of the list.
6663    ///
6664    /// # Panics
6665    ///
6666    /// Panics if the value cannot be represented in the target type. This
6667    /// cannot happen with values of the struct received from the X11 server.
6668    pub fn n(&self) -> u32 {
6669        self.data.len()
6670            .try_into().unwrap()
6671    }
6672}
6673
6674/// Opcode for the GetMaterialfv request
6675pub const GET_MATERIALFV_REQUEST: u8 = 123;
6676#[derive(Clone, Copy, Default)]
6677#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6678#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6679pub struct GetMaterialfvRequest {
6680    pub context_tag: ContextTag,
6681    pub face: u32,
6682    pub pname: u32,
6683}
6684impl_debug_if_no_extra_traits!(GetMaterialfvRequest, "GetMaterialfvRequest");
6685impl GetMaterialfvRequest {
6686    /// Serialize this request into bytes for the provided connection
6687    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
6688        let length_so_far = 0;
6689        let context_tag_bytes = self.context_tag.serialize();
6690        let face_bytes = self.face.serialize();
6691        let pname_bytes = self.pname.serialize();
6692        let mut request0 = vec![
6693            major_opcode,
6694            GET_MATERIALFV_REQUEST,
6695            0,
6696            0,
6697            context_tag_bytes[0],
6698            context_tag_bytes[1],
6699            context_tag_bytes[2],
6700            context_tag_bytes[3],
6701            face_bytes[0],
6702            face_bytes[1],
6703            face_bytes[2],
6704            face_bytes[3],
6705            pname_bytes[0],
6706            pname_bytes[1],
6707            pname_bytes[2],
6708            pname_bytes[3],
6709        ];
6710        let length_so_far = length_so_far + request0.len();
6711        assert_eq!(length_so_far % 4, 0);
6712        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6713        request0[2..4].copy_from_slice(&length.to_ne_bytes());
6714        ([request0.into()], vec![])
6715    }
6716    /// Parse this request given its header, its body, and any fds that go along with it
6717    #[cfg(feature = "request-parsing")]
6718    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6719        if header.minor_opcode != GET_MATERIALFV_REQUEST {
6720            return Err(ParseError::InvalidValue);
6721        }
6722        let (context_tag, remaining) = ContextTag::try_parse(value)?;
6723        let (face, remaining) = u32::try_parse(remaining)?;
6724        let (pname, remaining) = u32::try_parse(remaining)?;
6725        let _ = remaining;
6726        Ok(GetMaterialfvRequest {
6727            context_tag,
6728            face,
6729            pname,
6730        })
6731    }
6732}
6733impl Request for GetMaterialfvRequest {
6734    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
6735
6736    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
6737        let (bufs, fds) = self.serialize(major_opcode);
6738        // Flatten the buffers into a single vector
6739        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
6740        (buf, fds)
6741    }
6742}
6743impl crate::x11_utils::ReplyRequest for GetMaterialfvRequest {
6744    type Reply = GetMaterialfvReply;
6745}
6746
6747#[derive(Clone, Default)]
6748#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
6749#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6750pub struct GetMaterialfvReply {
6751    pub sequence: u16,
6752    pub length: u32,
6753    pub datum: Float32,
6754    pub data: Vec<Float32>,
6755}
6756impl_debug_if_no_extra_traits!(GetMaterialfvReply, "GetMaterialfvReply");
6757impl TryParse for GetMaterialfvReply {
6758    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6759        let remaining = initial_value;
6760        let (response_type, remaining) = u8::try_parse(remaining)?;
6761        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6762        let (sequence, remaining) = u16::try_parse(remaining)?;
6763        let (length, remaining) = u32::try_parse(remaining)?;
6764        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6765        let (n, remaining) = u32::try_parse(remaining)?;
6766        let (datum, remaining) = Float32::try_parse(remaining)?;
6767        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6768        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
6769        if response_type != 1 {
6770            return Err(ParseError::InvalidValue);
6771        }
6772        let result = GetMaterialfvReply { sequence, length, datum, data };
6773        let _ = remaining;
6774        let remaining = initial_value.get(32 + length as usize * 4..)
6775            .ok_or(ParseError::InsufficientData)?;
6776        Ok((result, remaining))
6777    }
6778}
6779impl Serialize for GetMaterialfvReply {
6780    type Bytes = Vec<u8>;
6781    fn serialize(&self) -> Vec<u8> {
6782        let mut result = Vec::new();
6783        self.serialize_into(&mut result);
6784        result
6785    }
6786    fn serialize_into(&self, bytes: &mut Vec<u8>) {
6787        bytes.reserve(32);
6788        let response_type_bytes = &[1];
6789        bytes.push(response_type_bytes[0]);
6790        bytes.extend_from_slice(&[0; 1]);
6791        self.sequence.serialize_into(bytes);
6792        self.length.serialize_into(bytes);
6793        bytes.extend_from_slice(&[0; 4]);
6794        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
6795        n.serialize_into(bytes);
6796        self.datum.serialize_into(bytes);
6797        bytes.extend_from_slice(&[0; 12]);
6798        self.data.serialize_into(bytes);
6799    }
6800}
6801impl GetMaterialfvReply {
6802    /// Get the value of the `n` field.
6803    ///
6804    /// The `n` field is used as the length field of the `data` field.
6805    /// This function computes the field's value again based on the length of the list.
6806    ///
6807    /// # Panics
6808    ///
6809    /// Panics if the value cannot be represented in the target type. This
6810    /// cannot happen with values of the struct received from the X11 server.
6811    pub fn n(&self) -> u32 {
6812        self.data.len()
6813            .try_into().unwrap()
6814    }
6815}
6816
6817/// Opcode for the GetMaterialiv request
6818pub const GET_MATERIALIV_REQUEST: u8 = 124;
6819#[derive(Clone, Copy, Default)]
6820#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6821#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6822pub struct GetMaterialivRequest {
6823    pub context_tag: ContextTag,
6824    pub face: u32,
6825    pub pname: u32,
6826}
6827impl_debug_if_no_extra_traits!(GetMaterialivRequest, "GetMaterialivRequest");
6828impl GetMaterialivRequest {
6829    /// Serialize this request into bytes for the provided connection
6830    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
6831        let length_so_far = 0;
6832        let context_tag_bytes = self.context_tag.serialize();
6833        let face_bytes = self.face.serialize();
6834        let pname_bytes = self.pname.serialize();
6835        let mut request0 = vec![
6836            major_opcode,
6837            GET_MATERIALIV_REQUEST,
6838            0,
6839            0,
6840            context_tag_bytes[0],
6841            context_tag_bytes[1],
6842            context_tag_bytes[2],
6843            context_tag_bytes[3],
6844            face_bytes[0],
6845            face_bytes[1],
6846            face_bytes[2],
6847            face_bytes[3],
6848            pname_bytes[0],
6849            pname_bytes[1],
6850            pname_bytes[2],
6851            pname_bytes[3],
6852        ];
6853        let length_so_far = length_so_far + request0.len();
6854        assert_eq!(length_so_far % 4, 0);
6855        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6856        request0[2..4].copy_from_slice(&length.to_ne_bytes());
6857        ([request0.into()], vec![])
6858    }
6859    /// Parse this request given its header, its body, and any fds that go along with it
6860    #[cfg(feature = "request-parsing")]
6861    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6862        if header.minor_opcode != GET_MATERIALIV_REQUEST {
6863            return Err(ParseError::InvalidValue);
6864        }
6865        let (context_tag, remaining) = ContextTag::try_parse(value)?;
6866        let (face, remaining) = u32::try_parse(remaining)?;
6867        let (pname, remaining) = u32::try_parse(remaining)?;
6868        let _ = remaining;
6869        Ok(GetMaterialivRequest {
6870            context_tag,
6871            face,
6872            pname,
6873        })
6874    }
6875}
6876impl Request for GetMaterialivRequest {
6877    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
6878
6879    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
6880        let (bufs, fds) = self.serialize(major_opcode);
6881        // Flatten the buffers into a single vector
6882        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
6883        (buf, fds)
6884    }
6885}
6886impl crate::x11_utils::ReplyRequest for GetMaterialivRequest {
6887    type Reply = GetMaterialivReply;
6888}
6889
6890#[derive(Clone, Default)]
6891#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6892#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6893pub struct GetMaterialivReply {
6894    pub sequence: u16,
6895    pub length: u32,
6896    pub datum: i32,
6897    pub data: Vec<i32>,
6898}
6899impl_debug_if_no_extra_traits!(GetMaterialivReply, "GetMaterialivReply");
6900impl TryParse for GetMaterialivReply {
6901    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6902        let remaining = initial_value;
6903        let (response_type, remaining) = u8::try_parse(remaining)?;
6904        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6905        let (sequence, remaining) = u16::try_parse(remaining)?;
6906        let (length, remaining) = u32::try_parse(remaining)?;
6907        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6908        let (n, remaining) = u32::try_parse(remaining)?;
6909        let (datum, remaining) = i32::try_parse(remaining)?;
6910        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6911        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
6912        if response_type != 1 {
6913            return Err(ParseError::InvalidValue);
6914        }
6915        let result = GetMaterialivReply { sequence, length, datum, data };
6916        let _ = remaining;
6917        let remaining = initial_value.get(32 + length as usize * 4..)
6918            .ok_or(ParseError::InsufficientData)?;
6919        Ok((result, remaining))
6920    }
6921}
6922impl Serialize for GetMaterialivReply {
6923    type Bytes = Vec<u8>;
6924    fn serialize(&self) -> Vec<u8> {
6925        let mut result = Vec::new();
6926        self.serialize_into(&mut result);
6927        result
6928    }
6929    fn serialize_into(&self, bytes: &mut Vec<u8>) {
6930        bytes.reserve(32);
6931        let response_type_bytes = &[1];
6932        bytes.push(response_type_bytes[0]);
6933        bytes.extend_from_slice(&[0; 1]);
6934        self.sequence.serialize_into(bytes);
6935        self.length.serialize_into(bytes);
6936        bytes.extend_from_slice(&[0; 4]);
6937        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
6938        n.serialize_into(bytes);
6939        self.datum.serialize_into(bytes);
6940        bytes.extend_from_slice(&[0; 12]);
6941        self.data.serialize_into(bytes);
6942    }
6943}
6944impl GetMaterialivReply {
6945    /// Get the value of the `n` field.
6946    ///
6947    /// The `n` field is used as the length field of the `data` field.
6948    /// This function computes the field's value again based on the length of the list.
6949    ///
6950    /// # Panics
6951    ///
6952    /// Panics if the value cannot be represented in the target type. This
6953    /// cannot happen with values of the struct received from the X11 server.
6954    pub fn n(&self) -> u32 {
6955        self.data.len()
6956            .try_into().unwrap()
6957    }
6958}
6959
6960/// Opcode for the GetPixelMapfv request
6961pub const GET_PIXEL_MAPFV_REQUEST: u8 = 125;
6962#[derive(Clone, Copy, Default)]
6963#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
6964#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6965pub struct GetPixelMapfvRequest {
6966    pub context_tag: ContextTag,
6967    pub map: u32,
6968}
6969impl_debug_if_no_extra_traits!(GetPixelMapfvRequest, "GetPixelMapfvRequest");
6970impl GetPixelMapfvRequest {
6971    /// Serialize this request into bytes for the provided connection
6972    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
6973        let length_so_far = 0;
6974        let context_tag_bytes = self.context_tag.serialize();
6975        let map_bytes = self.map.serialize();
6976        let mut request0 = vec![
6977            major_opcode,
6978            GET_PIXEL_MAPFV_REQUEST,
6979            0,
6980            0,
6981            context_tag_bytes[0],
6982            context_tag_bytes[1],
6983            context_tag_bytes[2],
6984            context_tag_bytes[3],
6985            map_bytes[0],
6986            map_bytes[1],
6987            map_bytes[2],
6988            map_bytes[3],
6989        ];
6990        let length_so_far = length_so_far + request0.len();
6991        assert_eq!(length_so_far % 4, 0);
6992        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6993        request0[2..4].copy_from_slice(&length.to_ne_bytes());
6994        ([request0.into()], vec![])
6995    }
6996    /// Parse this request given its header, its body, and any fds that go along with it
6997    #[cfg(feature = "request-parsing")]
6998    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6999        if header.minor_opcode != GET_PIXEL_MAPFV_REQUEST {
7000            return Err(ParseError::InvalidValue);
7001        }
7002        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7003        let (map, remaining) = u32::try_parse(remaining)?;
7004        let _ = remaining;
7005        Ok(GetPixelMapfvRequest {
7006            context_tag,
7007            map,
7008        })
7009    }
7010}
7011impl Request for GetPixelMapfvRequest {
7012    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7013
7014    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7015        let (bufs, fds) = self.serialize(major_opcode);
7016        // Flatten the buffers into a single vector
7017        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7018        (buf, fds)
7019    }
7020}
7021impl crate::x11_utils::ReplyRequest for GetPixelMapfvRequest {
7022    type Reply = GetPixelMapfvReply;
7023}
7024
7025#[derive(Clone, Default)]
7026#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
7027#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7028pub struct GetPixelMapfvReply {
7029    pub sequence: u16,
7030    pub length: u32,
7031    pub datum: Float32,
7032    pub data: Vec<Float32>,
7033}
7034impl_debug_if_no_extra_traits!(GetPixelMapfvReply, "GetPixelMapfvReply");
7035impl TryParse for GetPixelMapfvReply {
7036    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7037        let remaining = initial_value;
7038        let (response_type, remaining) = u8::try_parse(remaining)?;
7039        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7040        let (sequence, remaining) = u16::try_parse(remaining)?;
7041        let (length, remaining) = u32::try_parse(remaining)?;
7042        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7043        let (n, remaining) = u32::try_parse(remaining)?;
7044        let (datum, remaining) = Float32::try_parse(remaining)?;
7045        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7046        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
7047        if response_type != 1 {
7048            return Err(ParseError::InvalidValue);
7049        }
7050        let result = GetPixelMapfvReply { sequence, length, datum, data };
7051        let _ = remaining;
7052        let remaining = initial_value.get(32 + length as usize * 4..)
7053            .ok_or(ParseError::InsufficientData)?;
7054        Ok((result, remaining))
7055    }
7056}
7057impl Serialize for GetPixelMapfvReply {
7058    type Bytes = Vec<u8>;
7059    fn serialize(&self) -> Vec<u8> {
7060        let mut result = Vec::new();
7061        self.serialize_into(&mut result);
7062        result
7063    }
7064    fn serialize_into(&self, bytes: &mut Vec<u8>) {
7065        bytes.reserve(32);
7066        let response_type_bytes = &[1];
7067        bytes.push(response_type_bytes[0]);
7068        bytes.extend_from_slice(&[0; 1]);
7069        self.sequence.serialize_into(bytes);
7070        self.length.serialize_into(bytes);
7071        bytes.extend_from_slice(&[0; 4]);
7072        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
7073        n.serialize_into(bytes);
7074        self.datum.serialize_into(bytes);
7075        bytes.extend_from_slice(&[0; 12]);
7076        self.data.serialize_into(bytes);
7077    }
7078}
7079impl GetPixelMapfvReply {
7080    /// Get the value of the `n` field.
7081    ///
7082    /// The `n` field is used as the length field of the `data` field.
7083    /// This function computes the field's value again based on the length of the list.
7084    ///
7085    /// # Panics
7086    ///
7087    /// Panics if the value cannot be represented in the target type. This
7088    /// cannot happen with values of the struct received from the X11 server.
7089    pub fn n(&self) -> u32 {
7090        self.data.len()
7091            .try_into().unwrap()
7092    }
7093}
7094
7095/// Opcode for the GetPixelMapuiv request
7096pub const GET_PIXEL_MAPUIV_REQUEST: u8 = 126;
7097#[derive(Clone, Copy, Default)]
7098#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7099#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7100pub struct GetPixelMapuivRequest {
7101    pub context_tag: ContextTag,
7102    pub map: u32,
7103}
7104impl_debug_if_no_extra_traits!(GetPixelMapuivRequest, "GetPixelMapuivRequest");
7105impl GetPixelMapuivRequest {
7106    /// Serialize this request into bytes for the provided connection
7107    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
7108        let length_so_far = 0;
7109        let context_tag_bytes = self.context_tag.serialize();
7110        let map_bytes = self.map.serialize();
7111        let mut request0 = vec![
7112            major_opcode,
7113            GET_PIXEL_MAPUIV_REQUEST,
7114            0,
7115            0,
7116            context_tag_bytes[0],
7117            context_tag_bytes[1],
7118            context_tag_bytes[2],
7119            context_tag_bytes[3],
7120            map_bytes[0],
7121            map_bytes[1],
7122            map_bytes[2],
7123            map_bytes[3],
7124        ];
7125        let length_so_far = length_so_far + request0.len();
7126        assert_eq!(length_so_far % 4, 0);
7127        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7128        request0[2..4].copy_from_slice(&length.to_ne_bytes());
7129        ([request0.into()], vec![])
7130    }
7131    /// Parse this request given its header, its body, and any fds that go along with it
7132    #[cfg(feature = "request-parsing")]
7133    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7134        if header.minor_opcode != GET_PIXEL_MAPUIV_REQUEST {
7135            return Err(ParseError::InvalidValue);
7136        }
7137        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7138        let (map, remaining) = u32::try_parse(remaining)?;
7139        let _ = remaining;
7140        Ok(GetPixelMapuivRequest {
7141            context_tag,
7142            map,
7143        })
7144    }
7145}
7146impl Request for GetPixelMapuivRequest {
7147    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7148
7149    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7150        let (bufs, fds) = self.serialize(major_opcode);
7151        // Flatten the buffers into a single vector
7152        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7153        (buf, fds)
7154    }
7155}
7156impl crate::x11_utils::ReplyRequest for GetPixelMapuivRequest {
7157    type Reply = GetPixelMapuivReply;
7158}
7159
7160#[derive(Clone, Default)]
7161#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7162#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7163pub struct GetPixelMapuivReply {
7164    pub sequence: u16,
7165    pub length: u32,
7166    pub datum: u32,
7167    pub data: Vec<u32>,
7168}
7169impl_debug_if_no_extra_traits!(GetPixelMapuivReply, "GetPixelMapuivReply");
7170impl TryParse for GetPixelMapuivReply {
7171    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7172        let remaining = initial_value;
7173        let (response_type, remaining) = u8::try_parse(remaining)?;
7174        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7175        let (sequence, remaining) = u16::try_parse(remaining)?;
7176        let (length, remaining) = u32::try_parse(remaining)?;
7177        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7178        let (n, remaining) = u32::try_parse(remaining)?;
7179        let (datum, remaining) = u32::try_parse(remaining)?;
7180        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7181        let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
7182        if response_type != 1 {
7183            return Err(ParseError::InvalidValue);
7184        }
7185        let result = GetPixelMapuivReply { sequence, length, datum, data };
7186        let _ = remaining;
7187        let remaining = initial_value.get(32 + length as usize * 4..)
7188            .ok_or(ParseError::InsufficientData)?;
7189        Ok((result, remaining))
7190    }
7191}
7192impl Serialize for GetPixelMapuivReply {
7193    type Bytes = Vec<u8>;
7194    fn serialize(&self) -> Vec<u8> {
7195        let mut result = Vec::new();
7196        self.serialize_into(&mut result);
7197        result
7198    }
7199    fn serialize_into(&self, bytes: &mut Vec<u8>) {
7200        bytes.reserve(32);
7201        let response_type_bytes = &[1];
7202        bytes.push(response_type_bytes[0]);
7203        bytes.extend_from_slice(&[0; 1]);
7204        self.sequence.serialize_into(bytes);
7205        self.length.serialize_into(bytes);
7206        bytes.extend_from_slice(&[0; 4]);
7207        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
7208        n.serialize_into(bytes);
7209        self.datum.serialize_into(bytes);
7210        bytes.extend_from_slice(&[0; 12]);
7211        self.data.serialize_into(bytes);
7212    }
7213}
7214impl GetPixelMapuivReply {
7215    /// Get the value of the `n` field.
7216    ///
7217    /// The `n` field is used as the length field of the `data` field.
7218    /// This function computes the field's value again based on the length of the list.
7219    ///
7220    /// # Panics
7221    ///
7222    /// Panics if the value cannot be represented in the target type. This
7223    /// cannot happen with values of the struct received from the X11 server.
7224    pub fn n(&self) -> u32 {
7225        self.data.len()
7226            .try_into().unwrap()
7227    }
7228}
7229
7230/// Opcode for the GetPixelMapusv request
7231pub const GET_PIXEL_MAPUSV_REQUEST: u8 = 127;
7232#[derive(Clone, Copy, Default)]
7233#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7234#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7235pub struct GetPixelMapusvRequest {
7236    pub context_tag: ContextTag,
7237    pub map: u32,
7238}
7239impl_debug_if_no_extra_traits!(GetPixelMapusvRequest, "GetPixelMapusvRequest");
7240impl GetPixelMapusvRequest {
7241    /// Serialize this request into bytes for the provided connection
7242    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
7243        let length_so_far = 0;
7244        let context_tag_bytes = self.context_tag.serialize();
7245        let map_bytes = self.map.serialize();
7246        let mut request0 = vec![
7247            major_opcode,
7248            GET_PIXEL_MAPUSV_REQUEST,
7249            0,
7250            0,
7251            context_tag_bytes[0],
7252            context_tag_bytes[1],
7253            context_tag_bytes[2],
7254            context_tag_bytes[3],
7255            map_bytes[0],
7256            map_bytes[1],
7257            map_bytes[2],
7258            map_bytes[3],
7259        ];
7260        let length_so_far = length_so_far + request0.len();
7261        assert_eq!(length_so_far % 4, 0);
7262        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7263        request0[2..4].copy_from_slice(&length.to_ne_bytes());
7264        ([request0.into()], vec![])
7265    }
7266    /// Parse this request given its header, its body, and any fds that go along with it
7267    #[cfg(feature = "request-parsing")]
7268    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7269        if header.minor_opcode != GET_PIXEL_MAPUSV_REQUEST {
7270            return Err(ParseError::InvalidValue);
7271        }
7272        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7273        let (map, remaining) = u32::try_parse(remaining)?;
7274        let _ = remaining;
7275        Ok(GetPixelMapusvRequest {
7276            context_tag,
7277            map,
7278        })
7279    }
7280}
7281impl Request for GetPixelMapusvRequest {
7282    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7283
7284    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7285        let (bufs, fds) = self.serialize(major_opcode);
7286        // Flatten the buffers into a single vector
7287        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7288        (buf, fds)
7289    }
7290}
7291impl crate::x11_utils::ReplyRequest for GetPixelMapusvRequest {
7292    type Reply = GetPixelMapusvReply;
7293}
7294
7295#[derive(Clone, Default)]
7296#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7297#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7298pub struct GetPixelMapusvReply {
7299    pub sequence: u16,
7300    pub length: u32,
7301    pub datum: u16,
7302    pub data: Vec<u16>,
7303}
7304impl_debug_if_no_extra_traits!(GetPixelMapusvReply, "GetPixelMapusvReply");
7305impl TryParse for GetPixelMapusvReply {
7306    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7307        let remaining = initial_value;
7308        let (response_type, remaining) = u8::try_parse(remaining)?;
7309        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7310        let (sequence, remaining) = u16::try_parse(remaining)?;
7311        let (length, remaining) = u32::try_parse(remaining)?;
7312        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7313        let (n, remaining) = u32::try_parse(remaining)?;
7314        let (datum, remaining) = u16::try_parse(remaining)?;
7315        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
7316        let (data, remaining) = crate::x11_utils::parse_list::<u16>(remaining, n.try_to_usize()?)?;
7317        if response_type != 1 {
7318            return Err(ParseError::InvalidValue);
7319        }
7320        let result = GetPixelMapusvReply { sequence, length, datum, data };
7321        let _ = remaining;
7322        let remaining = initial_value.get(32 + length as usize * 4..)
7323            .ok_or(ParseError::InsufficientData)?;
7324        Ok((result, remaining))
7325    }
7326}
7327impl Serialize for GetPixelMapusvReply {
7328    type Bytes = Vec<u8>;
7329    fn serialize(&self) -> Vec<u8> {
7330        let mut result = Vec::new();
7331        self.serialize_into(&mut result);
7332        result
7333    }
7334    fn serialize_into(&self, bytes: &mut Vec<u8>) {
7335        bytes.reserve(34);
7336        let response_type_bytes = &[1];
7337        bytes.push(response_type_bytes[0]);
7338        bytes.extend_from_slice(&[0; 1]);
7339        self.sequence.serialize_into(bytes);
7340        self.length.serialize_into(bytes);
7341        bytes.extend_from_slice(&[0; 4]);
7342        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
7343        n.serialize_into(bytes);
7344        self.datum.serialize_into(bytes);
7345        bytes.extend_from_slice(&[0; 16]);
7346        self.data.serialize_into(bytes);
7347    }
7348}
7349impl GetPixelMapusvReply {
7350    /// Get the value of the `n` field.
7351    ///
7352    /// The `n` field is used as the length field of the `data` field.
7353    /// This function computes the field's value again based on the length of the list.
7354    ///
7355    /// # Panics
7356    ///
7357    /// Panics if the value cannot be represented in the target type. This
7358    /// cannot happen with values of the struct received from the X11 server.
7359    pub fn n(&self) -> u32 {
7360        self.data.len()
7361            .try_into().unwrap()
7362    }
7363}
7364
7365/// Opcode for the GetPolygonStipple request
7366pub const GET_POLYGON_STIPPLE_REQUEST: u8 = 128;
7367#[derive(Clone, Copy, Default)]
7368#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7369#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7370pub struct GetPolygonStippleRequest {
7371    pub context_tag: ContextTag,
7372    pub lsb_first: bool,
7373}
7374impl_debug_if_no_extra_traits!(GetPolygonStippleRequest, "GetPolygonStippleRequest");
7375impl GetPolygonStippleRequest {
7376    /// Serialize this request into bytes for the provided connection
7377    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
7378        let length_so_far = 0;
7379        let context_tag_bytes = self.context_tag.serialize();
7380        let lsb_first_bytes = self.lsb_first.serialize();
7381        let mut request0 = vec![
7382            major_opcode,
7383            GET_POLYGON_STIPPLE_REQUEST,
7384            0,
7385            0,
7386            context_tag_bytes[0],
7387            context_tag_bytes[1],
7388            context_tag_bytes[2],
7389            context_tag_bytes[3],
7390            lsb_first_bytes[0],
7391            0,
7392            0,
7393            0,
7394        ];
7395        let length_so_far = length_so_far + request0.len();
7396        assert_eq!(length_so_far % 4, 0);
7397        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7398        request0[2..4].copy_from_slice(&length.to_ne_bytes());
7399        ([request0.into()], vec![])
7400    }
7401    /// Parse this request given its header, its body, and any fds that go along with it
7402    #[cfg(feature = "request-parsing")]
7403    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7404        if header.minor_opcode != GET_POLYGON_STIPPLE_REQUEST {
7405            return Err(ParseError::InvalidValue);
7406        }
7407        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7408        let (lsb_first, remaining) = bool::try_parse(remaining)?;
7409        let _ = remaining;
7410        Ok(GetPolygonStippleRequest {
7411            context_tag,
7412            lsb_first,
7413        })
7414    }
7415}
7416impl Request for GetPolygonStippleRequest {
7417    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7418
7419    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7420        let (bufs, fds) = self.serialize(major_opcode);
7421        // Flatten the buffers into a single vector
7422        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7423        (buf, fds)
7424    }
7425}
7426impl crate::x11_utils::ReplyRequest for GetPolygonStippleRequest {
7427    type Reply = GetPolygonStippleReply;
7428}
7429
7430#[derive(Clone, Default)]
7431#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7432#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7433pub struct GetPolygonStippleReply {
7434    pub sequence: u16,
7435    pub data: Vec<u8>,
7436}
7437impl_debug_if_no_extra_traits!(GetPolygonStippleReply, "GetPolygonStippleReply");
7438impl TryParse for GetPolygonStippleReply {
7439    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7440        let remaining = initial_value;
7441        let (response_type, remaining) = u8::try_parse(remaining)?;
7442        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7443        let (sequence, remaining) = u16::try_parse(remaining)?;
7444        let (length, remaining) = u32::try_parse(remaining)?;
7445        let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
7446        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
7447        let data = data.to_vec();
7448        if response_type != 1 {
7449            return Err(ParseError::InvalidValue);
7450        }
7451        let result = GetPolygonStippleReply { sequence, data };
7452        let _ = remaining;
7453        let remaining = initial_value.get(32 + length as usize * 4..)
7454            .ok_or(ParseError::InsufficientData)?;
7455        Ok((result, remaining))
7456    }
7457}
7458impl Serialize for GetPolygonStippleReply {
7459    type Bytes = Vec<u8>;
7460    fn serialize(&self) -> Vec<u8> {
7461        let mut result = Vec::new();
7462        self.serialize_into(&mut result);
7463        result
7464    }
7465    fn serialize_into(&self, bytes: &mut Vec<u8>) {
7466        bytes.reserve(32);
7467        let response_type_bytes = &[1];
7468        bytes.push(response_type_bytes[0]);
7469        bytes.extend_from_slice(&[0; 1]);
7470        self.sequence.serialize_into(bytes);
7471        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
7472        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
7473        length.serialize_into(bytes);
7474        bytes.extend_from_slice(&[0; 24]);
7475        bytes.extend_from_slice(&self.data);
7476    }
7477}
7478impl GetPolygonStippleReply {
7479    /// Get the value of the `length` field.
7480    ///
7481    /// The `length` field is used as the length field of the `data` field.
7482    /// This function computes the field's value again based on the length of the list.
7483    ///
7484    /// # Panics
7485    ///
7486    /// Panics if the value cannot be represented in the target type. This
7487    /// cannot happen with values of the struct received from the X11 server.
7488    pub fn length(&self) -> u32 {
7489        self.data.len()
7490            .checked_div(4).unwrap()
7491            .try_into().unwrap()
7492    }
7493}
7494
7495/// Opcode for the GetString request
7496pub const GET_STRING_REQUEST: u8 = 129;
7497#[derive(Clone, Copy, Default)]
7498#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7499#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7500pub struct GetStringRequest {
7501    pub context_tag: ContextTag,
7502    pub name: u32,
7503}
7504impl_debug_if_no_extra_traits!(GetStringRequest, "GetStringRequest");
7505impl GetStringRequest {
7506    /// Serialize this request into bytes for the provided connection
7507    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
7508        let length_so_far = 0;
7509        let context_tag_bytes = self.context_tag.serialize();
7510        let name_bytes = self.name.serialize();
7511        let mut request0 = vec![
7512            major_opcode,
7513            GET_STRING_REQUEST,
7514            0,
7515            0,
7516            context_tag_bytes[0],
7517            context_tag_bytes[1],
7518            context_tag_bytes[2],
7519            context_tag_bytes[3],
7520            name_bytes[0],
7521            name_bytes[1],
7522            name_bytes[2],
7523            name_bytes[3],
7524        ];
7525        let length_so_far = length_so_far + request0.len();
7526        assert_eq!(length_so_far % 4, 0);
7527        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7528        request0[2..4].copy_from_slice(&length.to_ne_bytes());
7529        ([request0.into()], vec![])
7530    }
7531    /// Parse this request given its header, its body, and any fds that go along with it
7532    #[cfg(feature = "request-parsing")]
7533    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7534        if header.minor_opcode != GET_STRING_REQUEST {
7535            return Err(ParseError::InvalidValue);
7536        }
7537        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7538        let (name, remaining) = u32::try_parse(remaining)?;
7539        let _ = remaining;
7540        Ok(GetStringRequest {
7541            context_tag,
7542            name,
7543        })
7544    }
7545}
7546impl Request for GetStringRequest {
7547    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7548
7549    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7550        let (bufs, fds) = self.serialize(major_opcode);
7551        // Flatten the buffers into a single vector
7552        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7553        (buf, fds)
7554    }
7555}
7556impl crate::x11_utils::ReplyRequest for GetStringRequest {
7557    type Reply = GetStringReply;
7558}
7559
7560#[derive(Clone, Default)]
7561#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7562#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7563pub struct GetStringReply {
7564    pub sequence: u16,
7565    pub length: u32,
7566    pub string: Vec<u8>,
7567}
7568impl_debug_if_no_extra_traits!(GetStringReply, "GetStringReply");
7569impl TryParse for GetStringReply {
7570    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7571        let remaining = initial_value;
7572        let (response_type, remaining) = u8::try_parse(remaining)?;
7573        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7574        let (sequence, remaining) = u16::try_parse(remaining)?;
7575        let (length, remaining) = u32::try_parse(remaining)?;
7576        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7577        let (n, remaining) = u32::try_parse(remaining)?;
7578        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
7579        let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, n.try_to_usize()?)?;
7580        let string = string.to_vec();
7581        if response_type != 1 {
7582            return Err(ParseError::InvalidValue);
7583        }
7584        let result = GetStringReply { sequence, length, string };
7585        let _ = remaining;
7586        let remaining = initial_value.get(32 + length as usize * 4..)
7587            .ok_or(ParseError::InsufficientData)?;
7588        Ok((result, remaining))
7589    }
7590}
7591impl Serialize for GetStringReply {
7592    type Bytes = Vec<u8>;
7593    fn serialize(&self) -> Vec<u8> {
7594        let mut result = Vec::new();
7595        self.serialize_into(&mut result);
7596        result
7597    }
7598    fn serialize_into(&self, bytes: &mut Vec<u8>) {
7599        bytes.reserve(32);
7600        let response_type_bytes = &[1];
7601        bytes.push(response_type_bytes[0]);
7602        bytes.extend_from_slice(&[0; 1]);
7603        self.sequence.serialize_into(bytes);
7604        self.length.serialize_into(bytes);
7605        bytes.extend_from_slice(&[0; 4]);
7606        let n = u32::try_from(self.string.len()).expect("`string` has too many elements");
7607        n.serialize_into(bytes);
7608        bytes.extend_from_slice(&[0; 16]);
7609        bytes.extend_from_slice(&self.string);
7610    }
7611}
7612impl GetStringReply {
7613    /// Get the value of the `n` field.
7614    ///
7615    /// The `n` field is used as the length field of the `string` field.
7616    /// This function computes the field's value again based on the length of the list.
7617    ///
7618    /// # Panics
7619    ///
7620    /// Panics if the value cannot be represented in the target type. This
7621    /// cannot happen with values of the struct received from the X11 server.
7622    pub fn n(&self) -> u32 {
7623        self.string.len()
7624            .try_into().unwrap()
7625    }
7626}
7627
7628/// Opcode for the GetTexEnvfv request
7629pub const GET_TEX_ENVFV_REQUEST: u8 = 130;
7630#[derive(Clone, Copy, Default)]
7631#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7632#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7633pub struct GetTexEnvfvRequest {
7634    pub context_tag: ContextTag,
7635    pub target: u32,
7636    pub pname: u32,
7637}
7638impl_debug_if_no_extra_traits!(GetTexEnvfvRequest, "GetTexEnvfvRequest");
7639impl GetTexEnvfvRequest {
7640    /// Serialize this request into bytes for the provided connection
7641    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
7642        let length_so_far = 0;
7643        let context_tag_bytes = self.context_tag.serialize();
7644        let target_bytes = self.target.serialize();
7645        let pname_bytes = self.pname.serialize();
7646        let mut request0 = vec![
7647            major_opcode,
7648            GET_TEX_ENVFV_REQUEST,
7649            0,
7650            0,
7651            context_tag_bytes[0],
7652            context_tag_bytes[1],
7653            context_tag_bytes[2],
7654            context_tag_bytes[3],
7655            target_bytes[0],
7656            target_bytes[1],
7657            target_bytes[2],
7658            target_bytes[3],
7659            pname_bytes[0],
7660            pname_bytes[1],
7661            pname_bytes[2],
7662            pname_bytes[3],
7663        ];
7664        let length_so_far = length_so_far + request0.len();
7665        assert_eq!(length_so_far % 4, 0);
7666        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7667        request0[2..4].copy_from_slice(&length.to_ne_bytes());
7668        ([request0.into()], vec![])
7669    }
7670    /// Parse this request given its header, its body, and any fds that go along with it
7671    #[cfg(feature = "request-parsing")]
7672    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7673        if header.minor_opcode != GET_TEX_ENVFV_REQUEST {
7674            return Err(ParseError::InvalidValue);
7675        }
7676        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7677        let (target, remaining) = u32::try_parse(remaining)?;
7678        let (pname, remaining) = u32::try_parse(remaining)?;
7679        let _ = remaining;
7680        Ok(GetTexEnvfvRequest {
7681            context_tag,
7682            target,
7683            pname,
7684        })
7685    }
7686}
7687impl Request for GetTexEnvfvRequest {
7688    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7689
7690    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7691        let (bufs, fds) = self.serialize(major_opcode);
7692        // Flatten the buffers into a single vector
7693        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7694        (buf, fds)
7695    }
7696}
7697impl crate::x11_utils::ReplyRequest for GetTexEnvfvRequest {
7698    type Reply = GetTexEnvfvReply;
7699}
7700
7701#[derive(Clone, Default)]
7702#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
7703#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7704pub struct GetTexEnvfvReply {
7705    pub sequence: u16,
7706    pub length: u32,
7707    pub datum: Float32,
7708    pub data: Vec<Float32>,
7709}
7710impl_debug_if_no_extra_traits!(GetTexEnvfvReply, "GetTexEnvfvReply");
7711impl TryParse for GetTexEnvfvReply {
7712    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7713        let remaining = initial_value;
7714        let (response_type, remaining) = u8::try_parse(remaining)?;
7715        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7716        let (sequence, remaining) = u16::try_parse(remaining)?;
7717        let (length, remaining) = u32::try_parse(remaining)?;
7718        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7719        let (n, remaining) = u32::try_parse(remaining)?;
7720        let (datum, remaining) = Float32::try_parse(remaining)?;
7721        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7722        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
7723        if response_type != 1 {
7724            return Err(ParseError::InvalidValue);
7725        }
7726        let result = GetTexEnvfvReply { sequence, length, datum, data };
7727        let _ = remaining;
7728        let remaining = initial_value.get(32 + length as usize * 4..)
7729            .ok_or(ParseError::InsufficientData)?;
7730        Ok((result, remaining))
7731    }
7732}
7733impl Serialize for GetTexEnvfvReply {
7734    type Bytes = Vec<u8>;
7735    fn serialize(&self) -> Vec<u8> {
7736        let mut result = Vec::new();
7737        self.serialize_into(&mut result);
7738        result
7739    }
7740    fn serialize_into(&self, bytes: &mut Vec<u8>) {
7741        bytes.reserve(32);
7742        let response_type_bytes = &[1];
7743        bytes.push(response_type_bytes[0]);
7744        bytes.extend_from_slice(&[0; 1]);
7745        self.sequence.serialize_into(bytes);
7746        self.length.serialize_into(bytes);
7747        bytes.extend_from_slice(&[0; 4]);
7748        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
7749        n.serialize_into(bytes);
7750        self.datum.serialize_into(bytes);
7751        bytes.extend_from_slice(&[0; 12]);
7752        self.data.serialize_into(bytes);
7753    }
7754}
7755impl GetTexEnvfvReply {
7756    /// Get the value of the `n` field.
7757    ///
7758    /// The `n` field is used as the length field of the `data` field.
7759    /// This function computes the field's value again based on the length of the list.
7760    ///
7761    /// # Panics
7762    ///
7763    /// Panics if the value cannot be represented in the target type. This
7764    /// cannot happen with values of the struct received from the X11 server.
7765    pub fn n(&self) -> u32 {
7766        self.data.len()
7767            .try_into().unwrap()
7768    }
7769}
7770
7771/// Opcode for the GetTexEnviv request
7772pub const GET_TEX_ENVIV_REQUEST: u8 = 131;
7773#[derive(Clone, Copy, Default)]
7774#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7775#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7776pub struct GetTexEnvivRequest {
7777    pub context_tag: ContextTag,
7778    pub target: u32,
7779    pub pname: u32,
7780}
7781impl_debug_if_no_extra_traits!(GetTexEnvivRequest, "GetTexEnvivRequest");
7782impl GetTexEnvivRequest {
7783    /// Serialize this request into bytes for the provided connection
7784    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
7785        let length_so_far = 0;
7786        let context_tag_bytes = self.context_tag.serialize();
7787        let target_bytes = self.target.serialize();
7788        let pname_bytes = self.pname.serialize();
7789        let mut request0 = vec![
7790            major_opcode,
7791            GET_TEX_ENVIV_REQUEST,
7792            0,
7793            0,
7794            context_tag_bytes[0],
7795            context_tag_bytes[1],
7796            context_tag_bytes[2],
7797            context_tag_bytes[3],
7798            target_bytes[0],
7799            target_bytes[1],
7800            target_bytes[2],
7801            target_bytes[3],
7802            pname_bytes[0],
7803            pname_bytes[1],
7804            pname_bytes[2],
7805            pname_bytes[3],
7806        ];
7807        let length_so_far = length_so_far + request0.len();
7808        assert_eq!(length_so_far % 4, 0);
7809        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7810        request0[2..4].copy_from_slice(&length.to_ne_bytes());
7811        ([request0.into()], vec![])
7812    }
7813    /// Parse this request given its header, its body, and any fds that go along with it
7814    #[cfg(feature = "request-parsing")]
7815    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7816        if header.minor_opcode != GET_TEX_ENVIV_REQUEST {
7817            return Err(ParseError::InvalidValue);
7818        }
7819        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7820        let (target, remaining) = u32::try_parse(remaining)?;
7821        let (pname, remaining) = u32::try_parse(remaining)?;
7822        let _ = remaining;
7823        Ok(GetTexEnvivRequest {
7824            context_tag,
7825            target,
7826            pname,
7827        })
7828    }
7829}
7830impl Request for GetTexEnvivRequest {
7831    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7832
7833    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7834        let (bufs, fds) = self.serialize(major_opcode);
7835        // Flatten the buffers into a single vector
7836        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7837        (buf, fds)
7838    }
7839}
7840impl crate::x11_utils::ReplyRequest for GetTexEnvivRequest {
7841    type Reply = GetTexEnvivReply;
7842}
7843
7844#[derive(Clone, Default)]
7845#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7846#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7847pub struct GetTexEnvivReply {
7848    pub sequence: u16,
7849    pub length: u32,
7850    pub datum: i32,
7851    pub data: Vec<i32>,
7852}
7853impl_debug_if_no_extra_traits!(GetTexEnvivReply, "GetTexEnvivReply");
7854impl TryParse for GetTexEnvivReply {
7855    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7856        let remaining = initial_value;
7857        let (response_type, remaining) = u8::try_parse(remaining)?;
7858        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7859        let (sequence, remaining) = u16::try_parse(remaining)?;
7860        let (length, remaining) = u32::try_parse(remaining)?;
7861        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7862        let (n, remaining) = u32::try_parse(remaining)?;
7863        let (datum, remaining) = i32::try_parse(remaining)?;
7864        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7865        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
7866        if response_type != 1 {
7867            return Err(ParseError::InvalidValue);
7868        }
7869        let result = GetTexEnvivReply { sequence, length, datum, data };
7870        let _ = remaining;
7871        let remaining = initial_value.get(32 + length as usize * 4..)
7872            .ok_or(ParseError::InsufficientData)?;
7873        Ok((result, remaining))
7874    }
7875}
7876impl Serialize for GetTexEnvivReply {
7877    type Bytes = Vec<u8>;
7878    fn serialize(&self) -> Vec<u8> {
7879        let mut result = Vec::new();
7880        self.serialize_into(&mut result);
7881        result
7882    }
7883    fn serialize_into(&self, bytes: &mut Vec<u8>) {
7884        bytes.reserve(32);
7885        let response_type_bytes = &[1];
7886        bytes.push(response_type_bytes[0]);
7887        bytes.extend_from_slice(&[0; 1]);
7888        self.sequence.serialize_into(bytes);
7889        self.length.serialize_into(bytes);
7890        bytes.extend_from_slice(&[0; 4]);
7891        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
7892        n.serialize_into(bytes);
7893        self.datum.serialize_into(bytes);
7894        bytes.extend_from_slice(&[0; 12]);
7895        self.data.serialize_into(bytes);
7896    }
7897}
7898impl GetTexEnvivReply {
7899    /// Get the value of the `n` field.
7900    ///
7901    /// The `n` field is used as the length field of the `data` field.
7902    /// This function computes the field's value again based on the length of the list.
7903    ///
7904    /// # Panics
7905    ///
7906    /// Panics if the value cannot be represented in the target type. This
7907    /// cannot happen with values of the struct received from the X11 server.
7908    pub fn n(&self) -> u32 {
7909        self.data.len()
7910            .try_into().unwrap()
7911    }
7912}
7913
7914/// Opcode for the GetTexGendv request
7915pub const GET_TEX_GENDV_REQUEST: u8 = 132;
7916#[derive(Clone, Copy, Default)]
7917#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
7918#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7919pub struct GetTexGendvRequest {
7920    pub context_tag: ContextTag,
7921    pub coord: u32,
7922    pub pname: u32,
7923}
7924impl_debug_if_no_extra_traits!(GetTexGendvRequest, "GetTexGendvRequest");
7925impl GetTexGendvRequest {
7926    /// Serialize this request into bytes for the provided connection
7927    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
7928        let length_so_far = 0;
7929        let context_tag_bytes = self.context_tag.serialize();
7930        let coord_bytes = self.coord.serialize();
7931        let pname_bytes = self.pname.serialize();
7932        let mut request0 = vec![
7933            major_opcode,
7934            GET_TEX_GENDV_REQUEST,
7935            0,
7936            0,
7937            context_tag_bytes[0],
7938            context_tag_bytes[1],
7939            context_tag_bytes[2],
7940            context_tag_bytes[3],
7941            coord_bytes[0],
7942            coord_bytes[1],
7943            coord_bytes[2],
7944            coord_bytes[3],
7945            pname_bytes[0],
7946            pname_bytes[1],
7947            pname_bytes[2],
7948            pname_bytes[3],
7949        ];
7950        let length_so_far = length_so_far + request0.len();
7951        assert_eq!(length_so_far % 4, 0);
7952        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7953        request0[2..4].copy_from_slice(&length.to_ne_bytes());
7954        ([request0.into()], vec![])
7955    }
7956    /// Parse this request given its header, its body, and any fds that go along with it
7957    #[cfg(feature = "request-parsing")]
7958    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7959        if header.minor_opcode != GET_TEX_GENDV_REQUEST {
7960            return Err(ParseError::InvalidValue);
7961        }
7962        let (context_tag, remaining) = ContextTag::try_parse(value)?;
7963        let (coord, remaining) = u32::try_parse(remaining)?;
7964        let (pname, remaining) = u32::try_parse(remaining)?;
7965        let _ = remaining;
7966        Ok(GetTexGendvRequest {
7967            context_tag,
7968            coord,
7969            pname,
7970        })
7971    }
7972}
7973impl Request for GetTexGendvRequest {
7974    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
7975
7976    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
7977        let (bufs, fds) = self.serialize(major_opcode);
7978        // Flatten the buffers into a single vector
7979        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
7980        (buf, fds)
7981    }
7982}
7983impl crate::x11_utils::ReplyRequest for GetTexGendvRequest {
7984    type Reply = GetTexGendvReply;
7985}
7986
7987#[derive(Clone, Default)]
7988#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
7989#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7990pub struct GetTexGendvReply {
7991    pub sequence: u16,
7992    pub length: u32,
7993    pub datum: Float64,
7994    pub data: Vec<Float64>,
7995}
7996impl_debug_if_no_extra_traits!(GetTexGendvReply, "GetTexGendvReply");
7997impl TryParse for GetTexGendvReply {
7998    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7999        let remaining = initial_value;
8000        let (response_type, remaining) = u8::try_parse(remaining)?;
8001        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8002        let (sequence, remaining) = u16::try_parse(remaining)?;
8003        let (length, remaining) = u32::try_parse(remaining)?;
8004        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8005        let (n, remaining) = u32::try_parse(remaining)?;
8006        let (datum, remaining) = Float64::try_parse(remaining)?;
8007        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
8008        let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, n.try_to_usize()?)?;
8009        if response_type != 1 {
8010            return Err(ParseError::InvalidValue);
8011        }
8012        let result = GetTexGendvReply { sequence, length, datum, data };
8013        let _ = remaining;
8014        let remaining = initial_value.get(32 + length as usize * 4..)
8015            .ok_or(ParseError::InsufficientData)?;
8016        Ok((result, remaining))
8017    }
8018}
8019impl Serialize for GetTexGendvReply {
8020    type Bytes = Vec<u8>;
8021    fn serialize(&self) -> Vec<u8> {
8022        let mut result = Vec::new();
8023        self.serialize_into(&mut result);
8024        result
8025    }
8026    fn serialize_into(&self, bytes: &mut Vec<u8>) {
8027        bytes.reserve(32);
8028        let response_type_bytes = &[1];
8029        bytes.push(response_type_bytes[0]);
8030        bytes.extend_from_slice(&[0; 1]);
8031        self.sequence.serialize_into(bytes);
8032        self.length.serialize_into(bytes);
8033        bytes.extend_from_slice(&[0; 4]);
8034        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
8035        n.serialize_into(bytes);
8036        self.datum.serialize_into(bytes);
8037        bytes.extend_from_slice(&[0; 8]);
8038        self.data.serialize_into(bytes);
8039    }
8040}
8041impl GetTexGendvReply {
8042    /// Get the value of the `n` field.
8043    ///
8044    /// The `n` field is used as the length field of the `data` field.
8045    /// This function computes the field's value again based on the length of the list.
8046    ///
8047    /// # Panics
8048    ///
8049    /// Panics if the value cannot be represented in the target type. This
8050    /// cannot happen with values of the struct received from the X11 server.
8051    pub fn n(&self) -> u32 {
8052        self.data.len()
8053            .try_into().unwrap()
8054    }
8055}
8056
8057/// Opcode for the GetTexGenfv request
8058pub const GET_TEX_GENFV_REQUEST: u8 = 133;
8059#[derive(Clone, Copy, Default)]
8060#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8061#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8062pub struct GetTexGenfvRequest {
8063    pub context_tag: ContextTag,
8064    pub coord: u32,
8065    pub pname: u32,
8066}
8067impl_debug_if_no_extra_traits!(GetTexGenfvRequest, "GetTexGenfvRequest");
8068impl GetTexGenfvRequest {
8069    /// Serialize this request into bytes for the provided connection
8070    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
8071        let length_so_far = 0;
8072        let context_tag_bytes = self.context_tag.serialize();
8073        let coord_bytes = self.coord.serialize();
8074        let pname_bytes = self.pname.serialize();
8075        let mut request0 = vec![
8076            major_opcode,
8077            GET_TEX_GENFV_REQUEST,
8078            0,
8079            0,
8080            context_tag_bytes[0],
8081            context_tag_bytes[1],
8082            context_tag_bytes[2],
8083            context_tag_bytes[3],
8084            coord_bytes[0],
8085            coord_bytes[1],
8086            coord_bytes[2],
8087            coord_bytes[3],
8088            pname_bytes[0],
8089            pname_bytes[1],
8090            pname_bytes[2],
8091            pname_bytes[3],
8092        ];
8093        let length_so_far = length_so_far + request0.len();
8094        assert_eq!(length_so_far % 4, 0);
8095        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8096        request0[2..4].copy_from_slice(&length.to_ne_bytes());
8097        ([request0.into()], vec![])
8098    }
8099    /// Parse this request given its header, its body, and any fds that go along with it
8100    #[cfg(feature = "request-parsing")]
8101    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8102        if header.minor_opcode != GET_TEX_GENFV_REQUEST {
8103            return Err(ParseError::InvalidValue);
8104        }
8105        let (context_tag, remaining) = ContextTag::try_parse(value)?;
8106        let (coord, remaining) = u32::try_parse(remaining)?;
8107        let (pname, remaining) = u32::try_parse(remaining)?;
8108        let _ = remaining;
8109        Ok(GetTexGenfvRequest {
8110            context_tag,
8111            coord,
8112            pname,
8113        })
8114    }
8115}
8116impl Request for GetTexGenfvRequest {
8117    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
8118
8119    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
8120        let (bufs, fds) = self.serialize(major_opcode);
8121        // Flatten the buffers into a single vector
8122        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
8123        (buf, fds)
8124    }
8125}
8126impl crate::x11_utils::ReplyRequest for GetTexGenfvRequest {
8127    type Reply = GetTexGenfvReply;
8128}
8129
8130#[derive(Clone, Default)]
8131#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
8132#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8133pub struct GetTexGenfvReply {
8134    pub sequence: u16,
8135    pub length: u32,
8136    pub datum: Float32,
8137    pub data: Vec<Float32>,
8138}
8139impl_debug_if_no_extra_traits!(GetTexGenfvReply, "GetTexGenfvReply");
8140impl TryParse for GetTexGenfvReply {
8141    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8142        let remaining = initial_value;
8143        let (response_type, remaining) = u8::try_parse(remaining)?;
8144        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8145        let (sequence, remaining) = u16::try_parse(remaining)?;
8146        let (length, remaining) = u32::try_parse(remaining)?;
8147        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8148        let (n, remaining) = u32::try_parse(remaining)?;
8149        let (datum, remaining) = Float32::try_parse(remaining)?;
8150        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8151        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
8152        if response_type != 1 {
8153            return Err(ParseError::InvalidValue);
8154        }
8155        let result = GetTexGenfvReply { sequence, length, datum, data };
8156        let _ = remaining;
8157        let remaining = initial_value.get(32 + length as usize * 4..)
8158            .ok_or(ParseError::InsufficientData)?;
8159        Ok((result, remaining))
8160    }
8161}
8162impl Serialize for GetTexGenfvReply {
8163    type Bytes = Vec<u8>;
8164    fn serialize(&self) -> Vec<u8> {
8165        let mut result = Vec::new();
8166        self.serialize_into(&mut result);
8167        result
8168    }
8169    fn serialize_into(&self, bytes: &mut Vec<u8>) {
8170        bytes.reserve(32);
8171        let response_type_bytes = &[1];
8172        bytes.push(response_type_bytes[0]);
8173        bytes.extend_from_slice(&[0; 1]);
8174        self.sequence.serialize_into(bytes);
8175        self.length.serialize_into(bytes);
8176        bytes.extend_from_slice(&[0; 4]);
8177        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
8178        n.serialize_into(bytes);
8179        self.datum.serialize_into(bytes);
8180        bytes.extend_from_slice(&[0; 12]);
8181        self.data.serialize_into(bytes);
8182    }
8183}
8184impl GetTexGenfvReply {
8185    /// Get the value of the `n` field.
8186    ///
8187    /// The `n` field is used as the length field of the `data` field.
8188    /// This function computes the field's value again based on the length of the list.
8189    ///
8190    /// # Panics
8191    ///
8192    /// Panics if the value cannot be represented in the target type. This
8193    /// cannot happen with values of the struct received from the X11 server.
8194    pub fn n(&self) -> u32 {
8195        self.data.len()
8196            .try_into().unwrap()
8197    }
8198}
8199
8200/// Opcode for the GetTexGeniv request
8201pub const GET_TEX_GENIV_REQUEST: u8 = 134;
8202#[derive(Clone, Copy, Default)]
8203#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8204#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8205pub struct GetTexGenivRequest {
8206    pub context_tag: ContextTag,
8207    pub coord: u32,
8208    pub pname: u32,
8209}
8210impl_debug_if_no_extra_traits!(GetTexGenivRequest, "GetTexGenivRequest");
8211impl GetTexGenivRequest {
8212    /// Serialize this request into bytes for the provided connection
8213    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
8214        let length_so_far = 0;
8215        let context_tag_bytes = self.context_tag.serialize();
8216        let coord_bytes = self.coord.serialize();
8217        let pname_bytes = self.pname.serialize();
8218        let mut request0 = vec![
8219            major_opcode,
8220            GET_TEX_GENIV_REQUEST,
8221            0,
8222            0,
8223            context_tag_bytes[0],
8224            context_tag_bytes[1],
8225            context_tag_bytes[2],
8226            context_tag_bytes[3],
8227            coord_bytes[0],
8228            coord_bytes[1],
8229            coord_bytes[2],
8230            coord_bytes[3],
8231            pname_bytes[0],
8232            pname_bytes[1],
8233            pname_bytes[2],
8234            pname_bytes[3],
8235        ];
8236        let length_so_far = length_so_far + request0.len();
8237        assert_eq!(length_so_far % 4, 0);
8238        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8239        request0[2..4].copy_from_slice(&length.to_ne_bytes());
8240        ([request0.into()], vec![])
8241    }
8242    /// Parse this request given its header, its body, and any fds that go along with it
8243    #[cfg(feature = "request-parsing")]
8244    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8245        if header.minor_opcode != GET_TEX_GENIV_REQUEST {
8246            return Err(ParseError::InvalidValue);
8247        }
8248        let (context_tag, remaining) = ContextTag::try_parse(value)?;
8249        let (coord, remaining) = u32::try_parse(remaining)?;
8250        let (pname, remaining) = u32::try_parse(remaining)?;
8251        let _ = remaining;
8252        Ok(GetTexGenivRequest {
8253            context_tag,
8254            coord,
8255            pname,
8256        })
8257    }
8258}
8259impl Request for GetTexGenivRequest {
8260    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
8261
8262    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
8263        let (bufs, fds) = self.serialize(major_opcode);
8264        // Flatten the buffers into a single vector
8265        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
8266        (buf, fds)
8267    }
8268}
8269impl crate::x11_utils::ReplyRequest for GetTexGenivRequest {
8270    type Reply = GetTexGenivReply;
8271}
8272
8273#[derive(Clone, Default)]
8274#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8275#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8276pub struct GetTexGenivReply {
8277    pub sequence: u16,
8278    pub length: u32,
8279    pub datum: i32,
8280    pub data: Vec<i32>,
8281}
8282impl_debug_if_no_extra_traits!(GetTexGenivReply, "GetTexGenivReply");
8283impl TryParse for GetTexGenivReply {
8284    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8285        let remaining = initial_value;
8286        let (response_type, remaining) = u8::try_parse(remaining)?;
8287        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8288        let (sequence, remaining) = u16::try_parse(remaining)?;
8289        let (length, remaining) = u32::try_parse(remaining)?;
8290        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8291        let (n, remaining) = u32::try_parse(remaining)?;
8292        let (datum, remaining) = i32::try_parse(remaining)?;
8293        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8294        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
8295        if response_type != 1 {
8296            return Err(ParseError::InvalidValue);
8297        }
8298        let result = GetTexGenivReply { sequence, length, datum, data };
8299        let _ = remaining;
8300        let remaining = initial_value.get(32 + length as usize * 4..)
8301            .ok_or(ParseError::InsufficientData)?;
8302        Ok((result, remaining))
8303    }
8304}
8305impl Serialize for GetTexGenivReply {
8306    type Bytes = Vec<u8>;
8307    fn serialize(&self) -> Vec<u8> {
8308        let mut result = Vec::new();
8309        self.serialize_into(&mut result);
8310        result
8311    }
8312    fn serialize_into(&self, bytes: &mut Vec<u8>) {
8313        bytes.reserve(32);
8314        let response_type_bytes = &[1];
8315        bytes.push(response_type_bytes[0]);
8316        bytes.extend_from_slice(&[0; 1]);
8317        self.sequence.serialize_into(bytes);
8318        self.length.serialize_into(bytes);
8319        bytes.extend_from_slice(&[0; 4]);
8320        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
8321        n.serialize_into(bytes);
8322        self.datum.serialize_into(bytes);
8323        bytes.extend_from_slice(&[0; 12]);
8324        self.data.serialize_into(bytes);
8325    }
8326}
8327impl GetTexGenivReply {
8328    /// Get the value of the `n` field.
8329    ///
8330    /// The `n` field is used as the length field of the `data` field.
8331    /// This function computes the field's value again based on the length of the list.
8332    ///
8333    /// # Panics
8334    ///
8335    /// Panics if the value cannot be represented in the target type. This
8336    /// cannot happen with values of the struct received from the X11 server.
8337    pub fn n(&self) -> u32 {
8338        self.data.len()
8339            .try_into().unwrap()
8340    }
8341}
8342
8343/// Opcode for the GetTexImage request
8344pub const GET_TEX_IMAGE_REQUEST: u8 = 135;
8345#[derive(Clone, Copy, Default)]
8346#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8347#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8348pub struct GetTexImageRequest {
8349    pub context_tag: ContextTag,
8350    pub target: u32,
8351    pub level: i32,
8352    pub format: u32,
8353    pub type_: u32,
8354    pub swap_bytes: bool,
8355}
8356impl_debug_if_no_extra_traits!(GetTexImageRequest, "GetTexImageRequest");
8357impl GetTexImageRequest {
8358    /// Serialize this request into bytes for the provided connection
8359    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
8360        let length_so_far = 0;
8361        let context_tag_bytes = self.context_tag.serialize();
8362        let target_bytes = self.target.serialize();
8363        let level_bytes = self.level.serialize();
8364        let format_bytes = self.format.serialize();
8365        let type_bytes = self.type_.serialize();
8366        let swap_bytes_bytes = self.swap_bytes.serialize();
8367        let mut request0 = vec![
8368            major_opcode,
8369            GET_TEX_IMAGE_REQUEST,
8370            0,
8371            0,
8372            context_tag_bytes[0],
8373            context_tag_bytes[1],
8374            context_tag_bytes[2],
8375            context_tag_bytes[3],
8376            target_bytes[0],
8377            target_bytes[1],
8378            target_bytes[2],
8379            target_bytes[3],
8380            level_bytes[0],
8381            level_bytes[1],
8382            level_bytes[2],
8383            level_bytes[3],
8384            format_bytes[0],
8385            format_bytes[1],
8386            format_bytes[2],
8387            format_bytes[3],
8388            type_bytes[0],
8389            type_bytes[1],
8390            type_bytes[2],
8391            type_bytes[3],
8392            swap_bytes_bytes[0],
8393            0,
8394            0,
8395            0,
8396        ];
8397        let length_so_far = length_so_far + request0.len();
8398        assert_eq!(length_so_far % 4, 0);
8399        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8400        request0[2..4].copy_from_slice(&length.to_ne_bytes());
8401        ([request0.into()], vec![])
8402    }
8403    /// Parse this request given its header, its body, and any fds that go along with it
8404    #[cfg(feature = "request-parsing")]
8405    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8406        if header.minor_opcode != GET_TEX_IMAGE_REQUEST {
8407            return Err(ParseError::InvalidValue);
8408        }
8409        let (context_tag, remaining) = ContextTag::try_parse(value)?;
8410        let (target, remaining) = u32::try_parse(remaining)?;
8411        let (level, remaining) = i32::try_parse(remaining)?;
8412        let (format, remaining) = u32::try_parse(remaining)?;
8413        let (type_, remaining) = u32::try_parse(remaining)?;
8414        let (swap_bytes, remaining) = bool::try_parse(remaining)?;
8415        let _ = remaining;
8416        Ok(GetTexImageRequest {
8417            context_tag,
8418            target,
8419            level,
8420            format,
8421            type_,
8422            swap_bytes,
8423        })
8424    }
8425}
8426impl Request for GetTexImageRequest {
8427    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
8428
8429    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
8430        let (bufs, fds) = self.serialize(major_opcode);
8431        // Flatten the buffers into a single vector
8432        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
8433        (buf, fds)
8434    }
8435}
8436impl crate::x11_utils::ReplyRequest for GetTexImageRequest {
8437    type Reply = GetTexImageReply;
8438}
8439
8440#[derive(Clone, Default)]
8441#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8442#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8443pub struct GetTexImageReply {
8444    pub sequence: u16,
8445    pub width: i32,
8446    pub height: i32,
8447    pub depth: i32,
8448    pub data: Vec<u8>,
8449}
8450impl_debug_if_no_extra_traits!(GetTexImageReply, "GetTexImageReply");
8451impl TryParse for GetTexImageReply {
8452    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8453        let remaining = initial_value;
8454        let (response_type, remaining) = u8::try_parse(remaining)?;
8455        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8456        let (sequence, remaining) = u16::try_parse(remaining)?;
8457        let (length, remaining) = u32::try_parse(remaining)?;
8458        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
8459        let (width, remaining) = i32::try_parse(remaining)?;
8460        let (height, remaining) = i32::try_parse(remaining)?;
8461        let (depth, remaining) = i32::try_parse(remaining)?;
8462        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8463        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
8464        let data = data.to_vec();
8465        if response_type != 1 {
8466            return Err(ParseError::InvalidValue);
8467        }
8468        let result = GetTexImageReply { sequence, width, height, depth, data };
8469        let _ = remaining;
8470        let remaining = initial_value.get(32 + length as usize * 4..)
8471            .ok_or(ParseError::InsufficientData)?;
8472        Ok((result, remaining))
8473    }
8474}
8475impl Serialize for GetTexImageReply {
8476    type Bytes = Vec<u8>;
8477    fn serialize(&self) -> Vec<u8> {
8478        let mut result = Vec::new();
8479        self.serialize_into(&mut result);
8480        result
8481    }
8482    fn serialize_into(&self, bytes: &mut Vec<u8>) {
8483        bytes.reserve(32);
8484        let response_type_bytes = &[1];
8485        bytes.push(response_type_bytes[0]);
8486        bytes.extend_from_slice(&[0; 1]);
8487        self.sequence.serialize_into(bytes);
8488        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
8489        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
8490        length.serialize_into(bytes);
8491        bytes.extend_from_slice(&[0; 8]);
8492        self.width.serialize_into(bytes);
8493        self.height.serialize_into(bytes);
8494        self.depth.serialize_into(bytes);
8495        bytes.extend_from_slice(&[0; 4]);
8496        bytes.extend_from_slice(&self.data);
8497    }
8498}
8499impl GetTexImageReply {
8500    /// Get the value of the `length` field.
8501    ///
8502    /// The `length` field is used as the length field of the `data` field.
8503    /// This function computes the field's value again based on the length of the list.
8504    ///
8505    /// # Panics
8506    ///
8507    /// Panics if the value cannot be represented in the target type. This
8508    /// cannot happen with values of the struct received from the X11 server.
8509    pub fn length(&self) -> u32 {
8510        self.data.len()
8511            .checked_div(4).unwrap()
8512            .try_into().unwrap()
8513    }
8514}
8515
8516/// Opcode for the GetTexParameterfv request
8517pub const GET_TEX_PARAMETERFV_REQUEST: u8 = 136;
8518#[derive(Clone, Copy, Default)]
8519#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8520#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8521pub struct GetTexParameterfvRequest {
8522    pub context_tag: ContextTag,
8523    pub target: u32,
8524    pub pname: u32,
8525}
8526impl_debug_if_no_extra_traits!(GetTexParameterfvRequest, "GetTexParameterfvRequest");
8527impl GetTexParameterfvRequest {
8528    /// Serialize this request into bytes for the provided connection
8529    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
8530        let length_so_far = 0;
8531        let context_tag_bytes = self.context_tag.serialize();
8532        let target_bytes = self.target.serialize();
8533        let pname_bytes = self.pname.serialize();
8534        let mut request0 = vec![
8535            major_opcode,
8536            GET_TEX_PARAMETERFV_REQUEST,
8537            0,
8538            0,
8539            context_tag_bytes[0],
8540            context_tag_bytes[1],
8541            context_tag_bytes[2],
8542            context_tag_bytes[3],
8543            target_bytes[0],
8544            target_bytes[1],
8545            target_bytes[2],
8546            target_bytes[3],
8547            pname_bytes[0],
8548            pname_bytes[1],
8549            pname_bytes[2],
8550            pname_bytes[3],
8551        ];
8552        let length_so_far = length_so_far + request0.len();
8553        assert_eq!(length_so_far % 4, 0);
8554        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8555        request0[2..4].copy_from_slice(&length.to_ne_bytes());
8556        ([request0.into()], vec![])
8557    }
8558    /// Parse this request given its header, its body, and any fds that go along with it
8559    #[cfg(feature = "request-parsing")]
8560    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8561        if header.minor_opcode != GET_TEX_PARAMETERFV_REQUEST {
8562            return Err(ParseError::InvalidValue);
8563        }
8564        let (context_tag, remaining) = ContextTag::try_parse(value)?;
8565        let (target, remaining) = u32::try_parse(remaining)?;
8566        let (pname, remaining) = u32::try_parse(remaining)?;
8567        let _ = remaining;
8568        Ok(GetTexParameterfvRequest {
8569            context_tag,
8570            target,
8571            pname,
8572        })
8573    }
8574}
8575impl Request for GetTexParameterfvRequest {
8576    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
8577
8578    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
8579        let (bufs, fds) = self.serialize(major_opcode);
8580        // Flatten the buffers into a single vector
8581        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
8582        (buf, fds)
8583    }
8584}
8585impl crate::x11_utils::ReplyRequest for GetTexParameterfvRequest {
8586    type Reply = GetTexParameterfvReply;
8587}
8588
8589#[derive(Clone, Default)]
8590#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
8591#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8592pub struct GetTexParameterfvReply {
8593    pub sequence: u16,
8594    pub length: u32,
8595    pub datum: Float32,
8596    pub data: Vec<Float32>,
8597}
8598impl_debug_if_no_extra_traits!(GetTexParameterfvReply, "GetTexParameterfvReply");
8599impl TryParse for GetTexParameterfvReply {
8600    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8601        let remaining = initial_value;
8602        let (response_type, remaining) = u8::try_parse(remaining)?;
8603        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8604        let (sequence, remaining) = u16::try_parse(remaining)?;
8605        let (length, remaining) = u32::try_parse(remaining)?;
8606        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8607        let (n, remaining) = u32::try_parse(remaining)?;
8608        let (datum, remaining) = Float32::try_parse(remaining)?;
8609        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8610        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
8611        if response_type != 1 {
8612            return Err(ParseError::InvalidValue);
8613        }
8614        let result = GetTexParameterfvReply { sequence, length, datum, data };
8615        let _ = remaining;
8616        let remaining = initial_value.get(32 + length as usize * 4..)
8617            .ok_or(ParseError::InsufficientData)?;
8618        Ok((result, remaining))
8619    }
8620}
8621impl Serialize for GetTexParameterfvReply {
8622    type Bytes = Vec<u8>;
8623    fn serialize(&self) -> Vec<u8> {
8624        let mut result = Vec::new();
8625        self.serialize_into(&mut result);
8626        result
8627    }
8628    fn serialize_into(&self, bytes: &mut Vec<u8>) {
8629        bytes.reserve(32);
8630        let response_type_bytes = &[1];
8631        bytes.push(response_type_bytes[0]);
8632        bytes.extend_from_slice(&[0; 1]);
8633        self.sequence.serialize_into(bytes);
8634        self.length.serialize_into(bytes);
8635        bytes.extend_from_slice(&[0; 4]);
8636        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
8637        n.serialize_into(bytes);
8638        self.datum.serialize_into(bytes);
8639        bytes.extend_from_slice(&[0; 12]);
8640        self.data.serialize_into(bytes);
8641    }
8642}
8643impl GetTexParameterfvReply {
8644    /// Get the value of the `n` field.
8645    ///
8646    /// The `n` field is used as the length field of the `data` field.
8647    /// This function computes the field's value again based on the length of the list.
8648    ///
8649    /// # Panics
8650    ///
8651    /// Panics if the value cannot be represented in the target type. This
8652    /// cannot happen with values of the struct received from the X11 server.
8653    pub fn n(&self) -> u32 {
8654        self.data.len()
8655            .try_into().unwrap()
8656    }
8657}
8658
8659/// Opcode for the GetTexParameteriv request
8660pub const GET_TEX_PARAMETERIV_REQUEST: u8 = 137;
8661#[derive(Clone, Copy, Default)]
8662#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8663#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8664pub struct GetTexParameterivRequest {
8665    pub context_tag: ContextTag,
8666    pub target: u32,
8667    pub pname: u32,
8668}
8669impl_debug_if_no_extra_traits!(GetTexParameterivRequest, "GetTexParameterivRequest");
8670impl GetTexParameterivRequest {
8671    /// Serialize this request into bytes for the provided connection
8672    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
8673        let length_so_far = 0;
8674        let context_tag_bytes = self.context_tag.serialize();
8675        let target_bytes = self.target.serialize();
8676        let pname_bytes = self.pname.serialize();
8677        let mut request0 = vec![
8678            major_opcode,
8679            GET_TEX_PARAMETERIV_REQUEST,
8680            0,
8681            0,
8682            context_tag_bytes[0],
8683            context_tag_bytes[1],
8684            context_tag_bytes[2],
8685            context_tag_bytes[3],
8686            target_bytes[0],
8687            target_bytes[1],
8688            target_bytes[2],
8689            target_bytes[3],
8690            pname_bytes[0],
8691            pname_bytes[1],
8692            pname_bytes[2],
8693            pname_bytes[3],
8694        ];
8695        let length_so_far = length_so_far + request0.len();
8696        assert_eq!(length_so_far % 4, 0);
8697        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8698        request0[2..4].copy_from_slice(&length.to_ne_bytes());
8699        ([request0.into()], vec![])
8700    }
8701    /// Parse this request given its header, its body, and any fds that go along with it
8702    #[cfg(feature = "request-parsing")]
8703    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8704        if header.minor_opcode != GET_TEX_PARAMETERIV_REQUEST {
8705            return Err(ParseError::InvalidValue);
8706        }
8707        let (context_tag, remaining) = ContextTag::try_parse(value)?;
8708        let (target, remaining) = u32::try_parse(remaining)?;
8709        let (pname, remaining) = u32::try_parse(remaining)?;
8710        let _ = remaining;
8711        Ok(GetTexParameterivRequest {
8712            context_tag,
8713            target,
8714            pname,
8715        })
8716    }
8717}
8718impl Request for GetTexParameterivRequest {
8719    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
8720
8721    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
8722        let (bufs, fds) = self.serialize(major_opcode);
8723        // Flatten the buffers into a single vector
8724        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
8725        (buf, fds)
8726    }
8727}
8728impl crate::x11_utils::ReplyRequest for GetTexParameterivRequest {
8729    type Reply = GetTexParameterivReply;
8730}
8731
8732#[derive(Clone, Default)]
8733#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8734#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8735pub struct GetTexParameterivReply {
8736    pub sequence: u16,
8737    pub length: u32,
8738    pub datum: i32,
8739    pub data: Vec<i32>,
8740}
8741impl_debug_if_no_extra_traits!(GetTexParameterivReply, "GetTexParameterivReply");
8742impl TryParse for GetTexParameterivReply {
8743    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8744        let remaining = initial_value;
8745        let (response_type, remaining) = u8::try_parse(remaining)?;
8746        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8747        let (sequence, remaining) = u16::try_parse(remaining)?;
8748        let (length, remaining) = u32::try_parse(remaining)?;
8749        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8750        let (n, remaining) = u32::try_parse(remaining)?;
8751        let (datum, remaining) = i32::try_parse(remaining)?;
8752        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8753        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
8754        if response_type != 1 {
8755            return Err(ParseError::InvalidValue);
8756        }
8757        let result = GetTexParameterivReply { sequence, length, datum, data };
8758        let _ = remaining;
8759        let remaining = initial_value.get(32 + length as usize * 4..)
8760            .ok_or(ParseError::InsufficientData)?;
8761        Ok((result, remaining))
8762    }
8763}
8764impl Serialize for GetTexParameterivReply {
8765    type Bytes = Vec<u8>;
8766    fn serialize(&self) -> Vec<u8> {
8767        let mut result = Vec::new();
8768        self.serialize_into(&mut result);
8769        result
8770    }
8771    fn serialize_into(&self, bytes: &mut Vec<u8>) {
8772        bytes.reserve(32);
8773        let response_type_bytes = &[1];
8774        bytes.push(response_type_bytes[0]);
8775        bytes.extend_from_slice(&[0; 1]);
8776        self.sequence.serialize_into(bytes);
8777        self.length.serialize_into(bytes);
8778        bytes.extend_from_slice(&[0; 4]);
8779        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
8780        n.serialize_into(bytes);
8781        self.datum.serialize_into(bytes);
8782        bytes.extend_from_slice(&[0; 12]);
8783        self.data.serialize_into(bytes);
8784    }
8785}
8786impl GetTexParameterivReply {
8787    /// Get the value of the `n` field.
8788    ///
8789    /// The `n` field is used as the length field of the `data` field.
8790    /// This function computes the field's value again based on the length of the list.
8791    ///
8792    /// # Panics
8793    ///
8794    /// Panics if the value cannot be represented in the target type. This
8795    /// cannot happen with values of the struct received from the X11 server.
8796    pub fn n(&self) -> u32 {
8797        self.data.len()
8798            .try_into().unwrap()
8799    }
8800}
8801
8802/// Opcode for the GetTexLevelParameterfv request
8803pub const GET_TEX_LEVEL_PARAMETERFV_REQUEST: u8 = 138;
8804#[derive(Clone, Copy, Default)]
8805#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8806#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8807pub struct GetTexLevelParameterfvRequest {
8808    pub context_tag: ContextTag,
8809    pub target: u32,
8810    pub level: i32,
8811    pub pname: u32,
8812}
8813impl_debug_if_no_extra_traits!(GetTexLevelParameterfvRequest, "GetTexLevelParameterfvRequest");
8814impl GetTexLevelParameterfvRequest {
8815    /// Serialize this request into bytes for the provided connection
8816    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
8817        let length_so_far = 0;
8818        let context_tag_bytes = self.context_tag.serialize();
8819        let target_bytes = self.target.serialize();
8820        let level_bytes = self.level.serialize();
8821        let pname_bytes = self.pname.serialize();
8822        let mut request0 = vec![
8823            major_opcode,
8824            GET_TEX_LEVEL_PARAMETERFV_REQUEST,
8825            0,
8826            0,
8827            context_tag_bytes[0],
8828            context_tag_bytes[1],
8829            context_tag_bytes[2],
8830            context_tag_bytes[3],
8831            target_bytes[0],
8832            target_bytes[1],
8833            target_bytes[2],
8834            target_bytes[3],
8835            level_bytes[0],
8836            level_bytes[1],
8837            level_bytes[2],
8838            level_bytes[3],
8839            pname_bytes[0],
8840            pname_bytes[1],
8841            pname_bytes[2],
8842            pname_bytes[3],
8843        ];
8844        let length_so_far = length_so_far + request0.len();
8845        assert_eq!(length_so_far % 4, 0);
8846        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8847        request0[2..4].copy_from_slice(&length.to_ne_bytes());
8848        ([request0.into()], vec![])
8849    }
8850    /// Parse this request given its header, its body, and any fds that go along with it
8851    #[cfg(feature = "request-parsing")]
8852    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8853        if header.minor_opcode != GET_TEX_LEVEL_PARAMETERFV_REQUEST {
8854            return Err(ParseError::InvalidValue);
8855        }
8856        let (context_tag, remaining) = ContextTag::try_parse(value)?;
8857        let (target, remaining) = u32::try_parse(remaining)?;
8858        let (level, remaining) = i32::try_parse(remaining)?;
8859        let (pname, remaining) = u32::try_parse(remaining)?;
8860        let _ = remaining;
8861        Ok(GetTexLevelParameterfvRequest {
8862            context_tag,
8863            target,
8864            level,
8865            pname,
8866        })
8867    }
8868}
8869impl Request for GetTexLevelParameterfvRequest {
8870    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
8871
8872    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
8873        let (bufs, fds) = self.serialize(major_opcode);
8874        // Flatten the buffers into a single vector
8875        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
8876        (buf, fds)
8877    }
8878}
8879impl crate::x11_utils::ReplyRequest for GetTexLevelParameterfvRequest {
8880    type Reply = GetTexLevelParameterfvReply;
8881}
8882
8883#[derive(Clone, Default)]
8884#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
8885#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8886pub struct GetTexLevelParameterfvReply {
8887    pub sequence: u16,
8888    pub length: u32,
8889    pub datum: Float32,
8890    pub data: Vec<Float32>,
8891}
8892impl_debug_if_no_extra_traits!(GetTexLevelParameterfvReply, "GetTexLevelParameterfvReply");
8893impl TryParse for GetTexLevelParameterfvReply {
8894    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8895        let remaining = initial_value;
8896        let (response_type, remaining) = u8::try_parse(remaining)?;
8897        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8898        let (sequence, remaining) = u16::try_parse(remaining)?;
8899        let (length, remaining) = u32::try_parse(remaining)?;
8900        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8901        let (n, remaining) = u32::try_parse(remaining)?;
8902        let (datum, remaining) = Float32::try_parse(remaining)?;
8903        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8904        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
8905        if response_type != 1 {
8906            return Err(ParseError::InvalidValue);
8907        }
8908        let result = GetTexLevelParameterfvReply { sequence, length, datum, data };
8909        let _ = remaining;
8910        let remaining = initial_value.get(32 + length as usize * 4..)
8911            .ok_or(ParseError::InsufficientData)?;
8912        Ok((result, remaining))
8913    }
8914}
8915impl Serialize for GetTexLevelParameterfvReply {
8916    type Bytes = Vec<u8>;
8917    fn serialize(&self) -> Vec<u8> {
8918        let mut result = Vec::new();
8919        self.serialize_into(&mut result);
8920        result
8921    }
8922    fn serialize_into(&self, bytes: &mut Vec<u8>) {
8923        bytes.reserve(32);
8924        let response_type_bytes = &[1];
8925        bytes.push(response_type_bytes[0]);
8926        bytes.extend_from_slice(&[0; 1]);
8927        self.sequence.serialize_into(bytes);
8928        self.length.serialize_into(bytes);
8929        bytes.extend_from_slice(&[0; 4]);
8930        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
8931        n.serialize_into(bytes);
8932        self.datum.serialize_into(bytes);
8933        bytes.extend_from_slice(&[0; 12]);
8934        self.data.serialize_into(bytes);
8935    }
8936}
8937impl GetTexLevelParameterfvReply {
8938    /// Get the value of the `n` field.
8939    ///
8940    /// The `n` field is used as the length field of the `data` field.
8941    /// This function computes the field's value again based on the length of the list.
8942    ///
8943    /// # Panics
8944    ///
8945    /// Panics if the value cannot be represented in the target type. This
8946    /// cannot happen with values of the struct received from the X11 server.
8947    pub fn n(&self) -> u32 {
8948        self.data.len()
8949            .try_into().unwrap()
8950    }
8951}
8952
8953/// Opcode for the GetTexLevelParameteriv request
8954pub const GET_TEX_LEVEL_PARAMETERIV_REQUEST: u8 = 139;
8955#[derive(Clone, Copy, Default)]
8956#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
8957#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8958pub struct GetTexLevelParameterivRequest {
8959    pub context_tag: ContextTag,
8960    pub target: u32,
8961    pub level: i32,
8962    pub pname: u32,
8963}
8964impl_debug_if_no_extra_traits!(GetTexLevelParameterivRequest, "GetTexLevelParameterivRequest");
8965impl GetTexLevelParameterivRequest {
8966    /// Serialize this request into bytes for the provided connection
8967    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
8968        let length_so_far = 0;
8969        let context_tag_bytes = self.context_tag.serialize();
8970        let target_bytes = self.target.serialize();
8971        let level_bytes = self.level.serialize();
8972        let pname_bytes = self.pname.serialize();
8973        let mut request0 = vec![
8974            major_opcode,
8975            GET_TEX_LEVEL_PARAMETERIV_REQUEST,
8976            0,
8977            0,
8978            context_tag_bytes[0],
8979            context_tag_bytes[1],
8980            context_tag_bytes[2],
8981            context_tag_bytes[3],
8982            target_bytes[0],
8983            target_bytes[1],
8984            target_bytes[2],
8985            target_bytes[3],
8986            level_bytes[0],
8987            level_bytes[1],
8988            level_bytes[2],
8989            level_bytes[3],
8990            pname_bytes[0],
8991            pname_bytes[1],
8992            pname_bytes[2],
8993            pname_bytes[3],
8994        ];
8995        let length_so_far = length_so_far + request0.len();
8996        assert_eq!(length_so_far % 4, 0);
8997        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8998        request0[2..4].copy_from_slice(&length.to_ne_bytes());
8999        ([request0.into()], vec![])
9000    }
9001    /// Parse this request given its header, its body, and any fds that go along with it
9002    #[cfg(feature = "request-parsing")]
9003    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9004        if header.minor_opcode != GET_TEX_LEVEL_PARAMETERIV_REQUEST {
9005            return Err(ParseError::InvalidValue);
9006        }
9007        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9008        let (target, remaining) = u32::try_parse(remaining)?;
9009        let (level, remaining) = i32::try_parse(remaining)?;
9010        let (pname, remaining) = u32::try_parse(remaining)?;
9011        let _ = remaining;
9012        Ok(GetTexLevelParameterivRequest {
9013            context_tag,
9014            target,
9015            level,
9016            pname,
9017        })
9018    }
9019}
9020impl Request for GetTexLevelParameterivRequest {
9021    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9022
9023    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9024        let (bufs, fds) = self.serialize(major_opcode);
9025        // Flatten the buffers into a single vector
9026        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9027        (buf, fds)
9028    }
9029}
9030impl crate::x11_utils::ReplyRequest for GetTexLevelParameterivRequest {
9031    type Reply = GetTexLevelParameterivReply;
9032}
9033
9034#[derive(Clone, Default)]
9035#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9036#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9037pub struct GetTexLevelParameterivReply {
9038    pub sequence: u16,
9039    pub length: u32,
9040    pub datum: i32,
9041    pub data: Vec<i32>,
9042}
9043impl_debug_if_no_extra_traits!(GetTexLevelParameterivReply, "GetTexLevelParameterivReply");
9044impl TryParse for GetTexLevelParameterivReply {
9045    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9046        let remaining = initial_value;
9047        let (response_type, remaining) = u8::try_parse(remaining)?;
9048        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9049        let (sequence, remaining) = u16::try_parse(remaining)?;
9050        let (length, remaining) = u32::try_parse(remaining)?;
9051        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
9052        let (n, remaining) = u32::try_parse(remaining)?;
9053        let (datum, remaining) = i32::try_parse(remaining)?;
9054        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
9055        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
9056        if response_type != 1 {
9057            return Err(ParseError::InvalidValue);
9058        }
9059        let result = GetTexLevelParameterivReply { sequence, length, datum, data };
9060        let _ = remaining;
9061        let remaining = initial_value.get(32 + length as usize * 4..)
9062            .ok_or(ParseError::InsufficientData)?;
9063        Ok((result, remaining))
9064    }
9065}
9066impl Serialize for GetTexLevelParameterivReply {
9067    type Bytes = Vec<u8>;
9068    fn serialize(&self) -> Vec<u8> {
9069        let mut result = Vec::new();
9070        self.serialize_into(&mut result);
9071        result
9072    }
9073    fn serialize_into(&self, bytes: &mut Vec<u8>) {
9074        bytes.reserve(32);
9075        let response_type_bytes = &[1];
9076        bytes.push(response_type_bytes[0]);
9077        bytes.extend_from_slice(&[0; 1]);
9078        self.sequence.serialize_into(bytes);
9079        self.length.serialize_into(bytes);
9080        bytes.extend_from_slice(&[0; 4]);
9081        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
9082        n.serialize_into(bytes);
9083        self.datum.serialize_into(bytes);
9084        bytes.extend_from_slice(&[0; 12]);
9085        self.data.serialize_into(bytes);
9086    }
9087}
9088impl GetTexLevelParameterivReply {
9089    /// Get the value of the `n` field.
9090    ///
9091    /// The `n` field is used as the length field of the `data` field.
9092    /// This function computes the field's value again based on the length of the list.
9093    ///
9094    /// # Panics
9095    ///
9096    /// Panics if the value cannot be represented in the target type. This
9097    /// cannot happen with values of the struct received from the X11 server.
9098    pub fn n(&self) -> u32 {
9099        self.data.len()
9100            .try_into().unwrap()
9101    }
9102}
9103
9104/// Opcode for the IsEnabled request
9105pub const IS_ENABLED_REQUEST: u8 = 140;
9106#[derive(Clone, Copy, Default)]
9107#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9108#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9109pub struct IsEnabledRequest {
9110    pub context_tag: ContextTag,
9111    pub capability: u32,
9112}
9113impl_debug_if_no_extra_traits!(IsEnabledRequest, "IsEnabledRequest");
9114impl IsEnabledRequest {
9115    /// Serialize this request into bytes for the provided connection
9116    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
9117        let length_so_far = 0;
9118        let context_tag_bytes = self.context_tag.serialize();
9119        let capability_bytes = self.capability.serialize();
9120        let mut request0 = vec![
9121            major_opcode,
9122            IS_ENABLED_REQUEST,
9123            0,
9124            0,
9125            context_tag_bytes[0],
9126            context_tag_bytes[1],
9127            context_tag_bytes[2],
9128            context_tag_bytes[3],
9129            capability_bytes[0],
9130            capability_bytes[1],
9131            capability_bytes[2],
9132            capability_bytes[3],
9133        ];
9134        let length_so_far = length_so_far + request0.len();
9135        assert_eq!(length_so_far % 4, 0);
9136        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9137        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9138        ([request0.into()], vec![])
9139    }
9140    /// Parse this request given its header, its body, and any fds that go along with it
9141    #[cfg(feature = "request-parsing")]
9142    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9143        if header.minor_opcode != IS_ENABLED_REQUEST {
9144            return Err(ParseError::InvalidValue);
9145        }
9146        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9147        let (capability, remaining) = u32::try_parse(remaining)?;
9148        let _ = remaining;
9149        Ok(IsEnabledRequest {
9150            context_tag,
9151            capability,
9152        })
9153    }
9154}
9155impl Request for IsEnabledRequest {
9156    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9157
9158    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9159        let (bufs, fds) = self.serialize(major_opcode);
9160        // Flatten the buffers into a single vector
9161        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9162        (buf, fds)
9163    }
9164}
9165impl crate::x11_utils::ReplyRequest for IsEnabledRequest {
9166    type Reply = IsEnabledReply;
9167}
9168
9169#[derive(Clone, Copy, Default)]
9170#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9171#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9172pub struct IsEnabledReply {
9173    pub sequence: u16,
9174    pub length: u32,
9175    pub ret_val: Bool32,
9176}
9177impl_debug_if_no_extra_traits!(IsEnabledReply, "IsEnabledReply");
9178impl TryParse for IsEnabledReply {
9179    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9180        let remaining = initial_value;
9181        let (response_type, remaining) = u8::try_parse(remaining)?;
9182        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9183        let (sequence, remaining) = u16::try_parse(remaining)?;
9184        let (length, remaining) = u32::try_parse(remaining)?;
9185        let (ret_val, remaining) = Bool32::try_parse(remaining)?;
9186        if response_type != 1 {
9187            return Err(ParseError::InvalidValue);
9188        }
9189        let result = IsEnabledReply { sequence, length, ret_val };
9190        let _ = remaining;
9191        let remaining = initial_value.get(32 + length as usize * 4..)
9192            .ok_or(ParseError::InsufficientData)?;
9193        Ok((result, remaining))
9194    }
9195}
9196impl Serialize for IsEnabledReply {
9197    type Bytes = [u8; 12];
9198    fn serialize(&self) -> [u8; 12] {
9199        let response_type_bytes = &[1];
9200        let sequence_bytes = self.sequence.serialize();
9201        let length_bytes = self.length.serialize();
9202        let ret_val_bytes = self.ret_val.serialize();
9203        [
9204            response_type_bytes[0],
9205            0,
9206            sequence_bytes[0],
9207            sequence_bytes[1],
9208            length_bytes[0],
9209            length_bytes[1],
9210            length_bytes[2],
9211            length_bytes[3],
9212            ret_val_bytes[0],
9213            ret_val_bytes[1],
9214            ret_val_bytes[2],
9215            ret_val_bytes[3],
9216        ]
9217    }
9218    fn serialize_into(&self, bytes: &mut Vec<u8>) {
9219        bytes.reserve(12);
9220        let response_type_bytes = &[1];
9221        bytes.push(response_type_bytes[0]);
9222        bytes.extend_from_slice(&[0; 1]);
9223        self.sequence.serialize_into(bytes);
9224        self.length.serialize_into(bytes);
9225        self.ret_val.serialize_into(bytes);
9226    }
9227}
9228
9229/// Opcode for the IsList request
9230pub const IS_LIST_REQUEST: u8 = 141;
9231#[derive(Clone, Copy, Default)]
9232#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9233#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9234pub struct IsListRequest {
9235    pub context_tag: ContextTag,
9236    pub list: u32,
9237}
9238impl_debug_if_no_extra_traits!(IsListRequest, "IsListRequest");
9239impl IsListRequest {
9240    /// Serialize this request into bytes for the provided connection
9241    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
9242        let length_so_far = 0;
9243        let context_tag_bytes = self.context_tag.serialize();
9244        let list_bytes = self.list.serialize();
9245        let mut request0 = vec![
9246            major_opcode,
9247            IS_LIST_REQUEST,
9248            0,
9249            0,
9250            context_tag_bytes[0],
9251            context_tag_bytes[1],
9252            context_tag_bytes[2],
9253            context_tag_bytes[3],
9254            list_bytes[0],
9255            list_bytes[1],
9256            list_bytes[2],
9257            list_bytes[3],
9258        ];
9259        let length_so_far = length_so_far + request0.len();
9260        assert_eq!(length_so_far % 4, 0);
9261        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9262        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9263        ([request0.into()], vec![])
9264    }
9265    /// Parse this request given its header, its body, and any fds that go along with it
9266    #[cfg(feature = "request-parsing")]
9267    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9268        if header.minor_opcode != IS_LIST_REQUEST {
9269            return Err(ParseError::InvalidValue);
9270        }
9271        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9272        let (list, remaining) = u32::try_parse(remaining)?;
9273        let _ = remaining;
9274        Ok(IsListRequest {
9275            context_tag,
9276            list,
9277        })
9278    }
9279}
9280impl Request for IsListRequest {
9281    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9282
9283    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9284        let (bufs, fds) = self.serialize(major_opcode);
9285        // Flatten the buffers into a single vector
9286        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9287        (buf, fds)
9288    }
9289}
9290impl crate::x11_utils::ReplyRequest for IsListRequest {
9291    type Reply = IsListReply;
9292}
9293
9294#[derive(Clone, Copy, Default)]
9295#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9296#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9297pub struct IsListReply {
9298    pub sequence: u16,
9299    pub length: u32,
9300    pub ret_val: Bool32,
9301}
9302impl_debug_if_no_extra_traits!(IsListReply, "IsListReply");
9303impl TryParse for IsListReply {
9304    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9305        let remaining = initial_value;
9306        let (response_type, remaining) = u8::try_parse(remaining)?;
9307        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9308        let (sequence, remaining) = u16::try_parse(remaining)?;
9309        let (length, remaining) = u32::try_parse(remaining)?;
9310        let (ret_val, remaining) = Bool32::try_parse(remaining)?;
9311        if response_type != 1 {
9312            return Err(ParseError::InvalidValue);
9313        }
9314        let result = IsListReply { sequence, length, ret_val };
9315        let _ = remaining;
9316        let remaining = initial_value.get(32 + length as usize * 4..)
9317            .ok_or(ParseError::InsufficientData)?;
9318        Ok((result, remaining))
9319    }
9320}
9321impl Serialize for IsListReply {
9322    type Bytes = [u8; 12];
9323    fn serialize(&self) -> [u8; 12] {
9324        let response_type_bytes = &[1];
9325        let sequence_bytes = self.sequence.serialize();
9326        let length_bytes = self.length.serialize();
9327        let ret_val_bytes = self.ret_val.serialize();
9328        [
9329            response_type_bytes[0],
9330            0,
9331            sequence_bytes[0],
9332            sequence_bytes[1],
9333            length_bytes[0],
9334            length_bytes[1],
9335            length_bytes[2],
9336            length_bytes[3],
9337            ret_val_bytes[0],
9338            ret_val_bytes[1],
9339            ret_val_bytes[2],
9340            ret_val_bytes[3],
9341        ]
9342    }
9343    fn serialize_into(&self, bytes: &mut Vec<u8>) {
9344        bytes.reserve(12);
9345        let response_type_bytes = &[1];
9346        bytes.push(response_type_bytes[0]);
9347        bytes.extend_from_slice(&[0; 1]);
9348        self.sequence.serialize_into(bytes);
9349        self.length.serialize_into(bytes);
9350        self.ret_val.serialize_into(bytes);
9351    }
9352}
9353
9354/// Opcode for the Flush request
9355pub const FLUSH_REQUEST: u8 = 142;
9356#[derive(Clone, Copy, Default)]
9357#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9358#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9359pub struct FlushRequest {
9360    pub context_tag: ContextTag,
9361}
9362impl_debug_if_no_extra_traits!(FlushRequest, "FlushRequest");
9363impl FlushRequest {
9364    /// Serialize this request into bytes for the provided connection
9365    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
9366        let length_so_far = 0;
9367        let context_tag_bytes = self.context_tag.serialize();
9368        let mut request0 = vec![
9369            major_opcode,
9370            FLUSH_REQUEST,
9371            0,
9372            0,
9373            context_tag_bytes[0],
9374            context_tag_bytes[1],
9375            context_tag_bytes[2],
9376            context_tag_bytes[3],
9377        ];
9378        let length_so_far = length_so_far + request0.len();
9379        assert_eq!(length_so_far % 4, 0);
9380        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9381        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9382        ([request0.into()], vec![])
9383    }
9384    /// Parse this request given its header, its body, and any fds that go along with it
9385    #[cfg(feature = "request-parsing")]
9386    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9387        if header.minor_opcode != FLUSH_REQUEST {
9388            return Err(ParseError::InvalidValue);
9389        }
9390        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9391        let _ = remaining;
9392        Ok(FlushRequest {
9393            context_tag,
9394        })
9395    }
9396}
9397impl Request for FlushRequest {
9398    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9399
9400    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9401        let (bufs, fds) = self.serialize(major_opcode);
9402        // Flatten the buffers into a single vector
9403        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9404        (buf, fds)
9405    }
9406}
9407impl crate::x11_utils::VoidRequest for FlushRequest {
9408}
9409
9410/// Opcode for the AreTexturesResident request
9411pub const ARE_TEXTURES_RESIDENT_REQUEST: u8 = 143;
9412#[derive(Clone, Default)]
9413#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9414#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9415pub struct AreTexturesResidentRequest<'input> {
9416    pub context_tag: ContextTag,
9417    pub textures: Cow<'input, [u32]>,
9418}
9419impl_debug_if_no_extra_traits!(AreTexturesResidentRequest<'_>, "AreTexturesResidentRequest");
9420impl<'input> AreTexturesResidentRequest<'input> {
9421    /// Serialize this request into bytes for the provided connection
9422    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
9423        let length_so_far = 0;
9424        let context_tag_bytes = self.context_tag.serialize();
9425        let n = i32::try_from(self.textures.len()).expect("`textures` has too many elements");
9426        let n_bytes = n.serialize();
9427        let mut request0 = vec![
9428            major_opcode,
9429            ARE_TEXTURES_RESIDENT_REQUEST,
9430            0,
9431            0,
9432            context_tag_bytes[0],
9433            context_tag_bytes[1],
9434            context_tag_bytes[2],
9435            context_tag_bytes[3],
9436            n_bytes[0],
9437            n_bytes[1],
9438            n_bytes[2],
9439            n_bytes[3],
9440        ];
9441        let length_so_far = length_so_far + request0.len();
9442        let textures_bytes = self.textures.serialize();
9443        let length_so_far = length_so_far + textures_bytes.len();
9444        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
9445        let length_so_far = length_so_far + padding0.len();
9446        assert_eq!(length_so_far % 4, 0);
9447        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9448        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9449        ([request0.into(), textures_bytes.into(), padding0.into()], vec![])
9450    }
9451    /// Parse this request given its header, its body, and any fds that go along with it
9452    #[cfg(feature = "request-parsing")]
9453    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
9454        if header.minor_opcode != ARE_TEXTURES_RESIDENT_REQUEST {
9455            return Err(ParseError::InvalidValue);
9456        }
9457        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9458        let (n, remaining) = i32::try_parse(remaining)?;
9459        let (textures, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
9460        let _ = remaining;
9461        Ok(AreTexturesResidentRequest {
9462            context_tag,
9463            textures: Cow::Owned(textures),
9464        })
9465    }
9466    /// Clone all borrowed data in this AreTexturesResidentRequest.
9467    pub fn into_owned(self) -> AreTexturesResidentRequest<'static> {
9468        AreTexturesResidentRequest {
9469            context_tag: self.context_tag,
9470            textures: Cow::Owned(self.textures.into_owned()),
9471        }
9472    }
9473}
9474impl<'input> Request for AreTexturesResidentRequest<'input> {
9475    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9476
9477    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9478        let (bufs, fds) = self.serialize(major_opcode);
9479        // Flatten the buffers into a single vector
9480        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9481        (buf, fds)
9482    }
9483}
9484impl<'input> crate::x11_utils::ReplyRequest for AreTexturesResidentRequest<'input> {
9485    type Reply = AreTexturesResidentReply;
9486}
9487
9488#[derive(Clone, Default)]
9489#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9490#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9491pub struct AreTexturesResidentReply {
9492    pub sequence: u16,
9493    pub ret_val: Bool32,
9494    pub data: Vec<bool>,
9495}
9496impl_debug_if_no_extra_traits!(AreTexturesResidentReply, "AreTexturesResidentReply");
9497impl TryParse for AreTexturesResidentReply {
9498    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9499        let remaining = initial_value;
9500        let (response_type, remaining) = u8::try_parse(remaining)?;
9501        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9502        let (sequence, remaining) = u16::try_parse(remaining)?;
9503        let (length, remaining) = u32::try_parse(remaining)?;
9504        let (ret_val, remaining) = Bool32::try_parse(remaining)?;
9505        let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
9506        let (data, remaining) = crate::x11_utils::parse_list::<bool>(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
9507        if response_type != 1 {
9508            return Err(ParseError::InvalidValue);
9509        }
9510        let result = AreTexturesResidentReply { sequence, ret_val, data };
9511        let _ = remaining;
9512        let remaining = initial_value.get(32 + length as usize * 4..)
9513            .ok_or(ParseError::InsufficientData)?;
9514        Ok((result, remaining))
9515    }
9516}
9517impl Serialize for AreTexturesResidentReply {
9518    type Bytes = Vec<u8>;
9519    fn serialize(&self) -> Vec<u8> {
9520        let mut result = Vec::new();
9521        self.serialize_into(&mut result);
9522        result
9523    }
9524    fn serialize_into(&self, bytes: &mut Vec<u8>) {
9525        bytes.reserve(32);
9526        let response_type_bytes = &[1];
9527        bytes.push(response_type_bytes[0]);
9528        bytes.extend_from_slice(&[0; 1]);
9529        self.sequence.serialize_into(bytes);
9530        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
9531        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
9532        length.serialize_into(bytes);
9533        self.ret_val.serialize_into(bytes);
9534        bytes.extend_from_slice(&[0; 20]);
9535        self.data.serialize_into(bytes);
9536    }
9537}
9538impl AreTexturesResidentReply {
9539    /// Get the value of the `length` field.
9540    ///
9541    /// The `length` field is used as the length field of the `data` field.
9542    /// This function computes the field's value again based on the length of the list.
9543    ///
9544    /// # Panics
9545    ///
9546    /// Panics if the value cannot be represented in the target type. This
9547    /// cannot happen with values of the struct received from the X11 server.
9548    pub fn length(&self) -> u32 {
9549        self.data.len()
9550            .checked_div(4).unwrap()
9551            .try_into().unwrap()
9552    }
9553}
9554
9555/// Opcode for the DeleteTextures request
9556pub const DELETE_TEXTURES_REQUEST: u8 = 144;
9557#[derive(Clone, Default)]
9558#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9559#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9560pub struct DeleteTexturesRequest<'input> {
9561    pub context_tag: ContextTag,
9562    pub textures: Cow<'input, [u32]>,
9563}
9564impl_debug_if_no_extra_traits!(DeleteTexturesRequest<'_>, "DeleteTexturesRequest");
9565impl<'input> DeleteTexturesRequest<'input> {
9566    /// Serialize this request into bytes for the provided connection
9567    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
9568        let length_so_far = 0;
9569        let context_tag_bytes = self.context_tag.serialize();
9570        let n = i32::try_from(self.textures.len()).expect("`textures` has too many elements");
9571        let n_bytes = n.serialize();
9572        let mut request0 = vec![
9573            major_opcode,
9574            DELETE_TEXTURES_REQUEST,
9575            0,
9576            0,
9577            context_tag_bytes[0],
9578            context_tag_bytes[1],
9579            context_tag_bytes[2],
9580            context_tag_bytes[3],
9581            n_bytes[0],
9582            n_bytes[1],
9583            n_bytes[2],
9584            n_bytes[3],
9585        ];
9586        let length_so_far = length_so_far + request0.len();
9587        let textures_bytes = self.textures.serialize();
9588        let length_so_far = length_so_far + textures_bytes.len();
9589        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
9590        let length_so_far = length_so_far + padding0.len();
9591        assert_eq!(length_so_far % 4, 0);
9592        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9593        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9594        ([request0.into(), textures_bytes.into(), padding0.into()], vec![])
9595    }
9596    /// Parse this request given its header, its body, and any fds that go along with it
9597    #[cfg(feature = "request-parsing")]
9598    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
9599        if header.minor_opcode != DELETE_TEXTURES_REQUEST {
9600            return Err(ParseError::InvalidValue);
9601        }
9602        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9603        let (n, remaining) = i32::try_parse(remaining)?;
9604        let (textures, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
9605        let _ = remaining;
9606        Ok(DeleteTexturesRequest {
9607            context_tag,
9608            textures: Cow::Owned(textures),
9609        })
9610    }
9611    /// Clone all borrowed data in this DeleteTexturesRequest.
9612    pub fn into_owned(self) -> DeleteTexturesRequest<'static> {
9613        DeleteTexturesRequest {
9614            context_tag: self.context_tag,
9615            textures: Cow::Owned(self.textures.into_owned()),
9616        }
9617    }
9618}
9619impl<'input> Request for DeleteTexturesRequest<'input> {
9620    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9621
9622    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9623        let (bufs, fds) = self.serialize(major_opcode);
9624        // Flatten the buffers into a single vector
9625        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9626        (buf, fds)
9627    }
9628}
9629impl<'input> crate::x11_utils::VoidRequest for DeleteTexturesRequest<'input> {
9630}
9631
9632/// Opcode for the GenTextures request
9633pub const GEN_TEXTURES_REQUEST: u8 = 145;
9634#[derive(Clone, Copy, Default)]
9635#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9636#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9637pub struct GenTexturesRequest {
9638    pub context_tag: ContextTag,
9639    pub n: i32,
9640}
9641impl_debug_if_no_extra_traits!(GenTexturesRequest, "GenTexturesRequest");
9642impl GenTexturesRequest {
9643    /// Serialize this request into bytes for the provided connection
9644    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
9645        let length_so_far = 0;
9646        let context_tag_bytes = self.context_tag.serialize();
9647        let n_bytes = self.n.serialize();
9648        let mut request0 = vec![
9649            major_opcode,
9650            GEN_TEXTURES_REQUEST,
9651            0,
9652            0,
9653            context_tag_bytes[0],
9654            context_tag_bytes[1],
9655            context_tag_bytes[2],
9656            context_tag_bytes[3],
9657            n_bytes[0],
9658            n_bytes[1],
9659            n_bytes[2],
9660            n_bytes[3],
9661        ];
9662        let length_so_far = length_so_far + request0.len();
9663        assert_eq!(length_so_far % 4, 0);
9664        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9665        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9666        ([request0.into()], vec![])
9667    }
9668    /// Parse this request given its header, its body, and any fds that go along with it
9669    #[cfg(feature = "request-parsing")]
9670    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9671        if header.minor_opcode != GEN_TEXTURES_REQUEST {
9672            return Err(ParseError::InvalidValue);
9673        }
9674        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9675        let (n, remaining) = i32::try_parse(remaining)?;
9676        let _ = remaining;
9677        Ok(GenTexturesRequest {
9678            context_tag,
9679            n,
9680        })
9681    }
9682}
9683impl Request for GenTexturesRequest {
9684    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9685
9686    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9687        let (bufs, fds) = self.serialize(major_opcode);
9688        // Flatten the buffers into a single vector
9689        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9690        (buf, fds)
9691    }
9692}
9693impl crate::x11_utils::ReplyRequest for GenTexturesRequest {
9694    type Reply = GenTexturesReply;
9695}
9696
9697#[derive(Clone, Default)]
9698#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9699#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9700pub struct GenTexturesReply {
9701    pub sequence: u16,
9702    pub data: Vec<u32>,
9703}
9704impl_debug_if_no_extra_traits!(GenTexturesReply, "GenTexturesReply");
9705impl TryParse for GenTexturesReply {
9706    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9707        let remaining = initial_value;
9708        let (response_type, remaining) = u8::try_parse(remaining)?;
9709        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9710        let (sequence, remaining) = u16::try_parse(remaining)?;
9711        let (length, remaining) = u32::try_parse(remaining)?;
9712        let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
9713        let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
9714        if response_type != 1 {
9715            return Err(ParseError::InvalidValue);
9716        }
9717        let result = GenTexturesReply { sequence, data };
9718        let _ = remaining;
9719        let remaining = initial_value.get(32 + length as usize * 4..)
9720            .ok_or(ParseError::InsufficientData)?;
9721        Ok((result, remaining))
9722    }
9723}
9724impl Serialize for GenTexturesReply {
9725    type Bytes = Vec<u8>;
9726    fn serialize(&self) -> Vec<u8> {
9727        let mut result = Vec::new();
9728        self.serialize_into(&mut result);
9729        result
9730    }
9731    fn serialize_into(&self, bytes: &mut Vec<u8>) {
9732        bytes.reserve(32);
9733        let response_type_bytes = &[1];
9734        bytes.push(response_type_bytes[0]);
9735        bytes.extend_from_slice(&[0; 1]);
9736        self.sequence.serialize_into(bytes);
9737        let length = u32::try_from(self.data.len()).expect("`data` has too many elements");
9738        length.serialize_into(bytes);
9739        bytes.extend_from_slice(&[0; 24]);
9740        self.data.serialize_into(bytes);
9741    }
9742}
9743impl GenTexturesReply {
9744    /// Get the value of the `length` field.
9745    ///
9746    /// The `length` field is used as the length field of the `data` field.
9747    /// This function computes the field's value again based on the length of the list.
9748    ///
9749    /// # Panics
9750    ///
9751    /// Panics if the value cannot be represented in the target type. This
9752    /// cannot happen with values of the struct received from the X11 server.
9753    pub fn length(&self) -> u32 {
9754        self.data.len()
9755            .try_into().unwrap()
9756    }
9757}
9758
9759/// Opcode for the IsTexture request
9760pub const IS_TEXTURE_REQUEST: u8 = 146;
9761#[derive(Clone, Copy, Default)]
9762#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9763#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9764pub struct IsTextureRequest {
9765    pub context_tag: ContextTag,
9766    pub texture: u32,
9767}
9768impl_debug_if_no_extra_traits!(IsTextureRequest, "IsTextureRequest");
9769impl IsTextureRequest {
9770    /// Serialize this request into bytes for the provided connection
9771    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
9772        let length_so_far = 0;
9773        let context_tag_bytes = self.context_tag.serialize();
9774        let texture_bytes = self.texture.serialize();
9775        let mut request0 = vec![
9776            major_opcode,
9777            IS_TEXTURE_REQUEST,
9778            0,
9779            0,
9780            context_tag_bytes[0],
9781            context_tag_bytes[1],
9782            context_tag_bytes[2],
9783            context_tag_bytes[3],
9784            texture_bytes[0],
9785            texture_bytes[1],
9786            texture_bytes[2],
9787            texture_bytes[3],
9788        ];
9789        let length_so_far = length_so_far + request0.len();
9790        assert_eq!(length_so_far % 4, 0);
9791        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9792        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9793        ([request0.into()], vec![])
9794    }
9795    /// Parse this request given its header, its body, and any fds that go along with it
9796    #[cfg(feature = "request-parsing")]
9797    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9798        if header.minor_opcode != IS_TEXTURE_REQUEST {
9799            return Err(ParseError::InvalidValue);
9800        }
9801        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9802        let (texture, remaining) = u32::try_parse(remaining)?;
9803        let _ = remaining;
9804        Ok(IsTextureRequest {
9805            context_tag,
9806            texture,
9807        })
9808    }
9809}
9810impl Request for IsTextureRequest {
9811    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9812
9813    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9814        let (bufs, fds) = self.serialize(major_opcode);
9815        // Flatten the buffers into a single vector
9816        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9817        (buf, fds)
9818    }
9819}
9820impl crate::x11_utils::ReplyRequest for IsTextureRequest {
9821    type Reply = IsTextureReply;
9822}
9823
9824#[derive(Clone, Copy, Default)]
9825#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9826#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9827pub struct IsTextureReply {
9828    pub sequence: u16,
9829    pub length: u32,
9830    pub ret_val: Bool32,
9831}
9832impl_debug_if_no_extra_traits!(IsTextureReply, "IsTextureReply");
9833impl TryParse for IsTextureReply {
9834    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9835        let remaining = initial_value;
9836        let (response_type, remaining) = u8::try_parse(remaining)?;
9837        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9838        let (sequence, remaining) = u16::try_parse(remaining)?;
9839        let (length, remaining) = u32::try_parse(remaining)?;
9840        let (ret_val, remaining) = Bool32::try_parse(remaining)?;
9841        if response_type != 1 {
9842            return Err(ParseError::InvalidValue);
9843        }
9844        let result = IsTextureReply { sequence, length, ret_val };
9845        let _ = remaining;
9846        let remaining = initial_value.get(32 + length as usize * 4..)
9847            .ok_or(ParseError::InsufficientData)?;
9848        Ok((result, remaining))
9849    }
9850}
9851impl Serialize for IsTextureReply {
9852    type Bytes = [u8; 12];
9853    fn serialize(&self) -> [u8; 12] {
9854        let response_type_bytes = &[1];
9855        let sequence_bytes = self.sequence.serialize();
9856        let length_bytes = self.length.serialize();
9857        let ret_val_bytes = self.ret_val.serialize();
9858        [
9859            response_type_bytes[0],
9860            0,
9861            sequence_bytes[0],
9862            sequence_bytes[1],
9863            length_bytes[0],
9864            length_bytes[1],
9865            length_bytes[2],
9866            length_bytes[3],
9867            ret_val_bytes[0],
9868            ret_val_bytes[1],
9869            ret_val_bytes[2],
9870            ret_val_bytes[3],
9871        ]
9872    }
9873    fn serialize_into(&self, bytes: &mut Vec<u8>) {
9874        bytes.reserve(12);
9875        let response_type_bytes = &[1];
9876        bytes.push(response_type_bytes[0]);
9877        bytes.extend_from_slice(&[0; 1]);
9878        self.sequence.serialize_into(bytes);
9879        self.length.serialize_into(bytes);
9880        self.ret_val.serialize_into(bytes);
9881    }
9882}
9883
9884/// Opcode for the GetColorTable request
9885pub const GET_COLOR_TABLE_REQUEST: u8 = 147;
9886#[derive(Clone, Copy, Default)]
9887#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9888#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9889pub struct GetColorTableRequest {
9890    pub context_tag: ContextTag,
9891    pub target: u32,
9892    pub format: u32,
9893    pub type_: u32,
9894    pub swap_bytes: bool,
9895}
9896impl_debug_if_no_extra_traits!(GetColorTableRequest, "GetColorTableRequest");
9897impl GetColorTableRequest {
9898    /// Serialize this request into bytes for the provided connection
9899    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
9900        let length_so_far = 0;
9901        let context_tag_bytes = self.context_tag.serialize();
9902        let target_bytes = self.target.serialize();
9903        let format_bytes = self.format.serialize();
9904        let type_bytes = self.type_.serialize();
9905        let swap_bytes_bytes = self.swap_bytes.serialize();
9906        let mut request0 = vec![
9907            major_opcode,
9908            GET_COLOR_TABLE_REQUEST,
9909            0,
9910            0,
9911            context_tag_bytes[0],
9912            context_tag_bytes[1],
9913            context_tag_bytes[2],
9914            context_tag_bytes[3],
9915            target_bytes[0],
9916            target_bytes[1],
9917            target_bytes[2],
9918            target_bytes[3],
9919            format_bytes[0],
9920            format_bytes[1],
9921            format_bytes[2],
9922            format_bytes[3],
9923            type_bytes[0],
9924            type_bytes[1],
9925            type_bytes[2],
9926            type_bytes[3],
9927            swap_bytes_bytes[0],
9928            0,
9929            0,
9930            0,
9931        ];
9932        let length_so_far = length_so_far + request0.len();
9933        assert_eq!(length_so_far % 4, 0);
9934        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9935        request0[2..4].copy_from_slice(&length.to_ne_bytes());
9936        ([request0.into()], vec![])
9937    }
9938    /// Parse this request given its header, its body, and any fds that go along with it
9939    #[cfg(feature = "request-parsing")]
9940    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9941        if header.minor_opcode != GET_COLOR_TABLE_REQUEST {
9942            return Err(ParseError::InvalidValue);
9943        }
9944        let (context_tag, remaining) = ContextTag::try_parse(value)?;
9945        let (target, remaining) = u32::try_parse(remaining)?;
9946        let (format, remaining) = u32::try_parse(remaining)?;
9947        let (type_, remaining) = u32::try_parse(remaining)?;
9948        let (swap_bytes, remaining) = bool::try_parse(remaining)?;
9949        let _ = remaining;
9950        Ok(GetColorTableRequest {
9951            context_tag,
9952            target,
9953            format,
9954            type_,
9955            swap_bytes,
9956        })
9957    }
9958}
9959impl Request for GetColorTableRequest {
9960    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
9961
9962    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
9963        let (bufs, fds) = self.serialize(major_opcode);
9964        // Flatten the buffers into a single vector
9965        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
9966        (buf, fds)
9967    }
9968}
9969impl crate::x11_utils::ReplyRequest for GetColorTableRequest {
9970    type Reply = GetColorTableReply;
9971}
9972
9973#[derive(Clone, Default)]
9974#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
9975#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9976pub struct GetColorTableReply {
9977    pub sequence: u16,
9978    pub width: i32,
9979    pub data: Vec<u8>,
9980}
9981impl_debug_if_no_extra_traits!(GetColorTableReply, "GetColorTableReply");
9982impl TryParse for GetColorTableReply {
9983    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9984        let remaining = initial_value;
9985        let (response_type, remaining) = u8::try_parse(remaining)?;
9986        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9987        let (sequence, remaining) = u16::try_parse(remaining)?;
9988        let (length, remaining) = u32::try_parse(remaining)?;
9989        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
9990        let (width, remaining) = i32::try_parse(remaining)?;
9991        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
9992        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
9993        let data = data.to_vec();
9994        if response_type != 1 {
9995            return Err(ParseError::InvalidValue);
9996        }
9997        let result = GetColorTableReply { sequence, width, data };
9998        let _ = remaining;
9999        let remaining = initial_value.get(32 + length as usize * 4..)
10000            .ok_or(ParseError::InsufficientData)?;
10001        Ok((result, remaining))
10002    }
10003}
10004impl Serialize for GetColorTableReply {
10005    type Bytes = Vec<u8>;
10006    fn serialize(&self) -> Vec<u8> {
10007        let mut result = Vec::new();
10008        self.serialize_into(&mut result);
10009        result
10010    }
10011    fn serialize_into(&self, bytes: &mut Vec<u8>) {
10012        bytes.reserve(32);
10013        let response_type_bytes = &[1];
10014        bytes.push(response_type_bytes[0]);
10015        bytes.extend_from_slice(&[0; 1]);
10016        self.sequence.serialize_into(bytes);
10017        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
10018        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
10019        length.serialize_into(bytes);
10020        bytes.extend_from_slice(&[0; 8]);
10021        self.width.serialize_into(bytes);
10022        bytes.extend_from_slice(&[0; 12]);
10023        bytes.extend_from_slice(&self.data);
10024    }
10025}
10026impl GetColorTableReply {
10027    /// Get the value of the `length` field.
10028    ///
10029    /// The `length` field is used as the length field of the `data` field.
10030    /// This function computes the field's value again based on the length of the list.
10031    ///
10032    /// # Panics
10033    ///
10034    /// Panics if the value cannot be represented in the target type. This
10035    /// cannot happen with values of the struct received from the X11 server.
10036    pub fn length(&self) -> u32 {
10037        self.data.len()
10038            .checked_div(4).unwrap()
10039            .try_into().unwrap()
10040    }
10041}
10042
10043/// Opcode for the GetColorTableParameterfv request
10044pub const GET_COLOR_TABLE_PARAMETERFV_REQUEST: u8 = 148;
10045#[derive(Clone, Copy, Default)]
10046#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10047#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10048pub struct GetColorTableParameterfvRequest {
10049    pub context_tag: ContextTag,
10050    pub target: u32,
10051    pub pname: u32,
10052}
10053impl_debug_if_no_extra_traits!(GetColorTableParameterfvRequest, "GetColorTableParameterfvRequest");
10054impl GetColorTableParameterfvRequest {
10055    /// Serialize this request into bytes for the provided connection
10056    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
10057        let length_so_far = 0;
10058        let context_tag_bytes = self.context_tag.serialize();
10059        let target_bytes = self.target.serialize();
10060        let pname_bytes = self.pname.serialize();
10061        let mut request0 = vec![
10062            major_opcode,
10063            GET_COLOR_TABLE_PARAMETERFV_REQUEST,
10064            0,
10065            0,
10066            context_tag_bytes[0],
10067            context_tag_bytes[1],
10068            context_tag_bytes[2],
10069            context_tag_bytes[3],
10070            target_bytes[0],
10071            target_bytes[1],
10072            target_bytes[2],
10073            target_bytes[3],
10074            pname_bytes[0],
10075            pname_bytes[1],
10076            pname_bytes[2],
10077            pname_bytes[3],
10078        ];
10079        let length_so_far = length_so_far + request0.len();
10080        assert_eq!(length_so_far % 4, 0);
10081        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10082        request0[2..4].copy_from_slice(&length.to_ne_bytes());
10083        ([request0.into()], vec![])
10084    }
10085    /// Parse this request given its header, its body, and any fds that go along with it
10086    #[cfg(feature = "request-parsing")]
10087    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10088        if header.minor_opcode != GET_COLOR_TABLE_PARAMETERFV_REQUEST {
10089            return Err(ParseError::InvalidValue);
10090        }
10091        let (context_tag, remaining) = ContextTag::try_parse(value)?;
10092        let (target, remaining) = u32::try_parse(remaining)?;
10093        let (pname, remaining) = u32::try_parse(remaining)?;
10094        let _ = remaining;
10095        Ok(GetColorTableParameterfvRequest {
10096            context_tag,
10097            target,
10098            pname,
10099        })
10100    }
10101}
10102impl Request for GetColorTableParameterfvRequest {
10103    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
10104
10105    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
10106        let (bufs, fds) = self.serialize(major_opcode);
10107        // Flatten the buffers into a single vector
10108        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
10109        (buf, fds)
10110    }
10111}
10112impl crate::x11_utils::ReplyRequest for GetColorTableParameterfvRequest {
10113    type Reply = GetColorTableParameterfvReply;
10114}
10115
10116#[derive(Clone, Default)]
10117#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
10118#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10119pub struct GetColorTableParameterfvReply {
10120    pub sequence: u16,
10121    pub length: u32,
10122    pub datum: Float32,
10123    pub data: Vec<Float32>,
10124}
10125impl_debug_if_no_extra_traits!(GetColorTableParameterfvReply, "GetColorTableParameterfvReply");
10126impl TryParse for GetColorTableParameterfvReply {
10127    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10128        let remaining = initial_value;
10129        let (response_type, remaining) = u8::try_parse(remaining)?;
10130        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10131        let (sequence, remaining) = u16::try_parse(remaining)?;
10132        let (length, remaining) = u32::try_parse(remaining)?;
10133        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10134        let (n, remaining) = u32::try_parse(remaining)?;
10135        let (datum, remaining) = Float32::try_parse(remaining)?;
10136        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10137        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
10138        if response_type != 1 {
10139            return Err(ParseError::InvalidValue);
10140        }
10141        let result = GetColorTableParameterfvReply { sequence, length, datum, data };
10142        let _ = remaining;
10143        let remaining = initial_value.get(32 + length as usize * 4..)
10144            .ok_or(ParseError::InsufficientData)?;
10145        Ok((result, remaining))
10146    }
10147}
10148impl Serialize for GetColorTableParameterfvReply {
10149    type Bytes = Vec<u8>;
10150    fn serialize(&self) -> Vec<u8> {
10151        let mut result = Vec::new();
10152        self.serialize_into(&mut result);
10153        result
10154    }
10155    fn serialize_into(&self, bytes: &mut Vec<u8>) {
10156        bytes.reserve(32);
10157        let response_type_bytes = &[1];
10158        bytes.push(response_type_bytes[0]);
10159        bytes.extend_from_slice(&[0; 1]);
10160        self.sequence.serialize_into(bytes);
10161        self.length.serialize_into(bytes);
10162        bytes.extend_from_slice(&[0; 4]);
10163        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
10164        n.serialize_into(bytes);
10165        self.datum.serialize_into(bytes);
10166        bytes.extend_from_slice(&[0; 12]);
10167        self.data.serialize_into(bytes);
10168    }
10169}
10170impl GetColorTableParameterfvReply {
10171    /// Get the value of the `n` field.
10172    ///
10173    /// The `n` field is used as the length field of the `data` field.
10174    /// This function computes the field's value again based on the length of the list.
10175    ///
10176    /// # Panics
10177    ///
10178    /// Panics if the value cannot be represented in the target type. This
10179    /// cannot happen with values of the struct received from the X11 server.
10180    pub fn n(&self) -> u32 {
10181        self.data.len()
10182            .try_into().unwrap()
10183    }
10184}
10185
10186/// Opcode for the GetColorTableParameteriv request
10187pub const GET_COLOR_TABLE_PARAMETERIV_REQUEST: u8 = 149;
10188#[derive(Clone, Copy, Default)]
10189#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10190#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10191pub struct GetColorTableParameterivRequest {
10192    pub context_tag: ContextTag,
10193    pub target: u32,
10194    pub pname: u32,
10195}
10196impl_debug_if_no_extra_traits!(GetColorTableParameterivRequest, "GetColorTableParameterivRequest");
10197impl GetColorTableParameterivRequest {
10198    /// Serialize this request into bytes for the provided connection
10199    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
10200        let length_so_far = 0;
10201        let context_tag_bytes = self.context_tag.serialize();
10202        let target_bytes = self.target.serialize();
10203        let pname_bytes = self.pname.serialize();
10204        let mut request0 = vec![
10205            major_opcode,
10206            GET_COLOR_TABLE_PARAMETERIV_REQUEST,
10207            0,
10208            0,
10209            context_tag_bytes[0],
10210            context_tag_bytes[1],
10211            context_tag_bytes[2],
10212            context_tag_bytes[3],
10213            target_bytes[0],
10214            target_bytes[1],
10215            target_bytes[2],
10216            target_bytes[3],
10217            pname_bytes[0],
10218            pname_bytes[1],
10219            pname_bytes[2],
10220            pname_bytes[3],
10221        ];
10222        let length_so_far = length_so_far + request0.len();
10223        assert_eq!(length_so_far % 4, 0);
10224        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10225        request0[2..4].copy_from_slice(&length.to_ne_bytes());
10226        ([request0.into()], vec![])
10227    }
10228    /// Parse this request given its header, its body, and any fds that go along with it
10229    #[cfg(feature = "request-parsing")]
10230    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10231        if header.minor_opcode != GET_COLOR_TABLE_PARAMETERIV_REQUEST {
10232            return Err(ParseError::InvalidValue);
10233        }
10234        let (context_tag, remaining) = ContextTag::try_parse(value)?;
10235        let (target, remaining) = u32::try_parse(remaining)?;
10236        let (pname, remaining) = u32::try_parse(remaining)?;
10237        let _ = remaining;
10238        Ok(GetColorTableParameterivRequest {
10239            context_tag,
10240            target,
10241            pname,
10242        })
10243    }
10244}
10245impl Request for GetColorTableParameterivRequest {
10246    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
10247
10248    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
10249        let (bufs, fds) = self.serialize(major_opcode);
10250        // Flatten the buffers into a single vector
10251        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
10252        (buf, fds)
10253    }
10254}
10255impl crate::x11_utils::ReplyRequest for GetColorTableParameterivRequest {
10256    type Reply = GetColorTableParameterivReply;
10257}
10258
10259#[derive(Clone, Default)]
10260#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10261#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10262pub struct GetColorTableParameterivReply {
10263    pub sequence: u16,
10264    pub length: u32,
10265    pub datum: i32,
10266    pub data: Vec<i32>,
10267}
10268impl_debug_if_no_extra_traits!(GetColorTableParameterivReply, "GetColorTableParameterivReply");
10269impl TryParse for GetColorTableParameterivReply {
10270    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10271        let remaining = initial_value;
10272        let (response_type, remaining) = u8::try_parse(remaining)?;
10273        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10274        let (sequence, remaining) = u16::try_parse(remaining)?;
10275        let (length, remaining) = u32::try_parse(remaining)?;
10276        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10277        let (n, remaining) = u32::try_parse(remaining)?;
10278        let (datum, remaining) = i32::try_parse(remaining)?;
10279        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10280        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
10281        if response_type != 1 {
10282            return Err(ParseError::InvalidValue);
10283        }
10284        let result = GetColorTableParameterivReply { sequence, length, datum, data };
10285        let _ = remaining;
10286        let remaining = initial_value.get(32 + length as usize * 4..)
10287            .ok_or(ParseError::InsufficientData)?;
10288        Ok((result, remaining))
10289    }
10290}
10291impl Serialize for GetColorTableParameterivReply {
10292    type Bytes = Vec<u8>;
10293    fn serialize(&self) -> Vec<u8> {
10294        let mut result = Vec::new();
10295        self.serialize_into(&mut result);
10296        result
10297    }
10298    fn serialize_into(&self, bytes: &mut Vec<u8>) {
10299        bytes.reserve(32);
10300        let response_type_bytes = &[1];
10301        bytes.push(response_type_bytes[0]);
10302        bytes.extend_from_slice(&[0; 1]);
10303        self.sequence.serialize_into(bytes);
10304        self.length.serialize_into(bytes);
10305        bytes.extend_from_slice(&[0; 4]);
10306        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
10307        n.serialize_into(bytes);
10308        self.datum.serialize_into(bytes);
10309        bytes.extend_from_slice(&[0; 12]);
10310        self.data.serialize_into(bytes);
10311    }
10312}
10313impl GetColorTableParameterivReply {
10314    /// Get the value of the `n` field.
10315    ///
10316    /// The `n` field is used as the length field of the `data` field.
10317    /// This function computes the field's value again based on the length of the list.
10318    ///
10319    /// # Panics
10320    ///
10321    /// Panics if the value cannot be represented in the target type. This
10322    /// cannot happen with values of the struct received from the X11 server.
10323    pub fn n(&self) -> u32 {
10324        self.data.len()
10325            .try_into().unwrap()
10326    }
10327}
10328
10329/// Opcode for the GetConvolutionFilter request
10330pub const GET_CONVOLUTION_FILTER_REQUEST: u8 = 150;
10331#[derive(Clone, Copy, Default)]
10332#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10333#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10334pub struct GetConvolutionFilterRequest {
10335    pub context_tag: ContextTag,
10336    pub target: u32,
10337    pub format: u32,
10338    pub type_: u32,
10339    pub swap_bytes: bool,
10340}
10341impl_debug_if_no_extra_traits!(GetConvolutionFilterRequest, "GetConvolutionFilterRequest");
10342impl GetConvolutionFilterRequest {
10343    /// Serialize this request into bytes for the provided connection
10344    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
10345        let length_so_far = 0;
10346        let context_tag_bytes = self.context_tag.serialize();
10347        let target_bytes = self.target.serialize();
10348        let format_bytes = self.format.serialize();
10349        let type_bytes = self.type_.serialize();
10350        let swap_bytes_bytes = self.swap_bytes.serialize();
10351        let mut request0 = vec![
10352            major_opcode,
10353            GET_CONVOLUTION_FILTER_REQUEST,
10354            0,
10355            0,
10356            context_tag_bytes[0],
10357            context_tag_bytes[1],
10358            context_tag_bytes[2],
10359            context_tag_bytes[3],
10360            target_bytes[0],
10361            target_bytes[1],
10362            target_bytes[2],
10363            target_bytes[3],
10364            format_bytes[0],
10365            format_bytes[1],
10366            format_bytes[2],
10367            format_bytes[3],
10368            type_bytes[0],
10369            type_bytes[1],
10370            type_bytes[2],
10371            type_bytes[3],
10372            swap_bytes_bytes[0],
10373            0,
10374            0,
10375            0,
10376        ];
10377        let length_so_far = length_so_far + request0.len();
10378        assert_eq!(length_so_far % 4, 0);
10379        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10380        request0[2..4].copy_from_slice(&length.to_ne_bytes());
10381        ([request0.into()], vec![])
10382    }
10383    /// Parse this request given its header, its body, and any fds that go along with it
10384    #[cfg(feature = "request-parsing")]
10385    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10386        if header.minor_opcode != GET_CONVOLUTION_FILTER_REQUEST {
10387            return Err(ParseError::InvalidValue);
10388        }
10389        let (context_tag, remaining) = ContextTag::try_parse(value)?;
10390        let (target, remaining) = u32::try_parse(remaining)?;
10391        let (format, remaining) = u32::try_parse(remaining)?;
10392        let (type_, remaining) = u32::try_parse(remaining)?;
10393        let (swap_bytes, remaining) = bool::try_parse(remaining)?;
10394        let _ = remaining;
10395        Ok(GetConvolutionFilterRequest {
10396            context_tag,
10397            target,
10398            format,
10399            type_,
10400            swap_bytes,
10401        })
10402    }
10403}
10404impl Request for GetConvolutionFilterRequest {
10405    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
10406
10407    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
10408        let (bufs, fds) = self.serialize(major_opcode);
10409        // Flatten the buffers into a single vector
10410        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
10411        (buf, fds)
10412    }
10413}
10414impl crate::x11_utils::ReplyRequest for GetConvolutionFilterRequest {
10415    type Reply = GetConvolutionFilterReply;
10416}
10417
10418#[derive(Clone, Default)]
10419#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10420#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10421pub struct GetConvolutionFilterReply {
10422    pub sequence: u16,
10423    pub width: i32,
10424    pub height: i32,
10425    pub data: Vec<u8>,
10426}
10427impl_debug_if_no_extra_traits!(GetConvolutionFilterReply, "GetConvolutionFilterReply");
10428impl TryParse for GetConvolutionFilterReply {
10429    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10430        let remaining = initial_value;
10431        let (response_type, remaining) = u8::try_parse(remaining)?;
10432        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10433        let (sequence, remaining) = u16::try_parse(remaining)?;
10434        let (length, remaining) = u32::try_parse(remaining)?;
10435        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
10436        let (width, remaining) = i32::try_parse(remaining)?;
10437        let (height, remaining) = i32::try_parse(remaining)?;
10438        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
10439        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
10440        let data = data.to_vec();
10441        if response_type != 1 {
10442            return Err(ParseError::InvalidValue);
10443        }
10444        let result = GetConvolutionFilterReply { sequence, width, height, data };
10445        let _ = remaining;
10446        let remaining = initial_value.get(32 + length as usize * 4..)
10447            .ok_or(ParseError::InsufficientData)?;
10448        Ok((result, remaining))
10449    }
10450}
10451impl Serialize for GetConvolutionFilterReply {
10452    type Bytes = Vec<u8>;
10453    fn serialize(&self) -> Vec<u8> {
10454        let mut result = Vec::new();
10455        self.serialize_into(&mut result);
10456        result
10457    }
10458    fn serialize_into(&self, bytes: &mut Vec<u8>) {
10459        bytes.reserve(32);
10460        let response_type_bytes = &[1];
10461        bytes.push(response_type_bytes[0]);
10462        bytes.extend_from_slice(&[0; 1]);
10463        self.sequence.serialize_into(bytes);
10464        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
10465        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
10466        length.serialize_into(bytes);
10467        bytes.extend_from_slice(&[0; 8]);
10468        self.width.serialize_into(bytes);
10469        self.height.serialize_into(bytes);
10470        bytes.extend_from_slice(&[0; 8]);
10471        bytes.extend_from_slice(&self.data);
10472    }
10473}
10474impl GetConvolutionFilterReply {
10475    /// Get the value of the `length` field.
10476    ///
10477    /// The `length` field is used as the length field of the `data` field.
10478    /// This function computes the field's value again based on the length of the list.
10479    ///
10480    /// # Panics
10481    ///
10482    /// Panics if the value cannot be represented in the target type. This
10483    /// cannot happen with values of the struct received from the X11 server.
10484    pub fn length(&self) -> u32 {
10485        self.data.len()
10486            .checked_div(4).unwrap()
10487            .try_into().unwrap()
10488    }
10489}
10490
10491/// Opcode for the GetConvolutionParameterfv request
10492pub const GET_CONVOLUTION_PARAMETERFV_REQUEST: u8 = 151;
10493#[derive(Clone, Copy, Default)]
10494#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10495#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10496pub struct GetConvolutionParameterfvRequest {
10497    pub context_tag: ContextTag,
10498    pub target: u32,
10499    pub pname: u32,
10500}
10501impl_debug_if_no_extra_traits!(GetConvolutionParameterfvRequest, "GetConvolutionParameterfvRequest");
10502impl GetConvolutionParameterfvRequest {
10503    /// Serialize this request into bytes for the provided connection
10504    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
10505        let length_so_far = 0;
10506        let context_tag_bytes = self.context_tag.serialize();
10507        let target_bytes = self.target.serialize();
10508        let pname_bytes = self.pname.serialize();
10509        let mut request0 = vec![
10510            major_opcode,
10511            GET_CONVOLUTION_PARAMETERFV_REQUEST,
10512            0,
10513            0,
10514            context_tag_bytes[0],
10515            context_tag_bytes[1],
10516            context_tag_bytes[2],
10517            context_tag_bytes[3],
10518            target_bytes[0],
10519            target_bytes[1],
10520            target_bytes[2],
10521            target_bytes[3],
10522            pname_bytes[0],
10523            pname_bytes[1],
10524            pname_bytes[2],
10525            pname_bytes[3],
10526        ];
10527        let length_so_far = length_so_far + request0.len();
10528        assert_eq!(length_so_far % 4, 0);
10529        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10530        request0[2..4].copy_from_slice(&length.to_ne_bytes());
10531        ([request0.into()], vec![])
10532    }
10533    /// Parse this request given its header, its body, and any fds that go along with it
10534    #[cfg(feature = "request-parsing")]
10535    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10536        if header.minor_opcode != GET_CONVOLUTION_PARAMETERFV_REQUEST {
10537            return Err(ParseError::InvalidValue);
10538        }
10539        let (context_tag, remaining) = ContextTag::try_parse(value)?;
10540        let (target, remaining) = u32::try_parse(remaining)?;
10541        let (pname, remaining) = u32::try_parse(remaining)?;
10542        let _ = remaining;
10543        Ok(GetConvolutionParameterfvRequest {
10544            context_tag,
10545            target,
10546            pname,
10547        })
10548    }
10549}
10550impl Request for GetConvolutionParameterfvRequest {
10551    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
10552
10553    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
10554        let (bufs, fds) = self.serialize(major_opcode);
10555        // Flatten the buffers into a single vector
10556        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
10557        (buf, fds)
10558    }
10559}
10560impl crate::x11_utils::ReplyRequest for GetConvolutionParameterfvRequest {
10561    type Reply = GetConvolutionParameterfvReply;
10562}
10563
10564#[derive(Clone, Default)]
10565#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
10566#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10567pub struct GetConvolutionParameterfvReply {
10568    pub sequence: u16,
10569    pub length: u32,
10570    pub datum: Float32,
10571    pub data: Vec<Float32>,
10572}
10573impl_debug_if_no_extra_traits!(GetConvolutionParameterfvReply, "GetConvolutionParameterfvReply");
10574impl TryParse for GetConvolutionParameterfvReply {
10575    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10576        let remaining = initial_value;
10577        let (response_type, remaining) = u8::try_parse(remaining)?;
10578        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10579        let (sequence, remaining) = u16::try_parse(remaining)?;
10580        let (length, remaining) = u32::try_parse(remaining)?;
10581        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10582        let (n, remaining) = u32::try_parse(remaining)?;
10583        let (datum, remaining) = Float32::try_parse(remaining)?;
10584        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10585        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
10586        if response_type != 1 {
10587            return Err(ParseError::InvalidValue);
10588        }
10589        let result = GetConvolutionParameterfvReply { sequence, length, datum, data };
10590        let _ = remaining;
10591        let remaining = initial_value.get(32 + length as usize * 4..)
10592            .ok_or(ParseError::InsufficientData)?;
10593        Ok((result, remaining))
10594    }
10595}
10596impl Serialize for GetConvolutionParameterfvReply {
10597    type Bytes = Vec<u8>;
10598    fn serialize(&self) -> Vec<u8> {
10599        let mut result = Vec::new();
10600        self.serialize_into(&mut result);
10601        result
10602    }
10603    fn serialize_into(&self, bytes: &mut Vec<u8>) {
10604        bytes.reserve(32);
10605        let response_type_bytes = &[1];
10606        bytes.push(response_type_bytes[0]);
10607        bytes.extend_from_slice(&[0; 1]);
10608        self.sequence.serialize_into(bytes);
10609        self.length.serialize_into(bytes);
10610        bytes.extend_from_slice(&[0; 4]);
10611        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
10612        n.serialize_into(bytes);
10613        self.datum.serialize_into(bytes);
10614        bytes.extend_from_slice(&[0; 12]);
10615        self.data.serialize_into(bytes);
10616    }
10617}
10618impl GetConvolutionParameterfvReply {
10619    /// Get the value of the `n` field.
10620    ///
10621    /// The `n` field is used as the length field of the `data` field.
10622    /// This function computes the field's value again based on the length of the list.
10623    ///
10624    /// # Panics
10625    ///
10626    /// Panics if the value cannot be represented in the target type. This
10627    /// cannot happen with values of the struct received from the X11 server.
10628    pub fn n(&self) -> u32 {
10629        self.data.len()
10630            .try_into().unwrap()
10631    }
10632}
10633
10634/// Opcode for the GetConvolutionParameteriv request
10635pub const GET_CONVOLUTION_PARAMETERIV_REQUEST: u8 = 152;
10636#[derive(Clone, Copy, Default)]
10637#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10638#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10639pub struct GetConvolutionParameterivRequest {
10640    pub context_tag: ContextTag,
10641    pub target: u32,
10642    pub pname: u32,
10643}
10644impl_debug_if_no_extra_traits!(GetConvolutionParameterivRequest, "GetConvolutionParameterivRequest");
10645impl GetConvolutionParameterivRequest {
10646    /// Serialize this request into bytes for the provided connection
10647    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
10648        let length_so_far = 0;
10649        let context_tag_bytes = self.context_tag.serialize();
10650        let target_bytes = self.target.serialize();
10651        let pname_bytes = self.pname.serialize();
10652        let mut request0 = vec![
10653            major_opcode,
10654            GET_CONVOLUTION_PARAMETERIV_REQUEST,
10655            0,
10656            0,
10657            context_tag_bytes[0],
10658            context_tag_bytes[1],
10659            context_tag_bytes[2],
10660            context_tag_bytes[3],
10661            target_bytes[0],
10662            target_bytes[1],
10663            target_bytes[2],
10664            target_bytes[3],
10665            pname_bytes[0],
10666            pname_bytes[1],
10667            pname_bytes[2],
10668            pname_bytes[3],
10669        ];
10670        let length_so_far = length_so_far + request0.len();
10671        assert_eq!(length_so_far % 4, 0);
10672        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10673        request0[2..4].copy_from_slice(&length.to_ne_bytes());
10674        ([request0.into()], vec![])
10675    }
10676    /// Parse this request given its header, its body, and any fds that go along with it
10677    #[cfg(feature = "request-parsing")]
10678    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10679        if header.minor_opcode != GET_CONVOLUTION_PARAMETERIV_REQUEST {
10680            return Err(ParseError::InvalidValue);
10681        }
10682        let (context_tag, remaining) = ContextTag::try_parse(value)?;
10683        let (target, remaining) = u32::try_parse(remaining)?;
10684        let (pname, remaining) = u32::try_parse(remaining)?;
10685        let _ = remaining;
10686        Ok(GetConvolutionParameterivRequest {
10687            context_tag,
10688            target,
10689            pname,
10690        })
10691    }
10692}
10693impl Request for GetConvolutionParameterivRequest {
10694    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
10695
10696    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
10697        let (bufs, fds) = self.serialize(major_opcode);
10698        // Flatten the buffers into a single vector
10699        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
10700        (buf, fds)
10701    }
10702}
10703impl crate::x11_utils::ReplyRequest for GetConvolutionParameterivRequest {
10704    type Reply = GetConvolutionParameterivReply;
10705}
10706
10707#[derive(Clone, Default)]
10708#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10709#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10710pub struct GetConvolutionParameterivReply {
10711    pub sequence: u16,
10712    pub length: u32,
10713    pub datum: i32,
10714    pub data: Vec<i32>,
10715}
10716impl_debug_if_no_extra_traits!(GetConvolutionParameterivReply, "GetConvolutionParameterivReply");
10717impl TryParse for GetConvolutionParameterivReply {
10718    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10719        let remaining = initial_value;
10720        let (response_type, remaining) = u8::try_parse(remaining)?;
10721        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10722        let (sequence, remaining) = u16::try_parse(remaining)?;
10723        let (length, remaining) = u32::try_parse(remaining)?;
10724        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10725        let (n, remaining) = u32::try_parse(remaining)?;
10726        let (datum, remaining) = i32::try_parse(remaining)?;
10727        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10728        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
10729        if response_type != 1 {
10730            return Err(ParseError::InvalidValue);
10731        }
10732        let result = GetConvolutionParameterivReply { sequence, length, datum, data };
10733        let _ = remaining;
10734        let remaining = initial_value.get(32 + length as usize * 4..)
10735            .ok_or(ParseError::InsufficientData)?;
10736        Ok((result, remaining))
10737    }
10738}
10739impl Serialize for GetConvolutionParameterivReply {
10740    type Bytes = Vec<u8>;
10741    fn serialize(&self) -> Vec<u8> {
10742        let mut result = Vec::new();
10743        self.serialize_into(&mut result);
10744        result
10745    }
10746    fn serialize_into(&self, bytes: &mut Vec<u8>) {
10747        bytes.reserve(32);
10748        let response_type_bytes = &[1];
10749        bytes.push(response_type_bytes[0]);
10750        bytes.extend_from_slice(&[0; 1]);
10751        self.sequence.serialize_into(bytes);
10752        self.length.serialize_into(bytes);
10753        bytes.extend_from_slice(&[0; 4]);
10754        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
10755        n.serialize_into(bytes);
10756        self.datum.serialize_into(bytes);
10757        bytes.extend_from_slice(&[0; 12]);
10758        self.data.serialize_into(bytes);
10759    }
10760}
10761impl GetConvolutionParameterivReply {
10762    /// Get the value of the `n` field.
10763    ///
10764    /// The `n` field is used as the length field of the `data` field.
10765    /// This function computes the field's value again based on the length of the list.
10766    ///
10767    /// # Panics
10768    ///
10769    /// Panics if the value cannot be represented in the target type. This
10770    /// cannot happen with values of the struct received from the X11 server.
10771    pub fn n(&self) -> u32 {
10772        self.data.len()
10773            .try_into().unwrap()
10774    }
10775}
10776
10777/// Opcode for the GetSeparableFilter request
10778pub const GET_SEPARABLE_FILTER_REQUEST: u8 = 153;
10779#[derive(Clone, Copy, Default)]
10780#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10781#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10782pub struct GetSeparableFilterRequest {
10783    pub context_tag: ContextTag,
10784    pub target: u32,
10785    pub format: u32,
10786    pub type_: u32,
10787    pub swap_bytes: bool,
10788}
10789impl_debug_if_no_extra_traits!(GetSeparableFilterRequest, "GetSeparableFilterRequest");
10790impl GetSeparableFilterRequest {
10791    /// Serialize this request into bytes for the provided connection
10792    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
10793        let length_so_far = 0;
10794        let context_tag_bytes = self.context_tag.serialize();
10795        let target_bytes = self.target.serialize();
10796        let format_bytes = self.format.serialize();
10797        let type_bytes = self.type_.serialize();
10798        let swap_bytes_bytes = self.swap_bytes.serialize();
10799        let mut request0 = vec![
10800            major_opcode,
10801            GET_SEPARABLE_FILTER_REQUEST,
10802            0,
10803            0,
10804            context_tag_bytes[0],
10805            context_tag_bytes[1],
10806            context_tag_bytes[2],
10807            context_tag_bytes[3],
10808            target_bytes[0],
10809            target_bytes[1],
10810            target_bytes[2],
10811            target_bytes[3],
10812            format_bytes[0],
10813            format_bytes[1],
10814            format_bytes[2],
10815            format_bytes[3],
10816            type_bytes[0],
10817            type_bytes[1],
10818            type_bytes[2],
10819            type_bytes[3],
10820            swap_bytes_bytes[0],
10821            0,
10822            0,
10823            0,
10824        ];
10825        let length_so_far = length_so_far + request0.len();
10826        assert_eq!(length_so_far % 4, 0);
10827        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10828        request0[2..4].copy_from_slice(&length.to_ne_bytes());
10829        ([request0.into()], vec![])
10830    }
10831    /// Parse this request given its header, its body, and any fds that go along with it
10832    #[cfg(feature = "request-parsing")]
10833    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10834        if header.minor_opcode != GET_SEPARABLE_FILTER_REQUEST {
10835            return Err(ParseError::InvalidValue);
10836        }
10837        let (context_tag, remaining) = ContextTag::try_parse(value)?;
10838        let (target, remaining) = u32::try_parse(remaining)?;
10839        let (format, remaining) = u32::try_parse(remaining)?;
10840        let (type_, remaining) = u32::try_parse(remaining)?;
10841        let (swap_bytes, remaining) = bool::try_parse(remaining)?;
10842        let _ = remaining;
10843        Ok(GetSeparableFilterRequest {
10844            context_tag,
10845            target,
10846            format,
10847            type_,
10848            swap_bytes,
10849        })
10850    }
10851}
10852impl Request for GetSeparableFilterRequest {
10853    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
10854
10855    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
10856        let (bufs, fds) = self.serialize(major_opcode);
10857        // Flatten the buffers into a single vector
10858        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
10859        (buf, fds)
10860    }
10861}
10862impl crate::x11_utils::ReplyRequest for GetSeparableFilterRequest {
10863    type Reply = GetSeparableFilterReply;
10864}
10865
10866#[derive(Clone, Default)]
10867#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10868#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10869pub struct GetSeparableFilterReply {
10870    pub sequence: u16,
10871    pub row_w: i32,
10872    pub col_h: i32,
10873    pub rows_and_cols: Vec<u8>,
10874}
10875impl_debug_if_no_extra_traits!(GetSeparableFilterReply, "GetSeparableFilterReply");
10876impl TryParse for GetSeparableFilterReply {
10877    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10878        let remaining = initial_value;
10879        let (response_type, remaining) = u8::try_parse(remaining)?;
10880        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10881        let (sequence, remaining) = u16::try_parse(remaining)?;
10882        let (length, remaining) = u32::try_parse(remaining)?;
10883        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
10884        let (row_w, remaining) = i32::try_parse(remaining)?;
10885        let (col_h, remaining) = i32::try_parse(remaining)?;
10886        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
10887        let (rows_and_cols, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
10888        let rows_and_cols = rows_and_cols.to_vec();
10889        if response_type != 1 {
10890            return Err(ParseError::InvalidValue);
10891        }
10892        let result = GetSeparableFilterReply { sequence, row_w, col_h, rows_and_cols };
10893        let _ = remaining;
10894        let remaining = initial_value.get(32 + length as usize * 4..)
10895            .ok_or(ParseError::InsufficientData)?;
10896        Ok((result, remaining))
10897    }
10898}
10899impl Serialize for GetSeparableFilterReply {
10900    type Bytes = Vec<u8>;
10901    fn serialize(&self) -> Vec<u8> {
10902        let mut result = Vec::new();
10903        self.serialize_into(&mut result);
10904        result
10905    }
10906    fn serialize_into(&self, bytes: &mut Vec<u8>) {
10907        bytes.reserve(32);
10908        let response_type_bytes = &[1];
10909        bytes.push(response_type_bytes[0]);
10910        bytes.extend_from_slice(&[0; 1]);
10911        self.sequence.serialize_into(bytes);
10912        assert_eq!(self.rows_and_cols.len() % 4, 0, "`rows_and_cols` has an incorrect length, must be a multiple of 4");
10913        let length = u32::try_from(self.rows_and_cols.len() / 4).expect("`rows_and_cols` has too many elements");
10914        length.serialize_into(bytes);
10915        bytes.extend_from_slice(&[0; 8]);
10916        self.row_w.serialize_into(bytes);
10917        self.col_h.serialize_into(bytes);
10918        bytes.extend_from_slice(&[0; 8]);
10919        bytes.extend_from_slice(&self.rows_and_cols);
10920    }
10921}
10922impl GetSeparableFilterReply {
10923    /// Get the value of the `length` field.
10924    ///
10925    /// The `length` field is used as the length field of the `rows_and_cols` field.
10926    /// This function computes the field's value again based on the length of the list.
10927    ///
10928    /// # Panics
10929    ///
10930    /// Panics if the value cannot be represented in the target type. This
10931    /// cannot happen with values of the struct received from the X11 server.
10932    pub fn length(&self) -> u32 {
10933        self.rows_and_cols.len()
10934            .checked_div(4).unwrap()
10935            .try_into().unwrap()
10936    }
10937}
10938
10939/// Opcode for the GetHistogram request
10940pub const GET_HISTOGRAM_REQUEST: u8 = 154;
10941#[derive(Clone, Copy, Default)]
10942#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
10943#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10944pub struct GetHistogramRequest {
10945    pub context_tag: ContextTag,
10946    pub target: u32,
10947    pub format: u32,
10948    pub type_: u32,
10949    pub swap_bytes: bool,
10950    pub reset: bool,
10951}
10952impl_debug_if_no_extra_traits!(GetHistogramRequest, "GetHistogramRequest");
10953impl GetHistogramRequest {
10954    /// Serialize this request into bytes for the provided connection
10955    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
10956        let length_so_far = 0;
10957        let context_tag_bytes = self.context_tag.serialize();
10958        let target_bytes = self.target.serialize();
10959        let format_bytes = self.format.serialize();
10960        let type_bytes = self.type_.serialize();
10961        let swap_bytes_bytes = self.swap_bytes.serialize();
10962        let reset_bytes = self.reset.serialize();
10963        let mut request0 = vec![
10964            major_opcode,
10965            GET_HISTOGRAM_REQUEST,
10966            0,
10967            0,
10968            context_tag_bytes[0],
10969            context_tag_bytes[1],
10970            context_tag_bytes[2],
10971            context_tag_bytes[3],
10972            target_bytes[0],
10973            target_bytes[1],
10974            target_bytes[2],
10975            target_bytes[3],
10976            format_bytes[0],
10977            format_bytes[1],
10978            format_bytes[2],
10979            format_bytes[3],
10980            type_bytes[0],
10981            type_bytes[1],
10982            type_bytes[2],
10983            type_bytes[3],
10984            swap_bytes_bytes[0],
10985            reset_bytes[0],
10986            0,
10987            0,
10988        ];
10989        let length_so_far = length_so_far + request0.len();
10990        assert_eq!(length_so_far % 4, 0);
10991        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10992        request0[2..4].copy_from_slice(&length.to_ne_bytes());
10993        ([request0.into()], vec![])
10994    }
10995    /// Parse this request given its header, its body, and any fds that go along with it
10996    #[cfg(feature = "request-parsing")]
10997    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10998        if header.minor_opcode != GET_HISTOGRAM_REQUEST {
10999            return Err(ParseError::InvalidValue);
11000        }
11001        let (context_tag, remaining) = ContextTag::try_parse(value)?;
11002        let (target, remaining) = u32::try_parse(remaining)?;
11003        let (format, remaining) = u32::try_parse(remaining)?;
11004        let (type_, remaining) = u32::try_parse(remaining)?;
11005        let (swap_bytes, remaining) = bool::try_parse(remaining)?;
11006        let (reset, remaining) = bool::try_parse(remaining)?;
11007        let _ = remaining;
11008        Ok(GetHistogramRequest {
11009            context_tag,
11010            target,
11011            format,
11012            type_,
11013            swap_bytes,
11014            reset,
11015        })
11016    }
11017}
11018impl Request for GetHistogramRequest {
11019    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
11020
11021    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
11022        let (bufs, fds) = self.serialize(major_opcode);
11023        // Flatten the buffers into a single vector
11024        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
11025        (buf, fds)
11026    }
11027}
11028impl crate::x11_utils::ReplyRequest for GetHistogramRequest {
11029    type Reply = GetHistogramReply;
11030}
11031
11032#[derive(Clone, Default)]
11033#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11034#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11035pub struct GetHistogramReply {
11036    pub sequence: u16,
11037    pub width: i32,
11038    pub data: Vec<u8>,
11039}
11040impl_debug_if_no_extra_traits!(GetHistogramReply, "GetHistogramReply");
11041impl TryParse for GetHistogramReply {
11042    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11043        let remaining = initial_value;
11044        let (response_type, remaining) = u8::try_parse(remaining)?;
11045        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11046        let (sequence, remaining) = u16::try_parse(remaining)?;
11047        let (length, remaining) = u32::try_parse(remaining)?;
11048        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
11049        let (width, remaining) = i32::try_parse(remaining)?;
11050        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11051        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
11052        let data = data.to_vec();
11053        if response_type != 1 {
11054            return Err(ParseError::InvalidValue);
11055        }
11056        let result = GetHistogramReply { sequence, width, data };
11057        let _ = remaining;
11058        let remaining = initial_value.get(32 + length as usize * 4..)
11059            .ok_or(ParseError::InsufficientData)?;
11060        Ok((result, remaining))
11061    }
11062}
11063impl Serialize for GetHistogramReply {
11064    type Bytes = Vec<u8>;
11065    fn serialize(&self) -> Vec<u8> {
11066        let mut result = Vec::new();
11067        self.serialize_into(&mut result);
11068        result
11069    }
11070    fn serialize_into(&self, bytes: &mut Vec<u8>) {
11071        bytes.reserve(32);
11072        let response_type_bytes = &[1];
11073        bytes.push(response_type_bytes[0]);
11074        bytes.extend_from_slice(&[0; 1]);
11075        self.sequence.serialize_into(bytes);
11076        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
11077        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
11078        length.serialize_into(bytes);
11079        bytes.extend_from_slice(&[0; 8]);
11080        self.width.serialize_into(bytes);
11081        bytes.extend_from_slice(&[0; 12]);
11082        bytes.extend_from_slice(&self.data);
11083    }
11084}
11085impl GetHistogramReply {
11086    /// Get the value of the `length` field.
11087    ///
11088    /// The `length` field is used as the length field of the `data` field.
11089    /// This function computes the field's value again based on the length of the list.
11090    ///
11091    /// # Panics
11092    ///
11093    /// Panics if the value cannot be represented in the target type. This
11094    /// cannot happen with values of the struct received from the X11 server.
11095    pub fn length(&self) -> u32 {
11096        self.data.len()
11097            .checked_div(4).unwrap()
11098            .try_into().unwrap()
11099    }
11100}
11101
11102/// Opcode for the GetHistogramParameterfv request
11103pub const GET_HISTOGRAM_PARAMETERFV_REQUEST: u8 = 155;
11104#[derive(Clone, Copy, Default)]
11105#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11106#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11107pub struct GetHistogramParameterfvRequest {
11108    pub context_tag: ContextTag,
11109    pub target: u32,
11110    pub pname: u32,
11111}
11112impl_debug_if_no_extra_traits!(GetHistogramParameterfvRequest, "GetHistogramParameterfvRequest");
11113impl GetHistogramParameterfvRequest {
11114    /// Serialize this request into bytes for the provided connection
11115    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
11116        let length_so_far = 0;
11117        let context_tag_bytes = self.context_tag.serialize();
11118        let target_bytes = self.target.serialize();
11119        let pname_bytes = self.pname.serialize();
11120        let mut request0 = vec![
11121            major_opcode,
11122            GET_HISTOGRAM_PARAMETERFV_REQUEST,
11123            0,
11124            0,
11125            context_tag_bytes[0],
11126            context_tag_bytes[1],
11127            context_tag_bytes[2],
11128            context_tag_bytes[3],
11129            target_bytes[0],
11130            target_bytes[1],
11131            target_bytes[2],
11132            target_bytes[3],
11133            pname_bytes[0],
11134            pname_bytes[1],
11135            pname_bytes[2],
11136            pname_bytes[3],
11137        ];
11138        let length_so_far = length_so_far + request0.len();
11139        assert_eq!(length_so_far % 4, 0);
11140        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11141        request0[2..4].copy_from_slice(&length.to_ne_bytes());
11142        ([request0.into()], vec![])
11143    }
11144    /// Parse this request given its header, its body, and any fds that go along with it
11145    #[cfg(feature = "request-parsing")]
11146    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11147        if header.minor_opcode != GET_HISTOGRAM_PARAMETERFV_REQUEST {
11148            return Err(ParseError::InvalidValue);
11149        }
11150        let (context_tag, remaining) = ContextTag::try_parse(value)?;
11151        let (target, remaining) = u32::try_parse(remaining)?;
11152        let (pname, remaining) = u32::try_parse(remaining)?;
11153        let _ = remaining;
11154        Ok(GetHistogramParameterfvRequest {
11155            context_tag,
11156            target,
11157            pname,
11158        })
11159    }
11160}
11161impl Request for GetHistogramParameterfvRequest {
11162    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
11163
11164    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
11165        let (bufs, fds) = self.serialize(major_opcode);
11166        // Flatten the buffers into a single vector
11167        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
11168        (buf, fds)
11169    }
11170}
11171impl crate::x11_utils::ReplyRequest for GetHistogramParameterfvRequest {
11172    type Reply = GetHistogramParameterfvReply;
11173}
11174
11175#[derive(Clone, Default)]
11176#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
11177#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11178pub struct GetHistogramParameterfvReply {
11179    pub sequence: u16,
11180    pub length: u32,
11181    pub datum: Float32,
11182    pub data: Vec<Float32>,
11183}
11184impl_debug_if_no_extra_traits!(GetHistogramParameterfvReply, "GetHistogramParameterfvReply");
11185impl TryParse for GetHistogramParameterfvReply {
11186    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11187        let remaining = initial_value;
11188        let (response_type, remaining) = u8::try_parse(remaining)?;
11189        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11190        let (sequence, remaining) = u16::try_parse(remaining)?;
11191        let (length, remaining) = u32::try_parse(remaining)?;
11192        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
11193        let (n, remaining) = u32::try_parse(remaining)?;
11194        let (datum, remaining) = Float32::try_parse(remaining)?;
11195        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11196        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
11197        if response_type != 1 {
11198            return Err(ParseError::InvalidValue);
11199        }
11200        let result = GetHistogramParameterfvReply { sequence, length, datum, data };
11201        let _ = remaining;
11202        let remaining = initial_value.get(32 + length as usize * 4..)
11203            .ok_or(ParseError::InsufficientData)?;
11204        Ok((result, remaining))
11205    }
11206}
11207impl Serialize for GetHistogramParameterfvReply {
11208    type Bytes = Vec<u8>;
11209    fn serialize(&self) -> Vec<u8> {
11210        let mut result = Vec::new();
11211        self.serialize_into(&mut result);
11212        result
11213    }
11214    fn serialize_into(&self, bytes: &mut Vec<u8>) {
11215        bytes.reserve(32);
11216        let response_type_bytes = &[1];
11217        bytes.push(response_type_bytes[0]);
11218        bytes.extend_from_slice(&[0; 1]);
11219        self.sequence.serialize_into(bytes);
11220        self.length.serialize_into(bytes);
11221        bytes.extend_from_slice(&[0; 4]);
11222        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
11223        n.serialize_into(bytes);
11224        self.datum.serialize_into(bytes);
11225        bytes.extend_from_slice(&[0; 12]);
11226        self.data.serialize_into(bytes);
11227    }
11228}
11229impl GetHistogramParameterfvReply {
11230    /// Get the value of the `n` field.
11231    ///
11232    /// The `n` field is used as the length field of the `data` field.
11233    /// This function computes the field's value again based on the length of the list.
11234    ///
11235    /// # Panics
11236    ///
11237    /// Panics if the value cannot be represented in the target type. This
11238    /// cannot happen with values of the struct received from the X11 server.
11239    pub fn n(&self) -> u32 {
11240        self.data.len()
11241            .try_into().unwrap()
11242    }
11243}
11244
11245/// Opcode for the GetHistogramParameteriv request
11246pub const GET_HISTOGRAM_PARAMETERIV_REQUEST: u8 = 156;
11247#[derive(Clone, Copy, Default)]
11248#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11249#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11250pub struct GetHistogramParameterivRequest {
11251    pub context_tag: ContextTag,
11252    pub target: u32,
11253    pub pname: u32,
11254}
11255impl_debug_if_no_extra_traits!(GetHistogramParameterivRequest, "GetHistogramParameterivRequest");
11256impl GetHistogramParameterivRequest {
11257    /// Serialize this request into bytes for the provided connection
11258    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
11259        let length_so_far = 0;
11260        let context_tag_bytes = self.context_tag.serialize();
11261        let target_bytes = self.target.serialize();
11262        let pname_bytes = self.pname.serialize();
11263        let mut request0 = vec![
11264            major_opcode,
11265            GET_HISTOGRAM_PARAMETERIV_REQUEST,
11266            0,
11267            0,
11268            context_tag_bytes[0],
11269            context_tag_bytes[1],
11270            context_tag_bytes[2],
11271            context_tag_bytes[3],
11272            target_bytes[0],
11273            target_bytes[1],
11274            target_bytes[2],
11275            target_bytes[3],
11276            pname_bytes[0],
11277            pname_bytes[1],
11278            pname_bytes[2],
11279            pname_bytes[3],
11280        ];
11281        let length_so_far = length_so_far + request0.len();
11282        assert_eq!(length_so_far % 4, 0);
11283        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11284        request0[2..4].copy_from_slice(&length.to_ne_bytes());
11285        ([request0.into()], vec![])
11286    }
11287    /// Parse this request given its header, its body, and any fds that go along with it
11288    #[cfg(feature = "request-parsing")]
11289    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11290        if header.minor_opcode != GET_HISTOGRAM_PARAMETERIV_REQUEST {
11291            return Err(ParseError::InvalidValue);
11292        }
11293        let (context_tag, remaining) = ContextTag::try_parse(value)?;
11294        let (target, remaining) = u32::try_parse(remaining)?;
11295        let (pname, remaining) = u32::try_parse(remaining)?;
11296        let _ = remaining;
11297        Ok(GetHistogramParameterivRequest {
11298            context_tag,
11299            target,
11300            pname,
11301        })
11302    }
11303}
11304impl Request for GetHistogramParameterivRequest {
11305    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
11306
11307    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
11308        let (bufs, fds) = self.serialize(major_opcode);
11309        // Flatten the buffers into a single vector
11310        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
11311        (buf, fds)
11312    }
11313}
11314impl crate::x11_utils::ReplyRequest for GetHistogramParameterivRequest {
11315    type Reply = GetHistogramParameterivReply;
11316}
11317
11318#[derive(Clone, Default)]
11319#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11320#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11321pub struct GetHistogramParameterivReply {
11322    pub sequence: u16,
11323    pub length: u32,
11324    pub datum: i32,
11325    pub data: Vec<i32>,
11326}
11327impl_debug_if_no_extra_traits!(GetHistogramParameterivReply, "GetHistogramParameterivReply");
11328impl TryParse for GetHistogramParameterivReply {
11329    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11330        let remaining = initial_value;
11331        let (response_type, remaining) = u8::try_parse(remaining)?;
11332        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11333        let (sequence, remaining) = u16::try_parse(remaining)?;
11334        let (length, remaining) = u32::try_parse(remaining)?;
11335        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
11336        let (n, remaining) = u32::try_parse(remaining)?;
11337        let (datum, remaining) = i32::try_parse(remaining)?;
11338        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11339        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
11340        if response_type != 1 {
11341            return Err(ParseError::InvalidValue);
11342        }
11343        let result = GetHistogramParameterivReply { sequence, length, datum, data };
11344        let _ = remaining;
11345        let remaining = initial_value.get(32 + length as usize * 4..)
11346            .ok_or(ParseError::InsufficientData)?;
11347        Ok((result, remaining))
11348    }
11349}
11350impl Serialize for GetHistogramParameterivReply {
11351    type Bytes = Vec<u8>;
11352    fn serialize(&self) -> Vec<u8> {
11353        let mut result = Vec::new();
11354        self.serialize_into(&mut result);
11355        result
11356    }
11357    fn serialize_into(&self, bytes: &mut Vec<u8>) {
11358        bytes.reserve(32);
11359        let response_type_bytes = &[1];
11360        bytes.push(response_type_bytes[0]);
11361        bytes.extend_from_slice(&[0; 1]);
11362        self.sequence.serialize_into(bytes);
11363        self.length.serialize_into(bytes);
11364        bytes.extend_from_slice(&[0; 4]);
11365        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
11366        n.serialize_into(bytes);
11367        self.datum.serialize_into(bytes);
11368        bytes.extend_from_slice(&[0; 12]);
11369        self.data.serialize_into(bytes);
11370    }
11371}
11372impl GetHistogramParameterivReply {
11373    /// Get the value of the `n` field.
11374    ///
11375    /// The `n` field is used as the length field of the `data` field.
11376    /// This function computes the field's value again based on the length of the list.
11377    ///
11378    /// # Panics
11379    ///
11380    /// Panics if the value cannot be represented in the target type. This
11381    /// cannot happen with values of the struct received from the X11 server.
11382    pub fn n(&self) -> u32 {
11383        self.data.len()
11384            .try_into().unwrap()
11385    }
11386}
11387
11388/// Opcode for the GetMinmax request
11389pub const GET_MINMAX_REQUEST: u8 = 157;
11390#[derive(Clone, Copy, Default)]
11391#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11392#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11393pub struct GetMinmaxRequest {
11394    pub context_tag: ContextTag,
11395    pub target: u32,
11396    pub format: u32,
11397    pub type_: u32,
11398    pub swap_bytes: bool,
11399    pub reset: bool,
11400}
11401impl_debug_if_no_extra_traits!(GetMinmaxRequest, "GetMinmaxRequest");
11402impl GetMinmaxRequest {
11403    /// Serialize this request into bytes for the provided connection
11404    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
11405        let length_so_far = 0;
11406        let context_tag_bytes = self.context_tag.serialize();
11407        let target_bytes = self.target.serialize();
11408        let format_bytes = self.format.serialize();
11409        let type_bytes = self.type_.serialize();
11410        let swap_bytes_bytes = self.swap_bytes.serialize();
11411        let reset_bytes = self.reset.serialize();
11412        let mut request0 = vec![
11413            major_opcode,
11414            GET_MINMAX_REQUEST,
11415            0,
11416            0,
11417            context_tag_bytes[0],
11418            context_tag_bytes[1],
11419            context_tag_bytes[2],
11420            context_tag_bytes[3],
11421            target_bytes[0],
11422            target_bytes[1],
11423            target_bytes[2],
11424            target_bytes[3],
11425            format_bytes[0],
11426            format_bytes[1],
11427            format_bytes[2],
11428            format_bytes[3],
11429            type_bytes[0],
11430            type_bytes[1],
11431            type_bytes[2],
11432            type_bytes[3],
11433            swap_bytes_bytes[0],
11434            reset_bytes[0],
11435            0,
11436            0,
11437        ];
11438        let length_so_far = length_so_far + request0.len();
11439        assert_eq!(length_so_far % 4, 0);
11440        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11441        request0[2..4].copy_from_slice(&length.to_ne_bytes());
11442        ([request0.into()], vec![])
11443    }
11444    /// Parse this request given its header, its body, and any fds that go along with it
11445    #[cfg(feature = "request-parsing")]
11446    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11447        if header.minor_opcode != GET_MINMAX_REQUEST {
11448            return Err(ParseError::InvalidValue);
11449        }
11450        let (context_tag, remaining) = ContextTag::try_parse(value)?;
11451        let (target, remaining) = u32::try_parse(remaining)?;
11452        let (format, remaining) = u32::try_parse(remaining)?;
11453        let (type_, remaining) = u32::try_parse(remaining)?;
11454        let (swap_bytes, remaining) = bool::try_parse(remaining)?;
11455        let (reset, remaining) = bool::try_parse(remaining)?;
11456        let _ = remaining;
11457        Ok(GetMinmaxRequest {
11458            context_tag,
11459            target,
11460            format,
11461            type_,
11462            swap_bytes,
11463            reset,
11464        })
11465    }
11466}
11467impl Request for GetMinmaxRequest {
11468    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
11469
11470    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
11471        let (bufs, fds) = self.serialize(major_opcode);
11472        // Flatten the buffers into a single vector
11473        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
11474        (buf, fds)
11475    }
11476}
11477impl crate::x11_utils::ReplyRequest for GetMinmaxRequest {
11478    type Reply = GetMinmaxReply;
11479}
11480
11481#[derive(Clone, Default)]
11482#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11483#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11484pub struct GetMinmaxReply {
11485    pub sequence: u16,
11486    pub data: Vec<u8>,
11487}
11488impl_debug_if_no_extra_traits!(GetMinmaxReply, "GetMinmaxReply");
11489impl TryParse for GetMinmaxReply {
11490    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11491        let remaining = initial_value;
11492        let (response_type, remaining) = u8::try_parse(remaining)?;
11493        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11494        let (sequence, remaining) = u16::try_parse(remaining)?;
11495        let (length, remaining) = u32::try_parse(remaining)?;
11496        let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
11497        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
11498        let data = data.to_vec();
11499        if response_type != 1 {
11500            return Err(ParseError::InvalidValue);
11501        }
11502        let result = GetMinmaxReply { sequence, data };
11503        let _ = remaining;
11504        let remaining = initial_value.get(32 + length as usize * 4..)
11505            .ok_or(ParseError::InsufficientData)?;
11506        Ok((result, remaining))
11507    }
11508}
11509impl Serialize for GetMinmaxReply {
11510    type Bytes = Vec<u8>;
11511    fn serialize(&self) -> Vec<u8> {
11512        let mut result = Vec::new();
11513        self.serialize_into(&mut result);
11514        result
11515    }
11516    fn serialize_into(&self, bytes: &mut Vec<u8>) {
11517        bytes.reserve(32);
11518        let response_type_bytes = &[1];
11519        bytes.push(response_type_bytes[0]);
11520        bytes.extend_from_slice(&[0; 1]);
11521        self.sequence.serialize_into(bytes);
11522        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
11523        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
11524        length.serialize_into(bytes);
11525        bytes.extend_from_slice(&[0; 24]);
11526        bytes.extend_from_slice(&self.data);
11527    }
11528}
11529impl GetMinmaxReply {
11530    /// Get the value of the `length` field.
11531    ///
11532    /// The `length` field is used as the length field of the `data` field.
11533    /// This function computes the field's value again based on the length of the list.
11534    ///
11535    /// # Panics
11536    ///
11537    /// Panics if the value cannot be represented in the target type. This
11538    /// cannot happen with values of the struct received from the X11 server.
11539    pub fn length(&self) -> u32 {
11540        self.data.len()
11541            .checked_div(4).unwrap()
11542            .try_into().unwrap()
11543    }
11544}
11545
11546/// Opcode for the GetMinmaxParameterfv request
11547pub const GET_MINMAX_PARAMETERFV_REQUEST: u8 = 158;
11548#[derive(Clone, Copy, Default)]
11549#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11550#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11551pub struct GetMinmaxParameterfvRequest {
11552    pub context_tag: ContextTag,
11553    pub target: u32,
11554    pub pname: u32,
11555}
11556impl_debug_if_no_extra_traits!(GetMinmaxParameterfvRequest, "GetMinmaxParameterfvRequest");
11557impl GetMinmaxParameterfvRequest {
11558    /// Serialize this request into bytes for the provided connection
11559    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
11560        let length_so_far = 0;
11561        let context_tag_bytes = self.context_tag.serialize();
11562        let target_bytes = self.target.serialize();
11563        let pname_bytes = self.pname.serialize();
11564        let mut request0 = vec![
11565            major_opcode,
11566            GET_MINMAX_PARAMETERFV_REQUEST,
11567            0,
11568            0,
11569            context_tag_bytes[0],
11570            context_tag_bytes[1],
11571            context_tag_bytes[2],
11572            context_tag_bytes[3],
11573            target_bytes[0],
11574            target_bytes[1],
11575            target_bytes[2],
11576            target_bytes[3],
11577            pname_bytes[0],
11578            pname_bytes[1],
11579            pname_bytes[2],
11580            pname_bytes[3],
11581        ];
11582        let length_so_far = length_so_far + request0.len();
11583        assert_eq!(length_so_far % 4, 0);
11584        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11585        request0[2..4].copy_from_slice(&length.to_ne_bytes());
11586        ([request0.into()], vec![])
11587    }
11588    /// Parse this request given its header, its body, and any fds that go along with it
11589    #[cfg(feature = "request-parsing")]
11590    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11591        if header.minor_opcode != GET_MINMAX_PARAMETERFV_REQUEST {
11592            return Err(ParseError::InvalidValue);
11593        }
11594        let (context_tag, remaining) = ContextTag::try_parse(value)?;
11595        let (target, remaining) = u32::try_parse(remaining)?;
11596        let (pname, remaining) = u32::try_parse(remaining)?;
11597        let _ = remaining;
11598        Ok(GetMinmaxParameterfvRequest {
11599            context_tag,
11600            target,
11601            pname,
11602        })
11603    }
11604}
11605impl Request for GetMinmaxParameterfvRequest {
11606    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
11607
11608    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
11609        let (bufs, fds) = self.serialize(major_opcode);
11610        // Flatten the buffers into a single vector
11611        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
11612        (buf, fds)
11613    }
11614}
11615impl crate::x11_utils::ReplyRequest for GetMinmaxParameterfvRequest {
11616    type Reply = GetMinmaxParameterfvReply;
11617}
11618
11619#[derive(Clone, Default)]
11620#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))]
11621#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11622pub struct GetMinmaxParameterfvReply {
11623    pub sequence: u16,
11624    pub length: u32,
11625    pub datum: Float32,
11626    pub data: Vec<Float32>,
11627}
11628impl_debug_if_no_extra_traits!(GetMinmaxParameterfvReply, "GetMinmaxParameterfvReply");
11629impl TryParse for GetMinmaxParameterfvReply {
11630    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11631        let remaining = initial_value;
11632        let (response_type, remaining) = u8::try_parse(remaining)?;
11633        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11634        let (sequence, remaining) = u16::try_parse(remaining)?;
11635        let (length, remaining) = u32::try_parse(remaining)?;
11636        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
11637        let (n, remaining) = u32::try_parse(remaining)?;
11638        let (datum, remaining) = Float32::try_parse(remaining)?;
11639        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11640        let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
11641        if response_type != 1 {
11642            return Err(ParseError::InvalidValue);
11643        }
11644        let result = GetMinmaxParameterfvReply { sequence, length, datum, data };
11645        let _ = remaining;
11646        let remaining = initial_value.get(32 + length as usize * 4..)
11647            .ok_or(ParseError::InsufficientData)?;
11648        Ok((result, remaining))
11649    }
11650}
11651impl Serialize for GetMinmaxParameterfvReply {
11652    type Bytes = Vec<u8>;
11653    fn serialize(&self) -> Vec<u8> {
11654        let mut result = Vec::new();
11655        self.serialize_into(&mut result);
11656        result
11657    }
11658    fn serialize_into(&self, bytes: &mut Vec<u8>) {
11659        bytes.reserve(32);
11660        let response_type_bytes = &[1];
11661        bytes.push(response_type_bytes[0]);
11662        bytes.extend_from_slice(&[0; 1]);
11663        self.sequence.serialize_into(bytes);
11664        self.length.serialize_into(bytes);
11665        bytes.extend_from_slice(&[0; 4]);
11666        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
11667        n.serialize_into(bytes);
11668        self.datum.serialize_into(bytes);
11669        bytes.extend_from_slice(&[0; 12]);
11670        self.data.serialize_into(bytes);
11671    }
11672}
11673impl GetMinmaxParameterfvReply {
11674    /// Get the value of the `n` field.
11675    ///
11676    /// The `n` field is used as the length field of the `data` field.
11677    /// This function computes the field's value again based on the length of the list.
11678    ///
11679    /// # Panics
11680    ///
11681    /// Panics if the value cannot be represented in the target type. This
11682    /// cannot happen with values of the struct received from the X11 server.
11683    pub fn n(&self) -> u32 {
11684        self.data.len()
11685            .try_into().unwrap()
11686    }
11687}
11688
11689/// Opcode for the GetMinmaxParameteriv request
11690pub const GET_MINMAX_PARAMETERIV_REQUEST: u8 = 159;
11691#[derive(Clone, Copy, Default)]
11692#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11693#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11694pub struct GetMinmaxParameterivRequest {
11695    pub context_tag: ContextTag,
11696    pub target: u32,
11697    pub pname: u32,
11698}
11699impl_debug_if_no_extra_traits!(GetMinmaxParameterivRequest, "GetMinmaxParameterivRequest");
11700impl GetMinmaxParameterivRequest {
11701    /// Serialize this request into bytes for the provided connection
11702    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
11703        let length_so_far = 0;
11704        let context_tag_bytes = self.context_tag.serialize();
11705        let target_bytes = self.target.serialize();
11706        let pname_bytes = self.pname.serialize();
11707        let mut request0 = vec![
11708            major_opcode,
11709            GET_MINMAX_PARAMETERIV_REQUEST,
11710            0,
11711            0,
11712            context_tag_bytes[0],
11713            context_tag_bytes[1],
11714            context_tag_bytes[2],
11715            context_tag_bytes[3],
11716            target_bytes[0],
11717            target_bytes[1],
11718            target_bytes[2],
11719            target_bytes[3],
11720            pname_bytes[0],
11721            pname_bytes[1],
11722            pname_bytes[2],
11723            pname_bytes[3],
11724        ];
11725        let length_so_far = length_so_far + request0.len();
11726        assert_eq!(length_so_far % 4, 0);
11727        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11728        request0[2..4].copy_from_slice(&length.to_ne_bytes());
11729        ([request0.into()], vec![])
11730    }
11731    /// Parse this request given its header, its body, and any fds that go along with it
11732    #[cfg(feature = "request-parsing")]
11733    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11734        if header.minor_opcode != GET_MINMAX_PARAMETERIV_REQUEST {
11735            return Err(ParseError::InvalidValue);
11736        }
11737        let (context_tag, remaining) = ContextTag::try_parse(value)?;
11738        let (target, remaining) = u32::try_parse(remaining)?;
11739        let (pname, remaining) = u32::try_parse(remaining)?;
11740        let _ = remaining;
11741        Ok(GetMinmaxParameterivRequest {
11742            context_tag,
11743            target,
11744            pname,
11745        })
11746    }
11747}
11748impl Request for GetMinmaxParameterivRequest {
11749    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
11750
11751    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
11752        let (bufs, fds) = self.serialize(major_opcode);
11753        // Flatten the buffers into a single vector
11754        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
11755        (buf, fds)
11756    }
11757}
11758impl crate::x11_utils::ReplyRequest for GetMinmaxParameterivRequest {
11759    type Reply = GetMinmaxParameterivReply;
11760}
11761
11762#[derive(Clone, Default)]
11763#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11764#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11765pub struct GetMinmaxParameterivReply {
11766    pub sequence: u16,
11767    pub length: u32,
11768    pub datum: i32,
11769    pub data: Vec<i32>,
11770}
11771impl_debug_if_no_extra_traits!(GetMinmaxParameterivReply, "GetMinmaxParameterivReply");
11772impl TryParse for GetMinmaxParameterivReply {
11773    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11774        let remaining = initial_value;
11775        let (response_type, remaining) = u8::try_parse(remaining)?;
11776        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11777        let (sequence, remaining) = u16::try_parse(remaining)?;
11778        let (length, remaining) = u32::try_parse(remaining)?;
11779        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
11780        let (n, remaining) = u32::try_parse(remaining)?;
11781        let (datum, remaining) = i32::try_parse(remaining)?;
11782        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11783        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
11784        if response_type != 1 {
11785            return Err(ParseError::InvalidValue);
11786        }
11787        let result = GetMinmaxParameterivReply { sequence, length, datum, data };
11788        let _ = remaining;
11789        let remaining = initial_value.get(32 + length as usize * 4..)
11790            .ok_or(ParseError::InsufficientData)?;
11791        Ok((result, remaining))
11792    }
11793}
11794impl Serialize for GetMinmaxParameterivReply {
11795    type Bytes = Vec<u8>;
11796    fn serialize(&self) -> Vec<u8> {
11797        let mut result = Vec::new();
11798        self.serialize_into(&mut result);
11799        result
11800    }
11801    fn serialize_into(&self, bytes: &mut Vec<u8>) {
11802        bytes.reserve(32);
11803        let response_type_bytes = &[1];
11804        bytes.push(response_type_bytes[0]);
11805        bytes.extend_from_slice(&[0; 1]);
11806        self.sequence.serialize_into(bytes);
11807        self.length.serialize_into(bytes);
11808        bytes.extend_from_slice(&[0; 4]);
11809        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
11810        n.serialize_into(bytes);
11811        self.datum.serialize_into(bytes);
11812        bytes.extend_from_slice(&[0; 12]);
11813        self.data.serialize_into(bytes);
11814    }
11815}
11816impl GetMinmaxParameterivReply {
11817    /// Get the value of the `n` field.
11818    ///
11819    /// The `n` field is used as the length field of the `data` field.
11820    /// This function computes the field's value again based on the length of the list.
11821    ///
11822    /// # Panics
11823    ///
11824    /// Panics if the value cannot be represented in the target type. This
11825    /// cannot happen with values of the struct received from the X11 server.
11826    pub fn n(&self) -> u32 {
11827        self.data.len()
11828            .try_into().unwrap()
11829    }
11830}
11831
11832/// Opcode for the GetCompressedTexImageARB request
11833pub const GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST: u8 = 160;
11834#[derive(Clone, Copy, Default)]
11835#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11836#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11837pub struct GetCompressedTexImageARBRequest {
11838    pub context_tag: ContextTag,
11839    pub target: u32,
11840    pub level: i32,
11841}
11842impl_debug_if_no_extra_traits!(GetCompressedTexImageARBRequest, "GetCompressedTexImageARBRequest");
11843impl GetCompressedTexImageARBRequest {
11844    /// Serialize this request into bytes for the provided connection
11845    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
11846        let length_so_far = 0;
11847        let context_tag_bytes = self.context_tag.serialize();
11848        let target_bytes = self.target.serialize();
11849        let level_bytes = self.level.serialize();
11850        let mut request0 = vec![
11851            major_opcode,
11852            GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST,
11853            0,
11854            0,
11855            context_tag_bytes[0],
11856            context_tag_bytes[1],
11857            context_tag_bytes[2],
11858            context_tag_bytes[3],
11859            target_bytes[0],
11860            target_bytes[1],
11861            target_bytes[2],
11862            target_bytes[3],
11863            level_bytes[0],
11864            level_bytes[1],
11865            level_bytes[2],
11866            level_bytes[3],
11867        ];
11868        let length_so_far = length_so_far + request0.len();
11869        assert_eq!(length_so_far % 4, 0);
11870        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11871        request0[2..4].copy_from_slice(&length.to_ne_bytes());
11872        ([request0.into()], vec![])
11873    }
11874    /// Parse this request given its header, its body, and any fds that go along with it
11875    #[cfg(feature = "request-parsing")]
11876    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11877        if header.minor_opcode != GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST {
11878            return Err(ParseError::InvalidValue);
11879        }
11880        let (context_tag, remaining) = ContextTag::try_parse(value)?;
11881        let (target, remaining) = u32::try_parse(remaining)?;
11882        let (level, remaining) = i32::try_parse(remaining)?;
11883        let _ = remaining;
11884        Ok(GetCompressedTexImageARBRequest {
11885            context_tag,
11886            target,
11887            level,
11888        })
11889    }
11890}
11891impl Request for GetCompressedTexImageARBRequest {
11892    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
11893
11894    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
11895        let (bufs, fds) = self.serialize(major_opcode);
11896        // Flatten the buffers into a single vector
11897        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
11898        (buf, fds)
11899    }
11900}
11901impl crate::x11_utils::ReplyRequest for GetCompressedTexImageARBRequest {
11902    type Reply = GetCompressedTexImageARBReply;
11903}
11904
11905#[derive(Clone, Default)]
11906#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11907#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11908pub struct GetCompressedTexImageARBReply {
11909    pub sequence: u16,
11910    pub size: i32,
11911    pub data: Vec<u8>,
11912}
11913impl_debug_if_no_extra_traits!(GetCompressedTexImageARBReply, "GetCompressedTexImageARBReply");
11914impl TryParse for GetCompressedTexImageARBReply {
11915    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11916        let remaining = initial_value;
11917        let (response_type, remaining) = u8::try_parse(remaining)?;
11918        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11919        let (sequence, remaining) = u16::try_parse(remaining)?;
11920        let (length, remaining) = u32::try_parse(remaining)?;
11921        let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
11922        let (size, remaining) = i32::try_parse(remaining)?;
11923        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11924        let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
11925        let data = data.to_vec();
11926        if response_type != 1 {
11927            return Err(ParseError::InvalidValue);
11928        }
11929        let result = GetCompressedTexImageARBReply { sequence, size, data };
11930        let _ = remaining;
11931        let remaining = initial_value.get(32 + length as usize * 4..)
11932            .ok_or(ParseError::InsufficientData)?;
11933        Ok((result, remaining))
11934    }
11935}
11936impl Serialize for GetCompressedTexImageARBReply {
11937    type Bytes = Vec<u8>;
11938    fn serialize(&self) -> Vec<u8> {
11939        let mut result = Vec::new();
11940        self.serialize_into(&mut result);
11941        result
11942    }
11943    fn serialize_into(&self, bytes: &mut Vec<u8>) {
11944        bytes.reserve(32);
11945        let response_type_bytes = &[1];
11946        bytes.push(response_type_bytes[0]);
11947        bytes.extend_from_slice(&[0; 1]);
11948        self.sequence.serialize_into(bytes);
11949        assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4");
11950        let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements");
11951        length.serialize_into(bytes);
11952        bytes.extend_from_slice(&[0; 8]);
11953        self.size.serialize_into(bytes);
11954        bytes.extend_from_slice(&[0; 12]);
11955        bytes.extend_from_slice(&self.data);
11956    }
11957}
11958impl GetCompressedTexImageARBReply {
11959    /// Get the value of the `length` field.
11960    ///
11961    /// The `length` field is used as the length field of the `data` field.
11962    /// This function computes the field's value again based on the length of the list.
11963    ///
11964    /// # Panics
11965    ///
11966    /// Panics if the value cannot be represented in the target type. This
11967    /// cannot happen with values of the struct received from the X11 server.
11968    pub fn length(&self) -> u32 {
11969        self.data.len()
11970            .checked_div(4).unwrap()
11971            .try_into().unwrap()
11972    }
11973}
11974
11975/// Opcode for the DeleteQueriesARB request
11976pub const DELETE_QUERIES_ARB_REQUEST: u8 = 161;
11977#[derive(Clone, Default)]
11978#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
11979#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11980pub struct DeleteQueriesARBRequest<'input> {
11981    pub context_tag: ContextTag,
11982    pub ids: Cow<'input, [u32]>,
11983}
11984impl_debug_if_no_extra_traits!(DeleteQueriesARBRequest<'_>, "DeleteQueriesARBRequest");
11985impl<'input> DeleteQueriesARBRequest<'input> {
11986    /// Serialize this request into bytes for the provided connection
11987    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> {
11988        let length_so_far = 0;
11989        let context_tag_bytes = self.context_tag.serialize();
11990        let n = i32::try_from(self.ids.len()).expect("`ids` has too many elements");
11991        let n_bytes = n.serialize();
11992        let mut request0 = vec![
11993            major_opcode,
11994            DELETE_QUERIES_ARB_REQUEST,
11995            0,
11996            0,
11997            context_tag_bytes[0],
11998            context_tag_bytes[1],
11999            context_tag_bytes[2],
12000            context_tag_bytes[3],
12001            n_bytes[0],
12002            n_bytes[1],
12003            n_bytes[2],
12004            n_bytes[3],
12005        ];
12006        let length_so_far = length_so_far + request0.len();
12007        let ids_bytes = self.ids.serialize();
12008        let length_so_far = length_so_far + ids_bytes.len();
12009        let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
12010        let length_so_far = length_so_far + padding0.len();
12011        assert_eq!(length_so_far % 4, 0);
12012        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
12013        request0[2..4].copy_from_slice(&length.to_ne_bytes());
12014        ([request0.into(), ids_bytes.into(), padding0.into()], vec![])
12015    }
12016    /// Parse this request given its header, its body, and any fds that go along with it
12017    #[cfg(feature = "request-parsing")]
12018    pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
12019        if header.minor_opcode != DELETE_QUERIES_ARB_REQUEST {
12020            return Err(ParseError::InvalidValue);
12021        }
12022        let (context_tag, remaining) = ContextTag::try_parse(value)?;
12023        let (n, remaining) = i32::try_parse(remaining)?;
12024        let (ids, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
12025        let _ = remaining;
12026        Ok(DeleteQueriesARBRequest {
12027            context_tag,
12028            ids: Cow::Owned(ids),
12029        })
12030    }
12031    /// Clone all borrowed data in this DeleteQueriesARBRequest.
12032    pub fn into_owned(self) -> DeleteQueriesARBRequest<'static> {
12033        DeleteQueriesARBRequest {
12034            context_tag: self.context_tag,
12035            ids: Cow::Owned(self.ids.into_owned()),
12036        }
12037    }
12038}
12039impl<'input> Request for DeleteQueriesARBRequest<'input> {
12040    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
12041
12042    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
12043        let (bufs, fds) = self.serialize(major_opcode);
12044        // Flatten the buffers into a single vector
12045        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
12046        (buf, fds)
12047    }
12048}
12049impl<'input> crate::x11_utils::VoidRequest for DeleteQueriesARBRequest<'input> {
12050}
12051
12052/// Opcode for the GenQueriesARB request
12053pub const GEN_QUERIES_ARB_REQUEST: u8 = 162;
12054#[derive(Clone, Copy, Default)]
12055#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12056#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12057pub struct GenQueriesARBRequest {
12058    pub context_tag: ContextTag,
12059    pub n: i32,
12060}
12061impl_debug_if_no_extra_traits!(GenQueriesARBRequest, "GenQueriesARBRequest");
12062impl GenQueriesARBRequest {
12063    /// Serialize this request into bytes for the provided connection
12064    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
12065        let length_so_far = 0;
12066        let context_tag_bytes = self.context_tag.serialize();
12067        let n_bytes = self.n.serialize();
12068        let mut request0 = vec![
12069            major_opcode,
12070            GEN_QUERIES_ARB_REQUEST,
12071            0,
12072            0,
12073            context_tag_bytes[0],
12074            context_tag_bytes[1],
12075            context_tag_bytes[2],
12076            context_tag_bytes[3],
12077            n_bytes[0],
12078            n_bytes[1],
12079            n_bytes[2],
12080            n_bytes[3],
12081        ];
12082        let length_so_far = length_so_far + request0.len();
12083        assert_eq!(length_so_far % 4, 0);
12084        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
12085        request0[2..4].copy_from_slice(&length.to_ne_bytes());
12086        ([request0.into()], vec![])
12087    }
12088    /// Parse this request given its header, its body, and any fds that go along with it
12089    #[cfg(feature = "request-parsing")]
12090    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
12091        if header.minor_opcode != GEN_QUERIES_ARB_REQUEST {
12092            return Err(ParseError::InvalidValue);
12093        }
12094        let (context_tag, remaining) = ContextTag::try_parse(value)?;
12095        let (n, remaining) = i32::try_parse(remaining)?;
12096        let _ = remaining;
12097        Ok(GenQueriesARBRequest {
12098            context_tag,
12099            n,
12100        })
12101    }
12102}
12103impl Request for GenQueriesARBRequest {
12104    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
12105
12106    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
12107        let (bufs, fds) = self.serialize(major_opcode);
12108        // Flatten the buffers into a single vector
12109        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
12110        (buf, fds)
12111    }
12112}
12113impl crate::x11_utils::ReplyRequest for GenQueriesARBRequest {
12114    type Reply = GenQueriesARBReply;
12115}
12116
12117#[derive(Clone, Default)]
12118#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12119#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12120pub struct GenQueriesARBReply {
12121    pub sequence: u16,
12122    pub data: Vec<u32>,
12123}
12124impl_debug_if_no_extra_traits!(GenQueriesARBReply, "GenQueriesARBReply");
12125impl TryParse for GenQueriesARBReply {
12126    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
12127        let remaining = initial_value;
12128        let (response_type, remaining) = u8::try_parse(remaining)?;
12129        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
12130        let (sequence, remaining) = u16::try_parse(remaining)?;
12131        let (length, remaining) = u32::try_parse(remaining)?;
12132        let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
12133        let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
12134        if response_type != 1 {
12135            return Err(ParseError::InvalidValue);
12136        }
12137        let result = GenQueriesARBReply { sequence, data };
12138        let _ = remaining;
12139        let remaining = initial_value.get(32 + length as usize * 4..)
12140            .ok_or(ParseError::InsufficientData)?;
12141        Ok((result, remaining))
12142    }
12143}
12144impl Serialize for GenQueriesARBReply {
12145    type Bytes = Vec<u8>;
12146    fn serialize(&self) -> Vec<u8> {
12147        let mut result = Vec::new();
12148        self.serialize_into(&mut result);
12149        result
12150    }
12151    fn serialize_into(&self, bytes: &mut Vec<u8>) {
12152        bytes.reserve(32);
12153        let response_type_bytes = &[1];
12154        bytes.push(response_type_bytes[0]);
12155        bytes.extend_from_slice(&[0; 1]);
12156        self.sequence.serialize_into(bytes);
12157        let length = u32::try_from(self.data.len()).expect("`data` has too many elements");
12158        length.serialize_into(bytes);
12159        bytes.extend_from_slice(&[0; 24]);
12160        self.data.serialize_into(bytes);
12161    }
12162}
12163impl GenQueriesARBReply {
12164    /// Get the value of the `length` field.
12165    ///
12166    /// The `length` field is used as the length field of the `data` field.
12167    /// This function computes the field's value again based on the length of the list.
12168    ///
12169    /// # Panics
12170    ///
12171    /// Panics if the value cannot be represented in the target type. This
12172    /// cannot happen with values of the struct received from the X11 server.
12173    pub fn length(&self) -> u32 {
12174        self.data.len()
12175            .try_into().unwrap()
12176    }
12177}
12178
12179/// Opcode for the IsQueryARB request
12180pub const IS_QUERY_ARB_REQUEST: u8 = 163;
12181#[derive(Clone, Copy, Default)]
12182#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12183#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12184pub struct IsQueryARBRequest {
12185    pub context_tag: ContextTag,
12186    pub id: u32,
12187}
12188impl_debug_if_no_extra_traits!(IsQueryARBRequest, "IsQueryARBRequest");
12189impl IsQueryARBRequest {
12190    /// Serialize this request into bytes for the provided connection
12191    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
12192        let length_so_far = 0;
12193        let context_tag_bytes = self.context_tag.serialize();
12194        let id_bytes = self.id.serialize();
12195        let mut request0 = vec![
12196            major_opcode,
12197            IS_QUERY_ARB_REQUEST,
12198            0,
12199            0,
12200            context_tag_bytes[0],
12201            context_tag_bytes[1],
12202            context_tag_bytes[2],
12203            context_tag_bytes[3],
12204            id_bytes[0],
12205            id_bytes[1],
12206            id_bytes[2],
12207            id_bytes[3],
12208        ];
12209        let length_so_far = length_so_far + request0.len();
12210        assert_eq!(length_so_far % 4, 0);
12211        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
12212        request0[2..4].copy_from_slice(&length.to_ne_bytes());
12213        ([request0.into()], vec![])
12214    }
12215    /// Parse this request given its header, its body, and any fds that go along with it
12216    #[cfg(feature = "request-parsing")]
12217    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
12218        if header.minor_opcode != IS_QUERY_ARB_REQUEST {
12219            return Err(ParseError::InvalidValue);
12220        }
12221        let (context_tag, remaining) = ContextTag::try_parse(value)?;
12222        let (id, remaining) = u32::try_parse(remaining)?;
12223        let _ = remaining;
12224        Ok(IsQueryARBRequest {
12225            context_tag,
12226            id,
12227        })
12228    }
12229}
12230impl Request for IsQueryARBRequest {
12231    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
12232
12233    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
12234        let (bufs, fds) = self.serialize(major_opcode);
12235        // Flatten the buffers into a single vector
12236        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
12237        (buf, fds)
12238    }
12239}
12240impl crate::x11_utils::ReplyRequest for IsQueryARBRequest {
12241    type Reply = IsQueryARBReply;
12242}
12243
12244#[derive(Clone, Copy, Default)]
12245#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12246#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12247pub struct IsQueryARBReply {
12248    pub sequence: u16,
12249    pub length: u32,
12250    pub ret_val: Bool32,
12251}
12252impl_debug_if_no_extra_traits!(IsQueryARBReply, "IsQueryARBReply");
12253impl TryParse for IsQueryARBReply {
12254    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
12255        let remaining = initial_value;
12256        let (response_type, remaining) = u8::try_parse(remaining)?;
12257        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
12258        let (sequence, remaining) = u16::try_parse(remaining)?;
12259        let (length, remaining) = u32::try_parse(remaining)?;
12260        let (ret_val, remaining) = Bool32::try_parse(remaining)?;
12261        if response_type != 1 {
12262            return Err(ParseError::InvalidValue);
12263        }
12264        let result = IsQueryARBReply { sequence, length, ret_val };
12265        let _ = remaining;
12266        let remaining = initial_value.get(32 + length as usize * 4..)
12267            .ok_or(ParseError::InsufficientData)?;
12268        Ok((result, remaining))
12269    }
12270}
12271impl Serialize for IsQueryARBReply {
12272    type Bytes = [u8; 12];
12273    fn serialize(&self) -> [u8; 12] {
12274        let response_type_bytes = &[1];
12275        let sequence_bytes = self.sequence.serialize();
12276        let length_bytes = self.length.serialize();
12277        let ret_val_bytes = self.ret_val.serialize();
12278        [
12279            response_type_bytes[0],
12280            0,
12281            sequence_bytes[0],
12282            sequence_bytes[1],
12283            length_bytes[0],
12284            length_bytes[1],
12285            length_bytes[2],
12286            length_bytes[3],
12287            ret_val_bytes[0],
12288            ret_val_bytes[1],
12289            ret_val_bytes[2],
12290            ret_val_bytes[3],
12291        ]
12292    }
12293    fn serialize_into(&self, bytes: &mut Vec<u8>) {
12294        bytes.reserve(12);
12295        let response_type_bytes = &[1];
12296        bytes.push(response_type_bytes[0]);
12297        bytes.extend_from_slice(&[0; 1]);
12298        self.sequence.serialize_into(bytes);
12299        self.length.serialize_into(bytes);
12300        self.ret_val.serialize_into(bytes);
12301    }
12302}
12303
12304/// Opcode for the GetQueryivARB request
12305pub const GET_QUERYIV_ARB_REQUEST: u8 = 164;
12306#[derive(Clone, Copy, Default)]
12307#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12308#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12309pub struct GetQueryivARBRequest {
12310    pub context_tag: ContextTag,
12311    pub target: u32,
12312    pub pname: u32,
12313}
12314impl_debug_if_no_extra_traits!(GetQueryivARBRequest, "GetQueryivARBRequest");
12315impl GetQueryivARBRequest {
12316    /// Serialize this request into bytes for the provided connection
12317    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
12318        let length_so_far = 0;
12319        let context_tag_bytes = self.context_tag.serialize();
12320        let target_bytes = self.target.serialize();
12321        let pname_bytes = self.pname.serialize();
12322        let mut request0 = vec![
12323            major_opcode,
12324            GET_QUERYIV_ARB_REQUEST,
12325            0,
12326            0,
12327            context_tag_bytes[0],
12328            context_tag_bytes[1],
12329            context_tag_bytes[2],
12330            context_tag_bytes[3],
12331            target_bytes[0],
12332            target_bytes[1],
12333            target_bytes[2],
12334            target_bytes[3],
12335            pname_bytes[0],
12336            pname_bytes[1],
12337            pname_bytes[2],
12338            pname_bytes[3],
12339        ];
12340        let length_so_far = length_so_far + request0.len();
12341        assert_eq!(length_so_far % 4, 0);
12342        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
12343        request0[2..4].copy_from_slice(&length.to_ne_bytes());
12344        ([request0.into()], vec![])
12345    }
12346    /// Parse this request given its header, its body, and any fds that go along with it
12347    #[cfg(feature = "request-parsing")]
12348    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
12349        if header.minor_opcode != GET_QUERYIV_ARB_REQUEST {
12350            return Err(ParseError::InvalidValue);
12351        }
12352        let (context_tag, remaining) = ContextTag::try_parse(value)?;
12353        let (target, remaining) = u32::try_parse(remaining)?;
12354        let (pname, remaining) = u32::try_parse(remaining)?;
12355        let _ = remaining;
12356        Ok(GetQueryivARBRequest {
12357            context_tag,
12358            target,
12359            pname,
12360        })
12361    }
12362}
12363impl Request for GetQueryivARBRequest {
12364    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
12365
12366    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
12367        let (bufs, fds) = self.serialize(major_opcode);
12368        // Flatten the buffers into a single vector
12369        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
12370        (buf, fds)
12371    }
12372}
12373impl crate::x11_utils::ReplyRequest for GetQueryivARBRequest {
12374    type Reply = GetQueryivARBReply;
12375}
12376
12377#[derive(Clone, Default)]
12378#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12379#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12380pub struct GetQueryivARBReply {
12381    pub sequence: u16,
12382    pub length: u32,
12383    pub datum: i32,
12384    pub data: Vec<i32>,
12385}
12386impl_debug_if_no_extra_traits!(GetQueryivARBReply, "GetQueryivARBReply");
12387impl TryParse for GetQueryivARBReply {
12388    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
12389        let remaining = initial_value;
12390        let (response_type, remaining) = u8::try_parse(remaining)?;
12391        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
12392        let (sequence, remaining) = u16::try_parse(remaining)?;
12393        let (length, remaining) = u32::try_parse(remaining)?;
12394        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
12395        let (n, remaining) = u32::try_parse(remaining)?;
12396        let (datum, remaining) = i32::try_parse(remaining)?;
12397        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
12398        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
12399        if response_type != 1 {
12400            return Err(ParseError::InvalidValue);
12401        }
12402        let result = GetQueryivARBReply { sequence, length, datum, data };
12403        let _ = remaining;
12404        let remaining = initial_value.get(32 + length as usize * 4..)
12405            .ok_or(ParseError::InsufficientData)?;
12406        Ok((result, remaining))
12407    }
12408}
12409impl Serialize for GetQueryivARBReply {
12410    type Bytes = Vec<u8>;
12411    fn serialize(&self) -> Vec<u8> {
12412        let mut result = Vec::new();
12413        self.serialize_into(&mut result);
12414        result
12415    }
12416    fn serialize_into(&self, bytes: &mut Vec<u8>) {
12417        bytes.reserve(32);
12418        let response_type_bytes = &[1];
12419        bytes.push(response_type_bytes[0]);
12420        bytes.extend_from_slice(&[0; 1]);
12421        self.sequence.serialize_into(bytes);
12422        self.length.serialize_into(bytes);
12423        bytes.extend_from_slice(&[0; 4]);
12424        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
12425        n.serialize_into(bytes);
12426        self.datum.serialize_into(bytes);
12427        bytes.extend_from_slice(&[0; 12]);
12428        self.data.serialize_into(bytes);
12429    }
12430}
12431impl GetQueryivARBReply {
12432    /// Get the value of the `n` field.
12433    ///
12434    /// The `n` field is used as the length field of the `data` field.
12435    /// This function computes the field's value again based on the length of the list.
12436    ///
12437    /// # Panics
12438    ///
12439    /// Panics if the value cannot be represented in the target type. This
12440    /// cannot happen with values of the struct received from the X11 server.
12441    pub fn n(&self) -> u32 {
12442        self.data.len()
12443            .try_into().unwrap()
12444    }
12445}
12446
12447/// Opcode for the GetQueryObjectivARB request
12448pub const GET_QUERY_OBJECTIV_ARB_REQUEST: u8 = 165;
12449#[derive(Clone, Copy, Default)]
12450#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12451#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12452pub struct GetQueryObjectivARBRequest {
12453    pub context_tag: ContextTag,
12454    pub id: u32,
12455    pub pname: u32,
12456}
12457impl_debug_if_no_extra_traits!(GetQueryObjectivARBRequest, "GetQueryObjectivARBRequest");
12458impl GetQueryObjectivARBRequest {
12459    /// Serialize this request into bytes for the provided connection
12460    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
12461        let length_so_far = 0;
12462        let context_tag_bytes = self.context_tag.serialize();
12463        let id_bytes = self.id.serialize();
12464        let pname_bytes = self.pname.serialize();
12465        let mut request0 = vec![
12466            major_opcode,
12467            GET_QUERY_OBJECTIV_ARB_REQUEST,
12468            0,
12469            0,
12470            context_tag_bytes[0],
12471            context_tag_bytes[1],
12472            context_tag_bytes[2],
12473            context_tag_bytes[3],
12474            id_bytes[0],
12475            id_bytes[1],
12476            id_bytes[2],
12477            id_bytes[3],
12478            pname_bytes[0],
12479            pname_bytes[1],
12480            pname_bytes[2],
12481            pname_bytes[3],
12482        ];
12483        let length_so_far = length_so_far + request0.len();
12484        assert_eq!(length_so_far % 4, 0);
12485        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
12486        request0[2..4].copy_from_slice(&length.to_ne_bytes());
12487        ([request0.into()], vec![])
12488    }
12489    /// Parse this request given its header, its body, and any fds that go along with it
12490    #[cfg(feature = "request-parsing")]
12491    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
12492        if header.minor_opcode != GET_QUERY_OBJECTIV_ARB_REQUEST {
12493            return Err(ParseError::InvalidValue);
12494        }
12495        let (context_tag, remaining) = ContextTag::try_parse(value)?;
12496        let (id, remaining) = u32::try_parse(remaining)?;
12497        let (pname, remaining) = u32::try_parse(remaining)?;
12498        let _ = remaining;
12499        Ok(GetQueryObjectivARBRequest {
12500            context_tag,
12501            id,
12502            pname,
12503        })
12504    }
12505}
12506impl Request for GetQueryObjectivARBRequest {
12507    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
12508
12509    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
12510        let (bufs, fds) = self.serialize(major_opcode);
12511        // Flatten the buffers into a single vector
12512        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
12513        (buf, fds)
12514    }
12515}
12516impl crate::x11_utils::ReplyRequest for GetQueryObjectivARBRequest {
12517    type Reply = GetQueryObjectivARBReply;
12518}
12519
12520#[derive(Clone, Default)]
12521#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12522#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12523pub struct GetQueryObjectivARBReply {
12524    pub sequence: u16,
12525    pub length: u32,
12526    pub datum: i32,
12527    pub data: Vec<i32>,
12528}
12529impl_debug_if_no_extra_traits!(GetQueryObjectivARBReply, "GetQueryObjectivARBReply");
12530impl TryParse for GetQueryObjectivARBReply {
12531    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
12532        let remaining = initial_value;
12533        let (response_type, remaining) = u8::try_parse(remaining)?;
12534        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
12535        let (sequence, remaining) = u16::try_parse(remaining)?;
12536        let (length, remaining) = u32::try_parse(remaining)?;
12537        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
12538        let (n, remaining) = u32::try_parse(remaining)?;
12539        let (datum, remaining) = i32::try_parse(remaining)?;
12540        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
12541        let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
12542        if response_type != 1 {
12543            return Err(ParseError::InvalidValue);
12544        }
12545        let result = GetQueryObjectivARBReply { sequence, length, datum, data };
12546        let _ = remaining;
12547        let remaining = initial_value.get(32 + length as usize * 4..)
12548            .ok_or(ParseError::InsufficientData)?;
12549        Ok((result, remaining))
12550    }
12551}
12552impl Serialize for GetQueryObjectivARBReply {
12553    type Bytes = Vec<u8>;
12554    fn serialize(&self) -> Vec<u8> {
12555        let mut result = Vec::new();
12556        self.serialize_into(&mut result);
12557        result
12558    }
12559    fn serialize_into(&self, bytes: &mut Vec<u8>) {
12560        bytes.reserve(32);
12561        let response_type_bytes = &[1];
12562        bytes.push(response_type_bytes[0]);
12563        bytes.extend_from_slice(&[0; 1]);
12564        self.sequence.serialize_into(bytes);
12565        self.length.serialize_into(bytes);
12566        bytes.extend_from_slice(&[0; 4]);
12567        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
12568        n.serialize_into(bytes);
12569        self.datum.serialize_into(bytes);
12570        bytes.extend_from_slice(&[0; 12]);
12571        self.data.serialize_into(bytes);
12572    }
12573}
12574impl GetQueryObjectivARBReply {
12575    /// Get the value of the `n` field.
12576    ///
12577    /// The `n` field is used as the length field of the `data` field.
12578    /// This function computes the field's value again based on the length of the list.
12579    ///
12580    /// # Panics
12581    ///
12582    /// Panics if the value cannot be represented in the target type. This
12583    /// cannot happen with values of the struct received from the X11 server.
12584    pub fn n(&self) -> u32 {
12585        self.data.len()
12586            .try_into().unwrap()
12587    }
12588}
12589
12590/// Opcode for the GetQueryObjectuivARB request
12591pub const GET_QUERY_OBJECTUIV_ARB_REQUEST: u8 = 166;
12592#[derive(Clone, Copy, Default)]
12593#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12594#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12595pub struct GetQueryObjectuivARBRequest {
12596    pub context_tag: ContextTag,
12597    pub id: u32,
12598    pub pname: u32,
12599}
12600impl_debug_if_no_extra_traits!(GetQueryObjectuivARBRequest, "GetQueryObjectuivARBRequest");
12601impl GetQueryObjectuivARBRequest {
12602    /// Serialize this request into bytes for the provided connection
12603    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
12604        let length_so_far = 0;
12605        let context_tag_bytes = self.context_tag.serialize();
12606        let id_bytes = self.id.serialize();
12607        let pname_bytes = self.pname.serialize();
12608        let mut request0 = vec![
12609            major_opcode,
12610            GET_QUERY_OBJECTUIV_ARB_REQUEST,
12611            0,
12612            0,
12613            context_tag_bytes[0],
12614            context_tag_bytes[1],
12615            context_tag_bytes[2],
12616            context_tag_bytes[3],
12617            id_bytes[0],
12618            id_bytes[1],
12619            id_bytes[2],
12620            id_bytes[3],
12621            pname_bytes[0],
12622            pname_bytes[1],
12623            pname_bytes[2],
12624            pname_bytes[3],
12625        ];
12626        let length_so_far = length_so_far + request0.len();
12627        assert_eq!(length_so_far % 4, 0);
12628        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
12629        request0[2..4].copy_from_slice(&length.to_ne_bytes());
12630        ([request0.into()], vec![])
12631    }
12632    /// Parse this request given its header, its body, and any fds that go along with it
12633    #[cfg(feature = "request-parsing")]
12634    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
12635        if header.minor_opcode != GET_QUERY_OBJECTUIV_ARB_REQUEST {
12636            return Err(ParseError::InvalidValue);
12637        }
12638        let (context_tag, remaining) = ContextTag::try_parse(value)?;
12639        let (id, remaining) = u32::try_parse(remaining)?;
12640        let (pname, remaining) = u32::try_parse(remaining)?;
12641        let _ = remaining;
12642        Ok(GetQueryObjectuivARBRequest {
12643            context_tag,
12644            id,
12645            pname,
12646        })
12647    }
12648}
12649impl Request for GetQueryObjectuivARBRequest {
12650    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
12651
12652    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
12653        let (bufs, fds) = self.serialize(major_opcode);
12654        // Flatten the buffers into a single vector
12655        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
12656        (buf, fds)
12657    }
12658}
12659impl crate::x11_utils::ReplyRequest for GetQueryObjectuivARBRequest {
12660    type Reply = GetQueryObjectuivARBReply;
12661}
12662
12663#[derive(Clone, Default)]
12664#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
12665#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12666pub struct GetQueryObjectuivARBReply {
12667    pub sequence: u16,
12668    pub length: u32,
12669    pub datum: u32,
12670    pub data: Vec<u32>,
12671}
12672impl_debug_if_no_extra_traits!(GetQueryObjectuivARBReply, "GetQueryObjectuivARBReply");
12673impl TryParse for GetQueryObjectuivARBReply {
12674    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
12675        let remaining = initial_value;
12676        let (response_type, remaining) = u8::try_parse(remaining)?;
12677        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
12678        let (sequence, remaining) = u16::try_parse(remaining)?;
12679        let (length, remaining) = u32::try_parse(remaining)?;
12680        let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
12681        let (n, remaining) = u32::try_parse(remaining)?;
12682        let (datum, remaining) = u32::try_parse(remaining)?;
12683        let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
12684        let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
12685        if response_type != 1 {
12686            return Err(ParseError::InvalidValue);
12687        }
12688        let result = GetQueryObjectuivARBReply { sequence, length, datum, data };
12689        let _ = remaining;
12690        let remaining = initial_value.get(32 + length as usize * 4..)
12691            .ok_or(ParseError::InsufficientData)?;
12692        Ok((result, remaining))
12693    }
12694}
12695impl Serialize for GetQueryObjectuivARBReply {
12696    type Bytes = Vec<u8>;
12697    fn serialize(&self) -> Vec<u8> {
12698        let mut result = Vec::new();
12699        self.serialize_into(&mut result);
12700        result
12701    }
12702    fn serialize_into(&self, bytes: &mut Vec<u8>) {
12703        bytes.reserve(32);
12704        let response_type_bytes = &[1];
12705        bytes.push(response_type_bytes[0]);
12706        bytes.extend_from_slice(&[0; 1]);
12707        self.sequence.serialize_into(bytes);
12708        self.length.serialize_into(bytes);
12709        bytes.extend_from_slice(&[0; 4]);
12710        let n = u32::try_from(self.data.len()).expect("`data` has too many elements");
12711        n.serialize_into(bytes);
12712        self.datum.serialize_into(bytes);
12713        bytes.extend_from_slice(&[0; 12]);
12714        self.data.serialize_into(bytes);
12715    }
12716}
12717impl GetQueryObjectuivARBReply {
12718    /// Get the value of the `n` field.
12719    ///
12720    /// The `n` field is used as the length field of the `data` field.
12721    /// This function computes the field's value again based on the length of the list.
12722    ///
12723    /// # Panics
12724    ///
12725    /// Panics if the value cannot be represented in the target type. This
12726    /// cannot happen with values of the struct received from the X11 server.
12727    pub fn n(&self) -> u32 {
12728        self.data.len()
12729            .try_into().unwrap()
12730    }
12731}
12732