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
8 #[allow(unused_imports)]
9 use std::borrow::Cow;
10 use std::convert::TryFrom;
11 #[allow(unused_imports)]
12 use std::convert::TryInto;
13 use std::io::IoSlice;
14 #[allow(unused_imports)]
15 use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum};
16 #[allow(unused_imports)]
17 use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize};
18 use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection};
19 #[allow(unused_imports)]
20 use crate::cookie::{Cookie, CookieWithFds, VoidCookie};
21 use crate::errors::{ConnectionError, ParseError};
22 use super::xproto;
23
24 /// The X11 name of the extension for QueryExtension
25 pub const X11_EXTENSION_NAME: &str = "GLX";
26
27 /// The version number of this extension that this client library supports.
28 ///
29 /// This constant contains the version number of this extension that is supported
30 /// by this build of x11rb. For most things, it does not make sense to use this
31 /// information. If you need to send a `QueryVersion`, it is recommended to instead
32 /// send the maximum version of the extension that you need.
33 pub const X11_XML_VERSION: (u32, u32) = (1, 4);
34
35 pub type Pixmap = u32;
36
37 pub type Context = u32;
38
39 pub type Pbuffer = u32;
40
41 pub type Window = u32;
42
43 pub type Fbconfig = u32;
44
45 pub type Drawable = u32;
46
47 pub type Float32 = f32;
48
49 pub type Float64 = f64;
50
51 pub type Bool32 = u32;
52
53 pub type ContextTag = u32;
54
55
56 /// Opcode for the BadContext error
57 pub const BAD_CONTEXT_ERROR: u8 = 0;
58
59 /// Opcode for the BadContextState error
60 pub const BAD_CONTEXT_STATE_ERROR: u8 = 1;
61
62 /// Opcode for the BadDrawable error
63 pub const BAD_DRAWABLE_ERROR: u8 = 2;
64
65 /// Opcode for the BadPixmap error
66 pub const BAD_PIXMAP_ERROR: u8 = 3;
67
68 /// Opcode for the BadContextTag error
69 pub const BAD_CONTEXT_TAG_ERROR: u8 = 4;
70
71 /// Opcode for the BadCurrentWindow error
72 pub const BAD_CURRENT_WINDOW_ERROR: u8 = 5;
73
74 /// Opcode for the BadRenderRequest error
75 pub const BAD_RENDER_REQUEST_ERROR: u8 = 6;
76
77 /// Opcode for the BadLargeRequest error
78 pub const BAD_LARGE_REQUEST_ERROR: u8 = 7;
79
80 /// Opcode for the UnsupportedPrivateRequest error
81 pub const UNSUPPORTED_PRIVATE_REQUEST_ERROR: u8 = 8;
82
83 /// Opcode for the BadFBConfig error
84 pub const BAD_FB_CONFIG_ERROR: u8 = 9;
85
86 /// Opcode for the BadPbuffer error
87 pub const BAD_PBUFFER_ERROR: u8 = 10;
88
89 /// Opcode for the BadCurrentDrawable error
90 pub const BAD_CURRENT_DRAWABLE_ERROR: u8 = 11;
91
92 /// Opcode for the BadWindow error
93 pub const BAD_WINDOW_ERROR: u8 = 12;
94
95 /// Opcode for the GLXBadProfileARB error
96 pub const GLX_BAD_PROFILE_ARB_ERROR: u8 = 13;
97
98 /// Opcode for the PbufferClobber event
99 pub const PBUFFER_CLOBBER_EVENT: u8 = 0;
100 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
101 pub struct PbufferClobberEvent {
102 pub response_type: u8,
103 pub sequence: u16,
104 pub event_type: u16,
105 pub draw_type: u16,
106 pub drawable: Drawable,
107 pub b_mask: u32,
108 pub aux_buffer: u16,
109 pub x: u16,
110 pub y: u16,
111 pub width: u16,
112 pub height: u16,
113 pub count: u16,
114 }
115 impl TryParse for PbufferClobberEvent {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>116 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
117 let remaining = initial_value;
118 let (response_type, remaining) = u8::try_parse(remaining)?;
119 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
120 let (sequence, remaining) = u16::try_parse(remaining)?;
121 let (event_type, remaining) = u16::try_parse(remaining)?;
122 let (draw_type, remaining) = u16::try_parse(remaining)?;
123 let (drawable, remaining) = Drawable::try_parse(remaining)?;
124 let (b_mask, remaining) = u32::try_parse(remaining)?;
125 let (aux_buffer, remaining) = u16::try_parse(remaining)?;
126 let (x, remaining) = u16::try_parse(remaining)?;
127 let (y, remaining) = u16::try_parse(remaining)?;
128 let (width, remaining) = u16::try_parse(remaining)?;
129 let (height, remaining) = u16::try_parse(remaining)?;
130 let (count, remaining) = u16::try_parse(remaining)?;
131 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
132 let result = PbufferClobberEvent { response_type, sequence, event_type, draw_type, drawable, b_mask, aux_buffer, x, y, width, height, count };
133 let _ = remaining;
134 let remaining = initial_value.get(32..)
135 .ok_or(ParseError::InsufficientData)?;
136 Ok((result, remaining))
137 }
138 }
139 impl From<&PbufferClobberEvent> for [u8; 32] {
from(input: &PbufferClobberEvent) -> Self140 fn from(input: &PbufferClobberEvent) -> Self {
141 let response_type_bytes = input.response_type.serialize();
142 let sequence_bytes = input.sequence.serialize();
143 let event_type_bytes = input.event_type.serialize();
144 let draw_type_bytes = input.draw_type.serialize();
145 let drawable_bytes = input.drawable.serialize();
146 let b_mask_bytes = input.b_mask.serialize();
147 let aux_buffer_bytes = input.aux_buffer.serialize();
148 let x_bytes = input.x.serialize();
149 let y_bytes = input.y.serialize();
150 let width_bytes = input.width.serialize();
151 let height_bytes = input.height.serialize();
152 let count_bytes = input.count.serialize();
153 [
154 response_type_bytes[0],
155 0,
156 sequence_bytes[0],
157 sequence_bytes[1],
158 event_type_bytes[0],
159 event_type_bytes[1],
160 draw_type_bytes[0],
161 draw_type_bytes[1],
162 drawable_bytes[0],
163 drawable_bytes[1],
164 drawable_bytes[2],
165 drawable_bytes[3],
166 b_mask_bytes[0],
167 b_mask_bytes[1],
168 b_mask_bytes[2],
169 b_mask_bytes[3],
170 aux_buffer_bytes[0],
171 aux_buffer_bytes[1],
172 x_bytes[0],
173 x_bytes[1],
174 y_bytes[0],
175 y_bytes[1],
176 width_bytes[0],
177 width_bytes[1],
178 height_bytes[0],
179 height_bytes[1],
180 count_bytes[0],
181 count_bytes[1],
182 0,
183 0,
184 0,
185 0,
186 ]
187 }
188 }
189 impl From<PbufferClobberEvent> for [u8; 32] {
from(input: PbufferClobberEvent) -> Self190 fn from(input: PbufferClobberEvent) -> Self {
191 Self::from(&input)
192 }
193 }
194
195 /// Opcode for the BufferSwapComplete event
196 pub const BUFFER_SWAP_COMPLETE_EVENT: u8 = 1;
197 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
198 pub struct BufferSwapCompleteEvent {
199 pub response_type: u8,
200 pub sequence: u16,
201 pub event_type: u16,
202 pub drawable: Drawable,
203 pub ust_hi: u32,
204 pub ust_lo: u32,
205 pub msc_hi: u32,
206 pub msc_lo: u32,
207 pub sbc: u32,
208 }
209 impl TryParse for BufferSwapCompleteEvent {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>210 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
211 let remaining = initial_value;
212 let (response_type, remaining) = u8::try_parse(remaining)?;
213 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
214 let (sequence, remaining) = u16::try_parse(remaining)?;
215 let (event_type, remaining) = u16::try_parse(remaining)?;
216 let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
217 let (drawable, remaining) = Drawable::try_parse(remaining)?;
218 let (ust_hi, remaining) = u32::try_parse(remaining)?;
219 let (ust_lo, remaining) = u32::try_parse(remaining)?;
220 let (msc_hi, remaining) = u32::try_parse(remaining)?;
221 let (msc_lo, remaining) = u32::try_parse(remaining)?;
222 let (sbc, remaining) = u32::try_parse(remaining)?;
223 let result = BufferSwapCompleteEvent { response_type, sequence, event_type, drawable, ust_hi, ust_lo, msc_hi, msc_lo, sbc };
224 let _ = remaining;
225 let remaining = initial_value.get(32..)
226 .ok_or(ParseError::InsufficientData)?;
227 Ok((result, remaining))
228 }
229 }
230 impl From<&BufferSwapCompleteEvent> for [u8; 32] {
from(input: &BufferSwapCompleteEvent) -> Self231 fn from(input: &BufferSwapCompleteEvent) -> Self {
232 let response_type_bytes = input.response_type.serialize();
233 let sequence_bytes = input.sequence.serialize();
234 let event_type_bytes = input.event_type.serialize();
235 let drawable_bytes = input.drawable.serialize();
236 let ust_hi_bytes = input.ust_hi.serialize();
237 let ust_lo_bytes = input.ust_lo.serialize();
238 let msc_hi_bytes = input.msc_hi.serialize();
239 let msc_lo_bytes = input.msc_lo.serialize();
240 let sbc_bytes = input.sbc.serialize();
241 [
242 response_type_bytes[0],
243 0,
244 sequence_bytes[0],
245 sequence_bytes[1],
246 event_type_bytes[0],
247 event_type_bytes[1],
248 0,
249 0,
250 drawable_bytes[0],
251 drawable_bytes[1],
252 drawable_bytes[2],
253 drawable_bytes[3],
254 ust_hi_bytes[0],
255 ust_hi_bytes[1],
256 ust_hi_bytes[2],
257 ust_hi_bytes[3],
258 ust_lo_bytes[0],
259 ust_lo_bytes[1],
260 ust_lo_bytes[2],
261 ust_lo_bytes[3],
262 msc_hi_bytes[0],
263 msc_hi_bytes[1],
264 msc_hi_bytes[2],
265 msc_hi_bytes[3],
266 msc_lo_bytes[0],
267 msc_lo_bytes[1],
268 msc_lo_bytes[2],
269 msc_lo_bytes[3],
270 sbc_bytes[0],
271 sbc_bytes[1],
272 sbc_bytes[2],
273 sbc_bytes[3],
274 ]
275 }
276 }
277 impl From<BufferSwapCompleteEvent> for [u8; 32] {
from(input: BufferSwapCompleteEvent) -> Self278 fn from(input: BufferSwapCompleteEvent) -> Self {
279 Self::from(&input)
280 }
281 }
282
283 #[derive(Clone, Copy, PartialEq, Eq)]
284 pub struct PBCET(u16);
285 impl PBCET {
286 pub const DAMAGED: Self = Self(32791);
287 pub const SAVED: Self = Self(32792);
288 }
289 impl From<PBCET> for u16 {
290 #[inline]
from(input: PBCET) -> Self291 fn from(input: PBCET) -> Self {
292 input.0
293 }
294 }
295 impl From<PBCET> for Option<u16> {
296 #[inline]
from(input: PBCET) -> Self297 fn from(input: PBCET) -> Self {
298 Some(input.0)
299 }
300 }
301 impl From<PBCET> for u32 {
302 #[inline]
from(input: PBCET) -> Self303 fn from(input: PBCET) -> Self {
304 u32::from(input.0)
305 }
306 }
307 impl From<PBCET> for Option<u32> {
308 #[inline]
from(input: PBCET) -> Self309 fn from(input: PBCET) -> Self {
310 Some(u32::from(input.0))
311 }
312 }
313 impl From<u8> for PBCET {
314 #[inline]
from(value: u8) -> Self315 fn from(value: u8) -> Self {
316 Self(value.into())
317 }
318 }
319 impl From<u16> for PBCET {
320 #[inline]
from(value: u16) -> Self321 fn from(value: u16) -> Self {
322 Self(value)
323 }
324 }
325 impl std::fmt::Debug for PBCET {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result326 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
327 let variants = [
328 (Self::DAMAGED.0.into(), "DAMAGED", "Damaged"),
329 (Self::SAVED.0.into(), "SAVED", "Saved"),
330 ];
331 pretty_print_enum(fmt, self.0.into(), &variants)
332 }
333 }
334
335 #[derive(Clone, Copy, PartialEq, Eq)]
336 pub struct PBCDT(u16);
337 impl PBCDT {
338 pub const WINDOW: Self = Self(32793);
339 pub const PBUFFER: Self = Self(32794);
340 }
341 impl From<PBCDT> for u16 {
342 #[inline]
from(input: PBCDT) -> Self343 fn from(input: PBCDT) -> Self {
344 input.0
345 }
346 }
347 impl From<PBCDT> for Option<u16> {
348 #[inline]
from(input: PBCDT) -> Self349 fn from(input: PBCDT) -> Self {
350 Some(input.0)
351 }
352 }
353 impl From<PBCDT> for u32 {
354 #[inline]
from(input: PBCDT) -> Self355 fn from(input: PBCDT) -> Self {
356 u32::from(input.0)
357 }
358 }
359 impl From<PBCDT> for Option<u32> {
360 #[inline]
from(input: PBCDT) -> Self361 fn from(input: PBCDT) -> Self {
362 Some(u32::from(input.0))
363 }
364 }
365 impl From<u8> for PBCDT {
366 #[inline]
from(value: u8) -> Self367 fn from(value: u8) -> Self {
368 Self(value.into())
369 }
370 }
371 impl From<u16> for PBCDT {
372 #[inline]
from(value: u16) -> Self373 fn from(value: u16) -> Self {
374 Self(value)
375 }
376 }
377 impl std::fmt::Debug for PBCDT {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result378 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
379 let variants = [
380 (Self::WINDOW.0.into(), "WINDOW", "Window"),
381 (Self::PBUFFER.0.into(), "PBUFFER", "Pbuffer"),
382 ];
383 pretty_print_enum(fmt, self.0.into(), &variants)
384 }
385 }
386
387 /// Opcode for the Render request
388 pub const RENDER_REQUEST: u8 = 1;
389 #[derive(Debug, Clone, PartialEq, Eq)]
390 pub struct RenderRequest<'input> {
391 pub context_tag: ContextTag,
392 pub data: Cow<'input, [u8]>,
393 }
394 impl<'input> RenderRequest<'input> {
395 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,396 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
397 where
398 Conn: RequestConnection + ?Sized,
399 {
400 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
401 .ok_or(ConnectionError::UnsupportedExtension)?;
402 let length_so_far = 0;
403 let context_tag_bytes = self.context_tag.serialize();
404 let mut request0 = vec![
405 extension_information.major_opcode,
406 RENDER_REQUEST,
407 0,
408 0,
409 context_tag_bytes[0],
410 context_tag_bytes[1],
411 context_tag_bytes[2],
412 context_tag_bytes[3],
413 ];
414 let length_so_far = length_so_far + request0.len();
415 let length_so_far = length_so_far + self.data.len();
416 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
417 let length_so_far = length_so_far + padding0.len();
418 assert_eq!(length_so_far % 4, 0);
419 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
420 request0[2..4].copy_from_slice(&length.to_ne_bytes());
421 Ok((vec![request0.into(), self.data, padding0.into()], vec![]))
422 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,423 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
424 where
425 Conn: RequestConnection + ?Sized,
426 {
427 let (bytes, fds) = self.serialize(conn)?;
428 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
429 conn.send_request_without_reply(&slices, fds)
430 }
431 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>432 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
433 if header.minor_opcode != RENDER_REQUEST {
434 return Err(ParseError::InvalidValue);
435 }
436 let (context_tag, remaining) = ContextTag::try_parse(value)?;
437 let (data, remaining) = remaining.split_at(remaining.len());
438 let _ = remaining;
439 Ok(RenderRequest {
440 context_tag,
441 data: Cow::Borrowed(data),
442 })
443 }
444 /// Clone all borrowed data in this RenderRequest.
into_owned(self) -> RenderRequest<'static>445 pub fn into_owned(self) -> RenderRequest<'static> {
446 RenderRequest {
447 context_tag: self.context_tag,
448 data: Cow::Owned(self.data.into_owned()),
449 }
450 }
451 }
452 impl<'input> Request for RenderRequest<'input> {
453 type Reply = ();
454 }
render<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,455 pub fn render<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
456 where
457 Conn: RequestConnection + ?Sized,
458 {
459 let request0 = RenderRequest {
460 context_tag,
461 data: Cow::Borrowed(data),
462 };
463 request0.send(conn)
464 }
465
466 /// Opcode for the RenderLarge request
467 pub const RENDER_LARGE_REQUEST: u8 = 2;
468 #[derive(Debug, Clone, PartialEq, Eq)]
469 pub struct RenderLargeRequest<'input> {
470 pub context_tag: ContextTag,
471 pub request_num: u16,
472 pub request_total: u16,
473 pub data: Cow<'input, [u8]>,
474 }
475 impl<'input> RenderLargeRequest<'input> {
476 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,477 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
478 where
479 Conn: RequestConnection + ?Sized,
480 {
481 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
482 .ok_or(ConnectionError::UnsupportedExtension)?;
483 let length_so_far = 0;
484 let context_tag_bytes = self.context_tag.serialize();
485 let request_num_bytes = self.request_num.serialize();
486 let request_total_bytes = self.request_total.serialize();
487 let data_len = u32::try_from(self.data.len()).expect("`data` has too many elements");
488 let data_len_bytes = data_len.serialize();
489 let mut request0 = vec![
490 extension_information.major_opcode,
491 RENDER_LARGE_REQUEST,
492 0,
493 0,
494 context_tag_bytes[0],
495 context_tag_bytes[1],
496 context_tag_bytes[2],
497 context_tag_bytes[3],
498 request_num_bytes[0],
499 request_num_bytes[1],
500 request_total_bytes[0],
501 request_total_bytes[1],
502 data_len_bytes[0],
503 data_len_bytes[1],
504 data_len_bytes[2],
505 data_len_bytes[3],
506 ];
507 let length_so_far = length_so_far + request0.len();
508 let length_so_far = length_so_far + self.data.len();
509 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
510 let length_so_far = length_so_far + padding0.len();
511 assert_eq!(length_so_far % 4, 0);
512 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
513 request0[2..4].copy_from_slice(&length.to_ne_bytes());
514 Ok((vec![request0.into(), self.data, padding0.into()], vec![]))
515 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,516 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
517 where
518 Conn: RequestConnection + ?Sized,
519 {
520 let (bytes, fds) = self.serialize(conn)?;
521 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
522 conn.send_request_without_reply(&slices, fds)
523 }
524 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>525 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
526 if header.minor_opcode != RENDER_LARGE_REQUEST {
527 return Err(ParseError::InvalidValue);
528 }
529 let (context_tag, remaining) = ContextTag::try_parse(value)?;
530 let (request_num, remaining) = u16::try_parse(remaining)?;
531 let (request_total, remaining) = u16::try_parse(remaining)?;
532 let (data_len, remaining) = u32::try_parse(remaining)?;
533 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, data_len.try_to_usize()?)?;
534 let _ = remaining;
535 Ok(RenderLargeRequest {
536 context_tag,
537 request_num,
538 request_total,
539 data: Cow::Borrowed(data),
540 })
541 }
542 /// Clone all borrowed data in this RenderLargeRequest.
into_owned(self) -> RenderLargeRequest<'static>543 pub fn into_owned(self) -> RenderLargeRequest<'static> {
544 RenderLargeRequest {
545 context_tag: self.context_tag,
546 request_num: self.request_num,
547 request_total: self.request_total,
548 data: Cow::Owned(self.data.into_owned()),
549 }
550 }
551 }
552 impl<'input> Request for RenderLargeRequest<'input> {
553 type Reply = ();
554 }
render_large<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, request_num: u16, request_total: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,555 pub fn render_large<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, request_num: u16, request_total: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
556 where
557 Conn: RequestConnection + ?Sized,
558 {
559 let request0 = RenderLargeRequest {
560 context_tag,
561 request_num,
562 request_total,
563 data: Cow::Borrowed(data),
564 };
565 request0.send(conn)
566 }
567
568 /// Opcode for the CreateContext request
569 pub const CREATE_CONTEXT_REQUEST: u8 = 3;
570 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
571 pub struct CreateContextRequest {
572 pub context: Context,
573 pub visual: xproto::Visualid,
574 pub screen: u32,
575 pub share_list: Context,
576 pub is_direct: bool,
577 }
578 impl CreateContextRequest {
579 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,580 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
581 where
582 Conn: RequestConnection + ?Sized,
583 {
584 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
585 .ok_or(ConnectionError::UnsupportedExtension)?;
586 let length_so_far = 0;
587 let context_bytes = self.context.serialize();
588 let visual_bytes = self.visual.serialize();
589 let screen_bytes = self.screen.serialize();
590 let share_list_bytes = self.share_list.serialize();
591 let is_direct_bytes = self.is_direct.serialize();
592 let mut request0 = vec![
593 extension_information.major_opcode,
594 CREATE_CONTEXT_REQUEST,
595 0,
596 0,
597 context_bytes[0],
598 context_bytes[1],
599 context_bytes[2],
600 context_bytes[3],
601 visual_bytes[0],
602 visual_bytes[1],
603 visual_bytes[2],
604 visual_bytes[3],
605 screen_bytes[0],
606 screen_bytes[1],
607 screen_bytes[2],
608 screen_bytes[3],
609 share_list_bytes[0],
610 share_list_bytes[1],
611 share_list_bytes[2],
612 share_list_bytes[3],
613 is_direct_bytes[0],
614 0,
615 0,
616 0,
617 ];
618 let length_so_far = length_so_far + request0.len();
619 assert_eq!(length_so_far % 4, 0);
620 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
621 request0[2..4].copy_from_slice(&length.to_ne_bytes());
622 Ok((vec![request0.into()], vec![]))
623 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,624 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
625 where
626 Conn: RequestConnection + ?Sized,
627 {
628 let (bytes, fds) = self.serialize(conn)?;
629 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
630 conn.send_request_without_reply(&slices, fds)
631 }
632 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>633 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
634 if header.minor_opcode != CREATE_CONTEXT_REQUEST {
635 return Err(ParseError::InvalidValue);
636 }
637 let (context, remaining) = Context::try_parse(value)?;
638 let (visual, remaining) = xproto::Visualid::try_parse(remaining)?;
639 let (screen, remaining) = u32::try_parse(remaining)?;
640 let (share_list, remaining) = Context::try_parse(remaining)?;
641 let (is_direct, remaining) = bool::try_parse(remaining)?;
642 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
643 let _ = remaining;
644 Ok(CreateContextRequest {
645 context,
646 visual,
647 screen,
648 share_list,
649 is_direct,
650 })
651 }
652 }
653 impl Request for CreateContextRequest {
654 type Reply = ();
655 }
create_context<Conn>(conn: &Conn, context: Context, visual: xproto::Visualid, screen: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,656 pub fn create_context<Conn>(conn: &Conn, context: Context, visual: xproto::Visualid, screen: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
657 where
658 Conn: RequestConnection + ?Sized,
659 {
660 let request0 = CreateContextRequest {
661 context,
662 visual,
663 screen,
664 share_list,
665 is_direct,
666 };
667 request0.send(conn)
668 }
669
670 /// Opcode for the DestroyContext request
671 pub const DESTROY_CONTEXT_REQUEST: u8 = 4;
672 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
673 pub struct DestroyContextRequest {
674 pub context: Context,
675 }
676 impl DestroyContextRequest {
677 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,678 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
679 where
680 Conn: RequestConnection + ?Sized,
681 {
682 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
683 .ok_or(ConnectionError::UnsupportedExtension)?;
684 let length_so_far = 0;
685 let context_bytes = self.context.serialize();
686 let mut request0 = vec![
687 extension_information.major_opcode,
688 DESTROY_CONTEXT_REQUEST,
689 0,
690 0,
691 context_bytes[0],
692 context_bytes[1],
693 context_bytes[2],
694 context_bytes[3],
695 ];
696 let length_so_far = length_so_far + request0.len();
697 assert_eq!(length_so_far % 4, 0);
698 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
699 request0[2..4].copy_from_slice(&length.to_ne_bytes());
700 Ok((vec![request0.into()], vec![]))
701 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,702 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
703 where
704 Conn: RequestConnection + ?Sized,
705 {
706 let (bytes, fds) = self.serialize(conn)?;
707 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
708 conn.send_request_without_reply(&slices, fds)
709 }
710 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>711 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
712 if header.minor_opcode != DESTROY_CONTEXT_REQUEST {
713 return Err(ParseError::InvalidValue);
714 }
715 let (context, remaining) = Context::try_parse(value)?;
716 let _ = remaining;
717 Ok(DestroyContextRequest {
718 context,
719 })
720 }
721 }
722 impl Request for DestroyContextRequest {
723 type Reply = ();
724 }
destroy_context<Conn>(conn: &Conn, context: Context) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,725 pub fn destroy_context<Conn>(conn: &Conn, context: Context) -> Result<VoidCookie<'_, Conn>, ConnectionError>
726 where
727 Conn: RequestConnection + ?Sized,
728 {
729 let request0 = DestroyContextRequest {
730 context,
731 };
732 request0.send(conn)
733 }
734
735 /// Opcode for the MakeCurrent request
736 pub const MAKE_CURRENT_REQUEST: u8 = 5;
737 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
738 pub struct MakeCurrentRequest {
739 pub drawable: Drawable,
740 pub context: Context,
741 pub old_context_tag: ContextTag,
742 }
743 impl MakeCurrentRequest {
744 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,745 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
746 where
747 Conn: RequestConnection + ?Sized,
748 {
749 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
750 .ok_or(ConnectionError::UnsupportedExtension)?;
751 let length_so_far = 0;
752 let drawable_bytes = self.drawable.serialize();
753 let context_bytes = self.context.serialize();
754 let old_context_tag_bytes = self.old_context_tag.serialize();
755 let mut request0 = vec![
756 extension_information.major_opcode,
757 MAKE_CURRENT_REQUEST,
758 0,
759 0,
760 drawable_bytes[0],
761 drawable_bytes[1],
762 drawable_bytes[2],
763 drawable_bytes[3],
764 context_bytes[0],
765 context_bytes[1],
766 context_bytes[2],
767 context_bytes[3],
768 old_context_tag_bytes[0],
769 old_context_tag_bytes[1],
770 old_context_tag_bytes[2],
771 old_context_tag_bytes[3],
772 ];
773 let length_so_far = length_so_far + request0.len();
774 assert_eq!(length_so_far % 4, 0);
775 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
776 request0[2..4].copy_from_slice(&length.to_ne_bytes());
777 Ok((vec![request0.into()], vec![]))
778 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, MakeCurrentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,779 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, MakeCurrentReply>, ConnectionError>
780 where
781 Conn: RequestConnection + ?Sized,
782 {
783 let (bytes, fds) = self.serialize(conn)?;
784 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
785 conn.send_request_with_reply(&slices, fds)
786 }
787 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>788 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
789 if header.minor_opcode != MAKE_CURRENT_REQUEST {
790 return Err(ParseError::InvalidValue);
791 }
792 let (drawable, remaining) = Drawable::try_parse(value)?;
793 let (context, remaining) = Context::try_parse(remaining)?;
794 let (old_context_tag, remaining) = ContextTag::try_parse(remaining)?;
795 let _ = remaining;
796 Ok(MakeCurrentRequest {
797 drawable,
798 context,
799 old_context_tag,
800 })
801 }
802 }
803 impl Request for MakeCurrentRequest {
804 type Reply = MakeCurrentReply;
805 }
make_current<Conn>(conn: &Conn, drawable: Drawable, context: Context, old_context_tag: ContextTag) -> Result<Cookie<'_, Conn, MakeCurrentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,806 pub fn make_current<Conn>(conn: &Conn, drawable: Drawable, context: Context, old_context_tag: ContextTag) -> Result<Cookie<'_, Conn, MakeCurrentReply>, ConnectionError>
807 where
808 Conn: RequestConnection + ?Sized,
809 {
810 let request0 = MakeCurrentRequest {
811 drawable,
812 context,
813 old_context_tag,
814 };
815 request0.send(conn)
816 }
817
818 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
819 pub struct MakeCurrentReply {
820 pub sequence: u16,
821 pub length: u32,
822 pub context_tag: ContextTag,
823 }
824 impl TryParse for MakeCurrentReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>825 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
826 let remaining = initial_value;
827 let (response_type, remaining) = u8::try_parse(remaining)?;
828 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
829 let (sequence, remaining) = u16::try_parse(remaining)?;
830 let (length, remaining) = u32::try_parse(remaining)?;
831 let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
832 let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
833 if response_type != 1 {
834 return Err(ParseError::InvalidValue);
835 }
836 let result = MakeCurrentReply { sequence, length, context_tag };
837 let _ = remaining;
838 let remaining = initial_value.get(32 + length as usize * 4..)
839 .ok_or(ParseError::InsufficientData)?;
840 Ok((result, remaining))
841 }
842 }
843
844 /// Opcode for the IsDirect request
845 pub const IS_DIRECT_REQUEST: u8 = 6;
846 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
847 pub struct IsDirectRequest {
848 pub context: Context,
849 }
850 impl IsDirectRequest {
851 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,852 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
853 where
854 Conn: RequestConnection + ?Sized,
855 {
856 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
857 .ok_or(ConnectionError::UnsupportedExtension)?;
858 let length_so_far = 0;
859 let context_bytes = self.context.serialize();
860 let mut request0 = vec![
861 extension_information.major_opcode,
862 IS_DIRECT_REQUEST,
863 0,
864 0,
865 context_bytes[0],
866 context_bytes[1],
867 context_bytes[2],
868 context_bytes[3],
869 ];
870 let length_so_far = length_so_far + request0.len();
871 assert_eq!(length_so_far % 4, 0);
872 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
873 request0[2..4].copy_from_slice(&length.to_ne_bytes());
874 Ok((vec![request0.into()], vec![]))
875 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsDirectReply>, ConnectionError> where Conn: RequestConnection + ?Sized,876 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsDirectReply>, ConnectionError>
877 where
878 Conn: RequestConnection + ?Sized,
879 {
880 let (bytes, fds) = self.serialize(conn)?;
881 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
882 conn.send_request_with_reply(&slices, fds)
883 }
884 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>885 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
886 if header.minor_opcode != IS_DIRECT_REQUEST {
887 return Err(ParseError::InvalidValue);
888 }
889 let (context, remaining) = Context::try_parse(value)?;
890 let _ = remaining;
891 Ok(IsDirectRequest {
892 context,
893 })
894 }
895 }
896 impl Request for IsDirectRequest {
897 type Reply = IsDirectReply;
898 }
is_direct<Conn>(conn: &Conn, context: Context) -> Result<Cookie<'_, Conn, IsDirectReply>, ConnectionError> where Conn: RequestConnection + ?Sized,899 pub fn is_direct<Conn>(conn: &Conn, context: Context) -> Result<Cookie<'_, Conn, IsDirectReply>, ConnectionError>
900 where
901 Conn: RequestConnection + ?Sized,
902 {
903 let request0 = IsDirectRequest {
904 context,
905 };
906 request0.send(conn)
907 }
908
909 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
910 pub struct IsDirectReply {
911 pub sequence: u16,
912 pub length: u32,
913 pub is_direct: bool,
914 }
915 impl TryParse for IsDirectReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>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 (is_direct, remaining) = bool::try_parse(remaining)?;
923 let remaining = remaining.get(23..).ok_or(ParseError::InsufficientData)?;
924 if response_type != 1 {
925 return Err(ParseError::InvalidValue);
926 }
927 let result = IsDirectReply { sequence, length, is_direct };
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 }
934
935 /// Opcode for the QueryVersion request
936 pub const QUERY_VERSION_REQUEST: u8 = 7;
937 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
938 pub struct QueryVersionRequest {
939 pub major_version: u32,
940 pub minor_version: u32,
941 }
942 impl QueryVersionRequest {
943 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,944 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
945 where
946 Conn: RequestConnection + ?Sized,
947 {
948 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
949 .ok_or(ConnectionError::UnsupportedExtension)?;
950 let length_so_far = 0;
951 let major_version_bytes = self.major_version.serialize();
952 let minor_version_bytes = self.minor_version.serialize();
953 let mut request0 = vec![
954 extension_information.major_opcode,
955 QUERY_VERSION_REQUEST,
956 0,
957 0,
958 major_version_bytes[0],
959 major_version_bytes[1],
960 major_version_bytes[2],
961 major_version_bytes[3],
962 minor_version_bytes[0],
963 minor_version_bytes[1],
964 minor_version_bytes[2],
965 minor_version_bytes[3],
966 ];
967 let length_so_far = length_so_far + request0.len();
968 assert_eq!(length_so_far % 4, 0);
969 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
970 request0[2..4].copy_from_slice(&length.to_ne_bytes());
971 Ok((vec![request0.into()], vec![]))
972 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,973 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
974 where
975 Conn: RequestConnection + ?Sized,
976 {
977 let (bytes, fds) = self.serialize(conn)?;
978 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
979 conn.send_request_with_reply(&slices, fds)
980 }
981 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>982 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
983 if header.minor_opcode != QUERY_VERSION_REQUEST {
984 return Err(ParseError::InvalidValue);
985 }
986 let (major_version, remaining) = u32::try_parse(value)?;
987 let (minor_version, remaining) = u32::try_parse(remaining)?;
988 let _ = remaining;
989 Ok(QueryVersionRequest {
990 major_version,
991 minor_version,
992 })
993 }
994 }
995 impl Request for QueryVersionRequest {
996 type Reply = QueryVersionReply;
997 }
query_version<Conn>(conn: &Conn, major_version: u32, minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,998 pub fn query_version<Conn>(conn: &Conn, major_version: u32, minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
999 where
1000 Conn: RequestConnection + ?Sized,
1001 {
1002 let request0 = QueryVersionRequest {
1003 major_version,
1004 minor_version,
1005 };
1006 request0.send(conn)
1007 }
1008
1009 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1010 pub struct QueryVersionReply {
1011 pub sequence: u16,
1012 pub length: u32,
1013 pub major_version: u32,
1014 pub minor_version: u32,
1015 }
1016 impl TryParse for QueryVersionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1017 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1018 let remaining = initial_value;
1019 let (response_type, remaining) = u8::try_parse(remaining)?;
1020 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1021 let (sequence, remaining) = u16::try_parse(remaining)?;
1022 let (length, remaining) = u32::try_parse(remaining)?;
1023 let (major_version, remaining) = u32::try_parse(remaining)?;
1024 let (minor_version, remaining) = u32::try_parse(remaining)?;
1025 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
1026 if response_type != 1 {
1027 return Err(ParseError::InvalidValue);
1028 }
1029 let result = QueryVersionReply { sequence, length, major_version, minor_version };
1030 let _ = remaining;
1031 let remaining = initial_value.get(32 + length as usize * 4..)
1032 .ok_or(ParseError::InsufficientData)?;
1033 Ok((result, remaining))
1034 }
1035 }
1036
1037 /// Opcode for the WaitGL request
1038 pub const WAIT_GL_REQUEST: u8 = 8;
1039 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1040 pub struct WaitGLRequest {
1041 pub context_tag: ContextTag,
1042 }
1043 impl WaitGLRequest {
1044 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1045 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1046 where
1047 Conn: RequestConnection + ?Sized,
1048 {
1049 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1050 .ok_or(ConnectionError::UnsupportedExtension)?;
1051 let length_so_far = 0;
1052 let context_tag_bytes = self.context_tag.serialize();
1053 let mut request0 = vec![
1054 extension_information.major_opcode,
1055 WAIT_GL_REQUEST,
1056 0,
1057 0,
1058 context_tag_bytes[0],
1059 context_tag_bytes[1],
1060 context_tag_bytes[2],
1061 context_tag_bytes[3],
1062 ];
1063 let length_so_far = length_so_far + request0.len();
1064 assert_eq!(length_so_far % 4, 0);
1065 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1066 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1067 Ok((vec![request0.into()], vec![]))
1068 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1069 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1070 where
1071 Conn: RequestConnection + ?Sized,
1072 {
1073 let (bytes, fds) = self.serialize(conn)?;
1074 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1075 conn.send_request_without_reply(&slices, fds)
1076 }
1077 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1078 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1079 if header.minor_opcode != WAIT_GL_REQUEST {
1080 return Err(ParseError::InvalidValue);
1081 }
1082 let (context_tag, remaining) = ContextTag::try_parse(value)?;
1083 let _ = remaining;
1084 Ok(WaitGLRequest {
1085 context_tag,
1086 })
1087 }
1088 }
1089 impl Request for WaitGLRequest {
1090 type Reply = ();
1091 }
wait_gl<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1092 pub fn wait_gl<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1093 where
1094 Conn: RequestConnection + ?Sized,
1095 {
1096 let request0 = WaitGLRequest {
1097 context_tag,
1098 };
1099 request0.send(conn)
1100 }
1101
1102 /// Opcode for the WaitX request
1103 pub const WAIT_X_REQUEST: u8 = 9;
1104 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1105 pub struct WaitXRequest {
1106 pub context_tag: ContextTag,
1107 }
1108 impl WaitXRequest {
1109 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1110 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1111 where
1112 Conn: RequestConnection + ?Sized,
1113 {
1114 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1115 .ok_or(ConnectionError::UnsupportedExtension)?;
1116 let length_so_far = 0;
1117 let context_tag_bytes = self.context_tag.serialize();
1118 let mut request0 = vec![
1119 extension_information.major_opcode,
1120 WAIT_X_REQUEST,
1121 0,
1122 0,
1123 context_tag_bytes[0],
1124 context_tag_bytes[1],
1125 context_tag_bytes[2],
1126 context_tag_bytes[3],
1127 ];
1128 let length_so_far = length_so_far + request0.len();
1129 assert_eq!(length_so_far % 4, 0);
1130 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1131 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1132 Ok((vec![request0.into()], vec![]))
1133 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1134 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1135 where
1136 Conn: RequestConnection + ?Sized,
1137 {
1138 let (bytes, fds) = self.serialize(conn)?;
1139 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1140 conn.send_request_without_reply(&slices, fds)
1141 }
1142 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1143 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1144 if header.minor_opcode != WAIT_X_REQUEST {
1145 return Err(ParseError::InvalidValue);
1146 }
1147 let (context_tag, remaining) = ContextTag::try_parse(value)?;
1148 let _ = remaining;
1149 Ok(WaitXRequest {
1150 context_tag,
1151 })
1152 }
1153 }
1154 impl Request for WaitXRequest {
1155 type Reply = ();
1156 }
wait_x<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1157 pub fn wait_x<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1158 where
1159 Conn: RequestConnection + ?Sized,
1160 {
1161 let request0 = WaitXRequest {
1162 context_tag,
1163 };
1164 request0.send(conn)
1165 }
1166
1167 /// Opcode for the CopyContext request
1168 pub const COPY_CONTEXT_REQUEST: u8 = 10;
1169 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1170 pub struct CopyContextRequest {
1171 pub src: Context,
1172 pub dest: Context,
1173 pub mask: u32,
1174 pub src_context_tag: ContextTag,
1175 }
1176 impl CopyContextRequest {
1177 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1178 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1179 where
1180 Conn: RequestConnection + ?Sized,
1181 {
1182 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1183 .ok_or(ConnectionError::UnsupportedExtension)?;
1184 let length_so_far = 0;
1185 let src_bytes = self.src.serialize();
1186 let dest_bytes = self.dest.serialize();
1187 let mask_bytes = self.mask.serialize();
1188 let src_context_tag_bytes = self.src_context_tag.serialize();
1189 let mut request0 = vec![
1190 extension_information.major_opcode,
1191 COPY_CONTEXT_REQUEST,
1192 0,
1193 0,
1194 src_bytes[0],
1195 src_bytes[1],
1196 src_bytes[2],
1197 src_bytes[3],
1198 dest_bytes[0],
1199 dest_bytes[1],
1200 dest_bytes[2],
1201 dest_bytes[3],
1202 mask_bytes[0],
1203 mask_bytes[1],
1204 mask_bytes[2],
1205 mask_bytes[3],
1206 src_context_tag_bytes[0],
1207 src_context_tag_bytes[1],
1208 src_context_tag_bytes[2],
1209 src_context_tag_bytes[3],
1210 ];
1211 let length_so_far = length_so_far + request0.len();
1212 assert_eq!(length_so_far % 4, 0);
1213 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1214 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1215 Ok((vec![request0.into()], vec![]))
1216 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1217 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1218 where
1219 Conn: RequestConnection + ?Sized,
1220 {
1221 let (bytes, fds) = self.serialize(conn)?;
1222 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1223 conn.send_request_without_reply(&slices, fds)
1224 }
1225 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1226 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1227 if header.minor_opcode != COPY_CONTEXT_REQUEST {
1228 return Err(ParseError::InvalidValue);
1229 }
1230 let (src, remaining) = Context::try_parse(value)?;
1231 let (dest, remaining) = Context::try_parse(remaining)?;
1232 let (mask, remaining) = u32::try_parse(remaining)?;
1233 let (src_context_tag, remaining) = ContextTag::try_parse(remaining)?;
1234 let _ = remaining;
1235 Ok(CopyContextRequest {
1236 src,
1237 dest,
1238 mask,
1239 src_context_tag,
1240 })
1241 }
1242 }
1243 impl Request for CopyContextRequest {
1244 type Reply = ();
1245 }
copy_context<Conn>(conn: &Conn, src: Context, dest: Context, mask: u32, src_context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1246 pub fn copy_context<Conn>(conn: &Conn, src: Context, dest: Context, mask: u32, src_context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1247 where
1248 Conn: RequestConnection + ?Sized,
1249 {
1250 let request0 = CopyContextRequest {
1251 src,
1252 dest,
1253 mask,
1254 src_context_tag,
1255 };
1256 request0.send(conn)
1257 }
1258
1259 #[derive(Clone, Copy, PartialEq, Eq)]
1260 pub struct GC(u32);
1261 impl GC {
1262 pub const GL_CURRENT_BIT: Self = Self(1 << 0);
1263 pub const GL_POINT_BIT: Self = Self(1 << 1);
1264 pub const GL_LINE_BIT: Self = Self(1 << 2);
1265 pub const GL_POLYGON_BIT: Self = Self(1 << 3);
1266 pub const GL_POLYGON_STIPPLE_BIT: Self = Self(1 << 4);
1267 pub const GL_PIXEL_MODE_BIT: Self = Self(1 << 5);
1268 pub const GL_LIGHTING_BIT: Self = Self(1 << 6);
1269 pub const GL_FOG_BIT: Self = Self(1 << 7);
1270 pub const GL_DEPTH_BUFFER_BIT: Self = Self(1 << 8);
1271 pub const GL_ACCUM_BUFFER_BIT: Self = Self(1 << 9);
1272 pub const GL_STENCIL_BUFFER_BIT: Self = Self(1 << 10);
1273 pub const GL_VIEWPORT_BIT: Self = Self(1 << 11);
1274 pub const GL_TRANSFORM_BIT: Self = Self(1 << 12);
1275 pub const GL_ENABLE_BIT: Self = Self(1 << 13);
1276 pub const GL_COLOR_BUFFER_BIT: Self = Self(1 << 14);
1277 pub const GL_HINT_BIT: Self = Self(1 << 15);
1278 pub const GL_EVAL_BIT: Self = Self(1 << 16);
1279 pub const GL_LIST_BIT: Self = Self(1 << 17);
1280 pub const GL_TEXTURE_BIT: Self = Self(1 << 18);
1281 pub const GL_SCISSOR_BIT: Self = Self(1 << 19);
1282 pub const GL_ALL_ATTRIB_BITS: Self = Self(16_777_215);
1283 }
1284 impl From<GC> for u32 {
1285 #[inline]
from(input: GC) -> Self1286 fn from(input: GC) -> Self {
1287 input.0
1288 }
1289 }
1290 impl From<GC> for Option<u32> {
1291 #[inline]
from(input: GC) -> Self1292 fn from(input: GC) -> Self {
1293 Some(input.0)
1294 }
1295 }
1296 impl From<u8> for GC {
1297 #[inline]
from(value: u8) -> Self1298 fn from(value: u8) -> Self {
1299 Self(value.into())
1300 }
1301 }
1302 impl From<u16> for GC {
1303 #[inline]
from(value: u16) -> Self1304 fn from(value: u16) -> Self {
1305 Self(value.into())
1306 }
1307 }
1308 impl From<u32> for GC {
1309 #[inline]
from(value: u32) -> Self1310 fn from(value: u32) -> Self {
1311 Self(value)
1312 }
1313 }
1314 impl std::fmt::Debug for GC {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result1315 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1316 let variants = [
1317 (Self::GL_CURRENT_BIT.0, "GL_CURRENT_BIT", "GL_CURRENT_BIT"),
1318 (Self::GL_POINT_BIT.0, "GL_POINT_BIT", "GL_POINT_BIT"),
1319 (Self::GL_LINE_BIT.0, "GL_LINE_BIT", "GL_LINE_BIT"),
1320 (Self::GL_POLYGON_BIT.0, "GL_POLYGON_BIT", "GL_POLYGON_BIT"),
1321 (Self::GL_POLYGON_STIPPLE_BIT.0, "GL_POLYGON_STIPPLE_BIT", "GL_POLYGON_STIPPLE_BIT"),
1322 (Self::GL_PIXEL_MODE_BIT.0, "GL_PIXEL_MODE_BIT", "GL_PIXEL_MODE_BIT"),
1323 (Self::GL_LIGHTING_BIT.0, "GL_LIGHTING_BIT", "GL_LIGHTING_BIT"),
1324 (Self::GL_FOG_BIT.0, "GL_FOG_BIT", "GL_FOG_BIT"),
1325 (Self::GL_DEPTH_BUFFER_BIT.0, "GL_DEPTH_BUFFER_BIT", "GL_DEPTH_BUFFER_BIT"),
1326 (Self::GL_ACCUM_BUFFER_BIT.0, "GL_ACCUM_BUFFER_BIT", "GL_ACCUM_BUFFER_BIT"),
1327 (Self::GL_STENCIL_BUFFER_BIT.0, "GL_STENCIL_BUFFER_BIT", "GL_STENCIL_BUFFER_BIT"),
1328 (Self::GL_VIEWPORT_BIT.0, "GL_VIEWPORT_BIT", "GL_VIEWPORT_BIT"),
1329 (Self::GL_TRANSFORM_BIT.0, "GL_TRANSFORM_BIT", "GL_TRANSFORM_BIT"),
1330 (Self::GL_ENABLE_BIT.0, "GL_ENABLE_BIT", "GL_ENABLE_BIT"),
1331 (Self::GL_COLOR_BUFFER_BIT.0, "GL_COLOR_BUFFER_BIT", "GL_COLOR_BUFFER_BIT"),
1332 (Self::GL_HINT_BIT.0, "GL_HINT_BIT", "GL_HINT_BIT"),
1333 (Self::GL_EVAL_BIT.0, "GL_EVAL_BIT", "GL_EVAL_BIT"),
1334 (Self::GL_LIST_BIT.0, "GL_LIST_BIT", "GL_LIST_BIT"),
1335 (Self::GL_TEXTURE_BIT.0, "GL_TEXTURE_BIT", "GL_TEXTURE_BIT"),
1336 (Self::GL_SCISSOR_BIT.0, "GL_SCISSOR_BIT", "GL_SCISSOR_BIT"),
1337 (Self::GL_ALL_ATTRIB_BITS.0, "GL_ALL_ATTRIB_BITS", "GL_ALL_ATTRIB_BITS"),
1338 ];
1339 pretty_print_enum(fmt, self.0, &variants)
1340 }
1341 }
1342
1343 /// Opcode for the SwapBuffers request
1344 pub const SWAP_BUFFERS_REQUEST: u8 = 11;
1345 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1346 pub struct SwapBuffersRequest {
1347 pub context_tag: ContextTag,
1348 pub drawable: Drawable,
1349 }
1350 impl SwapBuffersRequest {
1351 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1352 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1353 where
1354 Conn: RequestConnection + ?Sized,
1355 {
1356 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1357 .ok_or(ConnectionError::UnsupportedExtension)?;
1358 let length_so_far = 0;
1359 let context_tag_bytes = self.context_tag.serialize();
1360 let drawable_bytes = self.drawable.serialize();
1361 let mut request0 = vec![
1362 extension_information.major_opcode,
1363 SWAP_BUFFERS_REQUEST,
1364 0,
1365 0,
1366 context_tag_bytes[0],
1367 context_tag_bytes[1],
1368 context_tag_bytes[2],
1369 context_tag_bytes[3],
1370 drawable_bytes[0],
1371 drawable_bytes[1],
1372 drawable_bytes[2],
1373 drawable_bytes[3],
1374 ];
1375 let length_so_far = length_so_far + request0.len();
1376 assert_eq!(length_so_far % 4, 0);
1377 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1378 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1379 Ok((vec![request0.into()], vec![]))
1380 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1381 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1382 where
1383 Conn: RequestConnection + ?Sized,
1384 {
1385 let (bytes, fds) = self.serialize(conn)?;
1386 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1387 conn.send_request_without_reply(&slices, fds)
1388 }
1389 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1390 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1391 if header.minor_opcode != SWAP_BUFFERS_REQUEST {
1392 return Err(ParseError::InvalidValue);
1393 }
1394 let (context_tag, remaining) = ContextTag::try_parse(value)?;
1395 let (drawable, remaining) = Drawable::try_parse(remaining)?;
1396 let _ = remaining;
1397 Ok(SwapBuffersRequest {
1398 context_tag,
1399 drawable,
1400 })
1401 }
1402 }
1403 impl Request for SwapBuffersRequest {
1404 type Reply = ();
1405 }
swap_buffers<Conn>(conn: &Conn, context_tag: ContextTag, drawable: Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1406 pub fn swap_buffers<Conn>(conn: &Conn, context_tag: ContextTag, drawable: Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1407 where
1408 Conn: RequestConnection + ?Sized,
1409 {
1410 let request0 = SwapBuffersRequest {
1411 context_tag,
1412 drawable,
1413 };
1414 request0.send(conn)
1415 }
1416
1417 /// Opcode for the UseXFont request
1418 pub const USE_X_FONT_REQUEST: u8 = 12;
1419 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1420 pub struct UseXFontRequest {
1421 pub context_tag: ContextTag,
1422 pub font: xproto::Font,
1423 pub first: u32,
1424 pub count: u32,
1425 pub list_base: u32,
1426 }
1427 impl UseXFontRequest {
1428 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1429 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1430 where
1431 Conn: RequestConnection + ?Sized,
1432 {
1433 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1434 .ok_or(ConnectionError::UnsupportedExtension)?;
1435 let length_so_far = 0;
1436 let context_tag_bytes = self.context_tag.serialize();
1437 let font_bytes = self.font.serialize();
1438 let first_bytes = self.first.serialize();
1439 let count_bytes = self.count.serialize();
1440 let list_base_bytes = self.list_base.serialize();
1441 let mut request0 = vec![
1442 extension_information.major_opcode,
1443 USE_X_FONT_REQUEST,
1444 0,
1445 0,
1446 context_tag_bytes[0],
1447 context_tag_bytes[1],
1448 context_tag_bytes[2],
1449 context_tag_bytes[3],
1450 font_bytes[0],
1451 font_bytes[1],
1452 font_bytes[2],
1453 font_bytes[3],
1454 first_bytes[0],
1455 first_bytes[1],
1456 first_bytes[2],
1457 first_bytes[3],
1458 count_bytes[0],
1459 count_bytes[1],
1460 count_bytes[2],
1461 count_bytes[3],
1462 list_base_bytes[0],
1463 list_base_bytes[1],
1464 list_base_bytes[2],
1465 list_base_bytes[3],
1466 ];
1467 let length_so_far = length_so_far + request0.len();
1468 assert_eq!(length_so_far % 4, 0);
1469 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1470 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1471 Ok((vec![request0.into()], vec![]))
1472 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1473 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1474 where
1475 Conn: RequestConnection + ?Sized,
1476 {
1477 let (bytes, fds) = self.serialize(conn)?;
1478 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1479 conn.send_request_without_reply(&slices, fds)
1480 }
1481 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1482 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1483 if header.minor_opcode != USE_X_FONT_REQUEST {
1484 return Err(ParseError::InvalidValue);
1485 }
1486 let (context_tag, remaining) = ContextTag::try_parse(value)?;
1487 let (font, remaining) = xproto::Font::try_parse(remaining)?;
1488 let (first, remaining) = u32::try_parse(remaining)?;
1489 let (count, remaining) = u32::try_parse(remaining)?;
1490 let (list_base, remaining) = u32::try_parse(remaining)?;
1491 let _ = remaining;
1492 Ok(UseXFontRequest {
1493 context_tag,
1494 font,
1495 first,
1496 count,
1497 list_base,
1498 })
1499 }
1500 }
1501 impl Request for UseXFontRequest {
1502 type Reply = ();
1503 }
use_x_font<Conn>(conn: &Conn, context_tag: ContextTag, font: xproto::Font, first: u32, count: u32, list_base: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1504 pub fn use_x_font<Conn>(conn: &Conn, context_tag: ContextTag, font: xproto::Font, first: u32, count: u32, list_base: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1505 where
1506 Conn: RequestConnection + ?Sized,
1507 {
1508 let request0 = UseXFontRequest {
1509 context_tag,
1510 font,
1511 first,
1512 count,
1513 list_base,
1514 };
1515 request0.send(conn)
1516 }
1517
1518 /// Opcode for the CreateGLXPixmap request
1519 pub const CREATE_GLX_PIXMAP_REQUEST: u8 = 13;
1520 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1521 pub struct CreateGLXPixmapRequest {
1522 pub screen: u32,
1523 pub visual: xproto::Visualid,
1524 pub pixmap: xproto::Pixmap,
1525 pub glx_pixmap: Pixmap,
1526 }
1527 impl CreateGLXPixmapRequest {
1528 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1529 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1530 where
1531 Conn: RequestConnection + ?Sized,
1532 {
1533 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1534 .ok_or(ConnectionError::UnsupportedExtension)?;
1535 let length_so_far = 0;
1536 let screen_bytes = self.screen.serialize();
1537 let visual_bytes = self.visual.serialize();
1538 let pixmap_bytes = self.pixmap.serialize();
1539 let glx_pixmap_bytes = self.glx_pixmap.serialize();
1540 let mut request0 = vec![
1541 extension_information.major_opcode,
1542 CREATE_GLX_PIXMAP_REQUEST,
1543 0,
1544 0,
1545 screen_bytes[0],
1546 screen_bytes[1],
1547 screen_bytes[2],
1548 screen_bytes[3],
1549 visual_bytes[0],
1550 visual_bytes[1],
1551 visual_bytes[2],
1552 visual_bytes[3],
1553 pixmap_bytes[0],
1554 pixmap_bytes[1],
1555 pixmap_bytes[2],
1556 pixmap_bytes[3],
1557 glx_pixmap_bytes[0],
1558 glx_pixmap_bytes[1],
1559 glx_pixmap_bytes[2],
1560 glx_pixmap_bytes[3],
1561 ];
1562 let length_so_far = length_so_far + request0.len();
1563 assert_eq!(length_so_far % 4, 0);
1564 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1565 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1566 Ok((vec![request0.into()], vec![]))
1567 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1568 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1569 where
1570 Conn: RequestConnection + ?Sized,
1571 {
1572 let (bytes, fds) = self.serialize(conn)?;
1573 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1574 conn.send_request_without_reply(&slices, fds)
1575 }
1576 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1577 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1578 if header.minor_opcode != CREATE_GLX_PIXMAP_REQUEST {
1579 return Err(ParseError::InvalidValue);
1580 }
1581 let (screen, remaining) = u32::try_parse(value)?;
1582 let (visual, remaining) = xproto::Visualid::try_parse(remaining)?;
1583 let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?;
1584 let (glx_pixmap, remaining) = Pixmap::try_parse(remaining)?;
1585 let _ = remaining;
1586 Ok(CreateGLXPixmapRequest {
1587 screen,
1588 visual,
1589 pixmap,
1590 glx_pixmap,
1591 })
1592 }
1593 }
1594 impl Request for CreateGLXPixmapRequest {
1595 type Reply = ();
1596 }
create_glx_pixmap<Conn>(conn: &Conn, screen: u32, visual: xproto::Visualid, pixmap: xproto::Pixmap, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1597 pub fn create_glx_pixmap<Conn>(conn: &Conn, screen: u32, visual: xproto::Visualid, pixmap: xproto::Pixmap, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1598 where
1599 Conn: RequestConnection + ?Sized,
1600 {
1601 let request0 = CreateGLXPixmapRequest {
1602 screen,
1603 visual,
1604 pixmap,
1605 glx_pixmap,
1606 };
1607 request0.send(conn)
1608 }
1609
1610 /// Opcode for the GetVisualConfigs request
1611 pub const GET_VISUAL_CONFIGS_REQUEST: u8 = 14;
1612 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1613 pub struct GetVisualConfigsRequest {
1614 pub screen: u32,
1615 }
1616 impl GetVisualConfigsRequest {
1617 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1618 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1619 where
1620 Conn: RequestConnection + ?Sized,
1621 {
1622 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1623 .ok_or(ConnectionError::UnsupportedExtension)?;
1624 let length_so_far = 0;
1625 let screen_bytes = self.screen.serialize();
1626 let mut request0 = vec![
1627 extension_information.major_opcode,
1628 GET_VISUAL_CONFIGS_REQUEST,
1629 0,
1630 0,
1631 screen_bytes[0],
1632 screen_bytes[1],
1633 screen_bytes[2],
1634 screen_bytes[3],
1635 ];
1636 let length_so_far = length_so_far + request0.len();
1637 assert_eq!(length_so_far % 4, 0);
1638 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1639 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1640 Ok((vec![request0.into()], vec![]))
1641 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetVisualConfigsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1642 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetVisualConfigsReply>, ConnectionError>
1643 where
1644 Conn: RequestConnection + ?Sized,
1645 {
1646 let (bytes, fds) = self.serialize(conn)?;
1647 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1648 conn.send_request_with_reply(&slices, fds)
1649 }
1650 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1651 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1652 if header.minor_opcode != GET_VISUAL_CONFIGS_REQUEST {
1653 return Err(ParseError::InvalidValue);
1654 }
1655 let (screen, remaining) = u32::try_parse(value)?;
1656 let _ = remaining;
1657 Ok(GetVisualConfigsRequest {
1658 screen,
1659 })
1660 }
1661 }
1662 impl Request for GetVisualConfigsRequest {
1663 type Reply = GetVisualConfigsReply;
1664 }
get_visual_configs<Conn>(conn: &Conn, screen: u32) -> Result<Cookie<'_, Conn, GetVisualConfigsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1665 pub fn get_visual_configs<Conn>(conn: &Conn, screen: u32) -> Result<Cookie<'_, Conn, GetVisualConfigsReply>, ConnectionError>
1666 where
1667 Conn: RequestConnection + ?Sized,
1668 {
1669 let request0 = GetVisualConfigsRequest {
1670 screen,
1671 };
1672 request0.send(conn)
1673 }
1674
1675 #[derive(Debug, Clone, PartialEq, Eq)]
1676 pub struct GetVisualConfigsReply {
1677 pub sequence: u16,
1678 pub num_visuals: u32,
1679 pub num_properties: u32,
1680 pub property_list: Vec<u32>,
1681 }
1682 impl TryParse for GetVisualConfigsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1683 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1684 let remaining = initial_value;
1685 let (response_type, remaining) = u8::try_parse(remaining)?;
1686 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1687 let (sequence, remaining) = u16::try_parse(remaining)?;
1688 let (length, remaining) = u32::try_parse(remaining)?;
1689 let (num_visuals, remaining) = u32::try_parse(remaining)?;
1690 let (num_properties, remaining) = u32::try_parse(remaining)?;
1691 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
1692 let (property_list, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
1693 if response_type != 1 {
1694 return Err(ParseError::InvalidValue);
1695 }
1696 let result = GetVisualConfigsReply { sequence, num_visuals, num_properties, property_list };
1697 let _ = remaining;
1698 let remaining = initial_value.get(32 + length as usize * 4..)
1699 .ok_or(ParseError::InsufficientData)?;
1700 Ok((result, remaining))
1701 }
1702 }
1703 impl GetVisualConfigsReply {
1704 /// Get the value of the `length` field.
1705 ///
1706 /// The `length` field is used as the length field of the `property_list` field.
1707 /// This function computes the field's value again based on the length of the list.
1708 ///
1709 /// # Panics
1710 ///
1711 /// Panics if the value cannot be represented in the target type. This
1712 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u321713 pub fn length(&self) -> u32 {
1714 self.property_list.len()
1715 .try_into().unwrap()
1716 }
1717 }
1718
1719 /// Opcode for the DestroyGLXPixmap request
1720 pub const DESTROY_GLX_PIXMAP_REQUEST: u8 = 15;
1721 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1722 pub struct DestroyGLXPixmapRequest {
1723 pub glx_pixmap: Pixmap,
1724 }
1725 impl DestroyGLXPixmapRequest {
1726 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1727 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1728 where
1729 Conn: RequestConnection + ?Sized,
1730 {
1731 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1732 .ok_or(ConnectionError::UnsupportedExtension)?;
1733 let length_so_far = 0;
1734 let glx_pixmap_bytes = self.glx_pixmap.serialize();
1735 let mut request0 = vec![
1736 extension_information.major_opcode,
1737 DESTROY_GLX_PIXMAP_REQUEST,
1738 0,
1739 0,
1740 glx_pixmap_bytes[0],
1741 glx_pixmap_bytes[1],
1742 glx_pixmap_bytes[2],
1743 glx_pixmap_bytes[3],
1744 ];
1745 let length_so_far = length_so_far + request0.len();
1746 assert_eq!(length_so_far % 4, 0);
1747 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1748 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1749 Ok((vec![request0.into()], vec![]))
1750 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1751 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1752 where
1753 Conn: RequestConnection + ?Sized,
1754 {
1755 let (bytes, fds) = self.serialize(conn)?;
1756 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1757 conn.send_request_without_reply(&slices, fds)
1758 }
1759 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>1760 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1761 if header.minor_opcode != DESTROY_GLX_PIXMAP_REQUEST {
1762 return Err(ParseError::InvalidValue);
1763 }
1764 let (glx_pixmap, remaining) = Pixmap::try_parse(value)?;
1765 let _ = remaining;
1766 Ok(DestroyGLXPixmapRequest {
1767 glx_pixmap,
1768 })
1769 }
1770 }
1771 impl Request for DestroyGLXPixmapRequest {
1772 type Reply = ();
1773 }
destroy_glx_pixmap<Conn>(conn: &Conn, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1774 pub fn destroy_glx_pixmap<Conn>(conn: &Conn, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1775 where
1776 Conn: RequestConnection + ?Sized,
1777 {
1778 let request0 = DestroyGLXPixmapRequest {
1779 glx_pixmap,
1780 };
1781 request0.send(conn)
1782 }
1783
1784 /// Opcode for the VendorPrivate request
1785 pub const VENDOR_PRIVATE_REQUEST: u8 = 16;
1786 #[derive(Debug, Clone, PartialEq, Eq)]
1787 pub struct VendorPrivateRequest<'input> {
1788 pub vendor_code: u32,
1789 pub context_tag: ContextTag,
1790 pub data: Cow<'input, [u8]>,
1791 }
1792 impl<'input> VendorPrivateRequest<'input> {
1793 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1794 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1795 where
1796 Conn: RequestConnection + ?Sized,
1797 {
1798 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1799 .ok_or(ConnectionError::UnsupportedExtension)?;
1800 let length_so_far = 0;
1801 let vendor_code_bytes = self.vendor_code.serialize();
1802 let context_tag_bytes = self.context_tag.serialize();
1803 let mut request0 = vec![
1804 extension_information.major_opcode,
1805 VENDOR_PRIVATE_REQUEST,
1806 0,
1807 0,
1808 vendor_code_bytes[0],
1809 vendor_code_bytes[1],
1810 vendor_code_bytes[2],
1811 vendor_code_bytes[3],
1812 context_tag_bytes[0],
1813 context_tag_bytes[1],
1814 context_tag_bytes[2],
1815 context_tag_bytes[3],
1816 ];
1817 let length_so_far = length_so_far + request0.len();
1818 let length_so_far = length_so_far + self.data.len();
1819 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1820 let length_so_far = length_so_far + padding0.len();
1821 assert_eq!(length_so_far % 4, 0);
1822 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1823 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1824 Ok((vec![request0.into(), self.data, padding0.into()], vec![]))
1825 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1826 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1827 where
1828 Conn: RequestConnection + ?Sized,
1829 {
1830 let (bytes, fds) = self.serialize(conn)?;
1831 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1832 conn.send_request_without_reply(&slices, fds)
1833 }
1834 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>1835 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1836 if header.minor_opcode != VENDOR_PRIVATE_REQUEST {
1837 return Err(ParseError::InvalidValue);
1838 }
1839 let (vendor_code, remaining) = u32::try_parse(value)?;
1840 let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
1841 let (data, remaining) = remaining.split_at(remaining.len());
1842 let _ = remaining;
1843 Ok(VendorPrivateRequest {
1844 vendor_code,
1845 context_tag,
1846 data: Cow::Borrowed(data),
1847 })
1848 }
1849 /// Clone all borrowed data in this VendorPrivateRequest.
into_owned(self) -> VendorPrivateRequest<'static>1850 pub fn into_owned(self) -> VendorPrivateRequest<'static> {
1851 VendorPrivateRequest {
1852 vendor_code: self.vendor_code,
1853 context_tag: self.context_tag,
1854 data: Cow::Owned(self.data.into_owned()),
1855 }
1856 }
1857 }
1858 impl<'input> Request for VendorPrivateRequest<'input> {
1859 type Reply = ();
1860 }
vendor_private<'c, 'input, Conn>(conn: &'c Conn, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1861 pub fn vendor_private<'c, 'input, Conn>(conn: &'c Conn, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
1862 where
1863 Conn: RequestConnection + ?Sized,
1864 {
1865 let request0 = VendorPrivateRequest {
1866 vendor_code,
1867 context_tag,
1868 data: Cow::Borrowed(data),
1869 };
1870 request0.send(conn)
1871 }
1872
1873 /// Opcode for the VendorPrivateWithReply request
1874 pub const VENDOR_PRIVATE_WITH_REPLY_REQUEST: u8 = 17;
1875 #[derive(Debug, Clone, PartialEq, Eq)]
1876 pub struct VendorPrivateWithReplyRequest<'input> {
1877 pub vendor_code: u32,
1878 pub context_tag: ContextTag,
1879 pub data: Cow<'input, [u8]>,
1880 }
1881 impl<'input> VendorPrivateWithReplyRequest<'input> {
1882 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1883 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1884 where
1885 Conn: RequestConnection + ?Sized,
1886 {
1887 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1888 .ok_or(ConnectionError::UnsupportedExtension)?;
1889 let length_so_far = 0;
1890 let vendor_code_bytes = self.vendor_code.serialize();
1891 let context_tag_bytes = self.context_tag.serialize();
1892 let mut request0 = vec![
1893 extension_information.major_opcode,
1894 VENDOR_PRIVATE_WITH_REPLY_REQUEST,
1895 0,
1896 0,
1897 vendor_code_bytes[0],
1898 vendor_code_bytes[1],
1899 vendor_code_bytes[2],
1900 vendor_code_bytes[3],
1901 context_tag_bytes[0],
1902 context_tag_bytes[1],
1903 context_tag_bytes[2],
1904 context_tag_bytes[3],
1905 ];
1906 let length_so_far = length_so_far + request0.len();
1907 let length_so_far = length_so_far + self.data.len();
1908 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
1909 let length_so_far = length_so_far + padding0.len();
1910 assert_eq!(length_so_far % 4, 0);
1911 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1912 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1913 Ok((vec![request0.into(), self.data, padding0.into()], vec![]))
1914 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, VendorPrivateWithReplyReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1915 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, VendorPrivateWithReplyReply>, ConnectionError>
1916 where
1917 Conn: RequestConnection + ?Sized,
1918 {
1919 let (bytes, fds) = self.serialize(conn)?;
1920 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1921 conn.send_request_with_reply(&slices, fds)
1922 }
1923 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>1924 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
1925 if header.minor_opcode != VENDOR_PRIVATE_WITH_REPLY_REQUEST {
1926 return Err(ParseError::InvalidValue);
1927 }
1928 let (vendor_code, remaining) = u32::try_parse(value)?;
1929 let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
1930 let (data, remaining) = remaining.split_at(remaining.len());
1931 let _ = remaining;
1932 Ok(VendorPrivateWithReplyRequest {
1933 vendor_code,
1934 context_tag,
1935 data: Cow::Borrowed(data),
1936 })
1937 }
1938 /// Clone all borrowed data in this VendorPrivateWithReplyRequest.
into_owned(self) -> VendorPrivateWithReplyRequest<'static>1939 pub fn into_owned(self) -> VendorPrivateWithReplyRequest<'static> {
1940 VendorPrivateWithReplyRequest {
1941 vendor_code: self.vendor_code,
1942 context_tag: self.context_tag,
1943 data: Cow::Owned(self.data.into_owned()),
1944 }
1945 }
1946 }
1947 impl<'input> Request for VendorPrivateWithReplyRequest<'input> {
1948 type Reply = VendorPrivateWithReplyReply;
1949 }
vendor_private_with_reply<'c, 'input, Conn>(conn: &'c Conn, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<Cookie<'c, Conn, VendorPrivateWithReplyReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1950 pub fn vendor_private_with_reply<'c, 'input, Conn>(conn: &'c Conn, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<Cookie<'c, Conn, VendorPrivateWithReplyReply>, ConnectionError>
1951 where
1952 Conn: RequestConnection + ?Sized,
1953 {
1954 let request0 = VendorPrivateWithReplyRequest {
1955 vendor_code,
1956 context_tag,
1957 data: Cow::Borrowed(data),
1958 };
1959 request0.send(conn)
1960 }
1961
1962 #[derive(Debug, Clone, PartialEq, Eq)]
1963 pub struct VendorPrivateWithReplyReply {
1964 pub sequence: u16,
1965 pub retval: u32,
1966 pub data1: [u8; 24],
1967 pub data2: Vec<u8>,
1968 }
1969 impl TryParse for VendorPrivateWithReplyReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1970 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1971 let remaining = initial_value;
1972 let (response_type, remaining) = u8::try_parse(remaining)?;
1973 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1974 let (sequence, remaining) = u16::try_parse(remaining)?;
1975 let (length, remaining) = u32::try_parse(remaining)?;
1976 let (retval, remaining) = u32::try_parse(remaining)?;
1977 let (data1, remaining) = crate::x11_utils::parse_u8_list(remaining, 24)?;
1978 let data1 = <[u8; 24]>::try_from(data1).unwrap();
1979 let (data2, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
1980 let data2 = data2.to_vec();
1981 if response_type != 1 {
1982 return Err(ParseError::InvalidValue);
1983 }
1984 let result = VendorPrivateWithReplyReply { sequence, retval, data1, data2 };
1985 let _ = remaining;
1986 let remaining = initial_value.get(32 + length as usize * 4..)
1987 .ok_or(ParseError::InsufficientData)?;
1988 Ok((result, remaining))
1989 }
1990 }
1991 impl VendorPrivateWithReplyReply {
1992 /// Get the value of the `length` field.
1993 ///
1994 /// The `length` field is used as the length field of the `data2` field.
1995 /// This function computes the field's value again based on the length of the list.
1996 ///
1997 /// # Panics
1998 ///
1999 /// Panics if the value cannot be represented in the target type. This
2000 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u322001 pub fn length(&self) -> u32 {
2002 self.data2.len()
2003 .checked_div(4).unwrap()
2004 .try_into().unwrap()
2005 }
2006 }
2007
2008 /// Opcode for the QueryExtensionsString request
2009 pub const QUERY_EXTENSIONS_STRING_REQUEST: u8 = 18;
2010 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2011 pub struct QueryExtensionsStringRequest {
2012 pub screen: u32,
2013 }
2014 impl QueryExtensionsStringRequest {
2015 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2016 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2017 where
2018 Conn: RequestConnection + ?Sized,
2019 {
2020 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2021 .ok_or(ConnectionError::UnsupportedExtension)?;
2022 let length_so_far = 0;
2023 let screen_bytes = self.screen.serialize();
2024 let mut request0 = vec![
2025 extension_information.major_opcode,
2026 QUERY_EXTENSIONS_STRING_REQUEST,
2027 0,
2028 0,
2029 screen_bytes[0],
2030 screen_bytes[1],
2031 screen_bytes[2],
2032 screen_bytes[3],
2033 ];
2034 let length_so_far = length_so_far + request0.len();
2035 assert_eq!(length_so_far % 4, 0);
2036 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2037 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2038 Ok((vec![request0.into()], vec![]))
2039 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryExtensionsStringReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2040 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryExtensionsStringReply>, ConnectionError>
2041 where
2042 Conn: RequestConnection + ?Sized,
2043 {
2044 let (bytes, fds) = self.serialize(conn)?;
2045 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2046 conn.send_request_with_reply(&slices, fds)
2047 }
2048 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2049 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2050 if header.minor_opcode != QUERY_EXTENSIONS_STRING_REQUEST {
2051 return Err(ParseError::InvalidValue);
2052 }
2053 let (screen, remaining) = u32::try_parse(value)?;
2054 let _ = remaining;
2055 Ok(QueryExtensionsStringRequest {
2056 screen,
2057 })
2058 }
2059 }
2060 impl Request for QueryExtensionsStringRequest {
2061 type Reply = QueryExtensionsStringReply;
2062 }
query_extensions_string<Conn>(conn: &Conn, screen: u32) -> Result<Cookie<'_, Conn, QueryExtensionsStringReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2063 pub fn query_extensions_string<Conn>(conn: &Conn, screen: u32) -> Result<Cookie<'_, Conn, QueryExtensionsStringReply>, ConnectionError>
2064 where
2065 Conn: RequestConnection + ?Sized,
2066 {
2067 let request0 = QueryExtensionsStringRequest {
2068 screen,
2069 };
2070 request0.send(conn)
2071 }
2072
2073 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2074 pub struct QueryExtensionsStringReply {
2075 pub sequence: u16,
2076 pub length: u32,
2077 pub n: u32,
2078 }
2079 impl TryParse for QueryExtensionsStringReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2080 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2081 let remaining = initial_value;
2082 let (response_type, remaining) = u8::try_parse(remaining)?;
2083 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2084 let (sequence, remaining) = u16::try_parse(remaining)?;
2085 let (length, remaining) = u32::try_parse(remaining)?;
2086 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
2087 let (n, remaining) = u32::try_parse(remaining)?;
2088 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
2089 if response_type != 1 {
2090 return Err(ParseError::InvalidValue);
2091 }
2092 let result = QueryExtensionsStringReply { sequence, length, n };
2093 let _ = remaining;
2094 let remaining = initial_value.get(32 + length as usize * 4..)
2095 .ok_or(ParseError::InsufficientData)?;
2096 Ok((result, remaining))
2097 }
2098 }
2099
2100 /// Opcode for the QueryServerString request
2101 pub const QUERY_SERVER_STRING_REQUEST: u8 = 19;
2102 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2103 pub struct QueryServerStringRequest {
2104 pub screen: u32,
2105 pub name: u32,
2106 }
2107 impl QueryServerStringRequest {
2108 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2109 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2110 where
2111 Conn: RequestConnection + ?Sized,
2112 {
2113 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2114 .ok_or(ConnectionError::UnsupportedExtension)?;
2115 let length_so_far = 0;
2116 let screen_bytes = self.screen.serialize();
2117 let name_bytes = self.name.serialize();
2118 let mut request0 = vec![
2119 extension_information.major_opcode,
2120 QUERY_SERVER_STRING_REQUEST,
2121 0,
2122 0,
2123 screen_bytes[0],
2124 screen_bytes[1],
2125 screen_bytes[2],
2126 screen_bytes[3],
2127 name_bytes[0],
2128 name_bytes[1],
2129 name_bytes[2],
2130 name_bytes[3],
2131 ];
2132 let length_so_far = length_so_far + request0.len();
2133 assert_eq!(length_so_far % 4, 0);
2134 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2135 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2136 Ok((vec![request0.into()], vec![]))
2137 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryServerStringReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2138 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryServerStringReply>, ConnectionError>
2139 where
2140 Conn: RequestConnection + ?Sized,
2141 {
2142 let (bytes, fds) = self.serialize(conn)?;
2143 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2144 conn.send_request_with_reply(&slices, fds)
2145 }
2146 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2147 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2148 if header.minor_opcode != QUERY_SERVER_STRING_REQUEST {
2149 return Err(ParseError::InvalidValue);
2150 }
2151 let (screen, remaining) = u32::try_parse(value)?;
2152 let (name, remaining) = u32::try_parse(remaining)?;
2153 let _ = remaining;
2154 Ok(QueryServerStringRequest {
2155 screen,
2156 name,
2157 })
2158 }
2159 }
2160 impl Request for QueryServerStringRequest {
2161 type Reply = QueryServerStringReply;
2162 }
query_server_string<Conn>(conn: &Conn, screen: u32, name: u32) -> Result<Cookie<'_, Conn, QueryServerStringReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2163 pub fn query_server_string<Conn>(conn: &Conn, screen: u32, name: u32) -> Result<Cookie<'_, Conn, QueryServerStringReply>, ConnectionError>
2164 where
2165 Conn: RequestConnection + ?Sized,
2166 {
2167 let request0 = QueryServerStringRequest {
2168 screen,
2169 name,
2170 };
2171 request0.send(conn)
2172 }
2173
2174 #[derive(Debug, Clone, PartialEq, Eq)]
2175 pub struct QueryServerStringReply {
2176 pub sequence: u16,
2177 pub length: u32,
2178 pub string: Vec<u8>,
2179 }
2180 impl TryParse for QueryServerStringReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2181 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2182 let remaining = initial_value;
2183 let (response_type, remaining) = u8::try_parse(remaining)?;
2184 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2185 let (sequence, remaining) = u16::try_parse(remaining)?;
2186 let (length, remaining) = u32::try_parse(remaining)?;
2187 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
2188 let (str_len, remaining) = u32::try_parse(remaining)?;
2189 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
2190 let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, str_len.try_to_usize()?)?;
2191 let string = string.to_vec();
2192 if response_type != 1 {
2193 return Err(ParseError::InvalidValue);
2194 }
2195 let result = QueryServerStringReply { sequence, length, string };
2196 let _ = remaining;
2197 let remaining = initial_value.get(32 + length as usize * 4..)
2198 .ok_or(ParseError::InsufficientData)?;
2199 Ok((result, remaining))
2200 }
2201 }
2202 impl QueryServerStringReply {
2203 /// Get the value of the `str_len` field.
2204 ///
2205 /// The `str_len` field is used as the length field of the `string` field.
2206 /// This function computes the field's value again based on the length of the list.
2207 ///
2208 /// # Panics
2209 ///
2210 /// Panics if the value cannot be represented in the target type. This
2211 /// cannot happen with values of the struct received from the X11 server.
str_len(&self) -> u322212 pub fn str_len(&self) -> u32 {
2213 self.string.len()
2214 .try_into().unwrap()
2215 }
2216 }
2217
2218 /// Opcode for the ClientInfo request
2219 pub const CLIENT_INFO_REQUEST: u8 = 20;
2220 #[derive(Debug, Clone, PartialEq, Eq)]
2221 pub struct ClientInfoRequest<'input> {
2222 pub major_version: u32,
2223 pub minor_version: u32,
2224 pub string: Cow<'input, [u8]>,
2225 }
2226 impl<'input> ClientInfoRequest<'input> {
2227 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2228 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2229 where
2230 Conn: RequestConnection + ?Sized,
2231 {
2232 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2233 .ok_or(ConnectionError::UnsupportedExtension)?;
2234 let length_so_far = 0;
2235 let major_version_bytes = self.major_version.serialize();
2236 let minor_version_bytes = self.minor_version.serialize();
2237 let str_len = u32::try_from(self.string.len()).expect("`string` has too many elements");
2238 let str_len_bytes = str_len.serialize();
2239 let mut request0 = vec![
2240 extension_information.major_opcode,
2241 CLIENT_INFO_REQUEST,
2242 0,
2243 0,
2244 major_version_bytes[0],
2245 major_version_bytes[1],
2246 major_version_bytes[2],
2247 major_version_bytes[3],
2248 minor_version_bytes[0],
2249 minor_version_bytes[1],
2250 minor_version_bytes[2],
2251 minor_version_bytes[3],
2252 str_len_bytes[0],
2253 str_len_bytes[1],
2254 str_len_bytes[2],
2255 str_len_bytes[3],
2256 ];
2257 let length_so_far = length_so_far + request0.len();
2258 let length_so_far = length_so_far + self.string.len();
2259 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2260 let length_so_far = length_so_far + padding0.len();
2261 assert_eq!(length_so_far % 4, 0);
2262 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2263 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2264 Ok((vec![request0.into(), self.string, padding0.into()], vec![]))
2265 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2266 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2267 where
2268 Conn: RequestConnection + ?Sized,
2269 {
2270 let (bytes, fds) = self.serialize(conn)?;
2271 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2272 conn.send_request_without_reply(&slices, fds)
2273 }
2274 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>2275 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2276 if header.minor_opcode != CLIENT_INFO_REQUEST {
2277 return Err(ParseError::InvalidValue);
2278 }
2279 let (major_version, remaining) = u32::try_parse(value)?;
2280 let (minor_version, remaining) = u32::try_parse(remaining)?;
2281 let (str_len, remaining) = u32::try_parse(remaining)?;
2282 let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, str_len.try_to_usize()?)?;
2283 let _ = remaining;
2284 Ok(ClientInfoRequest {
2285 major_version,
2286 minor_version,
2287 string: Cow::Borrowed(string),
2288 })
2289 }
2290 /// Clone all borrowed data in this ClientInfoRequest.
into_owned(self) -> ClientInfoRequest<'static>2291 pub fn into_owned(self) -> ClientInfoRequest<'static> {
2292 ClientInfoRequest {
2293 major_version: self.major_version,
2294 minor_version: self.minor_version,
2295 string: Cow::Owned(self.string.into_owned()),
2296 }
2297 }
2298 }
2299 impl<'input> Request for ClientInfoRequest<'input> {
2300 type Reply = ();
2301 }
client_info<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, string: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2302 pub fn client_info<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, string: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2303 where
2304 Conn: RequestConnection + ?Sized,
2305 {
2306 let request0 = ClientInfoRequest {
2307 major_version,
2308 minor_version,
2309 string: Cow::Borrowed(string),
2310 };
2311 request0.send(conn)
2312 }
2313
2314 /// Opcode for the GetFBConfigs request
2315 pub const GET_FB_CONFIGS_REQUEST: u8 = 21;
2316 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2317 pub struct GetFBConfigsRequest {
2318 pub screen: u32,
2319 }
2320 impl GetFBConfigsRequest {
2321 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2322 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2323 where
2324 Conn: RequestConnection + ?Sized,
2325 {
2326 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2327 .ok_or(ConnectionError::UnsupportedExtension)?;
2328 let length_so_far = 0;
2329 let screen_bytes = self.screen.serialize();
2330 let mut request0 = vec![
2331 extension_information.major_opcode,
2332 GET_FB_CONFIGS_REQUEST,
2333 0,
2334 0,
2335 screen_bytes[0],
2336 screen_bytes[1],
2337 screen_bytes[2],
2338 screen_bytes[3],
2339 ];
2340 let length_so_far = length_so_far + request0.len();
2341 assert_eq!(length_so_far % 4, 0);
2342 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2343 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2344 Ok((vec![request0.into()], vec![]))
2345 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetFBConfigsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2346 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetFBConfigsReply>, ConnectionError>
2347 where
2348 Conn: RequestConnection + ?Sized,
2349 {
2350 let (bytes, fds) = self.serialize(conn)?;
2351 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2352 conn.send_request_with_reply(&slices, fds)
2353 }
2354 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2355 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2356 if header.minor_opcode != GET_FB_CONFIGS_REQUEST {
2357 return Err(ParseError::InvalidValue);
2358 }
2359 let (screen, remaining) = u32::try_parse(value)?;
2360 let _ = remaining;
2361 Ok(GetFBConfigsRequest {
2362 screen,
2363 })
2364 }
2365 }
2366 impl Request for GetFBConfigsRequest {
2367 type Reply = GetFBConfigsReply;
2368 }
get_fb_configs<Conn>(conn: &Conn, screen: u32) -> Result<Cookie<'_, Conn, GetFBConfigsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2369 pub fn get_fb_configs<Conn>(conn: &Conn, screen: u32) -> Result<Cookie<'_, Conn, GetFBConfigsReply>, ConnectionError>
2370 where
2371 Conn: RequestConnection + ?Sized,
2372 {
2373 let request0 = GetFBConfigsRequest {
2374 screen,
2375 };
2376 request0.send(conn)
2377 }
2378
2379 #[derive(Debug, Clone, PartialEq, Eq)]
2380 pub struct GetFBConfigsReply {
2381 pub sequence: u16,
2382 pub num_fb_configs: u32,
2383 pub num_properties: u32,
2384 pub property_list: Vec<u32>,
2385 }
2386 impl TryParse for GetFBConfigsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2387 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2388 let remaining = initial_value;
2389 let (response_type, remaining) = u8::try_parse(remaining)?;
2390 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2391 let (sequence, remaining) = u16::try_parse(remaining)?;
2392 let (length, remaining) = u32::try_parse(remaining)?;
2393 let (num_fb_configs, remaining) = u32::try_parse(remaining)?;
2394 let (num_properties, remaining) = u32::try_parse(remaining)?;
2395 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
2396 let (property_list, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
2397 if response_type != 1 {
2398 return Err(ParseError::InvalidValue);
2399 }
2400 let result = GetFBConfigsReply { sequence, num_fb_configs, num_properties, property_list };
2401 let _ = remaining;
2402 let remaining = initial_value.get(32 + length as usize * 4..)
2403 .ok_or(ParseError::InsufficientData)?;
2404 Ok((result, remaining))
2405 }
2406 }
2407 impl GetFBConfigsReply {
2408 /// Get the value of the `length` field.
2409 ///
2410 /// The `length` field is used as the length field of the `property_list` field.
2411 /// This function computes the field's value again based on the length of the list.
2412 ///
2413 /// # Panics
2414 ///
2415 /// Panics if the value cannot be represented in the target type. This
2416 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u322417 pub fn length(&self) -> u32 {
2418 self.property_list.len()
2419 .try_into().unwrap()
2420 }
2421 }
2422
2423 /// Opcode for the CreatePixmap request
2424 pub const CREATE_PIXMAP_REQUEST: u8 = 22;
2425 #[derive(Debug, Clone, PartialEq, Eq)]
2426 pub struct CreatePixmapRequest<'input> {
2427 pub screen: u32,
2428 pub fbconfig: Fbconfig,
2429 pub pixmap: xproto::Pixmap,
2430 pub glx_pixmap: Pixmap,
2431 pub attribs: Cow<'input, [u32]>,
2432 }
2433 impl<'input> CreatePixmapRequest<'input> {
2434 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2435 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2436 where
2437 Conn: RequestConnection + ?Sized,
2438 {
2439 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2440 .ok_or(ConnectionError::UnsupportedExtension)?;
2441 let length_so_far = 0;
2442 let screen_bytes = self.screen.serialize();
2443 let fbconfig_bytes = self.fbconfig.serialize();
2444 let pixmap_bytes = self.pixmap.serialize();
2445 let glx_pixmap_bytes = self.glx_pixmap.serialize();
2446 assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
2447 let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
2448 let num_attribs_bytes = num_attribs.serialize();
2449 let mut request0 = vec![
2450 extension_information.major_opcode,
2451 CREATE_PIXMAP_REQUEST,
2452 0,
2453 0,
2454 screen_bytes[0],
2455 screen_bytes[1],
2456 screen_bytes[2],
2457 screen_bytes[3],
2458 fbconfig_bytes[0],
2459 fbconfig_bytes[1],
2460 fbconfig_bytes[2],
2461 fbconfig_bytes[3],
2462 pixmap_bytes[0],
2463 pixmap_bytes[1],
2464 pixmap_bytes[2],
2465 pixmap_bytes[3],
2466 glx_pixmap_bytes[0],
2467 glx_pixmap_bytes[1],
2468 glx_pixmap_bytes[2],
2469 glx_pixmap_bytes[3],
2470 num_attribs_bytes[0],
2471 num_attribs_bytes[1],
2472 num_attribs_bytes[2],
2473 num_attribs_bytes[3],
2474 ];
2475 let length_so_far = length_so_far + request0.len();
2476 let attribs_bytes = self.attribs.serialize();
2477 let length_so_far = length_so_far + attribs_bytes.len();
2478 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2479 let length_so_far = length_so_far + padding0.len();
2480 assert_eq!(length_so_far % 4, 0);
2481 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2482 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2483 Ok((vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]))
2484 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2485 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2486 where
2487 Conn: RequestConnection + ?Sized,
2488 {
2489 let (bytes, fds) = self.serialize(conn)?;
2490 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2491 conn.send_request_without_reply(&slices, fds)
2492 }
2493 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>2494 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
2495 if header.minor_opcode != CREATE_PIXMAP_REQUEST {
2496 return Err(ParseError::InvalidValue);
2497 }
2498 let (screen, remaining) = u32::try_parse(value)?;
2499 let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
2500 let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?;
2501 let (glx_pixmap, remaining) = Pixmap::try_parse(remaining)?;
2502 let (num_attribs, remaining) = u32::try_parse(remaining)?;
2503 let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_attribs.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
2504 let _ = remaining;
2505 Ok(CreatePixmapRequest {
2506 screen,
2507 fbconfig,
2508 pixmap,
2509 glx_pixmap,
2510 attribs: Cow::Owned(attribs),
2511 })
2512 }
2513 /// Clone all borrowed data in this CreatePixmapRequest.
into_owned(self) -> CreatePixmapRequest<'static>2514 pub fn into_owned(self) -> CreatePixmapRequest<'static> {
2515 CreatePixmapRequest {
2516 screen: self.screen,
2517 fbconfig: self.fbconfig,
2518 pixmap: self.pixmap,
2519 glx_pixmap: self.glx_pixmap,
2520 attribs: Cow::Owned(self.attribs.into_owned()),
2521 }
2522 }
2523 }
2524 impl<'input> Request for CreatePixmapRequest<'input> {
2525 type Reply = ();
2526 }
create_pixmap<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, pixmap: xproto::Pixmap, glx_pixmap: Pixmap, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2527 pub fn create_pixmap<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, pixmap: xproto::Pixmap, glx_pixmap: Pixmap, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
2528 where
2529 Conn: RequestConnection + ?Sized,
2530 {
2531 let request0 = CreatePixmapRequest {
2532 screen,
2533 fbconfig,
2534 pixmap,
2535 glx_pixmap,
2536 attribs: Cow::Borrowed(attribs),
2537 };
2538 request0.send(conn)
2539 }
2540
2541 /// Opcode for the DestroyPixmap request
2542 pub const DESTROY_PIXMAP_REQUEST: u8 = 23;
2543 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2544 pub struct DestroyPixmapRequest {
2545 pub glx_pixmap: Pixmap,
2546 }
2547 impl DestroyPixmapRequest {
2548 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2549 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2550 where
2551 Conn: RequestConnection + ?Sized,
2552 {
2553 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2554 .ok_or(ConnectionError::UnsupportedExtension)?;
2555 let length_so_far = 0;
2556 let glx_pixmap_bytes = self.glx_pixmap.serialize();
2557 let mut request0 = vec![
2558 extension_information.major_opcode,
2559 DESTROY_PIXMAP_REQUEST,
2560 0,
2561 0,
2562 glx_pixmap_bytes[0],
2563 glx_pixmap_bytes[1],
2564 glx_pixmap_bytes[2],
2565 glx_pixmap_bytes[3],
2566 ];
2567 let length_so_far = length_so_far + request0.len();
2568 assert_eq!(length_so_far % 4, 0);
2569 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2570 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2571 Ok((vec![request0.into()], vec![]))
2572 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2573 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2574 where
2575 Conn: RequestConnection + ?Sized,
2576 {
2577 let (bytes, fds) = self.serialize(conn)?;
2578 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2579 conn.send_request_without_reply(&slices, fds)
2580 }
2581 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2582 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2583 if header.minor_opcode != DESTROY_PIXMAP_REQUEST {
2584 return Err(ParseError::InvalidValue);
2585 }
2586 let (glx_pixmap, remaining) = Pixmap::try_parse(value)?;
2587 let _ = remaining;
2588 Ok(DestroyPixmapRequest {
2589 glx_pixmap,
2590 })
2591 }
2592 }
2593 impl Request for DestroyPixmapRequest {
2594 type Reply = ();
2595 }
destroy_pixmap<Conn>(conn: &Conn, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2596 pub fn destroy_pixmap<Conn>(conn: &Conn, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2597 where
2598 Conn: RequestConnection + ?Sized,
2599 {
2600 let request0 = DestroyPixmapRequest {
2601 glx_pixmap,
2602 };
2603 request0.send(conn)
2604 }
2605
2606 /// Opcode for the CreateNewContext request
2607 pub const CREATE_NEW_CONTEXT_REQUEST: u8 = 24;
2608 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2609 pub struct CreateNewContextRequest {
2610 pub context: Context,
2611 pub fbconfig: Fbconfig,
2612 pub screen: u32,
2613 pub render_type: u32,
2614 pub share_list: Context,
2615 pub is_direct: bool,
2616 }
2617 impl CreateNewContextRequest {
2618 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2619 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2620 where
2621 Conn: RequestConnection + ?Sized,
2622 {
2623 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2624 .ok_or(ConnectionError::UnsupportedExtension)?;
2625 let length_so_far = 0;
2626 let context_bytes = self.context.serialize();
2627 let fbconfig_bytes = self.fbconfig.serialize();
2628 let screen_bytes = self.screen.serialize();
2629 let render_type_bytes = self.render_type.serialize();
2630 let share_list_bytes = self.share_list.serialize();
2631 let is_direct_bytes = self.is_direct.serialize();
2632 let mut request0 = vec![
2633 extension_information.major_opcode,
2634 CREATE_NEW_CONTEXT_REQUEST,
2635 0,
2636 0,
2637 context_bytes[0],
2638 context_bytes[1],
2639 context_bytes[2],
2640 context_bytes[3],
2641 fbconfig_bytes[0],
2642 fbconfig_bytes[1],
2643 fbconfig_bytes[2],
2644 fbconfig_bytes[3],
2645 screen_bytes[0],
2646 screen_bytes[1],
2647 screen_bytes[2],
2648 screen_bytes[3],
2649 render_type_bytes[0],
2650 render_type_bytes[1],
2651 render_type_bytes[2],
2652 render_type_bytes[3],
2653 share_list_bytes[0],
2654 share_list_bytes[1],
2655 share_list_bytes[2],
2656 share_list_bytes[3],
2657 is_direct_bytes[0],
2658 0,
2659 0,
2660 0,
2661 ];
2662 let length_so_far = length_so_far + request0.len();
2663 assert_eq!(length_so_far % 4, 0);
2664 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2665 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2666 Ok((vec![request0.into()], vec![]))
2667 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2668 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2669 where
2670 Conn: RequestConnection + ?Sized,
2671 {
2672 let (bytes, fds) = self.serialize(conn)?;
2673 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2674 conn.send_request_without_reply(&slices, fds)
2675 }
2676 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2677 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2678 if header.minor_opcode != CREATE_NEW_CONTEXT_REQUEST {
2679 return Err(ParseError::InvalidValue);
2680 }
2681 let (context, remaining) = Context::try_parse(value)?;
2682 let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
2683 let (screen, remaining) = u32::try_parse(remaining)?;
2684 let (render_type, remaining) = u32::try_parse(remaining)?;
2685 let (share_list, remaining) = Context::try_parse(remaining)?;
2686 let (is_direct, remaining) = bool::try_parse(remaining)?;
2687 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2688 let _ = remaining;
2689 Ok(CreateNewContextRequest {
2690 context,
2691 fbconfig,
2692 screen,
2693 render_type,
2694 share_list,
2695 is_direct,
2696 })
2697 }
2698 }
2699 impl Request for CreateNewContextRequest {
2700 type Reply = ();
2701 }
create_new_context<Conn>(conn: &Conn, context: Context, fbconfig: Fbconfig, screen: u32, render_type: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2702 pub fn create_new_context<Conn>(conn: &Conn, context: Context, fbconfig: Fbconfig, screen: u32, render_type: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2703 where
2704 Conn: RequestConnection + ?Sized,
2705 {
2706 let request0 = CreateNewContextRequest {
2707 context,
2708 fbconfig,
2709 screen,
2710 render_type,
2711 share_list,
2712 is_direct,
2713 };
2714 request0.send(conn)
2715 }
2716
2717 /// Opcode for the QueryContext request
2718 pub const QUERY_CONTEXT_REQUEST: u8 = 25;
2719 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2720 pub struct QueryContextRequest {
2721 pub context: Context,
2722 }
2723 impl QueryContextRequest {
2724 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2725 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2726 where
2727 Conn: RequestConnection + ?Sized,
2728 {
2729 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2730 .ok_or(ConnectionError::UnsupportedExtension)?;
2731 let length_so_far = 0;
2732 let context_bytes = self.context.serialize();
2733 let mut request0 = vec![
2734 extension_information.major_opcode,
2735 QUERY_CONTEXT_REQUEST,
2736 0,
2737 0,
2738 context_bytes[0],
2739 context_bytes[1],
2740 context_bytes[2],
2741 context_bytes[3],
2742 ];
2743 let length_so_far = length_so_far + request0.len();
2744 assert_eq!(length_so_far % 4, 0);
2745 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2746 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2747 Ok((vec![request0.into()], vec![]))
2748 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2749 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryContextReply>, ConnectionError>
2750 where
2751 Conn: RequestConnection + ?Sized,
2752 {
2753 let (bytes, fds) = self.serialize(conn)?;
2754 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2755 conn.send_request_with_reply(&slices, fds)
2756 }
2757 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2758 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2759 if header.minor_opcode != QUERY_CONTEXT_REQUEST {
2760 return Err(ParseError::InvalidValue);
2761 }
2762 let (context, remaining) = Context::try_parse(value)?;
2763 let _ = remaining;
2764 Ok(QueryContextRequest {
2765 context,
2766 })
2767 }
2768 }
2769 impl Request for QueryContextRequest {
2770 type Reply = QueryContextReply;
2771 }
query_context<Conn>(conn: &Conn, context: Context) -> Result<Cookie<'_, Conn, QueryContextReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2772 pub fn query_context<Conn>(conn: &Conn, context: Context) -> Result<Cookie<'_, Conn, QueryContextReply>, ConnectionError>
2773 where
2774 Conn: RequestConnection + ?Sized,
2775 {
2776 let request0 = QueryContextRequest {
2777 context,
2778 };
2779 request0.send(conn)
2780 }
2781
2782 #[derive(Debug, Clone, PartialEq, Eq)]
2783 pub struct QueryContextReply {
2784 pub sequence: u16,
2785 pub length: u32,
2786 pub attribs: Vec<u32>,
2787 }
2788 impl TryParse for QueryContextReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2789 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2790 let remaining = initial_value;
2791 let (response_type, remaining) = u8::try_parse(remaining)?;
2792 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2793 let (sequence, remaining) = u16::try_parse(remaining)?;
2794 let (length, remaining) = u32::try_parse(remaining)?;
2795 let (num_attribs, remaining) = u32::try_parse(remaining)?;
2796 let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2797 let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_attribs.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
2798 if response_type != 1 {
2799 return Err(ParseError::InvalidValue);
2800 }
2801 let result = QueryContextReply { sequence, length, attribs };
2802 let _ = remaining;
2803 let remaining = initial_value.get(32 + length as usize * 4..)
2804 .ok_or(ParseError::InsufficientData)?;
2805 Ok((result, remaining))
2806 }
2807 }
2808 impl QueryContextReply {
2809 /// Get the value of the `num_attribs` field.
2810 ///
2811 /// The `num_attribs` field is used as the length field of the `attribs` field.
2812 /// This function computes the field's value again based on the length of the list.
2813 ///
2814 /// # Panics
2815 ///
2816 /// Panics if the value cannot be represented in the target type. This
2817 /// cannot happen with values of the struct received from the X11 server.
num_attribs(&self) -> u322818 pub fn num_attribs(&self) -> u32 {
2819 self.attribs.len()
2820 .checked_div(2).unwrap()
2821 .try_into().unwrap()
2822 }
2823 }
2824
2825 /// Opcode for the MakeContextCurrent request
2826 pub const MAKE_CONTEXT_CURRENT_REQUEST: u8 = 26;
2827 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2828 pub struct MakeContextCurrentRequest {
2829 pub old_context_tag: ContextTag,
2830 pub drawable: Drawable,
2831 pub read_drawable: Drawable,
2832 pub context: Context,
2833 }
2834 impl MakeContextCurrentRequest {
2835 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2836 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2837 where
2838 Conn: RequestConnection + ?Sized,
2839 {
2840 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2841 .ok_or(ConnectionError::UnsupportedExtension)?;
2842 let length_so_far = 0;
2843 let old_context_tag_bytes = self.old_context_tag.serialize();
2844 let drawable_bytes = self.drawable.serialize();
2845 let read_drawable_bytes = self.read_drawable.serialize();
2846 let context_bytes = self.context.serialize();
2847 let mut request0 = vec![
2848 extension_information.major_opcode,
2849 MAKE_CONTEXT_CURRENT_REQUEST,
2850 0,
2851 0,
2852 old_context_tag_bytes[0],
2853 old_context_tag_bytes[1],
2854 old_context_tag_bytes[2],
2855 old_context_tag_bytes[3],
2856 drawable_bytes[0],
2857 drawable_bytes[1],
2858 drawable_bytes[2],
2859 drawable_bytes[3],
2860 read_drawable_bytes[0],
2861 read_drawable_bytes[1],
2862 read_drawable_bytes[2],
2863 read_drawable_bytes[3],
2864 context_bytes[0],
2865 context_bytes[1],
2866 context_bytes[2],
2867 context_bytes[3],
2868 ];
2869 let length_so_far = length_so_far + request0.len();
2870 assert_eq!(length_so_far % 4, 0);
2871 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2872 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2873 Ok((vec![request0.into()], vec![]))
2874 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, MakeContextCurrentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2875 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, MakeContextCurrentReply>, ConnectionError>
2876 where
2877 Conn: RequestConnection + ?Sized,
2878 {
2879 let (bytes, fds) = self.serialize(conn)?;
2880 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2881 conn.send_request_with_reply(&slices, fds)
2882 }
2883 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>2884 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2885 if header.minor_opcode != MAKE_CONTEXT_CURRENT_REQUEST {
2886 return Err(ParseError::InvalidValue);
2887 }
2888 let (old_context_tag, remaining) = ContextTag::try_parse(value)?;
2889 let (drawable, remaining) = Drawable::try_parse(remaining)?;
2890 let (read_drawable, remaining) = Drawable::try_parse(remaining)?;
2891 let (context, remaining) = Context::try_parse(remaining)?;
2892 let _ = remaining;
2893 Ok(MakeContextCurrentRequest {
2894 old_context_tag,
2895 drawable,
2896 read_drawable,
2897 context,
2898 })
2899 }
2900 }
2901 impl Request for MakeContextCurrentRequest {
2902 type Reply = MakeContextCurrentReply;
2903 }
make_context_current<Conn>(conn: &Conn, old_context_tag: ContextTag, drawable: Drawable, read_drawable: Drawable, context: Context) -> Result<Cookie<'_, Conn, MakeContextCurrentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2904 pub fn make_context_current<Conn>(conn: &Conn, old_context_tag: ContextTag, drawable: Drawable, read_drawable: Drawable, context: Context) -> Result<Cookie<'_, Conn, MakeContextCurrentReply>, ConnectionError>
2905 where
2906 Conn: RequestConnection + ?Sized,
2907 {
2908 let request0 = MakeContextCurrentRequest {
2909 old_context_tag,
2910 drawable,
2911 read_drawable,
2912 context,
2913 };
2914 request0.send(conn)
2915 }
2916
2917 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2918 pub struct MakeContextCurrentReply {
2919 pub sequence: u16,
2920 pub length: u32,
2921 pub context_tag: ContextTag,
2922 }
2923 impl TryParse for MakeContextCurrentReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2924 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2925 let remaining = initial_value;
2926 let (response_type, remaining) = u8::try_parse(remaining)?;
2927 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2928 let (sequence, remaining) = u16::try_parse(remaining)?;
2929 let (length, remaining) = u32::try_parse(remaining)?;
2930 let (context_tag, remaining) = ContextTag::try_parse(remaining)?;
2931 let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2932 if response_type != 1 {
2933 return Err(ParseError::InvalidValue);
2934 }
2935 let result = MakeContextCurrentReply { sequence, length, context_tag };
2936 let _ = remaining;
2937 let remaining = initial_value.get(32 + length as usize * 4..)
2938 .ok_or(ParseError::InsufficientData)?;
2939 Ok((result, remaining))
2940 }
2941 }
2942
2943 /// Opcode for the CreatePbuffer request
2944 pub const CREATE_PBUFFER_REQUEST: u8 = 27;
2945 #[derive(Debug, Clone, PartialEq, Eq)]
2946 pub struct CreatePbufferRequest<'input> {
2947 pub screen: u32,
2948 pub fbconfig: Fbconfig,
2949 pub pbuffer: Pbuffer,
2950 pub attribs: Cow<'input, [u32]>,
2951 }
2952 impl<'input> CreatePbufferRequest<'input> {
2953 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2954 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2955 where
2956 Conn: RequestConnection + ?Sized,
2957 {
2958 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2959 .ok_or(ConnectionError::UnsupportedExtension)?;
2960 let length_so_far = 0;
2961 let screen_bytes = self.screen.serialize();
2962 let fbconfig_bytes = self.fbconfig.serialize();
2963 let pbuffer_bytes = self.pbuffer.serialize();
2964 assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
2965 let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
2966 let num_attribs_bytes = num_attribs.serialize();
2967 let mut request0 = vec![
2968 extension_information.major_opcode,
2969 CREATE_PBUFFER_REQUEST,
2970 0,
2971 0,
2972 screen_bytes[0],
2973 screen_bytes[1],
2974 screen_bytes[2],
2975 screen_bytes[3],
2976 fbconfig_bytes[0],
2977 fbconfig_bytes[1],
2978 fbconfig_bytes[2],
2979 fbconfig_bytes[3],
2980 pbuffer_bytes[0],
2981 pbuffer_bytes[1],
2982 pbuffer_bytes[2],
2983 pbuffer_bytes[3],
2984 num_attribs_bytes[0],
2985 num_attribs_bytes[1],
2986 num_attribs_bytes[2],
2987 num_attribs_bytes[3],
2988 ];
2989 let length_so_far = length_so_far + request0.len();
2990 let attribs_bytes = self.attribs.serialize();
2991 let length_so_far = length_so_far + attribs_bytes.len();
2992 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
2993 let length_so_far = length_so_far + padding0.len();
2994 assert_eq!(length_so_far % 4, 0);
2995 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2996 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2997 Ok((vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]))
2998 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2999 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3000 where
3001 Conn: RequestConnection + ?Sized,
3002 {
3003 let (bytes, fds) = self.serialize(conn)?;
3004 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3005 conn.send_request_without_reply(&slices, fds)
3006 }
3007 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>3008 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3009 if header.minor_opcode != CREATE_PBUFFER_REQUEST {
3010 return Err(ParseError::InvalidValue);
3011 }
3012 let (screen, remaining) = u32::try_parse(value)?;
3013 let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
3014 let (pbuffer, remaining) = Pbuffer::try_parse(remaining)?;
3015 let (num_attribs, remaining) = u32::try_parse(remaining)?;
3016 let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_attribs.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3017 let _ = remaining;
3018 Ok(CreatePbufferRequest {
3019 screen,
3020 fbconfig,
3021 pbuffer,
3022 attribs: Cow::Owned(attribs),
3023 })
3024 }
3025 /// Clone all borrowed data in this CreatePbufferRequest.
into_owned(self) -> CreatePbufferRequest<'static>3026 pub fn into_owned(self) -> CreatePbufferRequest<'static> {
3027 CreatePbufferRequest {
3028 screen: self.screen,
3029 fbconfig: self.fbconfig,
3030 pbuffer: self.pbuffer,
3031 attribs: Cow::Owned(self.attribs.into_owned()),
3032 }
3033 }
3034 }
3035 impl<'input> Request for CreatePbufferRequest<'input> {
3036 type Reply = ();
3037 }
create_pbuffer<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, pbuffer: Pbuffer, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3038 pub fn create_pbuffer<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, pbuffer: Pbuffer, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3039 where
3040 Conn: RequestConnection + ?Sized,
3041 {
3042 let request0 = CreatePbufferRequest {
3043 screen,
3044 fbconfig,
3045 pbuffer,
3046 attribs: Cow::Borrowed(attribs),
3047 };
3048 request0.send(conn)
3049 }
3050
3051 /// Opcode for the DestroyPbuffer request
3052 pub const DESTROY_PBUFFER_REQUEST: u8 = 28;
3053 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3054 pub struct DestroyPbufferRequest {
3055 pub pbuffer: Pbuffer,
3056 }
3057 impl DestroyPbufferRequest {
3058 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3059 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3060 where
3061 Conn: RequestConnection + ?Sized,
3062 {
3063 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3064 .ok_or(ConnectionError::UnsupportedExtension)?;
3065 let length_so_far = 0;
3066 let pbuffer_bytes = self.pbuffer.serialize();
3067 let mut request0 = vec![
3068 extension_information.major_opcode,
3069 DESTROY_PBUFFER_REQUEST,
3070 0,
3071 0,
3072 pbuffer_bytes[0],
3073 pbuffer_bytes[1],
3074 pbuffer_bytes[2],
3075 pbuffer_bytes[3],
3076 ];
3077 let length_so_far = length_so_far + request0.len();
3078 assert_eq!(length_so_far % 4, 0);
3079 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3080 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3081 Ok((vec![request0.into()], vec![]))
3082 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3083 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3084 where
3085 Conn: RequestConnection + ?Sized,
3086 {
3087 let (bytes, fds) = self.serialize(conn)?;
3088 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3089 conn.send_request_without_reply(&slices, fds)
3090 }
3091 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>3092 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3093 if header.minor_opcode != DESTROY_PBUFFER_REQUEST {
3094 return Err(ParseError::InvalidValue);
3095 }
3096 let (pbuffer, remaining) = Pbuffer::try_parse(value)?;
3097 let _ = remaining;
3098 Ok(DestroyPbufferRequest {
3099 pbuffer,
3100 })
3101 }
3102 }
3103 impl Request for DestroyPbufferRequest {
3104 type Reply = ();
3105 }
destroy_pbuffer<Conn>(conn: &Conn, pbuffer: Pbuffer) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3106 pub fn destroy_pbuffer<Conn>(conn: &Conn, pbuffer: Pbuffer) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3107 where
3108 Conn: RequestConnection + ?Sized,
3109 {
3110 let request0 = DestroyPbufferRequest {
3111 pbuffer,
3112 };
3113 request0.send(conn)
3114 }
3115
3116 /// Opcode for the GetDrawableAttributes request
3117 pub const GET_DRAWABLE_ATTRIBUTES_REQUEST: u8 = 29;
3118 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3119 pub struct GetDrawableAttributesRequest {
3120 pub drawable: Drawable,
3121 }
3122 impl GetDrawableAttributesRequest {
3123 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3124 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3125 where
3126 Conn: RequestConnection + ?Sized,
3127 {
3128 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3129 .ok_or(ConnectionError::UnsupportedExtension)?;
3130 let length_so_far = 0;
3131 let drawable_bytes = self.drawable.serialize();
3132 let mut request0 = vec![
3133 extension_information.major_opcode,
3134 GET_DRAWABLE_ATTRIBUTES_REQUEST,
3135 0,
3136 0,
3137 drawable_bytes[0],
3138 drawable_bytes[1],
3139 drawable_bytes[2],
3140 drawable_bytes[3],
3141 ];
3142 let length_so_far = length_so_far + request0.len();
3143 assert_eq!(length_so_far % 4, 0);
3144 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3145 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3146 Ok((vec![request0.into()], vec![]))
3147 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDrawableAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,3148 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDrawableAttributesReply>, ConnectionError>
3149 where
3150 Conn: RequestConnection + ?Sized,
3151 {
3152 let (bytes, fds) = self.serialize(conn)?;
3153 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3154 conn.send_request_with_reply(&slices, fds)
3155 }
3156 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>3157 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3158 if header.minor_opcode != GET_DRAWABLE_ATTRIBUTES_REQUEST {
3159 return Err(ParseError::InvalidValue);
3160 }
3161 let (drawable, remaining) = Drawable::try_parse(value)?;
3162 let _ = remaining;
3163 Ok(GetDrawableAttributesRequest {
3164 drawable,
3165 })
3166 }
3167 }
3168 impl Request for GetDrawableAttributesRequest {
3169 type Reply = GetDrawableAttributesReply;
3170 }
get_drawable_attributes<Conn>(conn: &Conn, drawable: Drawable) -> Result<Cookie<'_, Conn, GetDrawableAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,3171 pub fn get_drawable_attributes<Conn>(conn: &Conn, drawable: Drawable) -> Result<Cookie<'_, Conn, GetDrawableAttributesReply>, ConnectionError>
3172 where
3173 Conn: RequestConnection + ?Sized,
3174 {
3175 let request0 = GetDrawableAttributesRequest {
3176 drawable,
3177 };
3178 request0.send(conn)
3179 }
3180
3181 #[derive(Debug, Clone, PartialEq, Eq)]
3182 pub struct GetDrawableAttributesReply {
3183 pub sequence: u16,
3184 pub length: u32,
3185 pub attribs: Vec<u32>,
3186 }
3187 impl TryParse for GetDrawableAttributesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>3188 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
3189 let remaining = initial_value;
3190 let (response_type, remaining) = u8::try_parse(remaining)?;
3191 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
3192 let (sequence, remaining) = u16::try_parse(remaining)?;
3193 let (length, remaining) = u32::try_parse(remaining)?;
3194 let (num_attribs, remaining) = u32::try_parse(remaining)?;
3195 let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
3196 let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_attribs.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3197 if response_type != 1 {
3198 return Err(ParseError::InvalidValue);
3199 }
3200 let result = GetDrawableAttributesReply { sequence, length, attribs };
3201 let _ = remaining;
3202 let remaining = initial_value.get(32 + length as usize * 4..)
3203 .ok_or(ParseError::InsufficientData)?;
3204 Ok((result, remaining))
3205 }
3206 }
3207 impl GetDrawableAttributesReply {
3208 /// Get the value of the `num_attribs` field.
3209 ///
3210 /// The `num_attribs` field is used as the length field of the `attribs` field.
3211 /// This function computes the field's value again based on the length of the list.
3212 ///
3213 /// # Panics
3214 ///
3215 /// Panics if the value cannot be represented in the target type. This
3216 /// cannot happen with values of the struct received from the X11 server.
num_attribs(&self) -> u323217 pub fn num_attribs(&self) -> u32 {
3218 self.attribs.len()
3219 .checked_div(2).unwrap()
3220 .try_into().unwrap()
3221 }
3222 }
3223
3224 /// Opcode for the ChangeDrawableAttributes request
3225 pub const CHANGE_DRAWABLE_ATTRIBUTES_REQUEST: u8 = 30;
3226 #[derive(Debug, Clone, PartialEq, Eq)]
3227 pub struct ChangeDrawableAttributesRequest<'input> {
3228 pub drawable: Drawable,
3229 pub attribs: Cow<'input, [u32]>,
3230 }
3231 impl<'input> ChangeDrawableAttributesRequest<'input> {
3232 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3233 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3234 where
3235 Conn: RequestConnection + ?Sized,
3236 {
3237 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3238 .ok_or(ConnectionError::UnsupportedExtension)?;
3239 let length_so_far = 0;
3240 let drawable_bytes = self.drawable.serialize();
3241 assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3242 let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3243 let num_attribs_bytes = num_attribs.serialize();
3244 let mut request0 = vec![
3245 extension_information.major_opcode,
3246 CHANGE_DRAWABLE_ATTRIBUTES_REQUEST,
3247 0,
3248 0,
3249 drawable_bytes[0],
3250 drawable_bytes[1],
3251 drawable_bytes[2],
3252 drawable_bytes[3],
3253 num_attribs_bytes[0],
3254 num_attribs_bytes[1],
3255 num_attribs_bytes[2],
3256 num_attribs_bytes[3],
3257 ];
3258 let length_so_far = length_so_far + request0.len();
3259 let attribs_bytes = self.attribs.serialize();
3260 let length_so_far = length_so_far + attribs_bytes.len();
3261 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3262 let length_so_far = length_so_far + padding0.len();
3263 assert_eq!(length_so_far % 4, 0);
3264 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3265 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3266 Ok((vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]))
3267 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3268 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3269 where
3270 Conn: RequestConnection + ?Sized,
3271 {
3272 let (bytes, fds) = self.serialize(conn)?;
3273 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3274 conn.send_request_without_reply(&slices, fds)
3275 }
3276 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>3277 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3278 if header.minor_opcode != CHANGE_DRAWABLE_ATTRIBUTES_REQUEST {
3279 return Err(ParseError::InvalidValue);
3280 }
3281 let (drawable, remaining) = Drawable::try_parse(value)?;
3282 let (num_attribs, remaining) = u32::try_parse(remaining)?;
3283 let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_attribs.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3284 let _ = remaining;
3285 Ok(ChangeDrawableAttributesRequest {
3286 drawable,
3287 attribs: Cow::Owned(attribs),
3288 })
3289 }
3290 /// Clone all borrowed data in this ChangeDrawableAttributesRequest.
into_owned(self) -> ChangeDrawableAttributesRequest<'static>3291 pub fn into_owned(self) -> ChangeDrawableAttributesRequest<'static> {
3292 ChangeDrawableAttributesRequest {
3293 drawable: self.drawable,
3294 attribs: Cow::Owned(self.attribs.into_owned()),
3295 }
3296 }
3297 }
3298 impl<'input> Request for ChangeDrawableAttributesRequest<'input> {
3299 type Reply = ();
3300 }
change_drawable_attributes<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3301 pub fn change_drawable_attributes<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3302 where
3303 Conn: RequestConnection + ?Sized,
3304 {
3305 let request0 = ChangeDrawableAttributesRequest {
3306 drawable,
3307 attribs: Cow::Borrowed(attribs),
3308 };
3309 request0.send(conn)
3310 }
3311
3312 /// Opcode for the CreateWindow request
3313 pub const CREATE_WINDOW_REQUEST: u8 = 31;
3314 #[derive(Debug, Clone, PartialEq, Eq)]
3315 pub struct CreateWindowRequest<'input> {
3316 pub screen: u32,
3317 pub fbconfig: Fbconfig,
3318 pub window: xproto::Window,
3319 pub glx_window: Window,
3320 pub attribs: Cow<'input, [u32]>,
3321 }
3322 impl<'input> CreateWindowRequest<'input> {
3323 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3324 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3325 where
3326 Conn: RequestConnection + ?Sized,
3327 {
3328 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3329 .ok_or(ConnectionError::UnsupportedExtension)?;
3330 let length_so_far = 0;
3331 let screen_bytes = self.screen.serialize();
3332 let fbconfig_bytes = self.fbconfig.serialize();
3333 let window_bytes = self.window.serialize();
3334 let glx_window_bytes = self.glx_window.serialize();
3335 assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3336 let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3337 let num_attribs_bytes = num_attribs.serialize();
3338 let mut request0 = vec![
3339 extension_information.major_opcode,
3340 CREATE_WINDOW_REQUEST,
3341 0,
3342 0,
3343 screen_bytes[0],
3344 screen_bytes[1],
3345 screen_bytes[2],
3346 screen_bytes[3],
3347 fbconfig_bytes[0],
3348 fbconfig_bytes[1],
3349 fbconfig_bytes[2],
3350 fbconfig_bytes[3],
3351 window_bytes[0],
3352 window_bytes[1],
3353 window_bytes[2],
3354 window_bytes[3],
3355 glx_window_bytes[0],
3356 glx_window_bytes[1],
3357 glx_window_bytes[2],
3358 glx_window_bytes[3],
3359 num_attribs_bytes[0],
3360 num_attribs_bytes[1],
3361 num_attribs_bytes[2],
3362 num_attribs_bytes[3],
3363 ];
3364 let length_so_far = length_so_far + request0.len();
3365 let attribs_bytes = self.attribs.serialize();
3366 let length_so_far = length_so_far + attribs_bytes.len();
3367 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3368 let length_so_far = length_so_far + padding0.len();
3369 assert_eq!(length_so_far % 4, 0);
3370 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3371 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3372 Ok((vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]))
3373 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3374 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3375 where
3376 Conn: RequestConnection + ?Sized,
3377 {
3378 let (bytes, fds) = self.serialize(conn)?;
3379 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3380 conn.send_request_without_reply(&slices, fds)
3381 }
3382 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>3383 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3384 if header.minor_opcode != CREATE_WINDOW_REQUEST {
3385 return Err(ParseError::InvalidValue);
3386 }
3387 let (screen, remaining) = u32::try_parse(value)?;
3388 let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
3389 let (window, remaining) = xproto::Window::try_parse(remaining)?;
3390 let (glx_window, remaining) = Window::try_parse(remaining)?;
3391 let (num_attribs, remaining) = u32::try_parse(remaining)?;
3392 let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_attribs.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3393 let _ = remaining;
3394 Ok(CreateWindowRequest {
3395 screen,
3396 fbconfig,
3397 window,
3398 glx_window,
3399 attribs: Cow::Owned(attribs),
3400 })
3401 }
3402 /// Clone all borrowed data in this CreateWindowRequest.
into_owned(self) -> CreateWindowRequest<'static>3403 pub fn into_owned(self) -> CreateWindowRequest<'static> {
3404 CreateWindowRequest {
3405 screen: self.screen,
3406 fbconfig: self.fbconfig,
3407 window: self.window,
3408 glx_window: self.glx_window,
3409 attribs: Cow::Owned(self.attribs.into_owned()),
3410 }
3411 }
3412 }
3413 impl<'input> Request for CreateWindowRequest<'input> {
3414 type Reply = ();
3415 }
create_window<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, window: xproto::Window, glx_window: Window, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3416 pub fn create_window<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, window: xproto::Window, glx_window: Window, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3417 where
3418 Conn: RequestConnection + ?Sized,
3419 {
3420 let request0 = CreateWindowRequest {
3421 screen,
3422 fbconfig,
3423 window,
3424 glx_window,
3425 attribs: Cow::Borrowed(attribs),
3426 };
3427 request0.send(conn)
3428 }
3429
3430 /// Opcode for the DeleteWindow request
3431 pub const DELETE_WINDOW_REQUEST: u8 = 32;
3432 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3433 pub struct DeleteWindowRequest {
3434 pub glxwindow: Window,
3435 }
3436 impl DeleteWindowRequest {
3437 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3438 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3439 where
3440 Conn: RequestConnection + ?Sized,
3441 {
3442 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3443 .ok_or(ConnectionError::UnsupportedExtension)?;
3444 let length_so_far = 0;
3445 let glxwindow_bytes = self.glxwindow.serialize();
3446 let mut request0 = vec![
3447 extension_information.major_opcode,
3448 DELETE_WINDOW_REQUEST,
3449 0,
3450 0,
3451 glxwindow_bytes[0],
3452 glxwindow_bytes[1],
3453 glxwindow_bytes[2],
3454 glxwindow_bytes[3],
3455 ];
3456 let length_so_far = length_so_far + request0.len();
3457 assert_eq!(length_so_far % 4, 0);
3458 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3459 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3460 Ok((vec![request0.into()], vec![]))
3461 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3462 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3463 where
3464 Conn: RequestConnection + ?Sized,
3465 {
3466 let (bytes, fds) = self.serialize(conn)?;
3467 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3468 conn.send_request_without_reply(&slices, fds)
3469 }
3470 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>3471 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3472 if header.minor_opcode != DELETE_WINDOW_REQUEST {
3473 return Err(ParseError::InvalidValue);
3474 }
3475 let (glxwindow, remaining) = Window::try_parse(value)?;
3476 let _ = remaining;
3477 Ok(DeleteWindowRequest {
3478 glxwindow,
3479 })
3480 }
3481 }
3482 impl Request for DeleteWindowRequest {
3483 type Reply = ();
3484 }
delete_window<Conn>(conn: &Conn, glxwindow: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3485 pub fn delete_window<Conn>(conn: &Conn, glxwindow: Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3486 where
3487 Conn: RequestConnection + ?Sized,
3488 {
3489 let request0 = DeleteWindowRequest {
3490 glxwindow,
3491 };
3492 request0.send(conn)
3493 }
3494
3495 /// Opcode for the SetClientInfoARB request
3496 pub const SET_CLIENT_INFO_ARB_REQUEST: u8 = 33;
3497 #[derive(Debug, Clone, PartialEq, Eq)]
3498 pub struct SetClientInfoARBRequest<'input> {
3499 pub major_version: u32,
3500 pub minor_version: u32,
3501 pub gl_versions: Cow<'input, [u32]>,
3502 pub gl_extension_string: Cow<'input, [u8]>,
3503 pub glx_extension_string: Cow<'input, [u8]>,
3504 }
3505 impl<'input> SetClientInfoARBRequest<'input> {
3506 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3507 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3508 where
3509 Conn: RequestConnection + ?Sized,
3510 {
3511 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3512 .ok_or(ConnectionError::UnsupportedExtension)?;
3513 let length_so_far = 0;
3514 let major_version_bytes = self.major_version.serialize();
3515 let minor_version_bytes = self.minor_version.serialize();
3516 assert_eq!(self.gl_versions.len() % 2, 0, "`gl_versions` has an incorrect length, must be a multiple of 2");
3517 let num_versions = u32::try_from(self.gl_versions.len() / 2).expect("`gl_versions` has too many elements");
3518 let num_versions_bytes = num_versions.serialize();
3519 let gl_str_len = u32::try_from(self.gl_extension_string.len()).expect("`gl_extension_string` has too many elements");
3520 let gl_str_len_bytes = gl_str_len.serialize();
3521 let glx_str_len = u32::try_from(self.glx_extension_string.len()).expect("`glx_extension_string` has too many elements");
3522 let glx_str_len_bytes = glx_str_len.serialize();
3523 let mut request0 = vec![
3524 extension_information.major_opcode,
3525 SET_CLIENT_INFO_ARB_REQUEST,
3526 0,
3527 0,
3528 major_version_bytes[0],
3529 major_version_bytes[1],
3530 major_version_bytes[2],
3531 major_version_bytes[3],
3532 minor_version_bytes[0],
3533 minor_version_bytes[1],
3534 minor_version_bytes[2],
3535 minor_version_bytes[3],
3536 num_versions_bytes[0],
3537 num_versions_bytes[1],
3538 num_versions_bytes[2],
3539 num_versions_bytes[3],
3540 gl_str_len_bytes[0],
3541 gl_str_len_bytes[1],
3542 gl_str_len_bytes[2],
3543 gl_str_len_bytes[3],
3544 glx_str_len_bytes[0],
3545 glx_str_len_bytes[1],
3546 glx_str_len_bytes[2],
3547 glx_str_len_bytes[3],
3548 ];
3549 let length_so_far = length_so_far + request0.len();
3550 let gl_versions_bytes = self.gl_versions.serialize();
3551 let length_so_far = length_so_far + gl_versions_bytes.len();
3552 let length_so_far = length_so_far + self.gl_extension_string.len();
3553 let length_so_far = length_so_far + self.glx_extension_string.len();
3554 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3555 let length_so_far = length_so_far + padding0.len();
3556 assert_eq!(length_so_far % 4, 0);
3557 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3558 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3559 Ok((vec![request0.into(), gl_versions_bytes.into(), self.gl_extension_string, self.glx_extension_string, padding0.into()], vec![]))
3560 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3561 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3562 where
3563 Conn: RequestConnection + ?Sized,
3564 {
3565 let (bytes, fds) = self.serialize(conn)?;
3566 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3567 conn.send_request_without_reply(&slices, fds)
3568 }
3569 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>3570 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3571 if header.minor_opcode != SET_CLIENT_INFO_ARB_REQUEST {
3572 return Err(ParseError::InvalidValue);
3573 }
3574 let (major_version, remaining) = u32::try_parse(value)?;
3575 let (minor_version, remaining) = u32::try_parse(remaining)?;
3576 let (num_versions, remaining) = u32::try_parse(remaining)?;
3577 let (gl_str_len, remaining) = u32::try_parse(remaining)?;
3578 let (glx_str_len, remaining) = u32::try_parse(remaining)?;
3579 let (gl_versions, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_versions.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3580 let (gl_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, gl_str_len.try_to_usize()?)?;
3581 let (glx_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, glx_str_len.try_to_usize()?)?;
3582 let _ = remaining;
3583 Ok(SetClientInfoARBRequest {
3584 major_version,
3585 minor_version,
3586 gl_versions: Cow::Owned(gl_versions),
3587 gl_extension_string: Cow::Borrowed(gl_extension_string),
3588 glx_extension_string: Cow::Borrowed(glx_extension_string),
3589 })
3590 }
3591 /// Clone all borrowed data in this SetClientInfoARBRequest.
into_owned(self) -> SetClientInfoARBRequest<'static>3592 pub fn into_owned(self) -> SetClientInfoARBRequest<'static> {
3593 SetClientInfoARBRequest {
3594 major_version: self.major_version,
3595 minor_version: self.minor_version,
3596 gl_versions: Cow::Owned(self.gl_versions.into_owned()),
3597 gl_extension_string: Cow::Owned(self.gl_extension_string.into_owned()),
3598 glx_extension_string: Cow::Owned(self.glx_extension_string.into_owned()),
3599 }
3600 }
3601 }
3602 impl<'input> Request for SetClientInfoARBRequest<'input> {
3603 type Reply = ();
3604 }
set_client_info_arb<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3605 pub fn set_client_info_arb<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3606 where
3607 Conn: RequestConnection + ?Sized,
3608 {
3609 let request0 = SetClientInfoARBRequest {
3610 major_version,
3611 minor_version,
3612 gl_versions: Cow::Borrowed(gl_versions),
3613 gl_extension_string: Cow::Borrowed(gl_extension_string),
3614 glx_extension_string: Cow::Borrowed(glx_extension_string),
3615 };
3616 request0.send(conn)
3617 }
3618
3619 /// Opcode for the CreateContextAttribsARB request
3620 pub const CREATE_CONTEXT_ATTRIBS_ARB_REQUEST: u8 = 34;
3621 #[derive(Debug, Clone, PartialEq, Eq)]
3622 pub struct CreateContextAttribsARBRequest<'input> {
3623 pub context: Context,
3624 pub fbconfig: Fbconfig,
3625 pub screen: u32,
3626 pub share_list: Context,
3627 pub is_direct: bool,
3628 pub attribs: Cow<'input, [u32]>,
3629 }
3630 impl<'input> CreateContextAttribsARBRequest<'input> {
3631 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3632 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3633 where
3634 Conn: RequestConnection + ?Sized,
3635 {
3636 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3637 .ok_or(ConnectionError::UnsupportedExtension)?;
3638 let length_so_far = 0;
3639 let context_bytes = self.context.serialize();
3640 let fbconfig_bytes = self.fbconfig.serialize();
3641 let screen_bytes = self.screen.serialize();
3642 let share_list_bytes = self.share_list.serialize();
3643 let is_direct_bytes = self.is_direct.serialize();
3644 assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2");
3645 let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements");
3646 let num_attribs_bytes = num_attribs.serialize();
3647 let mut request0 = vec![
3648 extension_information.major_opcode,
3649 CREATE_CONTEXT_ATTRIBS_ARB_REQUEST,
3650 0,
3651 0,
3652 context_bytes[0],
3653 context_bytes[1],
3654 context_bytes[2],
3655 context_bytes[3],
3656 fbconfig_bytes[0],
3657 fbconfig_bytes[1],
3658 fbconfig_bytes[2],
3659 fbconfig_bytes[3],
3660 screen_bytes[0],
3661 screen_bytes[1],
3662 screen_bytes[2],
3663 screen_bytes[3],
3664 share_list_bytes[0],
3665 share_list_bytes[1],
3666 share_list_bytes[2],
3667 share_list_bytes[3],
3668 is_direct_bytes[0],
3669 0,
3670 0,
3671 0,
3672 num_attribs_bytes[0],
3673 num_attribs_bytes[1],
3674 num_attribs_bytes[2],
3675 num_attribs_bytes[3],
3676 ];
3677 let length_so_far = length_so_far + request0.len();
3678 let attribs_bytes = self.attribs.serialize();
3679 let length_so_far = length_so_far + attribs_bytes.len();
3680 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3681 let length_so_far = length_so_far + padding0.len();
3682 assert_eq!(length_so_far % 4, 0);
3683 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3684 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3685 Ok((vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]))
3686 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3687 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3688 where
3689 Conn: RequestConnection + ?Sized,
3690 {
3691 let (bytes, fds) = self.serialize(conn)?;
3692 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3693 conn.send_request_without_reply(&slices, fds)
3694 }
3695 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>3696 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3697 if header.minor_opcode != CREATE_CONTEXT_ATTRIBS_ARB_REQUEST {
3698 return Err(ParseError::InvalidValue);
3699 }
3700 let (context, remaining) = Context::try_parse(value)?;
3701 let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?;
3702 let (screen, remaining) = u32::try_parse(remaining)?;
3703 let (share_list, remaining) = Context::try_parse(remaining)?;
3704 let (is_direct, remaining) = bool::try_parse(remaining)?;
3705 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
3706 let (num_attribs, remaining) = u32::try_parse(remaining)?;
3707 let (attribs, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_attribs.checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3708 let _ = remaining;
3709 Ok(CreateContextAttribsARBRequest {
3710 context,
3711 fbconfig,
3712 screen,
3713 share_list,
3714 is_direct,
3715 attribs: Cow::Owned(attribs),
3716 })
3717 }
3718 /// Clone all borrowed data in this CreateContextAttribsARBRequest.
into_owned(self) -> CreateContextAttribsARBRequest<'static>3719 pub fn into_owned(self) -> CreateContextAttribsARBRequest<'static> {
3720 CreateContextAttribsARBRequest {
3721 context: self.context,
3722 fbconfig: self.fbconfig,
3723 screen: self.screen,
3724 share_list: self.share_list,
3725 is_direct: self.is_direct,
3726 attribs: Cow::Owned(self.attribs.into_owned()),
3727 }
3728 }
3729 }
3730 impl<'input> Request for CreateContextAttribsARBRequest<'input> {
3731 type Reply = ();
3732 }
create_context_attribs_arb<'c, 'input, Conn>(conn: &'c Conn, context: Context, fbconfig: Fbconfig, screen: u32, share_list: Context, is_direct: bool, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3733 pub fn create_context_attribs_arb<'c, 'input, Conn>(conn: &'c Conn, context: Context, fbconfig: Fbconfig, screen: u32, share_list: Context, is_direct: bool, attribs: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3734 where
3735 Conn: RequestConnection + ?Sized,
3736 {
3737 let request0 = CreateContextAttribsARBRequest {
3738 context,
3739 fbconfig,
3740 screen,
3741 share_list,
3742 is_direct,
3743 attribs: Cow::Borrowed(attribs),
3744 };
3745 request0.send(conn)
3746 }
3747
3748 /// Opcode for the SetClientInfo2ARB request
3749 pub const SET_CLIENT_INFO2_ARB_REQUEST: u8 = 35;
3750 #[derive(Debug, Clone, PartialEq, Eq)]
3751 pub struct SetClientInfo2ARBRequest<'input> {
3752 pub major_version: u32,
3753 pub minor_version: u32,
3754 pub gl_versions: Cow<'input, [u32]>,
3755 pub gl_extension_string: Cow<'input, [u8]>,
3756 pub glx_extension_string: Cow<'input, [u8]>,
3757 }
3758 impl<'input> SetClientInfo2ARBRequest<'input> {
3759 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3760 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3761 where
3762 Conn: RequestConnection + ?Sized,
3763 {
3764 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3765 .ok_or(ConnectionError::UnsupportedExtension)?;
3766 let length_so_far = 0;
3767 let major_version_bytes = self.major_version.serialize();
3768 let minor_version_bytes = self.minor_version.serialize();
3769 assert_eq!(self.gl_versions.len() % 3, 0, "`gl_versions` has an incorrect length, must be a multiple of 3");
3770 let num_versions = u32::try_from(self.gl_versions.len() / 3).expect("`gl_versions` has too many elements");
3771 let num_versions_bytes = num_versions.serialize();
3772 let gl_str_len = u32::try_from(self.gl_extension_string.len()).expect("`gl_extension_string` has too many elements");
3773 let gl_str_len_bytes = gl_str_len.serialize();
3774 let glx_str_len = u32::try_from(self.glx_extension_string.len()).expect("`glx_extension_string` has too many elements");
3775 let glx_str_len_bytes = glx_str_len.serialize();
3776 let mut request0 = vec![
3777 extension_information.major_opcode,
3778 SET_CLIENT_INFO2_ARB_REQUEST,
3779 0,
3780 0,
3781 major_version_bytes[0],
3782 major_version_bytes[1],
3783 major_version_bytes[2],
3784 major_version_bytes[3],
3785 minor_version_bytes[0],
3786 minor_version_bytes[1],
3787 minor_version_bytes[2],
3788 minor_version_bytes[3],
3789 num_versions_bytes[0],
3790 num_versions_bytes[1],
3791 num_versions_bytes[2],
3792 num_versions_bytes[3],
3793 gl_str_len_bytes[0],
3794 gl_str_len_bytes[1],
3795 gl_str_len_bytes[2],
3796 gl_str_len_bytes[3],
3797 glx_str_len_bytes[0],
3798 glx_str_len_bytes[1],
3799 glx_str_len_bytes[2],
3800 glx_str_len_bytes[3],
3801 ];
3802 let length_so_far = length_so_far + request0.len();
3803 let gl_versions_bytes = self.gl_versions.serialize();
3804 let length_so_far = length_so_far + gl_versions_bytes.len();
3805 let length_so_far = length_so_far + self.gl_extension_string.len();
3806 let length_so_far = length_so_far + self.glx_extension_string.len();
3807 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3808 let length_so_far = length_so_far + padding0.len();
3809 assert_eq!(length_so_far % 4, 0);
3810 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3811 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3812 Ok((vec![request0.into(), gl_versions_bytes.into(), self.gl_extension_string, self.glx_extension_string, padding0.into()], vec![]))
3813 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3814 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3815 where
3816 Conn: RequestConnection + ?Sized,
3817 {
3818 let (bytes, fds) = self.serialize(conn)?;
3819 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3820 conn.send_request_without_reply(&slices, fds)
3821 }
3822 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>3823 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3824 if header.minor_opcode != SET_CLIENT_INFO2_ARB_REQUEST {
3825 return Err(ParseError::InvalidValue);
3826 }
3827 let (major_version, remaining) = u32::try_parse(value)?;
3828 let (minor_version, remaining) = u32::try_parse(remaining)?;
3829 let (num_versions, remaining) = u32::try_parse(remaining)?;
3830 let (gl_str_len, remaining) = u32::try_parse(remaining)?;
3831 let (glx_str_len, remaining) = u32::try_parse(remaining)?;
3832 let (gl_versions, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_versions.checked_mul(3u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
3833 let (gl_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, gl_str_len.try_to_usize()?)?;
3834 let (glx_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, glx_str_len.try_to_usize()?)?;
3835 let _ = remaining;
3836 Ok(SetClientInfo2ARBRequest {
3837 major_version,
3838 minor_version,
3839 gl_versions: Cow::Owned(gl_versions),
3840 gl_extension_string: Cow::Borrowed(gl_extension_string),
3841 glx_extension_string: Cow::Borrowed(glx_extension_string),
3842 })
3843 }
3844 /// Clone all borrowed data in this SetClientInfo2ARBRequest.
into_owned(self) -> SetClientInfo2ARBRequest<'static>3845 pub fn into_owned(self) -> SetClientInfo2ARBRequest<'static> {
3846 SetClientInfo2ARBRequest {
3847 major_version: self.major_version,
3848 minor_version: self.minor_version,
3849 gl_versions: Cow::Owned(self.gl_versions.into_owned()),
3850 gl_extension_string: Cow::Owned(self.gl_extension_string.into_owned()),
3851 glx_extension_string: Cow::Owned(self.glx_extension_string.into_owned()),
3852 }
3853 }
3854 }
3855 impl<'input> Request for SetClientInfo2ARBRequest<'input> {
3856 type Reply = ();
3857 }
set_client_info2_arb<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3858 pub fn set_client_info2_arb<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3859 where
3860 Conn: RequestConnection + ?Sized,
3861 {
3862 let request0 = SetClientInfo2ARBRequest {
3863 major_version,
3864 minor_version,
3865 gl_versions: Cow::Borrowed(gl_versions),
3866 gl_extension_string: Cow::Borrowed(gl_extension_string),
3867 glx_extension_string: Cow::Borrowed(glx_extension_string),
3868 };
3869 request0.send(conn)
3870 }
3871
3872 /// Opcode for the NewList request
3873 pub const NEW_LIST_REQUEST: u8 = 101;
3874 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3875 pub struct NewListRequest {
3876 pub context_tag: ContextTag,
3877 pub list: u32,
3878 pub mode: u32,
3879 }
3880 impl NewListRequest {
3881 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3882 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3883 where
3884 Conn: RequestConnection + ?Sized,
3885 {
3886 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3887 .ok_or(ConnectionError::UnsupportedExtension)?;
3888 let length_so_far = 0;
3889 let context_tag_bytes = self.context_tag.serialize();
3890 let list_bytes = self.list.serialize();
3891 let mode_bytes = self.mode.serialize();
3892 let mut request0 = vec![
3893 extension_information.major_opcode,
3894 NEW_LIST_REQUEST,
3895 0,
3896 0,
3897 context_tag_bytes[0],
3898 context_tag_bytes[1],
3899 context_tag_bytes[2],
3900 context_tag_bytes[3],
3901 list_bytes[0],
3902 list_bytes[1],
3903 list_bytes[2],
3904 list_bytes[3],
3905 mode_bytes[0],
3906 mode_bytes[1],
3907 mode_bytes[2],
3908 mode_bytes[3],
3909 ];
3910 let length_so_far = length_so_far + request0.len();
3911 assert_eq!(length_so_far % 4, 0);
3912 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3913 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3914 Ok((vec![request0.into()], vec![]))
3915 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3916 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3917 where
3918 Conn: RequestConnection + ?Sized,
3919 {
3920 let (bytes, fds) = self.serialize(conn)?;
3921 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3922 conn.send_request_without_reply(&slices, fds)
3923 }
3924 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>3925 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3926 if header.minor_opcode != NEW_LIST_REQUEST {
3927 return Err(ParseError::InvalidValue);
3928 }
3929 let (context_tag, remaining) = ContextTag::try_parse(value)?;
3930 let (list, remaining) = u32::try_parse(remaining)?;
3931 let (mode, remaining) = u32::try_parse(remaining)?;
3932 let _ = remaining;
3933 Ok(NewListRequest {
3934 context_tag,
3935 list,
3936 mode,
3937 })
3938 }
3939 }
3940 impl Request for NewListRequest {
3941 type Reply = ();
3942 }
new_list<Conn>(conn: &Conn, context_tag: ContextTag, list: u32, mode: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3943 pub fn new_list<Conn>(conn: &Conn, context_tag: ContextTag, list: u32, mode: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3944 where
3945 Conn: RequestConnection + ?Sized,
3946 {
3947 let request0 = NewListRequest {
3948 context_tag,
3949 list,
3950 mode,
3951 };
3952 request0.send(conn)
3953 }
3954
3955 /// Opcode for the EndList request
3956 pub const END_LIST_REQUEST: u8 = 102;
3957 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3958 pub struct EndListRequest {
3959 pub context_tag: ContextTag,
3960 }
3961 impl EndListRequest {
3962 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3963 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3964 where
3965 Conn: RequestConnection + ?Sized,
3966 {
3967 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3968 .ok_or(ConnectionError::UnsupportedExtension)?;
3969 let length_so_far = 0;
3970 let context_tag_bytes = self.context_tag.serialize();
3971 let mut request0 = vec![
3972 extension_information.major_opcode,
3973 END_LIST_REQUEST,
3974 0,
3975 0,
3976 context_tag_bytes[0],
3977 context_tag_bytes[1],
3978 context_tag_bytes[2],
3979 context_tag_bytes[3],
3980 ];
3981 let length_so_far = length_so_far + request0.len();
3982 assert_eq!(length_so_far % 4, 0);
3983 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3984 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3985 Ok((vec![request0.into()], vec![]))
3986 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3987 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3988 where
3989 Conn: RequestConnection + ?Sized,
3990 {
3991 let (bytes, fds) = self.serialize(conn)?;
3992 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3993 conn.send_request_without_reply(&slices, fds)
3994 }
3995 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>3996 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3997 if header.minor_opcode != END_LIST_REQUEST {
3998 return Err(ParseError::InvalidValue);
3999 }
4000 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4001 let _ = remaining;
4002 Ok(EndListRequest {
4003 context_tag,
4004 })
4005 }
4006 }
4007 impl Request for EndListRequest {
4008 type Reply = ();
4009 }
end_list<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4010 pub fn end_list<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4011 where
4012 Conn: RequestConnection + ?Sized,
4013 {
4014 let request0 = EndListRequest {
4015 context_tag,
4016 };
4017 request0.send(conn)
4018 }
4019
4020 /// Opcode for the DeleteLists request
4021 pub const DELETE_LISTS_REQUEST: u8 = 103;
4022 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4023 pub struct DeleteListsRequest {
4024 pub context_tag: ContextTag,
4025 pub list: u32,
4026 pub range: i32,
4027 }
4028 impl DeleteListsRequest {
4029 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4030 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4031 where
4032 Conn: RequestConnection + ?Sized,
4033 {
4034 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4035 .ok_or(ConnectionError::UnsupportedExtension)?;
4036 let length_so_far = 0;
4037 let context_tag_bytes = self.context_tag.serialize();
4038 let list_bytes = self.list.serialize();
4039 let range_bytes = self.range.serialize();
4040 let mut request0 = vec![
4041 extension_information.major_opcode,
4042 DELETE_LISTS_REQUEST,
4043 0,
4044 0,
4045 context_tag_bytes[0],
4046 context_tag_bytes[1],
4047 context_tag_bytes[2],
4048 context_tag_bytes[3],
4049 list_bytes[0],
4050 list_bytes[1],
4051 list_bytes[2],
4052 list_bytes[3],
4053 range_bytes[0],
4054 range_bytes[1],
4055 range_bytes[2],
4056 range_bytes[3],
4057 ];
4058 let length_so_far = length_so_far + request0.len();
4059 assert_eq!(length_so_far % 4, 0);
4060 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4061 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4062 Ok((vec![request0.into()], vec![]))
4063 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4064 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4065 where
4066 Conn: RequestConnection + ?Sized,
4067 {
4068 let (bytes, fds) = self.serialize(conn)?;
4069 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4070 conn.send_request_without_reply(&slices, fds)
4071 }
4072 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4073 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4074 if header.minor_opcode != DELETE_LISTS_REQUEST {
4075 return Err(ParseError::InvalidValue);
4076 }
4077 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4078 let (list, remaining) = u32::try_parse(remaining)?;
4079 let (range, remaining) = i32::try_parse(remaining)?;
4080 let _ = remaining;
4081 Ok(DeleteListsRequest {
4082 context_tag,
4083 list,
4084 range,
4085 })
4086 }
4087 }
4088 impl Request for DeleteListsRequest {
4089 type Reply = ();
4090 }
delete_lists<Conn>(conn: &Conn, context_tag: ContextTag, list: u32, range: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4091 pub fn delete_lists<Conn>(conn: &Conn, context_tag: ContextTag, list: u32, range: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4092 where
4093 Conn: RequestConnection + ?Sized,
4094 {
4095 let request0 = DeleteListsRequest {
4096 context_tag,
4097 list,
4098 range,
4099 };
4100 request0.send(conn)
4101 }
4102
4103 /// Opcode for the GenLists request
4104 pub const GEN_LISTS_REQUEST: u8 = 104;
4105 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4106 pub struct GenListsRequest {
4107 pub context_tag: ContextTag,
4108 pub range: i32,
4109 }
4110 impl GenListsRequest {
4111 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4112 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4113 where
4114 Conn: RequestConnection + ?Sized,
4115 {
4116 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4117 .ok_or(ConnectionError::UnsupportedExtension)?;
4118 let length_so_far = 0;
4119 let context_tag_bytes = self.context_tag.serialize();
4120 let range_bytes = self.range.serialize();
4121 let mut request0 = vec![
4122 extension_information.major_opcode,
4123 GEN_LISTS_REQUEST,
4124 0,
4125 0,
4126 context_tag_bytes[0],
4127 context_tag_bytes[1],
4128 context_tag_bytes[2],
4129 context_tag_bytes[3],
4130 range_bytes[0],
4131 range_bytes[1],
4132 range_bytes[2],
4133 range_bytes[3],
4134 ];
4135 let length_so_far = length_so_far + request0.len();
4136 assert_eq!(length_so_far % 4, 0);
4137 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4138 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4139 Ok((vec![request0.into()], vec![]))
4140 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GenListsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4141 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GenListsReply>, ConnectionError>
4142 where
4143 Conn: RequestConnection + ?Sized,
4144 {
4145 let (bytes, fds) = self.serialize(conn)?;
4146 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4147 conn.send_request_with_reply(&slices, fds)
4148 }
4149 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4150 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4151 if header.minor_opcode != GEN_LISTS_REQUEST {
4152 return Err(ParseError::InvalidValue);
4153 }
4154 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4155 let (range, remaining) = i32::try_parse(remaining)?;
4156 let _ = remaining;
4157 Ok(GenListsRequest {
4158 context_tag,
4159 range,
4160 })
4161 }
4162 }
4163 impl Request for GenListsRequest {
4164 type Reply = GenListsReply;
4165 }
gen_lists<Conn>(conn: &Conn, context_tag: ContextTag, range: i32) -> Result<Cookie<'_, Conn, GenListsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4166 pub fn gen_lists<Conn>(conn: &Conn, context_tag: ContextTag, range: i32) -> Result<Cookie<'_, Conn, GenListsReply>, ConnectionError>
4167 where
4168 Conn: RequestConnection + ?Sized,
4169 {
4170 let request0 = GenListsRequest {
4171 context_tag,
4172 range,
4173 };
4174 request0.send(conn)
4175 }
4176
4177 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4178 pub struct GenListsReply {
4179 pub sequence: u16,
4180 pub length: u32,
4181 pub ret_val: u32,
4182 }
4183 impl TryParse for GenListsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>4184 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4185 let remaining = initial_value;
4186 let (response_type, remaining) = u8::try_parse(remaining)?;
4187 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4188 let (sequence, remaining) = u16::try_parse(remaining)?;
4189 let (length, remaining) = u32::try_parse(remaining)?;
4190 let (ret_val, remaining) = u32::try_parse(remaining)?;
4191 if response_type != 1 {
4192 return Err(ParseError::InvalidValue);
4193 }
4194 let result = GenListsReply { sequence, length, ret_val };
4195 let _ = remaining;
4196 let remaining = initial_value.get(32 + length as usize * 4..)
4197 .ok_or(ParseError::InsufficientData)?;
4198 Ok((result, remaining))
4199 }
4200 }
4201
4202 /// Opcode for the FeedbackBuffer request
4203 pub const FEEDBACK_BUFFER_REQUEST: u8 = 105;
4204 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4205 pub struct FeedbackBufferRequest {
4206 pub context_tag: ContextTag,
4207 pub size: i32,
4208 pub type_: i32,
4209 }
4210 impl FeedbackBufferRequest {
4211 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4212 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4213 where
4214 Conn: RequestConnection + ?Sized,
4215 {
4216 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4217 .ok_or(ConnectionError::UnsupportedExtension)?;
4218 let length_so_far = 0;
4219 let context_tag_bytes = self.context_tag.serialize();
4220 let size_bytes = self.size.serialize();
4221 let type_bytes = self.type_.serialize();
4222 let mut request0 = vec![
4223 extension_information.major_opcode,
4224 FEEDBACK_BUFFER_REQUEST,
4225 0,
4226 0,
4227 context_tag_bytes[0],
4228 context_tag_bytes[1],
4229 context_tag_bytes[2],
4230 context_tag_bytes[3],
4231 size_bytes[0],
4232 size_bytes[1],
4233 size_bytes[2],
4234 size_bytes[3],
4235 type_bytes[0],
4236 type_bytes[1],
4237 type_bytes[2],
4238 type_bytes[3],
4239 ];
4240 let length_so_far = length_so_far + request0.len();
4241 assert_eq!(length_so_far % 4, 0);
4242 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4243 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4244 Ok((vec![request0.into()], vec![]))
4245 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4246 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4247 where
4248 Conn: RequestConnection + ?Sized,
4249 {
4250 let (bytes, fds) = self.serialize(conn)?;
4251 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4252 conn.send_request_without_reply(&slices, fds)
4253 }
4254 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4255 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4256 if header.minor_opcode != FEEDBACK_BUFFER_REQUEST {
4257 return Err(ParseError::InvalidValue);
4258 }
4259 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4260 let (size, remaining) = i32::try_parse(remaining)?;
4261 let (type_, remaining) = i32::try_parse(remaining)?;
4262 let _ = remaining;
4263 Ok(FeedbackBufferRequest {
4264 context_tag,
4265 size,
4266 type_,
4267 })
4268 }
4269 }
4270 impl Request for FeedbackBufferRequest {
4271 type Reply = ();
4272 }
feedback_buffer<Conn>(conn: &Conn, context_tag: ContextTag, size: i32, type_: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4273 pub fn feedback_buffer<Conn>(conn: &Conn, context_tag: ContextTag, size: i32, type_: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4274 where
4275 Conn: RequestConnection + ?Sized,
4276 {
4277 let request0 = FeedbackBufferRequest {
4278 context_tag,
4279 size,
4280 type_,
4281 };
4282 request0.send(conn)
4283 }
4284
4285 /// Opcode for the SelectBuffer request
4286 pub const SELECT_BUFFER_REQUEST: u8 = 106;
4287 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4288 pub struct SelectBufferRequest {
4289 pub context_tag: ContextTag,
4290 pub size: i32,
4291 }
4292 impl SelectBufferRequest {
4293 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4294 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4295 where
4296 Conn: RequestConnection + ?Sized,
4297 {
4298 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4299 .ok_or(ConnectionError::UnsupportedExtension)?;
4300 let length_so_far = 0;
4301 let context_tag_bytes = self.context_tag.serialize();
4302 let size_bytes = self.size.serialize();
4303 let mut request0 = vec![
4304 extension_information.major_opcode,
4305 SELECT_BUFFER_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 size_bytes[0],
4313 size_bytes[1],
4314 size_bytes[2],
4315 size_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 Ok((vec![request0.into()], vec![]))
4322 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4323 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4324 where
4325 Conn: RequestConnection + ?Sized,
4326 {
4327 let (bytes, fds) = self.serialize(conn)?;
4328 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4329 conn.send_request_without_reply(&slices, fds)
4330 }
4331 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4332 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4333 if header.minor_opcode != SELECT_BUFFER_REQUEST {
4334 return Err(ParseError::InvalidValue);
4335 }
4336 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4337 let (size, remaining) = i32::try_parse(remaining)?;
4338 let _ = remaining;
4339 Ok(SelectBufferRequest {
4340 context_tag,
4341 size,
4342 })
4343 }
4344 }
4345 impl Request for SelectBufferRequest {
4346 type Reply = ();
4347 }
select_buffer<Conn>(conn: &Conn, context_tag: ContextTag, size: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4348 pub fn select_buffer<Conn>(conn: &Conn, context_tag: ContextTag, size: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4349 where
4350 Conn: RequestConnection + ?Sized,
4351 {
4352 let request0 = SelectBufferRequest {
4353 context_tag,
4354 size,
4355 };
4356 request0.send(conn)
4357 }
4358
4359 /// Opcode for the RenderMode request
4360 pub const RENDER_MODE_REQUEST: u8 = 107;
4361 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4362 pub struct RenderModeRequest {
4363 pub context_tag: ContextTag,
4364 pub mode: u32,
4365 }
4366 impl RenderModeRequest {
4367 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4368 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4369 where
4370 Conn: RequestConnection + ?Sized,
4371 {
4372 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4373 .ok_or(ConnectionError::UnsupportedExtension)?;
4374 let length_so_far = 0;
4375 let context_tag_bytes = self.context_tag.serialize();
4376 let mode_bytes = self.mode.serialize();
4377 let mut request0 = vec![
4378 extension_information.major_opcode,
4379 RENDER_MODE_REQUEST,
4380 0,
4381 0,
4382 context_tag_bytes[0],
4383 context_tag_bytes[1],
4384 context_tag_bytes[2],
4385 context_tag_bytes[3],
4386 mode_bytes[0],
4387 mode_bytes[1],
4388 mode_bytes[2],
4389 mode_bytes[3],
4390 ];
4391 let length_so_far = length_so_far + request0.len();
4392 assert_eq!(length_so_far % 4, 0);
4393 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4394 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4395 Ok((vec![request0.into()], vec![]))
4396 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, RenderModeReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4397 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, RenderModeReply>, ConnectionError>
4398 where
4399 Conn: RequestConnection + ?Sized,
4400 {
4401 let (bytes, fds) = self.serialize(conn)?;
4402 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4403 conn.send_request_with_reply(&slices, fds)
4404 }
4405 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4406 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4407 if header.minor_opcode != RENDER_MODE_REQUEST {
4408 return Err(ParseError::InvalidValue);
4409 }
4410 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4411 let (mode, remaining) = u32::try_parse(remaining)?;
4412 let _ = remaining;
4413 Ok(RenderModeRequest {
4414 context_tag,
4415 mode,
4416 })
4417 }
4418 }
4419 impl Request for RenderModeRequest {
4420 type Reply = RenderModeReply;
4421 }
render_mode<Conn>(conn: &Conn, context_tag: ContextTag, mode: u32) -> Result<Cookie<'_, Conn, RenderModeReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4422 pub fn render_mode<Conn>(conn: &Conn, context_tag: ContextTag, mode: u32) -> Result<Cookie<'_, Conn, RenderModeReply>, ConnectionError>
4423 where
4424 Conn: RequestConnection + ?Sized,
4425 {
4426 let request0 = RenderModeRequest {
4427 context_tag,
4428 mode,
4429 };
4430 request0.send(conn)
4431 }
4432
4433 #[derive(Debug, Clone, PartialEq, Eq)]
4434 pub struct RenderModeReply {
4435 pub sequence: u16,
4436 pub length: u32,
4437 pub ret_val: u32,
4438 pub new_mode: u32,
4439 pub data: Vec<u32>,
4440 }
4441 impl TryParse for RenderModeReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>4442 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4443 let remaining = initial_value;
4444 let (response_type, remaining) = u8::try_parse(remaining)?;
4445 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4446 let (sequence, remaining) = u16::try_parse(remaining)?;
4447 let (length, remaining) = u32::try_parse(remaining)?;
4448 let (ret_val, remaining) = u32::try_parse(remaining)?;
4449 let (n, remaining) = u32::try_parse(remaining)?;
4450 let (new_mode, remaining) = u32::try_parse(remaining)?;
4451 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
4452 let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
4453 if response_type != 1 {
4454 return Err(ParseError::InvalidValue);
4455 }
4456 let result = RenderModeReply { sequence, length, ret_val, new_mode, data };
4457 let _ = remaining;
4458 let remaining = initial_value.get(32 + length as usize * 4..)
4459 .ok_or(ParseError::InsufficientData)?;
4460 Ok((result, remaining))
4461 }
4462 }
4463 impl RenderModeReply {
4464 /// Get the value of the `n` field.
4465 ///
4466 /// The `n` field is used as the length field of the `data` field.
4467 /// This function computes the field's value again based on the length of the list.
4468 ///
4469 /// # Panics
4470 ///
4471 /// Panics if the value cannot be represented in the target type. This
4472 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u324473 pub fn n(&self) -> u32 {
4474 self.data.len()
4475 .try_into().unwrap()
4476 }
4477 }
4478
4479 #[derive(Clone, Copy, PartialEq, Eq)]
4480 pub struct RM(u16);
4481 impl RM {
4482 pub const GL_RENDER: Self = Self(7168);
4483 pub const GL_FEEDBACK: Self = Self(7169);
4484 pub const GL_SELECT: Self = Self(7170);
4485 }
4486 impl From<RM> for u16 {
4487 #[inline]
from(input: RM) -> Self4488 fn from(input: RM) -> Self {
4489 input.0
4490 }
4491 }
4492 impl From<RM> for Option<u16> {
4493 #[inline]
from(input: RM) -> Self4494 fn from(input: RM) -> Self {
4495 Some(input.0)
4496 }
4497 }
4498 impl From<RM> for u32 {
4499 #[inline]
from(input: RM) -> Self4500 fn from(input: RM) -> Self {
4501 u32::from(input.0)
4502 }
4503 }
4504 impl From<RM> for Option<u32> {
4505 #[inline]
from(input: RM) -> Self4506 fn from(input: RM) -> Self {
4507 Some(u32::from(input.0))
4508 }
4509 }
4510 impl From<u8> for RM {
4511 #[inline]
from(value: u8) -> Self4512 fn from(value: u8) -> Self {
4513 Self(value.into())
4514 }
4515 }
4516 impl From<u16> for RM {
4517 #[inline]
from(value: u16) -> Self4518 fn from(value: u16) -> Self {
4519 Self(value)
4520 }
4521 }
4522 impl std::fmt::Debug for RM {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result4523 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4524 let variants = [
4525 (Self::GL_RENDER.0.into(), "GL_RENDER", "GL_RENDER"),
4526 (Self::GL_FEEDBACK.0.into(), "GL_FEEDBACK", "GL_FEEDBACK"),
4527 (Self::GL_SELECT.0.into(), "GL_SELECT", "GL_SELECT"),
4528 ];
4529 pretty_print_enum(fmt, self.0.into(), &variants)
4530 }
4531 }
4532
4533 /// Opcode for the Finish request
4534 pub const FINISH_REQUEST: u8 = 108;
4535 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4536 pub struct FinishRequest {
4537 pub context_tag: ContextTag,
4538 }
4539 impl FinishRequest {
4540 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4541 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4542 where
4543 Conn: RequestConnection + ?Sized,
4544 {
4545 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4546 .ok_or(ConnectionError::UnsupportedExtension)?;
4547 let length_so_far = 0;
4548 let context_tag_bytes = self.context_tag.serialize();
4549 let mut request0 = vec![
4550 extension_information.major_opcode,
4551 FINISH_REQUEST,
4552 0,
4553 0,
4554 context_tag_bytes[0],
4555 context_tag_bytes[1],
4556 context_tag_bytes[2],
4557 context_tag_bytes[3],
4558 ];
4559 let length_so_far = length_so_far + request0.len();
4560 assert_eq!(length_so_far % 4, 0);
4561 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4562 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4563 Ok((vec![request0.into()], vec![]))
4564 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, FinishReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4565 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, FinishReply>, ConnectionError>
4566 where
4567 Conn: RequestConnection + ?Sized,
4568 {
4569 let (bytes, fds) = self.serialize(conn)?;
4570 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4571 conn.send_request_with_reply(&slices, fds)
4572 }
4573 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4574 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4575 if header.minor_opcode != FINISH_REQUEST {
4576 return Err(ParseError::InvalidValue);
4577 }
4578 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4579 let _ = remaining;
4580 Ok(FinishRequest {
4581 context_tag,
4582 })
4583 }
4584 }
4585 impl Request for FinishRequest {
4586 type Reply = FinishReply;
4587 }
finish<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<Cookie<'_, Conn, FinishReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4588 pub fn finish<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<Cookie<'_, Conn, FinishReply>, ConnectionError>
4589 where
4590 Conn: RequestConnection + ?Sized,
4591 {
4592 let request0 = FinishRequest {
4593 context_tag,
4594 };
4595 request0.send(conn)
4596 }
4597
4598 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4599 pub struct FinishReply {
4600 pub sequence: u16,
4601 pub length: u32,
4602 }
4603 impl TryParse for FinishReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>4604 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4605 let remaining = initial_value;
4606 let (response_type, remaining) = u8::try_parse(remaining)?;
4607 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4608 let (sequence, remaining) = u16::try_parse(remaining)?;
4609 let (length, remaining) = u32::try_parse(remaining)?;
4610 if response_type != 1 {
4611 return Err(ParseError::InvalidValue);
4612 }
4613 let result = FinishReply { sequence, length };
4614 let _ = remaining;
4615 let remaining = initial_value.get(32 + length as usize * 4..)
4616 .ok_or(ParseError::InsufficientData)?;
4617 Ok((result, remaining))
4618 }
4619 }
4620
4621 /// Opcode for the PixelStoref request
4622 pub const PIXEL_STOREF_REQUEST: u8 = 109;
4623 #[derive(Debug, Clone, Copy, PartialEq)]
4624 pub struct PixelStorefRequest {
4625 pub context_tag: ContextTag,
4626 pub pname: u32,
4627 pub datum: Float32,
4628 }
4629 impl PixelStorefRequest {
4630 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4631 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4632 where
4633 Conn: RequestConnection + ?Sized,
4634 {
4635 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4636 .ok_or(ConnectionError::UnsupportedExtension)?;
4637 let length_so_far = 0;
4638 let context_tag_bytes = self.context_tag.serialize();
4639 let pname_bytes = self.pname.serialize();
4640 let datum_bytes = self.datum.serialize();
4641 let mut request0 = vec![
4642 extension_information.major_opcode,
4643 PIXEL_STOREF_REQUEST,
4644 0,
4645 0,
4646 context_tag_bytes[0],
4647 context_tag_bytes[1],
4648 context_tag_bytes[2],
4649 context_tag_bytes[3],
4650 pname_bytes[0],
4651 pname_bytes[1],
4652 pname_bytes[2],
4653 pname_bytes[3],
4654 datum_bytes[0],
4655 datum_bytes[1],
4656 datum_bytes[2],
4657 datum_bytes[3],
4658 ];
4659 let length_so_far = length_so_far + request0.len();
4660 assert_eq!(length_so_far % 4, 0);
4661 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4662 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4663 Ok((vec![request0.into()], vec![]))
4664 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4665 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4666 where
4667 Conn: RequestConnection + ?Sized,
4668 {
4669 let (bytes, fds) = self.serialize(conn)?;
4670 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4671 conn.send_request_without_reply(&slices, fds)
4672 }
4673 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4674 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4675 if header.minor_opcode != PIXEL_STOREF_REQUEST {
4676 return Err(ParseError::InvalidValue);
4677 }
4678 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4679 let (pname, remaining) = u32::try_parse(remaining)?;
4680 let (datum, remaining) = Float32::try_parse(remaining)?;
4681 let _ = remaining;
4682 Ok(PixelStorefRequest {
4683 context_tag,
4684 pname,
4685 datum,
4686 })
4687 }
4688 }
4689 impl Request for PixelStorefRequest {
4690 type Reply = ();
4691 }
pixel_storef<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32, datum: Float32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4692 pub fn pixel_storef<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32, datum: Float32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4693 where
4694 Conn: RequestConnection + ?Sized,
4695 {
4696 let request0 = PixelStorefRequest {
4697 context_tag,
4698 pname,
4699 datum,
4700 };
4701 request0.send(conn)
4702 }
4703
4704 /// Opcode for the PixelStorei request
4705 pub const PIXEL_STOREI_REQUEST: u8 = 110;
4706 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4707 pub struct PixelStoreiRequest {
4708 pub context_tag: ContextTag,
4709 pub pname: u32,
4710 pub datum: i32,
4711 }
4712 impl PixelStoreiRequest {
4713 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4714 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4715 where
4716 Conn: RequestConnection + ?Sized,
4717 {
4718 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4719 .ok_or(ConnectionError::UnsupportedExtension)?;
4720 let length_so_far = 0;
4721 let context_tag_bytes = self.context_tag.serialize();
4722 let pname_bytes = self.pname.serialize();
4723 let datum_bytes = self.datum.serialize();
4724 let mut request0 = vec![
4725 extension_information.major_opcode,
4726 PIXEL_STOREI_REQUEST,
4727 0,
4728 0,
4729 context_tag_bytes[0],
4730 context_tag_bytes[1],
4731 context_tag_bytes[2],
4732 context_tag_bytes[3],
4733 pname_bytes[0],
4734 pname_bytes[1],
4735 pname_bytes[2],
4736 pname_bytes[3],
4737 datum_bytes[0],
4738 datum_bytes[1],
4739 datum_bytes[2],
4740 datum_bytes[3],
4741 ];
4742 let length_so_far = length_so_far + request0.len();
4743 assert_eq!(length_so_far % 4, 0);
4744 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4745 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4746 Ok((vec![request0.into()], vec![]))
4747 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4748 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4749 where
4750 Conn: RequestConnection + ?Sized,
4751 {
4752 let (bytes, fds) = self.serialize(conn)?;
4753 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4754 conn.send_request_without_reply(&slices, fds)
4755 }
4756 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4757 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4758 if header.minor_opcode != PIXEL_STOREI_REQUEST {
4759 return Err(ParseError::InvalidValue);
4760 }
4761 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4762 let (pname, remaining) = u32::try_parse(remaining)?;
4763 let (datum, remaining) = i32::try_parse(remaining)?;
4764 let _ = remaining;
4765 Ok(PixelStoreiRequest {
4766 context_tag,
4767 pname,
4768 datum,
4769 })
4770 }
4771 }
4772 impl Request for PixelStoreiRequest {
4773 type Reply = ();
4774 }
pixel_storei<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32, datum: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,4775 pub fn pixel_storei<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32, datum: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
4776 where
4777 Conn: RequestConnection + ?Sized,
4778 {
4779 let request0 = PixelStoreiRequest {
4780 context_tag,
4781 pname,
4782 datum,
4783 };
4784 request0.send(conn)
4785 }
4786
4787 /// Opcode for the ReadPixels request
4788 pub const READ_PIXELS_REQUEST: u8 = 111;
4789 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4790 pub struct ReadPixelsRequest {
4791 pub context_tag: ContextTag,
4792 pub x: i32,
4793 pub y: i32,
4794 pub width: i32,
4795 pub height: i32,
4796 pub format: u32,
4797 pub type_: u32,
4798 pub swap_bytes: bool,
4799 pub lsb_first: bool,
4800 }
4801 impl ReadPixelsRequest {
4802 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4803 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4804 where
4805 Conn: RequestConnection + ?Sized,
4806 {
4807 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4808 .ok_or(ConnectionError::UnsupportedExtension)?;
4809 let length_so_far = 0;
4810 let context_tag_bytes = self.context_tag.serialize();
4811 let x_bytes = self.x.serialize();
4812 let y_bytes = self.y.serialize();
4813 let width_bytes = self.width.serialize();
4814 let height_bytes = self.height.serialize();
4815 let format_bytes = self.format.serialize();
4816 let type_bytes = self.type_.serialize();
4817 let swap_bytes_bytes = self.swap_bytes.serialize();
4818 let lsb_first_bytes = self.lsb_first.serialize();
4819 let mut request0 = vec![
4820 extension_information.major_opcode,
4821 READ_PIXELS_REQUEST,
4822 0,
4823 0,
4824 context_tag_bytes[0],
4825 context_tag_bytes[1],
4826 context_tag_bytes[2],
4827 context_tag_bytes[3],
4828 x_bytes[0],
4829 x_bytes[1],
4830 x_bytes[2],
4831 x_bytes[3],
4832 y_bytes[0],
4833 y_bytes[1],
4834 y_bytes[2],
4835 y_bytes[3],
4836 width_bytes[0],
4837 width_bytes[1],
4838 width_bytes[2],
4839 width_bytes[3],
4840 height_bytes[0],
4841 height_bytes[1],
4842 height_bytes[2],
4843 height_bytes[3],
4844 format_bytes[0],
4845 format_bytes[1],
4846 format_bytes[2],
4847 format_bytes[3],
4848 type_bytes[0],
4849 type_bytes[1],
4850 type_bytes[2],
4851 type_bytes[3],
4852 swap_bytes_bytes[0],
4853 lsb_first_bytes[0],
4854 0,
4855 0,
4856 ];
4857 let length_so_far = length_so_far + request0.len();
4858 assert_eq!(length_so_far % 4, 0);
4859 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4860 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4861 Ok((vec![request0.into()], vec![]))
4862 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ReadPixelsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4863 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ReadPixelsReply>, ConnectionError>
4864 where
4865 Conn: RequestConnection + ?Sized,
4866 {
4867 let (bytes, fds) = self.serialize(conn)?;
4868 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
4869 conn.send_request_with_reply(&slices, fds)
4870 }
4871 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>4872 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
4873 if header.minor_opcode != READ_PIXELS_REQUEST {
4874 return Err(ParseError::InvalidValue);
4875 }
4876 let (context_tag, remaining) = ContextTag::try_parse(value)?;
4877 let (x, remaining) = i32::try_parse(remaining)?;
4878 let (y, remaining) = i32::try_parse(remaining)?;
4879 let (width, remaining) = i32::try_parse(remaining)?;
4880 let (height, remaining) = i32::try_parse(remaining)?;
4881 let (format, remaining) = u32::try_parse(remaining)?;
4882 let (type_, remaining) = u32::try_parse(remaining)?;
4883 let (swap_bytes, remaining) = bool::try_parse(remaining)?;
4884 let (lsb_first, remaining) = bool::try_parse(remaining)?;
4885 let _ = remaining;
4886 Ok(ReadPixelsRequest {
4887 context_tag,
4888 x,
4889 y,
4890 width,
4891 height,
4892 format,
4893 type_,
4894 swap_bytes,
4895 lsb_first,
4896 })
4897 }
4898 }
4899 impl Request for ReadPixelsRequest {
4900 type Reply = ReadPixelsReply;
4901 }
read_pixels<Conn>(conn: &Conn, context_tag: ContextTag, x: i32, y: i32, width: i32, height: i32, format: u32, type_: u32, swap_bytes: bool, lsb_first: bool) -> Result<Cookie<'_, Conn, ReadPixelsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,4902 pub fn read_pixels<Conn>(conn: &Conn, context_tag: ContextTag, x: i32, y: i32, width: i32, height: i32, format: u32, type_: u32, swap_bytes: bool, lsb_first: bool) -> Result<Cookie<'_, Conn, ReadPixelsReply>, ConnectionError>
4903 where
4904 Conn: RequestConnection + ?Sized,
4905 {
4906 let request0 = ReadPixelsRequest {
4907 context_tag,
4908 x,
4909 y,
4910 width,
4911 height,
4912 format,
4913 type_,
4914 swap_bytes,
4915 lsb_first,
4916 };
4917 request0.send(conn)
4918 }
4919
4920 #[derive(Debug, Clone, PartialEq, Eq)]
4921 pub struct ReadPixelsReply {
4922 pub sequence: u16,
4923 pub data: Vec<u8>,
4924 }
4925 impl TryParse for ReadPixelsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>4926 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
4927 let remaining = initial_value;
4928 let (response_type, remaining) = u8::try_parse(remaining)?;
4929 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
4930 let (sequence, remaining) = u16::try_parse(remaining)?;
4931 let (length, remaining) = u32::try_parse(remaining)?;
4932 let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
4933 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
4934 let data = data.to_vec();
4935 if response_type != 1 {
4936 return Err(ParseError::InvalidValue);
4937 }
4938 let result = ReadPixelsReply { sequence, data };
4939 let _ = remaining;
4940 let remaining = initial_value.get(32 + length as usize * 4..)
4941 .ok_or(ParseError::InsufficientData)?;
4942 Ok((result, remaining))
4943 }
4944 }
4945 impl ReadPixelsReply {
4946 /// Get the value of the `length` field.
4947 ///
4948 /// The `length` field is used as the length field of the `data` field.
4949 /// This function computes the field's value again based on the length of the list.
4950 ///
4951 /// # Panics
4952 ///
4953 /// Panics if the value cannot be represented in the target type. This
4954 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u324955 pub fn length(&self) -> u32 {
4956 self.data.len()
4957 .checked_div(4).unwrap()
4958 .try_into().unwrap()
4959 }
4960 }
4961
4962 /// Opcode for the GetBooleanv request
4963 pub const GET_BOOLEANV_REQUEST: u8 = 112;
4964 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
4965 pub struct GetBooleanvRequest {
4966 pub context_tag: ContextTag,
4967 pub pname: i32,
4968 }
4969 impl GetBooleanvRequest {
4970 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,4971 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
4972 where
4973 Conn: RequestConnection + ?Sized,
4974 {
4975 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
4976 .ok_or(ConnectionError::UnsupportedExtension)?;
4977 let length_so_far = 0;
4978 let context_tag_bytes = self.context_tag.serialize();
4979 let pname_bytes = self.pname.serialize();
4980 let mut request0 = vec![
4981 extension_information.major_opcode,
4982 GET_BOOLEANV_REQUEST,
4983 0,
4984 0,
4985 context_tag_bytes[0],
4986 context_tag_bytes[1],
4987 context_tag_bytes[2],
4988 context_tag_bytes[3],
4989 pname_bytes[0],
4990 pname_bytes[1],
4991 pname_bytes[2],
4992 pname_bytes[3],
4993 ];
4994 let length_so_far = length_so_far + request0.len();
4995 assert_eq!(length_so_far % 4, 0);
4996 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
4997 request0[2..4].copy_from_slice(&length.to_ne_bytes());
4998 Ok((vec![request0.into()], vec![]))
4999 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetBooleanvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5000 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetBooleanvReply>, ConnectionError>
5001 where
5002 Conn: RequestConnection + ?Sized,
5003 {
5004 let (bytes, fds) = self.serialize(conn)?;
5005 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5006 conn.send_request_with_reply(&slices, fds)
5007 }
5008 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5009 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5010 if header.minor_opcode != GET_BOOLEANV_REQUEST {
5011 return Err(ParseError::InvalidValue);
5012 }
5013 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5014 let (pname, remaining) = i32::try_parse(remaining)?;
5015 let _ = remaining;
5016 Ok(GetBooleanvRequest {
5017 context_tag,
5018 pname,
5019 })
5020 }
5021 }
5022 impl Request for GetBooleanvRequest {
5023 type Reply = GetBooleanvReply;
5024 }
get_booleanv<Conn>(conn: &Conn, context_tag: ContextTag, pname: i32) -> Result<Cookie<'_, Conn, GetBooleanvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5025 pub fn get_booleanv<Conn>(conn: &Conn, context_tag: ContextTag, pname: i32) -> Result<Cookie<'_, Conn, GetBooleanvReply>, ConnectionError>
5026 where
5027 Conn: RequestConnection + ?Sized,
5028 {
5029 let request0 = GetBooleanvRequest {
5030 context_tag,
5031 pname,
5032 };
5033 request0.send(conn)
5034 }
5035
5036 #[derive(Debug, Clone, PartialEq, Eq)]
5037 pub struct GetBooleanvReply {
5038 pub sequence: u16,
5039 pub length: u32,
5040 pub datum: bool,
5041 pub data: Vec<bool>,
5042 }
5043 impl TryParse for GetBooleanvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5044 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5045 let remaining = initial_value;
5046 let (response_type, remaining) = u8::try_parse(remaining)?;
5047 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5048 let (sequence, remaining) = u16::try_parse(remaining)?;
5049 let (length, remaining) = u32::try_parse(remaining)?;
5050 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5051 let (n, remaining) = u32::try_parse(remaining)?;
5052 let (datum, remaining) = bool::try_parse(remaining)?;
5053 let remaining = remaining.get(15..).ok_or(ParseError::InsufficientData)?;
5054 let (data, remaining) = crate::x11_utils::parse_list::<bool>(remaining, n.try_to_usize()?)?;
5055 if response_type != 1 {
5056 return Err(ParseError::InvalidValue);
5057 }
5058 let result = GetBooleanvReply { sequence, length, datum, data };
5059 let _ = remaining;
5060 let remaining = initial_value.get(32 + length as usize * 4..)
5061 .ok_or(ParseError::InsufficientData)?;
5062 Ok((result, remaining))
5063 }
5064 }
5065 impl GetBooleanvReply {
5066 /// Get the value of the `n` field.
5067 ///
5068 /// The `n` field is used as the length field of the `data` field.
5069 /// This function computes the field's value again based on the length of the list.
5070 ///
5071 /// # Panics
5072 ///
5073 /// Panics if the value cannot be represented in the target type. This
5074 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u325075 pub fn n(&self) -> u32 {
5076 self.data.len()
5077 .try_into().unwrap()
5078 }
5079 }
5080
5081 /// Opcode for the GetClipPlane request
5082 pub const GET_CLIP_PLANE_REQUEST: u8 = 113;
5083 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5084 pub struct GetClipPlaneRequest {
5085 pub context_tag: ContextTag,
5086 pub plane: i32,
5087 }
5088 impl GetClipPlaneRequest {
5089 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5090 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5091 where
5092 Conn: RequestConnection + ?Sized,
5093 {
5094 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5095 .ok_or(ConnectionError::UnsupportedExtension)?;
5096 let length_so_far = 0;
5097 let context_tag_bytes = self.context_tag.serialize();
5098 let plane_bytes = self.plane.serialize();
5099 let mut request0 = vec![
5100 extension_information.major_opcode,
5101 GET_CLIP_PLANE_REQUEST,
5102 0,
5103 0,
5104 context_tag_bytes[0],
5105 context_tag_bytes[1],
5106 context_tag_bytes[2],
5107 context_tag_bytes[3],
5108 plane_bytes[0],
5109 plane_bytes[1],
5110 plane_bytes[2],
5111 plane_bytes[3],
5112 ];
5113 let length_so_far = length_so_far + request0.len();
5114 assert_eq!(length_so_far % 4, 0);
5115 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5116 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5117 Ok((vec![request0.into()], vec![]))
5118 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetClipPlaneReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5119 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetClipPlaneReply>, ConnectionError>
5120 where
5121 Conn: RequestConnection + ?Sized,
5122 {
5123 let (bytes, fds) = self.serialize(conn)?;
5124 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5125 conn.send_request_with_reply(&slices, fds)
5126 }
5127 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5128 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5129 if header.minor_opcode != GET_CLIP_PLANE_REQUEST {
5130 return Err(ParseError::InvalidValue);
5131 }
5132 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5133 let (plane, remaining) = i32::try_parse(remaining)?;
5134 let _ = remaining;
5135 Ok(GetClipPlaneRequest {
5136 context_tag,
5137 plane,
5138 })
5139 }
5140 }
5141 impl Request for GetClipPlaneRequest {
5142 type Reply = GetClipPlaneReply;
5143 }
get_clip_plane<Conn>(conn: &Conn, context_tag: ContextTag, plane: i32) -> Result<Cookie<'_, Conn, GetClipPlaneReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5144 pub fn get_clip_plane<Conn>(conn: &Conn, context_tag: ContextTag, plane: i32) -> Result<Cookie<'_, Conn, GetClipPlaneReply>, ConnectionError>
5145 where
5146 Conn: RequestConnection + ?Sized,
5147 {
5148 let request0 = GetClipPlaneRequest {
5149 context_tag,
5150 plane,
5151 };
5152 request0.send(conn)
5153 }
5154
5155 #[derive(Debug, Clone, PartialEq)]
5156 pub struct GetClipPlaneReply {
5157 pub sequence: u16,
5158 pub data: Vec<Float64>,
5159 }
5160 impl TryParse for GetClipPlaneReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5161 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5162 let remaining = initial_value;
5163 let (response_type, remaining) = u8::try_parse(remaining)?;
5164 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5165 let (sequence, remaining) = u16::try_parse(remaining)?;
5166 let (length, remaining) = u32::try_parse(remaining)?;
5167 let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
5168 let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, length.checked_div(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
5169 if response_type != 1 {
5170 return Err(ParseError::InvalidValue);
5171 }
5172 let result = GetClipPlaneReply { sequence, data };
5173 let _ = remaining;
5174 let remaining = initial_value.get(32 + length as usize * 4..)
5175 .ok_or(ParseError::InsufficientData)?;
5176 Ok((result, remaining))
5177 }
5178 }
5179 impl GetClipPlaneReply {
5180 /// Get the value of the `length` field.
5181 ///
5182 /// The `length` field is used as the length field of the `data` field.
5183 /// This function computes the field's value again based on the length of the list.
5184 ///
5185 /// # Panics
5186 ///
5187 /// Panics if the value cannot be represented in the target type. This
5188 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u325189 pub fn length(&self) -> u32 {
5190 self.data.len()
5191 .checked_mul(2).unwrap()
5192 .try_into().unwrap()
5193 }
5194 }
5195
5196 /// Opcode for the GetDoublev request
5197 pub const GET_DOUBLEV_REQUEST: u8 = 114;
5198 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5199 pub struct GetDoublevRequest {
5200 pub context_tag: ContextTag,
5201 pub pname: u32,
5202 }
5203 impl GetDoublevRequest {
5204 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5205 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5206 where
5207 Conn: RequestConnection + ?Sized,
5208 {
5209 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5210 .ok_or(ConnectionError::UnsupportedExtension)?;
5211 let length_so_far = 0;
5212 let context_tag_bytes = self.context_tag.serialize();
5213 let pname_bytes = self.pname.serialize();
5214 let mut request0 = vec![
5215 extension_information.major_opcode,
5216 GET_DOUBLEV_REQUEST,
5217 0,
5218 0,
5219 context_tag_bytes[0],
5220 context_tag_bytes[1],
5221 context_tag_bytes[2],
5222 context_tag_bytes[3],
5223 pname_bytes[0],
5224 pname_bytes[1],
5225 pname_bytes[2],
5226 pname_bytes[3],
5227 ];
5228 let length_so_far = length_so_far + request0.len();
5229 assert_eq!(length_so_far % 4, 0);
5230 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5231 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5232 Ok((vec![request0.into()], vec![]))
5233 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDoublevReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5234 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetDoublevReply>, ConnectionError>
5235 where
5236 Conn: RequestConnection + ?Sized,
5237 {
5238 let (bytes, fds) = self.serialize(conn)?;
5239 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5240 conn.send_request_with_reply(&slices, fds)
5241 }
5242 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5243 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5244 if header.minor_opcode != GET_DOUBLEV_REQUEST {
5245 return Err(ParseError::InvalidValue);
5246 }
5247 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5248 let (pname, remaining) = u32::try_parse(remaining)?;
5249 let _ = remaining;
5250 Ok(GetDoublevRequest {
5251 context_tag,
5252 pname,
5253 })
5254 }
5255 }
5256 impl Request for GetDoublevRequest {
5257 type Reply = GetDoublevReply;
5258 }
get_doublev<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Conn, GetDoublevReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5259 pub fn get_doublev<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Conn, GetDoublevReply>, ConnectionError>
5260 where
5261 Conn: RequestConnection + ?Sized,
5262 {
5263 let request0 = GetDoublevRequest {
5264 context_tag,
5265 pname,
5266 };
5267 request0.send(conn)
5268 }
5269
5270 #[derive(Debug, Clone, PartialEq)]
5271 pub struct GetDoublevReply {
5272 pub sequence: u16,
5273 pub length: u32,
5274 pub datum: Float64,
5275 pub data: Vec<Float64>,
5276 }
5277 impl TryParse for GetDoublevReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5278 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5279 let remaining = initial_value;
5280 let (response_type, remaining) = u8::try_parse(remaining)?;
5281 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5282 let (sequence, remaining) = u16::try_parse(remaining)?;
5283 let (length, remaining) = u32::try_parse(remaining)?;
5284 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5285 let (n, remaining) = u32::try_parse(remaining)?;
5286 let (datum, remaining) = Float64::try_parse(remaining)?;
5287 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
5288 let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, n.try_to_usize()?)?;
5289 if response_type != 1 {
5290 return Err(ParseError::InvalidValue);
5291 }
5292 let result = GetDoublevReply { sequence, length, datum, data };
5293 let _ = remaining;
5294 let remaining = initial_value.get(32 + length as usize * 4..)
5295 .ok_or(ParseError::InsufficientData)?;
5296 Ok((result, remaining))
5297 }
5298 }
5299 impl GetDoublevReply {
5300 /// Get the value of the `n` field.
5301 ///
5302 /// The `n` field is used as the length field of the `data` field.
5303 /// This function computes the field's value again based on the length of the list.
5304 ///
5305 /// # Panics
5306 ///
5307 /// Panics if the value cannot be represented in the target type. This
5308 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u325309 pub fn n(&self) -> u32 {
5310 self.data.len()
5311 .try_into().unwrap()
5312 }
5313 }
5314
5315 /// Opcode for the GetError request
5316 pub const GET_ERROR_REQUEST: u8 = 115;
5317 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5318 pub struct GetErrorRequest {
5319 pub context_tag: ContextTag,
5320 }
5321 impl GetErrorRequest {
5322 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5323 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5324 where
5325 Conn: RequestConnection + ?Sized,
5326 {
5327 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5328 .ok_or(ConnectionError::UnsupportedExtension)?;
5329 let length_so_far = 0;
5330 let context_tag_bytes = self.context_tag.serialize();
5331 let mut request0 = vec![
5332 extension_information.major_opcode,
5333 GET_ERROR_REQUEST,
5334 0,
5335 0,
5336 context_tag_bytes[0],
5337 context_tag_bytes[1],
5338 context_tag_bytes[2],
5339 context_tag_bytes[3],
5340 ];
5341 let length_so_far = length_so_far + request0.len();
5342 assert_eq!(length_so_far % 4, 0);
5343 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5344 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5345 Ok((vec![request0.into()], vec![]))
5346 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetErrorReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5347 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetErrorReply>, ConnectionError>
5348 where
5349 Conn: RequestConnection + ?Sized,
5350 {
5351 let (bytes, fds) = self.serialize(conn)?;
5352 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5353 conn.send_request_with_reply(&slices, fds)
5354 }
5355 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5356 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5357 if header.minor_opcode != GET_ERROR_REQUEST {
5358 return Err(ParseError::InvalidValue);
5359 }
5360 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5361 let _ = remaining;
5362 Ok(GetErrorRequest {
5363 context_tag,
5364 })
5365 }
5366 }
5367 impl Request for GetErrorRequest {
5368 type Reply = GetErrorReply;
5369 }
get_error<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<Cookie<'_, Conn, GetErrorReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5370 pub fn get_error<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<Cookie<'_, Conn, GetErrorReply>, ConnectionError>
5371 where
5372 Conn: RequestConnection + ?Sized,
5373 {
5374 let request0 = GetErrorRequest {
5375 context_tag,
5376 };
5377 request0.send(conn)
5378 }
5379
5380 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5381 pub struct GetErrorReply {
5382 pub sequence: u16,
5383 pub length: u32,
5384 pub error: i32,
5385 }
5386 impl TryParse for GetErrorReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5387 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5388 let remaining = initial_value;
5389 let (response_type, remaining) = u8::try_parse(remaining)?;
5390 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5391 let (sequence, remaining) = u16::try_parse(remaining)?;
5392 let (length, remaining) = u32::try_parse(remaining)?;
5393 let (error, remaining) = i32::try_parse(remaining)?;
5394 if response_type != 1 {
5395 return Err(ParseError::InvalidValue);
5396 }
5397 let result = GetErrorReply { sequence, length, error };
5398 let _ = remaining;
5399 let remaining = initial_value.get(32 + length as usize * 4..)
5400 .ok_or(ParseError::InsufficientData)?;
5401 Ok((result, remaining))
5402 }
5403 }
5404
5405 /// Opcode for the GetFloatv request
5406 pub const GET_FLOATV_REQUEST: u8 = 116;
5407 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5408 pub struct GetFloatvRequest {
5409 pub context_tag: ContextTag,
5410 pub pname: u32,
5411 }
5412 impl GetFloatvRequest {
5413 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5414 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5415 where
5416 Conn: RequestConnection + ?Sized,
5417 {
5418 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5419 .ok_or(ConnectionError::UnsupportedExtension)?;
5420 let length_so_far = 0;
5421 let context_tag_bytes = self.context_tag.serialize();
5422 let pname_bytes = self.pname.serialize();
5423 let mut request0 = vec![
5424 extension_information.major_opcode,
5425 GET_FLOATV_REQUEST,
5426 0,
5427 0,
5428 context_tag_bytes[0],
5429 context_tag_bytes[1],
5430 context_tag_bytes[2],
5431 context_tag_bytes[3],
5432 pname_bytes[0],
5433 pname_bytes[1],
5434 pname_bytes[2],
5435 pname_bytes[3],
5436 ];
5437 let length_so_far = length_so_far + request0.len();
5438 assert_eq!(length_so_far % 4, 0);
5439 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5440 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5441 Ok((vec![request0.into()], vec![]))
5442 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetFloatvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5443 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetFloatvReply>, ConnectionError>
5444 where
5445 Conn: RequestConnection + ?Sized,
5446 {
5447 let (bytes, fds) = self.serialize(conn)?;
5448 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5449 conn.send_request_with_reply(&slices, fds)
5450 }
5451 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5452 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5453 if header.minor_opcode != GET_FLOATV_REQUEST {
5454 return Err(ParseError::InvalidValue);
5455 }
5456 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5457 let (pname, remaining) = u32::try_parse(remaining)?;
5458 let _ = remaining;
5459 Ok(GetFloatvRequest {
5460 context_tag,
5461 pname,
5462 })
5463 }
5464 }
5465 impl Request for GetFloatvRequest {
5466 type Reply = GetFloatvReply;
5467 }
get_floatv<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Conn, GetFloatvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5468 pub fn get_floatv<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Conn, GetFloatvReply>, ConnectionError>
5469 where
5470 Conn: RequestConnection + ?Sized,
5471 {
5472 let request0 = GetFloatvRequest {
5473 context_tag,
5474 pname,
5475 };
5476 request0.send(conn)
5477 }
5478
5479 #[derive(Debug, Clone, PartialEq)]
5480 pub struct GetFloatvReply {
5481 pub sequence: u16,
5482 pub length: u32,
5483 pub datum: Float32,
5484 pub data: Vec<Float32>,
5485 }
5486 impl TryParse for GetFloatvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5487 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5488 let remaining = initial_value;
5489 let (response_type, remaining) = u8::try_parse(remaining)?;
5490 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5491 let (sequence, remaining) = u16::try_parse(remaining)?;
5492 let (length, remaining) = u32::try_parse(remaining)?;
5493 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5494 let (n, remaining) = u32::try_parse(remaining)?;
5495 let (datum, remaining) = Float32::try_parse(remaining)?;
5496 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
5497 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
5498 if response_type != 1 {
5499 return Err(ParseError::InvalidValue);
5500 }
5501 let result = GetFloatvReply { sequence, length, datum, data };
5502 let _ = remaining;
5503 let remaining = initial_value.get(32 + length as usize * 4..)
5504 .ok_or(ParseError::InsufficientData)?;
5505 Ok((result, remaining))
5506 }
5507 }
5508 impl GetFloatvReply {
5509 /// Get the value of the `n` field.
5510 ///
5511 /// The `n` field is used as the length field of the `data` field.
5512 /// This function computes the field's value again based on the length of the list.
5513 ///
5514 /// # Panics
5515 ///
5516 /// Panics if the value cannot be represented in the target type. This
5517 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u325518 pub fn n(&self) -> u32 {
5519 self.data.len()
5520 .try_into().unwrap()
5521 }
5522 }
5523
5524 /// Opcode for the GetIntegerv request
5525 pub const GET_INTEGERV_REQUEST: u8 = 117;
5526 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5527 pub struct GetIntegervRequest {
5528 pub context_tag: ContextTag,
5529 pub pname: u32,
5530 }
5531 impl GetIntegervRequest {
5532 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5533 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5534 where
5535 Conn: RequestConnection + ?Sized,
5536 {
5537 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5538 .ok_or(ConnectionError::UnsupportedExtension)?;
5539 let length_so_far = 0;
5540 let context_tag_bytes = self.context_tag.serialize();
5541 let pname_bytes = self.pname.serialize();
5542 let mut request0 = vec![
5543 extension_information.major_opcode,
5544 GET_INTEGERV_REQUEST,
5545 0,
5546 0,
5547 context_tag_bytes[0],
5548 context_tag_bytes[1],
5549 context_tag_bytes[2],
5550 context_tag_bytes[3],
5551 pname_bytes[0],
5552 pname_bytes[1],
5553 pname_bytes[2],
5554 pname_bytes[3],
5555 ];
5556 let length_so_far = length_so_far + request0.len();
5557 assert_eq!(length_so_far % 4, 0);
5558 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5559 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5560 Ok((vec![request0.into()], vec![]))
5561 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetIntegervReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5562 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetIntegervReply>, ConnectionError>
5563 where
5564 Conn: RequestConnection + ?Sized,
5565 {
5566 let (bytes, fds) = self.serialize(conn)?;
5567 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5568 conn.send_request_with_reply(&slices, fds)
5569 }
5570 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5571 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5572 if header.minor_opcode != GET_INTEGERV_REQUEST {
5573 return Err(ParseError::InvalidValue);
5574 }
5575 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5576 let (pname, remaining) = u32::try_parse(remaining)?;
5577 let _ = remaining;
5578 Ok(GetIntegervRequest {
5579 context_tag,
5580 pname,
5581 })
5582 }
5583 }
5584 impl Request for GetIntegervRequest {
5585 type Reply = GetIntegervReply;
5586 }
get_integerv<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Conn, GetIntegervReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5587 pub fn get_integerv<Conn>(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Conn, GetIntegervReply>, ConnectionError>
5588 where
5589 Conn: RequestConnection + ?Sized,
5590 {
5591 let request0 = GetIntegervRequest {
5592 context_tag,
5593 pname,
5594 };
5595 request0.send(conn)
5596 }
5597
5598 #[derive(Debug, Clone, PartialEq, Eq)]
5599 pub struct GetIntegervReply {
5600 pub sequence: u16,
5601 pub length: u32,
5602 pub datum: i32,
5603 pub data: Vec<i32>,
5604 }
5605 impl TryParse for GetIntegervReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5606 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5607 let remaining = initial_value;
5608 let (response_type, remaining) = u8::try_parse(remaining)?;
5609 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5610 let (sequence, remaining) = u16::try_parse(remaining)?;
5611 let (length, remaining) = u32::try_parse(remaining)?;
5612 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5613 let (n, remaining) = u32::try_parse(remaining)?;
5614 let (datum, remaining) = i32::try_parse(remaining)?;
5615 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
5616 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
5617 if response_type != 1 {
5618 return Err(ParseError::InvalidValue);
5619 }
5620 let result = GetIntegervReply { sequence, length, datum, data };
5621 let _ = remaining;
5622 let remaining = initial_value.get(32 + length as usize * 4..)
5623 .ok_or(ParseError::InsufficientData)?;
5624 Ok((result, remaining))
5625 }
5626 }
5627 impl GetIntegervReply {
5628 /// Get the value of the `n` field.
5629 ///
5630 /// The `n` field is used as the length field of the `data` field.
5631 /// This function computes the field's value again based on the length of the list.
5632 ///
5633 /// # Panics
5634 ///
5635 /// Panics if the value cannot be represented in the target type. This
5636 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u325637 pub fn n(&self) -> u32 {
5638 self.data.len()
5639 .try_into().unwrap()
5640 }
5641 }
5642
5643 /// Opcode for the GetLightfv request
5644 pub const GET_LIGHTFV_REQUEST: u8 = 118;
5645 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5646 pub struct GetLightfvRequest {
5647 pub context_tag: ContextTag,
5648 pub light: u32,
5649 pub pname: u32,
5650 }
5651 impl GetLightfvRequest {
5652 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5653 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5654 where
5655 Conn: RequestConnection + ?Sized,
5656 {
5657 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5658 .ok_or(ConnectionError::UnsupportedExtension)?;
5659 let length_so_far = 0;
5660 let context_tag_bytes = self.context_tag.serialize();
5661 let light_bytes = self.light.serialize();
5662 let pname_bytes = self.pname.serialize();
5663 let mut request0 = vec![
5664 extension_information.major_opcode,
5665 GET_LIGHTFV_REQUEST,
5666 0,
5667 0,
5668 context_tag_bytes[0],
5669 context_tag_bytes[1],
5670 context_tag_bytes[2],
5671 context_tag_bytes[3],
5672 light_bytes[0],
5673 light_bytes[1],
5674 light_bytes[2],
5675 light_bytes[3],
5676 pname_bytes[0],
5677 pname_bytes[1],
5678 pname_bytes[2],
5679 pname_bytes[3],
5680 ];
5681 let length_so_far = length_so_far + request0.len();
5682 assert_eq!(length_so_far % 4, 0);
5683 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5684 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5685 Ok((vec![request0.into()], vec![]))
5686 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetLightfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5687 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetLightfvReply>, ConnectionError>
5688 where
5689 Conn: RequestConnection + ?Sized,
5690 {
5691 let (bytes, fds) = self.serialize(conn)?;
5692 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5693 conn.send_request_with_reply(&slices, fds)
5694 }
5695 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5696 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5697 if header.minor_opcode != GET_LIGHTFV_REQUEST {
5698 return Err(ParseError::InvalidValue);
5699 }
5700 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5701 let (light, remaining) = u32::try_parse(remaining)?;
5702 let (pname, remaining) = u32::try_parse(remaining)?;
5703 let _ = remaining;
5704 Ok(GetLightfvRequest {
5705 context_tag,
5706 light,
5707 pname,
5708 })
5709 }
5710 }
5711 impl Request for GetLightfvRequest {
5712 type Reply = GetLightfvReply;
5713 }
get_lightfv<Conn>(conn: &Conn, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Conn, GetLightfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5714 pub fn get_lightfv<Conn>(conn: &Conn, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Conn, GetLightfvReply>, ConnectionError>
5715 where
5716 Conn: RequestConnection + ?Sized,
5717 {
5718 let request0 = GetLightfvRequest {
5719 context_tag,
5720 light,
5721 pname,
5722 };
5723 request0.send(conn)
5724 }
5725
5726 #[derive(Debug, Clone, PartialEq)]
5727 pub struct GetLightfvReply {
5728 pub sequence: u16,
5729 pub length: u32,
5730 pub datum: Float32,
5731 pub data: Vec<Float32>,
5732 }
5733 impl TryParse for GetLightfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5734 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5735 let remaining = initial_value;
5736 let (response_type, remaining) = u8::try_parse(remaining)?;
5737 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5738 let (sequence, remaining) = u16::try_parse(remaining)?;
5739 let (length, remaining) = u32::try_parse(remaining)?;
5740 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5741 let (n, remaining) = u32::try_parse(remaining)?;
5742 let (datum, remaining) = Float32::try_parse(remaining)?;
5743 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
5744 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
5745 if response_type != 1 {
5746 return Err(ParseError::InvalidValue);
5747 }
5748 let result = GetLightfvReply { sequence, length, datum, data };
5749 let _ = remaining;
5750 let remaining = initial_value.get(32 + length as usize * 4..)
5751 .ok_or(ParseError::InsufficientData)?;
5752 Ok((result, remaining))
5753 }
5754 }
5755 impl GetLightfvReply {
5756 /// Get the value of the `n` field.
5757 ///
5758 /// The `n` field is used as the length field of the `data` field.
5759 /// This function computes the field's value again based on the length of the list.
5760 ///
5761 /// # Panics
5762 ///
5763 /// Panics if the value cannot be represented in the target type. This
5764 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u325765 pub fn n(&self) -> u32 {
5766 self.data.len()
5767 .try_into().unwrap()
5768 }
5769 }
5770
5771 /// Opcode for the GetLightiv request
5772 pub const GET_LIGHTIV_REQUEST: u8 = 119;
5773 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5774 pub struct GetLightivRequest {
5775 pub context_tag: ContextTag,
5776 pub light: u32,
5777 pub pname: u32,
5778 }
5779 impl GetLightivRequest {
5780 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5781 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5782 where
5783 Conn: RequestConnection + ?Sized,
5784 {
5785 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5786 .ok_or(ConnectionError::UnsupportedExtension)?;
5787 let length_so_far = 0;
5788 let context_tag_bytes = self.context_tag.serialize();
5789 let light_bytes = self.light.serialize();
5790 let pname_bytes = self.pname.serialize();
5791 let mut request0 = vec![
5792 extension_information.major_opcode,
5793 GET_LIGHTIV_REQUEST,
5794 0,
5795 0,
5796 context_tag_bytes[0],
5797 context_tag_bytes[1],
5798 context_tag_bytes[2],
5799 context_tag_bytes[3],
5800 light_bytes[0],
5801 light_bytes[1],
5802 light_bytes[2],
5803 light_bytes[3],
5804 pname_bytes[0],
5805 pname_bytes[1],
5806 pname_bytes[2],
5807 pname_bytes[3],
5808 ];
5809 let length_so_far = length_so_far + request0.len();
5810 assert_eq!(length_so_far % 4, 0);
5811 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5812 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5813 Ok((vec![request0.into()], vec![]))
5814 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetLightivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5815 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetLightivReply>, ConnectionError>
5816 where
5817 Conn: RequestConnection + ?Sized,
5818 {
5819 let (bytes, fds) = self.serialize(conn)?;
5820 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5821 conn.send_request_with_reply(&slices, fds)
5822 }
5823 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5824 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5825 if header.minor_opcode != GET_LIGHTIV_REQUEST {
5826 return Err(ParseError::InvalidValue);
5827 }
5828 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5829 let (light, remaining) = u32::try_parse(remaining)?;
5830 let (pname, remaining) = u32::try_parse(remaining)?;
5831 let _ = remaining;
5832 Ok(GetLightivRequest {
5833 context_tag,
5834 light,
5835 pname,
5836 })
5837 }
5838 }
5839 impl Request for GetLightivRequest {
5840 type Reply = GetLightivReply;
5841 }
get_lightiv<Conn>(conn: &Conn, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Conn, GetLightivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5842 pub fn get_lightiv<Conn>(conn: &Conn, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Conn, GetLightivReply>, ConnectionError>
5843 where
5844 Conn: RequestConnection + ?Sized,
5845 {
5846 let request0 = GetLightivRequest {
5847 context_tag,
5848 light,
5849 pname,
5850 };
5851 request0.send(conn)
5852 }
5853
5854 #[derive(Debug, Clone, PartialEq, Eq)]
5855 pub struct GetLightivReply {
5856 pub sequence: u16,
5857 pub length: u32,
5858 pub datum: i32,
5859 pub data: Vec<i32>,
5860 }
5861 impl TryParse for GetLightivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5862 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5863 let remaining = initial_value;
5864 let (response_type, remaining) = u8::try_parse(remaining)?;
5865 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5866 let (sequence, remaining) = u16::try_parse(remaining)?;
5867 let (length, remaining) = u32::try_parse(remaining)?;
5868 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5869 let (n, remaining) = u32::try_parse(remaining)?;
5870 let (datum, remaining) = i32::try_parse(remaining)?;
5871 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
5872 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
5873 if response_type != 1 {
5874 return Err(ParseError::InvalidValue);
5875 }
5876 let result = GetLightivReply { sequence, length, datum, data };
5877 let _ = remaining;
5878 let remaining = initial_value.get(32 + length as usize * 4..)
5879 .ok_or(ParseError::InsufficientData)?;
5880 Ok((result, remaining))
5881 }
5882 }
5883 impl GetLightivReply {
5884 /// Get the value of the `n` field.
5885 ///
5886 /// The `n` field is used as the length field of the `data` field.
5887 /// This function computes the field's value again based on the length of the list.
5888 ///
5889 /// # Panics
5890 ///
5891 /// Panics if the value cannot be represented in the target type. This
5892 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u325893 pub fn n(&self) -> u32 {
5894 self.data.len()
5895 .try_into().unwrap()
5896 }
5897 }
5898
5899 /// Opcode for the GetMapdv request
5900 pub const GET_MAPDV_REQUEST: u8 = 120;
5901 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
5902 pub struct GetMapdvRequest {
5903 pub context_tag: ContextTag,
5904 pub target: u32,
5905 pub query: u32,
5906 }
5907 impl GetMapdvRequest {
5908 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,5909 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
5910 where
5911 Conn: RequestConnection + ?Sized,
5912 {
5913 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
5914 .ok_or(ConnectionError::UnsupportedExtension)?;
5915 let length_so_far = 0;
5916 let context_tag_bytes = self.context_tag.serialize();
5917 let target_bytes = self.target.serialize();
5918 let query_bytes = self.query.serialize();
5919 let mut request0 = vec![
5920 extension_information.major_opcode,
5921 GET_MAPDV_REQUEST,
5922 0,
5923 0,
5924 context_tag_bytes[0],
5925 context_tag_bytes[1],
5926 context_tag_bytes[2],
5927 context_tag_bytes[3],
5928 target_bytes[0],
5929 target_bytes[1],
5930 target_bytes[2],
5931 target_bytes[3],
5932 query_bytes[0],
5933 query_bytes[1],
5934 query_bytes[2],
5935 query_bytes[3],
5936 ];
5937 let length_so_far = length_so_far + request0.len();
5938 assert_eq!(length_so_far % 4, 0);
5939 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
5940 request0[2..4].copy_from_slice(&length.to_ne_bytes());
5941 Ok((vec![request0.into()], vec![]))
5942 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMapdvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5943 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMapdvReply>, ConnectionError>
5944 where
5945 Conn: RequestConnection + ?Sized,
5946 {
5947 let (bytes, fds) = self.serialize(conn)?;
5948 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
5949 conn.send_request_with_reply(&slices, fds)
5950 }
5951 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>5952 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
5953 if header.minor_opcode != GET_MAPDV_REQUEST {
5954 return Err(ParseError::InvalidValue);
5955 }
5956 let (context_tag, remaining) = ContextTag::try_parse(value)?;
5957 let (target, remaining) = u32::try_parse(remaining)?;
5958 let (query, remaining) = u32::try_parse(remaining)?;
5959 let _ = remaining;
5960 Ok(GetMapdvRequest {
5961 context_tag,
5962 target,
5963 query,
5964 })
5965 }
5966 }
5967 impl Request for GetMapdvRequest {
5968 type Reply = GetMapdvReply;
5969 }
get_mapdv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Conn, GetMapdvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,5970 pub fn get_mapdv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Conn, GetMapdvReply>, ConnectionError>
5971 where
5972 Conn: RequestConnection + ?Sized,
5973 {
5974 let request0 = GetMapdvRequest {
5975 context_tag,
5976 target,
5977 query,
5978 };
5979 request0.send(conn)
5980 }
5981
5982 #[derive(Debug, Clone, PartialEq)]
5983 pub struct GetMapdvReply {
5984 pub sequence: u16,
5985 pub length: u32,
5986 pub datum: Float64,
5987 pub data: Vec<Float64>,
5988 }
5989 impl TryParse for GetMapdvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>5990 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
5991 let remaining = initial_value;
5992 let (response_type, remaining) = u8::try_parse(remaining)?;
5993 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
5994 let (sequence, remaining) = u16::try_parse(remaining)?;
5995 let (length, remaining) = u32::try_parse(remaining)?;
5996 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
5997 let (n, remaining) = u32::try_parse(remaining)?;
5998 let (datum, remaining) = Float64::try_parse(remaining)?;
5999 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
6000 let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, n.try_to_usize()?)?;
6001 if response_type != 1 {
6002 return Err(ParseError::InvalidValue);
6003 }
6004 let result = GetMapdvReply { sequence, length, datum, data };
6005 let _ = remaining;
6006 let remaining = initial_value.get(32 + length as usize * 4..)
6007 .ok_or(ParseError::InsufficientData)?;
6008 Ok((result, remaining))
6009 }
6010 }
6011 impl GetMapdvReply {
6012 /// Get the value of the `n` field.
6013 ///
6014 /// The `n` field is used as the length field of the `data` field.
6015 /// This function computes the field's value again based on the length of the list.
6016 ///
6017 /// # Panics
6018 ///
6019 /// Panics if the value cannot be represented in the target type. This
6020 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326021 pub fn n(&self) -> u32 {
6022 self.data.len()
6023 .try_into().unwrap()
6024 }
6025 }
6026
6027 /// Opcode for the GetMapfv request
6028 pub const GET_MAPFV_REQUEST: u8 = 121;
6029 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6030 pub struct GetMapfvRequest {
6031 pub context_tag: ContextTag,
6032 pub target: u32,
6033 pub query: u32,
6034 }
6035 impl GetMapfvRequest {
6036 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6037 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6038 where
6039 Conn: RequestConnection + ?Sized,
6040 {
6041 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6042 .ok_or(ConnectionError::UnsupportedExtension)?;
6043 let length_so_far = 0;
6044 let context_tag_bytes = self.context_tag.serialize();
6045 let target_bytes = self.target.serialize();
6046 let query_bytes = self.query.serialize();
6047 let mut request0 = vec![
6048 extension_information.major_opcode,
6049 GET_MAPFV_REQUEST,
6050 0,
6051 0,
6052 context_tag_bytes[0],
6053 context_tag_bytes[1],
6054 context_tag_bytes[2],
6055 context_tag_bytes[3],
6056 target_bytes[0],
6057 target_bytes[1],
6058 target_bytes[2],
6059 target_bytes[3],
6060 query_bytes[0],
6061 query_bytes[1],
6062 query_bytes[2],
6063 query_bytes[3],
6064 ];
6065 let length_so_far = length_so_far + request0.len();
6066 assert_eq!(length_so_far % 4, 0);
6067 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6068 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6069 Ok((vec![request0.into()], vec![]))
6070 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMapfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6071 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMapfvReply>, ConnectionError>
6072 where
6073 Conn: RequestConnection + ?Sized,
6074 {
6075 let (bytes, fds) = self.serialize(conn)?;
6076 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6077 conn.send_request_with_reply(&slices, fds)
6078 }
6079 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6080 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6081 if header.minor_opcode != GET_MAPFV_REQUEST {
6082 return Err(ParseError::InvalidValue);
6083 }
6084 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6085 let (target, remaining) = u32::try_parse(remaining)?;
6086 let (query, remaining) = u32::try_parse(remaining)?;
6087 let _ = remaining;
6088 Ok(GetMapfvRequest {
6089 context_tag,
6090 target,
6091 query,
6092 })
6093 }
6094 }
6095 impl Request for GetMapfvRequest {
6096 type Reply = GetMapfvReply;
6097 }
get_mapfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Conn, GetMapfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6098 pub fn get_mapfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Conn, GetMapfvReply>, ConnectionError>
6099 where
6100 Conn: RequestConnection + ?Sized,
6101 {
6102 let request0 = GetMapfvRequest {
6103 context_tag,
6104 target,
6105 query,
6106 };
6107 request0.send(conn)
6108 }
6109
6110 #[derive(Debug, Clone, PartialEq)]
6111 pub struct GetMapfvReply {
6112 pub sequence: u16,
6113 pub length: u32,
6114 pub datum: Float32,
6115 pub data: Vec<Float32>,
6116 }
6117 impl TryParse for GetMapfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6118 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6119 let remaining = initial_value;
6120 let (response_type, remaining) = u8::try_parse(remaining)?;
6121 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6122 let (sequence, remaining) = u16::try_parse(remaining)?;
6123 let (length, remaining) = u32::try_parse(remaining)?;
6124 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6125 let (n, remaining) = u32::try_parse(remaining)?;
6126 let (datum, remaining) = Float32::try_parse(remaining)?;
6127 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6128 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
6129 if response_type != 1 {
6130 return Err(ParseError::InvalidValue);
6131 }
6132 let result = GetMapfvReply { sequence, length, datum, data };
6133 let _ = remaining;
6134 let remaining = initial_value.get(32 + length as usize * 4..)
6135 .ok_or(ParseError::InsufficientData)?;
6136 Ok((result, remaining))
6137 }
6138 }
6139 impl GetMapfvReply {
6140 /// Get the value of the `n` field.
6141 ///
6142 /// The `n` field is used as the length field of the `data` field.
6143 /// This function computes the field's value again based on the length of the list.
6144 ///
6145 /// # Panics
6146 ///
6147 /// Panics if the value cannot be represented in the target type. This
6148 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326149 pub fn n(&self) -> u32 {
6150 self.data.len()
6151 .try_into().unwrap()
6152 }
6153 }
6154
6155 /// Opcode for the GetMapiv request
6156 pub const GET_MAPIV_REQUEST: u8 = 122;
6157 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6158 pub struct GetMapivRequest {
6159 pub context_tag: ContextTag,
6160 pub target: u32,
6161 pub query: u32,
6162 }
6163 impl GetMapivRequest {
6164 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6165 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6166 where
6167 Conn: RequestConnection + ?Sized,
6168 {
6169 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6170 .ok_or(ConnectionError::UnsupportedExtension)?;
6171 let length_so_far = 0;
6172 let context_tag_bytes = self.context_tag.serialize();
6173 let target_bytes = self.target.serialize();
6174 let query_bytes = self.query.serialize();
6175 let mut request0 = vec![
6176 extension_information.major_opcode,
6177 GET_MAPIV_REQUEST,
6178 0,
6179 0,
6180 context_tag_bytes[0],
6181 context_tag_bytes[1],
6182 context_tag_bytes[2],
6183 context_tag_bytes[3],
6184 target_bytes[0],
6185 target_bytes[1],
6186 target_bytes[2],
6187 target_bytes[3],
6188 query_bytes[0],
6189 query_bytes[1],
6190 query_bytes[2],
6191 query_bytes[3],
6192 ];
6193 let length_so_far = length_so_far + request0.len();
6194 assert_eq!(length_so_far % 4, 0);
6195 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6196 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6197 Ok((vec![request0.into()], vec![]))
6198 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMapivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6199 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMapivReply>, ConnectionError>
6200 where
6201 Conn: RequestConnection + ?Sized,
6202 {
6203 let (bytes, fds) = self.serialize(conn)?;
6204 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6205 conn.send_request_with_reply(&slices, fds)
6206 }
6207 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6208 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6209 if header.minor_opcode != GET_MAPIV_REQUEST {
6210 return Err(ParseError::InvalidValue);
6211 }
6212 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6213 let (target, remaining) = u32::try_parse(remaining)?;
6214 let (query, remaining) = u32::try_parse(remaining)?;
6215 let _ = remaining;
6216 Ok(GetMapivRequest {
6217 context_tag,
6218 target,
6219 query,
6220 })
6221 }
6222 }
6223 impl Request for GetMapivRequest {
6224 type Reply = GetMapivReply;
6225 }
get_mapiv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Conn, GetMapivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6226 pub fn get_mapiv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Conn, GetMapivReply>, ConnectionError>
6227 where
6228 Conn: RequestConnection + ?Sized,
6229 {
6230 let request0 = GetMapivRequest {
6231 context_tag,
6232 target,
6233 query,
6234 };
6235 request0.send(conn)
6236 }
6237
6238 #[derive(Debug, Clone, PartialEq, Eq)]
6239 pub struct GetMapivReply {
6240 pub sequence: u16,
6241 pub length: u32,
6242 pub datum: i32,
6243 pub data: Vec<i32>,
6244 }
6245 impl TryParse for GetMapivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6246 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6247 let remaining = initial_value;
6248 let (response_type, remaining) = u8::try_parse(remaining)?;
6249 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6250 let (sequence, remaining) = u16::try_parse(remaining)?;
6251 let (length, remaining) = u32::try_parse(remaining)?;
6252 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6253 let (n, remaining) = u32::try_parse(remaining)?;
6254 let (datum, remaining) = i32::try_parse(remaining)?;
6255 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6256 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
6257 if response_type != 1 {
6258 return Err(ParseError::InvalidValue);
6259 }
6260 let result = GetMapivReply { sequence, length, datum, data };
6261 let _ = remaining;
6262 let remaining = initial_value.get(32 + length as usize * 4..)
6263 .ok_or(ParseError::InsufficientData)?;
6264 Ok((result, remaining))
6265 }
6266 }
6267 impl GetMapivReply {
6268 /// Get the value of the `n` field.
6269 ///
6270 /// The `n` field is used as the length field of the `data` field.
6271 /// This function computes the field's value again based on the length of the list.
6272 ///
6273 /// # Panics
6274 ///
6275 /// Panics if the value cannot be represented in the target type. This
6276 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326277 pub fn n(&self) -> u32 {
6278 self.data.len()
6279 .try_into().unwrap()
6280 }
6281 }
6282
6283 /// Opcode for the GetMaterialfv request
6284 pub const GET_MATERIALFV_REQUEST: u8 = 123;
6285 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6286 pub struct GetMaterialfvRequest {
6287 pub context_tag: ContextTag,
6288 pub face: u32,
6289 pub pname: u32,
6290 }
6291 impl GetMaterialfvRequest {
6292 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6293 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6294 where
6295 Conn: RequestConnection + ?Sized,
6296 {
6297 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6298 .ok_or(ConnectionError::UnsupportedExtension)?;
6299 let length_so_far = 0;
6300 let context_tag_bytes = self.context_tag.serialize();
6301 let face_bytes = self.face.serialize();
6302 let pname_bytes = self.pname.serialize();
6303 let mut request0 = vec![
6304 extension_information.major_opcode,
6305 GET_MATERIALFV_REQUEST,
6306 0,
6307 0,
6308 context_tag_bytes[0],
6309 context_tag_bytes[1],
6310 context_tag_bytes[2],
6311 context_tag_bytes[3],
6312 face_bytes[0],
6313 face_bytes[1],
6314 face_bytes[2],
6315 face_bytes[3],
6316 pname_bytes[0],
6317 pname_bytes[1],
6318 pname_bytes[2],
6319 pname_bytes[3],
6320 ];
6321 let length_so_far = length_so_far + request0.len();
6322 assert_eq!(length_so_far % 4, 0);
6323 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6324 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6325 Ok((vec![request0.into()], vec![]))
6326 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMaterialfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6327 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMaterialfvReply>, ConnectionError>
6328 where
6329 Conn: RequestConnection + ?Sized,
6330 {
6331 let (bytes, fds) = self.serialize(conn)?;
6332 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6333 conn.send_request_with_reply(&slices, fds)
6334 }
6335 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6336 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6337 if header.minor_opcode != GET_MATERIALFV_REQUEST {
6338 return Err(ParseError::InvalidValue);
6339 }
6340 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6341 let (face, remaining) = u32::try_parse(remaining)?;
6342 let (pname, remaining) = u32::try_parse(remaining)?;
6343 let _ = remaining;
6344 Ok(GetMaterialfvRequest {
6345 context_tag,
6346 face,
6347 pname,
6348 })
6349 }
6350 }
6351 impl Request for GetMaterialfvRequest {
6352 type Reply = GetMaterialfvReply;
6353 }
get_materialfv<Conn>(conn: &Conn, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMaterialfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6354 pub fn get_materialfv<Conn>(conn: &Conn, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMaterialfvReply>, ConnectionError>
6355 where
6356 Conn: RequestConnection + ?Sized,
6357 {
6358 let request0 = GetMaterialfvRequest {
6359 context_tag,
6360 face,
6361 pname,
6362 };
6363 request0.send(conn)
6364 }
6365
6366 #[derive(Debug, Clone, PartialEq)]
6367 pub struct GetMaterialfvReply {
6368 pub sequence: u16,
6369 pub length: u32,
6370 pub datum: Float32,
6371 pub data: Vec<Float32>,
6372 }
6373 impl TryParse for GetMaterialfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6374 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6375 let remaining = initial_value;
6376 let (response_type, remaining) = u8::try_parse(remaining)?;
6377 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6378 let (sequence, remaining) = u16::try_parse(remaining)?;
6379 let (length, remaining) = u32::try_parse(remaining)?;
6380 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6381 let (n, remaining) = u32::try_parse(remaining)?;
6382 let (datum, remaining) = Float32::try_parse(remaining)?;
6383 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6384 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
6385 if response_type != 1 {
6386 return Err(ParseError::InvalidValue);
6387 }
6388 let result = GetMaterialfvReply { sequence, length, datum, data };
6389 let _ = remaining;
6390 let remaining = initial_value.get(32 + length as usize * 4..)
6391 .ok_or(ParseError::InsufficientData)?;
6392 Ok((result, remaining))
6393 }
6394 }
6395 impl GetMaterialfvReply {
6396 /// Get the value of the `n` field.
6397 ///
6398 /// The `n` field is used as the length field of the `data` field.
6399 /// This function computes the field's value again based on the length of the list.
6400 ///
6401 /// # Panics
6402 ///
6403 /// Panics if the value cannot be represented in the target type. This
6404 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326405 pub fn n(&self) -> u32 {
6406 self.data.len()
6407 .try_into().unwrap()
6408 }
6409 }
6410
6411 /// Opcode for the GetMaterialiv request
6412 pub const GET_MATERIALIV_REQUEST: u8 = 124;
6413 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6414 pub struct GetMaterialivRequest {
6415 pub context_tag: ContextTag,
6416 pub face: u32,
6417 pub pname: u32,
6418 }
6419 impl GetMaterialivRequest {
6420 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6421 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6422 where
6423 Conn: RequestConnection + ?Sized,
6424 {
6425 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6426 .ok_or(ConnectionError::UnsupportedExtension)?;
6427 let length_so_far = 0;
6428 let context_tag_bytes = self.context_tag.serialize();
6429 let face_bytes = self.face.serialize();
6430 let pname_bytes = self.pname.serialize();
6431 let mut request0 = vec![
6432 extension_information.major_opcode,
6433 GET_MATERIALIV_REQUEST,
6434 0,
6435 0,
6436 context_tag_bytes[0],
6437 context_tag_bytes[1],
6438 context_tag_bytes[2],
6439 context_tag_bytes[3],
6440 face_bytes[0],
6441 face_bytes[1],
6442 face_bytes[2],
6443 face_bytes[3],
6444 pname_bytes[0],
6445 pname_bytes[1],
6446 pname_bytes[2],
6447 pname_bytes[3],
6448 ];
6449 let length_so_far = length_so_far + request0.len();
6450 assert_eq!(length_so_far % 4, 0);
6451 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6452 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6453 Ok((vec![request0.into()], vec![]))
6454 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMaterialivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6455 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMaterialivReply>, ConnectionError>
6456 where
6457 Conn: RequestConnection + ?Sized,
6458 {
6459 let (bytes, fds) = self.serialize(conn)?;
6460 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6461 conn.send_request_with_reply(&slices, fds)
6462 }
6463 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6464 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6465 if header.minor_opcode != GET_MATERIALIV_REQUEST {
6466 return Err(ParseError::InvalidValue);
6467 }
6468 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6469 let (face, remaining) = u32::try_parse(remaining)?;
6470 let (pname, remaining) = u32::try_parse(remaining)?;
6471 let _ = remaining;
6472 Ok(GetMaterialivRequest {
6473 context_tag,
6474 face,
6475 pname,
6476 })
6477 }
6478 }
6479 impl Request for GetMaterialivRequest {
6480 type Reply = GetMaterialivReply;
6481 }
get_materialiv<Conn>(conn: &Conn, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMaterialivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6482 pub fn get_materialiv<Conn>(conn: &Conn, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMaterialivReply>, ConnectionError>
6483 where
6484 Conn: RequestConnection + ?Sized,
6485 {
6486 let request0 = GetMaterialivRequest {
6487 context_tag,
6488 face,
6489 pname,
6490 };
6491 request0.send(conn)
6492 }
6493
6494 #[derive(Debug, Clone, PartialEq, Eq)]
6495 pub struct GetMaterialivReply {
6496 pub sequence: u16,
6497 pub length: u32,
6498 pub datum: i32,
6499 pub data: Vec<i32>,
6500 }
6501 impl TryParse for GetMaterialivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6502 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6503 let remaining = initial_value;
6504 let (response_type, remaining) = u8::try_parse(remaining)?;
6505 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6506 let (sequence, remaining) = u16::try_parse(remaining)?;
6507 let (length, remaining) = u32::try_parse(remaining)?;
6508 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6509 let (n, remaining) = u32::try_parse(remaining)?;
6510 let (datum, remaining) = i32::try_parse(remaining)?;
6511 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6512 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
6513 if response_type != 1 {
6514 return Err(ParseError::InvalidValue);
6515 }
6516 let result = GetMaterialivReply { sequence, length, datum, data };
6517 let _ = remaining;
6518 let remaining = initial_value.get(32 + length as usize * 4..)
6519 .ok_or(ParseError::InsufficientData)?;
6520 Ok((result, remaining))
6521 }
6522 }
6523 impl GetMaterialivReply {
6524 /// Get the value of the `n` field.
6525 ///
6526 /// The `n` field is used as the length field of the `data` field.
6527 /// This function computes the field's value again based on the length of the list.
6528 ///
6529 /// # Panics
6530 ///
6531 /// Panics if the value cannot be represented in the target type. This
6532 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326533 pub fn n(&self) -> u32 {
6534 self.data.len()
6535 .try_into().unwrap()
6536 }
6537 }
6538
6539 /// Opcode for the GetPixelMapfv request
6540 pub const GET_PIXEL_MAPFV_REQUEST: u8 = 125;
6541 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6542 pub struct GetPixelMapfvRequest {
6543 pub context_tag: ContextTag,
6544 pub map: u32,
6545 }
6546 impl GetPixelMapfvRequest {
6547 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6548 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6549 where
6550 Conn: RequestConnection + ?Sized,
6551 {
6552 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6553 .ok_or(ConnectionError::UnsupportedExtension)?;
6554 let length_so_far = 0;
6555 let context_tag_bytes = self.context_tag.serialize();
6556 let map_bytes = self.map.serialize();
6557 let mut request0 = vec![
6558 extension_information.major_opcode,
6559 GET_PIXEL_MAPFV_REQUEST,
6560 0,
6561 0,
6562 context_tag_bytes[0],
6563 context_tag_bytes[1],
6564 context_tag_bytes[2],
6565 context_tag_bytes[3],
6566 map_bytes[0],
6567 map_bytes[1],
6568 map_bytes[2],
6569 map_bytes[3],
6570 ];
6571 let length_so_far = length_so_far + request0.len();
6572 assert_eq!(length_so_far % 4, 0);
6573 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6574 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6575 Ok((vec![request0.into()], vec![]))
6576 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPixelMapfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6577 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPixelMapfvReply>, ConnectionError>
6578 where
6579 Conn: RequestConnection + ?Sized,
6580 {
6581 let (bytes, fds) = self.serialize(conn)?;
6582 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6583 conn.send_request_with_reply(&slices, fds)
6584 }
6585 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6586 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6587 if header.minor_opcode != GET_PIXEL_MAPFV_REQUEST {
6588 return Err(ParseError::InvalidValue);
6589 }
6590 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6591 let (map, remaining) = u32::try_parse(remaining)?;
6592 let _ = remaining;
6593 Ok(GetPixelMapfvRequest {
6594 context_tag,
6595 map,
6596 })
6597 }
6598 }
6599 impl Request for GetPixelMapfvRequest {
6600 type Reply = GetPixelMapfvReply;
6601 }
get_pixel_mapfv<Conn>(conn: &Conn, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Conn, GetPixelMapfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6602 pub fn get_pixel_mapfv<Conn>(conn: &Conn, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Conn, GetPixelMapfvReply>, ConnectionError>
6603 where
6604 Conn: RequestConnection + ?Sized,
6605 {
6606 let request0 = GetPixelMapfvRequest {
6607 context_tag,
6608 map,
6609 };
6610 request0.send(conn)
6611 }
6612
6613 #[derive(Debug, Clone, PartialEq)]
6614 pub struct GetPixelMapfvReply {
6615 pub sequence: u16,
6616 pub length: u32,
6617 pub datum: Float32,
6618 pub data: Vec<Float32>,
6619 }
6620 impl TryParse for GetPixelMapfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6621 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6622 let remaining = initial_value;
6623 let (response_type, remaining) = u8::try_parse(remaining)?;
6624 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6625 let (sequence, remaining) = u16::try_parse(remaining)?;
6626 let (length, remaining) = u32::try_parse(remaining)?;
6627 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6628 let (n, remaining) = u32::try_parse(remaining)?;
6629 let (datum, remaining) = Float32::try_parse(remaining)?;
6630 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6631 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
6632 if response_type != 1 {
6633 return Err(ParseError::InvalidValue);
6634 }
6635 let result = GetPixelMapfvReply { sequence, length, datum, data };
6636 let _ = remaining;
6637 let remaining = initial_value.get(32 + length as usize * 4..)
6638 .ok_or(ParseError::InsufficientData)?;
6639 Ok((result, remaining))
6640 }
6641 }
6642 impl GetPixelMapfvReply {
6643 /// Get the value of the `n` field.
6644 ///
6645 /// The `n` field is used as the length field of the `data` field.
6646 /// This function computes the field's value again based on the length of the list.
6647 ///
6648 /// # Panics
6649 ///
6650 /// Panics if the value cannot be represented in the target type. This
6651 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326652 pub fn n(&self) -> u32 {
6653 self.data.len()
6654 .try_into().unwrap()
6655 }
6656 }
6657
6658 /// Opcode for the GetPixelMapuiv request
6659 pub const GET_PIXEL_MAPUIV_REQUEST: u8 = 126;
6660 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6661 pub struct GetPixelMapuivRequest {
6662 pub context_tag: ContextTag,
6663 pub map: u32,
6664 }
6665 impl GetPixelMapuivRequest {
6666 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6667 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6668 where
6669 Conn: RequestConnection + ?Sized,
6670 {
6671 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6672 .ok_or(ConnectionError::UnsupportedExtension)?;
6673 let length_so_far = 0;
6674 let context_tag_bytes = self.context_tag.serialize();
6675 let map_bytes = self.map.serialize();
6676 let mut request0 = vec![
6677 extension_information.major_opcode,
6678 GET_PIXEL_MAPUIV_REQUEST,
6679 0,
6680 0,
6681 context_tag_bytes[0],
6682 context_tag_bytes[1],
6683 context_tag_bytes[2],
6684 context_tag_bytes[3],
6685 map_bytes[0],
6686 map_bytes[1],
6687 map_bytes[2],
6688 map_bytes[3],
6689 ];
6690 let length_so_far = length_so_far + request0.len();
6691 assert_eq!(length_so_far % 4, 0);
6692 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6693 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6694 Ok((vec![request0.into()], vec![]))
6695 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPixelMapuivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6696 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPixelMapuivReply>, ConnectionError>
6697 where
6698 Conn: RequestConnection + ?Sized,
6699 {
6700 let (bytes, fds) = self.serialize(conn)?;
6701 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6702 conn.send_request_with_reply(&slices, fds)
6703 }
6704 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6705 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6706 if header.minor_opcode != GET_PIXEL_MAPUIV_REQUEST {
6707 return Err(ParseError::InvalidValue);
6708 }
6709 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6710 let (map, remaining) = u32::try_parse(remaining)?;
6711 let _ = remaining;
6712 Ok(GetPixelMapuivRequest {
6713 context_tag,
6714 map,
6715 })
6716 }
6717 }
6718 impl Request for GetPixelMapuivRequest {
6719 type Reply = GetPixelMapuivReply;
6720 }
get_pixel_mapuiv<Conn>(conn: &Conn, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Conn, GetPixelMapuivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6721 pub fn get_pixel_mapuiv<Conn>(conn: &Conn, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Conn, GetPixelMapuivReply>, ConnectionError>
6722 where
6723 Conn: RequestConnection + ?Sized,
6724 {
6725 let request0 = GetPixelMapuivRequest {
6726 context_tag,
6727 map,
6728 };
6729 request0.send(conn)
6730 }
6731
6732 #[derive(Debug, Clone, PartialEq, Eq)]
6733 pub struct GetPixelMapuivReply {
6734 pub sequence: u16,
6735 pub length: u32,
6736 pub datum: u32,
6737 pub data: Vec<u32>,
6738 }
6739 impl TryParse for GetPixelMapuivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6740 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6741 let remaining = initial_value;
6742 let (response_type, remaining) = u8::try_parse(remaining)?;
6743 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6744 let (sequence, remaining) = u16::try_parse(remaining)?;
6745 let (length, remaining) = u32::try_parse(remaining)?;
6746 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6747 let (n, remaining) = u32::try_parse(remaining)?;
6748 let (datum, remaining) = u32::try_parse(remaining)?;
6749 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
6750 let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
6751 if response_type != 1 {
6752 return Err(ParseError::InvalidValue);
6753 }
6754 let result = GetPixelMapuivReply { sequence, length, datum, data };
6755 let _ = remaining;
6756 let remaining = initial_value.get(32 + length as usize * 4..)
6757 .ok_or(ParseError::InsufficientData)?;
6758 Ok((result, remaining))
6759 }
6760 }
6761 impl GetPixelMapuivReply {
6762 /// Get the value of the `n` field.
6763 ///
6764 /// The `n` field is used as the length field of the `data` field.
6765 /// This function computes the field's value again based on the length of the list.
6766 ///
6767 /// # Panics
6768 ///
6769 /// Panics if the value cannot be represented in the target type. This
6770 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326771 pub fn n(&self) -> u32 {
6772 self.data.len()
6773 .try_into().unwrap()
6774 }
6775 }
6776
6777 /// Opcode for the GetPixelMapusv request
6778 pub const GET_PIXEL_MAPUSV_REQUEST: u8 = 127;
6779 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6780 pub struct GetPixelMapusvRequest {
6781 pub context_tag: ContextTag,
6782 pub map: u32,
6783 }
6784 impl GetPixelMapusvRequest {
6785 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6786 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6787 where
6788 Conn: RequestConnection + ?Sized,
6789 {
6790 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6791 .ok_or(ConnectionError::UnsupportedExtension)?;
6792 let length_so_far = 0;
6793 let context_tag_bytes = self.context_tag.serialize();
6794 let map_bytes = self.map.serialize();
6795 let mut request0 = vec![
6796 extension_information.major_opcode,
6797 GET_PIXEL_MAPUSV_REQUEST,
6798 0,
6799 0,
6800 context_tag_bytes[0],
6801 context_tag_bytes[1],
6802 context_tag_bytes[2],
6803 context_tag_bytes[3],
6804 map_bytes[0],
6805 map_bytes[1],
6806 map_bytes[2],
6807 map_bytes[3],
6808 ];
6809 let length_so_far = length_so_far + request0.len();
6810 assert_eq!(length_so_far % 4, 0);
6811 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6812 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6813 Ok((vec![request0.into()], vec![]))
6814 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPixelMapusvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6815 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPixelMapusvReply>, ConnectionError>
6816 where
6817 Conn: RequestConnection + ?Sized,
6818 {
6819 let (bytes, fds) = self.serialize(conn)?;
6820 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6821 conn.send_request_with_reply(&slices, fds)
6822 }
6823 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6824 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6825 if header.minor_opcode != GET_PIXEL_MAPUSV_REQUEST {
6826 return Err(ParseError::InvalidValue);
6827 }
6828 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6829 let (map, remaining) = u32::try_parse(remaining)?;
6830 let _ = remaining;
6831 Ok(GetPixelMapusvRequest {
6832 context_tag,
6833 map,
6834 })
6835 }
6836 }
6837 impl Request for GetPixelMapusvRequest {
6838 type Reply = GetPixelMapusvReply;
6839 }
get_pixel_mapusv<Conn>(conn: &Conn, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Conn, GetPixelMapusvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6840 pub fn get_pixel_mapusv<Conn>(conn: &Conn, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Conn, GetPixelMapusvReply>, ConnectionError>
6841 where
6842 Conn: RequestConnection + ?Sized,
6843 {
6844 let request0 = GetPixelMapusvRequest {
6845 context_tag,
6846 map,
6847 };
6848 request0.send(conn)
6849 }
6850
6851 #[derive(Debug, Clone, PartialEq, Eq)]
6852 pub struct GetPixelMapusvReply {
6853 pub sequence: u16,
6854 pub length: u32,
6855 pub datum: u16,
6856 pub data: Vec<u16>,
6857 }
6858 impl TryParse for GetPixelMapusvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6859 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6860 let remaining = initial_value;
6861 let (response_type, remaining) = u8::try_parse(remaining)?;
6862 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6863 let (sequence, remaining) = u16::try_parse(remaining)?;
6864 let (length, remaining) = u32::try_parse(remaining)?;
6865 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
6866 let (n, remaining) = u32::try_parse(remaining)?;
6867 let (datum, remaining) = u16::try_parse(remaining)?;
6868 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
6869 let (data, remaining) = crate::x11_utils::parse_list::<u16>(remaining, n.try_to_usize()?)?;
6870 if response_type != 1 {
6871 return Err(ParseError::InvalidValue);
6872 }
6873 let result = GetPixelMapusvReply { sequence, length, datum, data };
6874 let _ = remaining;
6875 let remaining = initial_value.get(32 + length as usize * 4..)
6876 .ok_or(ParseError::InsufficientData)?;
6877 Ok((result, remaining))
6878 }
6879 }
6880 impl GetPixelMapusvReply {
6881 /// Get the value of the `n` field.
6882 ///
6883 /// The `n` field is used as the length field of the `data` field.
6884 /// This function computes the field's value again based on the length of the list.
6885 ///
6886 /// # Panics
6887 ///
6888 /// Panics if the value cannot be represented in the target type. This
6889 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u326890 pub fn n(&self) -> u32 {
6891 self.data.len()
6892 .try_into().unwrap()
6893 }
6894 }
6895
6896 /// Opcode for the GetPolygonStipple request
6897 pub const GET_POLYGON_STIPPLE_REQUEST: u8 = 128;
6898 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
6899 pub struct GetPolygonStippleRequest {
6900 pub context_tag: ContextTag,
6901 pub lsb_first: bool,
6902 }
6903 impl GetPolygonStippleRequest {
6904 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,6905 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
6906 where
6907 Conn: RequestConnection + ?Sized,
6908 {
6909 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
6910 .ok_or(ConnectionError::UnsupportedExtension)?;
6911 let length_so_far = 0;
6912 let context_tag_bytes = self.context_tag.serialize();
6913 let lsb_first_bytes = self.lsb_first.serialize();
6914 let mut request0 = vec![
6915 extension_information.major_opcode,
6916 GET_POLYGON_STIPPLE_REQUEST,
6917 0,
6918 0,
6919 context_tag_bytes[0],
6920 context_tag_bytes[1],
6921 context_tag_bytes[2],
6922 context_tag_bytes[3],
6923 lsb_first_bytes[0],
6924 0,
6925 0,
6926 0,
6927 ];
6928 let length_so_far = length_so_far + request0.len();
6929 assert_eq!(length_so_far % 4, 0);
6930 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
6931 request0[2..4].copy_from_slice(&length.to_ne_bytes());
6932 Ok((vec![request0.into()], vec![]))
6933 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPolygonStippleReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6934 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPolygonStippleReply>, ConnectionError>
6935 where
6936 Conn: RequestConnection + ?Sized,
6937 {
6938 let (bytes, fds) = self.serialize(conn)?;
6939 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
6940 conn.send_request_with_reply(&slices, fds)
6941 }
6942 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>6943 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
6944 if header.minor_opcode != GET_POLYGON_STIPPLE_REQUEST {
6945 return Err(ParseError::InvalidValue);
6946 }
6947 let (context_tag, remaining) = ContextTag::try_parse(value)?;
6948 let (lsb_first, remaining) = bool::try_parse(remaining)?;
6949 let _ = remaining;
6950 Ok(GetPolygonStippleRequest {
6951 context_tag,
6952 lsb_first,
6953 })
6954 }
6955 }
6956 impl Request for GetPolygonStippleRequest {
6957 type Reply = GetPolygonStippleReply;
6958 }
get_polygon_stipple<Conn>(conn: &Conn, context_tag: ContextTag, lsb_first: bool) -> Result<Cookie<'_, Conn, GetPolygonStippleReply>, ConnectionError> where Conn: RequestConnection + ?Sized,6959 pub fn get_polygon_stipple<Conn>(conn: &Conn, context_tag: ContextTag, lsb_first: bool) -> Result<Cookie<'_, Conn, GetPolygonStippleReply>, ConnectionError>
6960 where
6961 Conn: RequestConnection + ?Sized,
6962 {
6963 let request0 = GetPolygonStippleRequest {
6964 context_tag,
6965 lsb_first,
6966 };
6967 request0.send(conn)
6968 }
6969
6970 #[derive(Debug, Clone, PartialEq, Eq)]
6971 pub struct GetPolygonStippleReply {
6972 pub sequence: u16,
6973 pub data: Vec<u8>,
6974 }
6975 impl TryParse for GetPolygonStippleReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>6976 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
6977 let remaining = initial_value;
6978 let (response_type, remaining) = u8::try_parse(remaining)?;
6979 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
6980 let (sequence, remaining) = u16::try_parse(remaining)?;
6981 let (length, remaining) = u32::try_parse(remaining)?;
6982 let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
6983 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
6984 let data = data.to_vec();
6985 if response_type != 1 {
6986 return Err(ParseError::InvalidValue);
6987 }
6988 let result = GetPolygonStippleReply { sequence, data };
6989 let _ = remaining;
6990 let remaining = initial_value.get(32 + length as usize * 4..)
6991 .ok_or(ParseError::InsufficientData)?;
6992 Ok((result, remaining))
6993 }
6994 }
6995 impl GetPolygonStippleReply {
6996 /// Get the value of the `length` field.
6997 ///
6998 /// The `length` field is used as the length field of the `data` field.
6999 /// This function computes the field's value again based on the length of the list.
7000 ///
7001 /// # Panics
7002 ///
7003 /// Panics if the value cannot be represented in the target type. This
7004 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u327005 pub fn length(&self) -> u32 {
7006 self.data.len()
7007 .checked_div(4).unwrap()
7008 .try_into().unwrap()
7009 }
7010 }
7011
7012 /// Opcode for the GetString request
7013 pub const GET_STRING_REQUEST: u8 = 129;
7014 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7015 pub struct GetStringRequest {
7016 pub context_tag: ContextTag,
7017 pub name: u32,
7018 }
7019 impl GetStringRequest {
7020 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7021 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7022 where
7023 Conn: RequestConnection + ?Sized,
7024 {
7025 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7026 .ok_or(ConnectionError::UnsupportedExtension)?;
7027 let length_so_far = 0;
7028 let context_tag_bytes = self.context_tag.serialize();
7029 let name_bytes = self.name.serialize();
7030 let mut request0 = vec![
7031 extension_information.major_opcode,
7032 GET_STRING_REQUEST,
7033 0,
7034 0,
7035 context_tag_bytes[0],
7036 context_tag_bytes[1],
7037 context_tag_bytes[2],
7038 context_tag_bytes[3],
7039 name_bytes[0],
7040 name_bytes[1],
7041 name_bytes[2],
7042 name_bytes[3],
7043 ];
7044 let length_so_far = length_so_far + request0.len();
7045 assert_eq!(length_so_far % 4, 0);
7046 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7047 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7048 Ok((vec![request0.into()], vec![]))
7049 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetStringReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7050 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetStringReply>, ConnectionError>
7051 where
7052 Conn: RequestConnection + ?Sized,
7053 {
7054 let (bytes, fds) = self.serialize(conn)?;
7055 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7056 conn.send_request_with_reply(&slices, fds)
7057 }
7058 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7059 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7060 if header.minor_opcode != GET_STRING_REQUEST {
7061 return Err(ParseError::InvalidValue);
7062 }
7063 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7064 let (name, remaining) = u32::try_parse(remaining)?;
7065 let _ = remaining;
7066 Ok(GetStringRequest {
7067 context_tag,
7068 name,
7069 })
7070 }
7071 }
7072 impl Request for GetStringRequest {
7073 type Reply = GetStringReply;
7074 }
get_string<Conn>(conn: &Conn, context_tag: ContextTag, name: u32) -> Result<Cookie<'_, Conn, GetStringReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7075 pub fn get_string<Conn>(conn: &Conn, context_tag: ContextTag, name: u32) -> Result<Cookie<'_, Conn, GetStringReply>, ConnectionError>
7076 where
7077 Conn: RequestConnection + ?Sized,
7078 {
7079 let request0 = GetStringRequest {
7080 context_tag,
7081 name,
7082 };
7083 request0.send(conn)
7084 }
7085
7086 #[derive(Debug, Clone, PartialEq, Eq)]
7087 pub struct GetStringReply {
7088 pub sequence: u16,
7089 pub length: u32,
7090 pub string: Vec<u8>,
7091 }
7092 impl TryParse for GetStringReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>7093 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7094 let remaining = initial_value;
7095 let (response_type, remaining) = u8::try_parse(remaining)?;
7096 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7097 let (sequence, remaining) = u16::try_parse(remaining)?;
7098 let (length, remaining) = u32::try_parse(remaining)?;
7099 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7100 let (n, remaining) = u32::try_parse(remaining)?;
7101 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
7102 let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, n.try_to_usize()?)?;
7103 let string = string.to_vec();
7104 if response_type != 1 {
7105 return Err(ParseError::InvalidValue);
7106 }
7107 let result = GetStringReply { sequence, length, string };
7108 let _ = remaining;
7109 let remaining = initial_value.get(32 + length as usize * 4..)
7110 .ok_or(ParseError::InsufficientData)?;
7111 Ok((result, remaining))
7112 }
7113 }
7114 impl GetStringReply {
7115 /// Get the value of the `n` field.
7116 ///
7117 /// The `n` field is used as the length field of the `string` field.
7118 /// This function computes the field's value again based on the length of the list.
7119 ///
7120 /// # Panics
7121 ///
7122 /// Panics if the value cannot be represented in the target type. This
7123 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u327124 pub fn n(&self) -> u32 {
7125 self.string.len()
7126 .try_into().unwrap()
7127 }
7128 }
7129
7130 /// Opcode for the GetTexEnvfv request
7131 pub const GET_TEX_ENVFV_REQUEST: u8 = 130;
7132 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7133 pub struct GetTexEnvfvRequest {
7134 pub context_tag: ContextTag,
7135 pub target: u32,
7136 pub pname: u32,
7137 }
7138 impl GetTexEnvfvRequest {
7139 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7140 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7141 where
7142 Conn: RequestConnection + ?Sized,
7143 {
7144 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7145 .ok_or(ConnectionError::UnsupportedExtension)?;
7146 let length_so_far = 0;
7147 let context_tag_bytes = self.context_tag.serialize();
7148 let target_bytes = self.target.serialize();
7149 let pname_bytes = self.pname.serialize();
7150 let mut request0 = vec![
7151 extension_information.major_opcode,
7152 GET_TEX_ENVFV_REQUEST,
7153 0,
7154 0,
7155 context_tag_bytes[0],
7156 context_tag_bytes[1],
7157 context_tag_bytes[2],
7158 context_tag_bytes[3],
7159 target_bytes[0],
7160 target_bytes[1],
7161 target_bytes[2],
7162 target_bytes[3],
7163 pname_bytes[0],
7164 pname_bytes[1],
7165 pname_bytes[2],
7166 pname_bytes[3],
7167 ];
7168 let length_so_far = length_so_far + request0.len();
7169 assert_eq!(length_so_far % 4, 0);
7170 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7171 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7172 Ok((vec![request0.into()], vec![]))
7173 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexEnvfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7174 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexEnvfvReply>, ConnectionError>
7175 where
7176 Conn: RequestConnection + ?Sized,
7177 {
7178 let (bytes, fds) = self.serialize(conn)?;
7179 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7180 conn.send_request_with_reply(&slices, fds)
7181 }
7182 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7183 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7184 if header.minor_opcode != GET_TEX_ENVFV_REQUEST {
7185 return Err(ParseError::InvalidValue);
7186 }
7187 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7188 let (target, remaining) = u32::try_parse(remaining)?;
7189 let (pname, remaining) = u32::try_parse(remaining)?;
7190 let _ = remaining;
7191 Ok(GetTexEnvfvRequest {
7192 context_tag,
7193 target,
7194 pname,
7195 })
7196 }
7197 }
7198 impl Request for GetTexEnvfvRequest {
7199 type Reply = GetTexEnvfvReply;
7200 }
get_tex_envfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexEnvfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7201 pub fn get_tex_envfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexEnvfvReply>, ConnectionError>
7202 where
7203 Conn: RequestConnection + ?Sized,
7204 {
7205 let request0 = GetTexEnvfvRequest {
7206 context_tag,
7207 target,
7208 pname,
7209 };
7210 request0.send(conn)
7211 }
7212
7213 #[derive(Debug, Clone, PartialEq)]
7214 pub struct GetTexEnvfvReply {
7215 pub sequence: u16,
7216 pub length: u32,
7217 pub datum: Float32,
7218 pub data: Vec<Float32>,
7219 }
7220 impl TryParse for GetTexEnvfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>7221 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7222 let remaining = initial_value;
7223 let (response_type, remaining) = u8::try_parse(remaining)?;
7224 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7225 let (sequence, remaining) = u16::try_parse(remaining)?;
7226 let (length, remaining) = u32::try_parse(remaining)?;
7227 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7228 let (n, remaining) = u32::try_parse(remaining)?;
7229 let (datum, remaining) = Float32::try_parse(remaining)?;
7230 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7231 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
7232 if response_type != 1 {
7233 return Err(ParseError::InvalidValue);
7234 }
7235 let result = GetTexEnvfvReply { sequence, length, datum, data };
7236 let _ = remaining;
7237 let remaining = initial_value.get(32 + length as usize * 4..)
7238 .ok_or(ParseError::InsufficientData)?;
7239 Ok((result, remaining))
7240 }
7241 }
7242 impl GetTexEnvfvReply {
7243 /// Get the value of the `n` field.
7244 ///
7245 /// The `n` field is used as the length field of the `data` field.
7246 /// This function computes the field's value again based on the length of the list.
7247 ///
7248 /// # Panics
7249 ///
7250 /// Panics if the value cannot be represented in the target type. This
7251 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u327252 pub fn n(&self) -> u32 {
7253 self.data.len()
7254 .try_into().unwrap()
7255 }
7256 }
7257
7258 /// Opcode for the GetTexEnviv request
7259 pub const GET_TEX_ENVIV_REQUEST: u8 = 131;
7260 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7261 pub struct GetTexEnvivRequest {
7262 pub context_tag: ContextTag,
7263 pub target: u32,
7264 pub pname: u32,
7265 }
7266 impl GetTexEnvivRequest {
7267 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7268 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7269 where
7270 Conn: RequestConnection + ?Sized,
7271 {
7272 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7273 .ok_or(ConnectionError::UnsupportedExtension)?;
7274 let length_so_far = 0;
7275 let context_tag_bytes = self.context_tag.serialize();
7276 let target_bytes = self.target.serialize();
7277 let pname_bytes = self.pname.serialize();
7278 let mut request0 = vec![
7279 extension_information.major_opcode,
7280 GET_TEX_ENVIV_REQUEST,
7281 0,
7282 0,
7283 context_tag_bytes[0],
7284 context_tag_bytes[1],
7285 context_tag_bytes[2],
7286 context_tag_bytes[3],
7287 target_bytes[0],
7288 target_bytes[1],
7289 target_bytes[2],
7290 target_bytes[3],
7291 pname_bytes[0],
7292 pname_bytes[1],
7293 pname_bytes[2],
7294 pname_bytes[3],
7295 ];
7296 let length_so_far = length_so_far + request0.len();
7297 assert_eq!(length_so_far % 4, 0);
7298 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7299 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7300 Ok((vec![request0.into()], vec![]))
7301 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexEnvivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7302 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexEnvivReply>, ConnectionError>
7303 where
7304 Conn: RequestConnection + ?Sized,
7305 {
7306 let (bytes, fds) = self.serialize(conn)?;
7307 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7308 conn.send_request_with_reply(&slices, fds)
7309 }
7310 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7311 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7312 if header.minor_opcode != GET_TEX_ENVIV_REQUEST {
7313 return Err(ParseError::InvalidValue);
7314 }
7315 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7316 let (target, remaining) = u32::try_parse(remaining)?;
7317 let (pname, remaining) = u32::try_parse(remaining)?;
7318 let _ = remaining;
7319 Ok(GetTexEnvivRequest {
7320 context_tag,
7321 target,
7322 pname,
7323 })
7324 }
7325 }
7326 impl Request for GetTexEnvivRequest {
7327 type Reply = GetTexEnvivReply;
7328 }
get_tex_enviv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexEnvivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7329 pub fn get_tex_enviv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexEnvivReply>, ConnectionError>
7330 where
7331 Conn: RequestConnection + ?Sized,
7332 {
7333 let request0 = GetTexEnvivRequest {
7334 context_tag,
7335 target,
7336 pname,
7337 };
7338 request0.send(conn)
7339 }
7340
7341 #[derive(Debug, Clone, PartialEq, Eq)]
7342 pub struct GetTexEnvivReply {
7343 pub sequence: u16,
7344 pub length: u32,
7345 pub datum: i32,
7346 pub data: Vec<i32>,
7347 }
7348 impl TryParse for GetTexEnvivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>7349 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7350 let remaining = initial_value;
7351 let (response_type, remaining) = u8::try_parse(remaining)?;
7352 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7353 let (sequence, remaining) = u16::try_parse(remaining)?;
7354 let (length, remaining) = u32::try_parse(remaining)?;
7355 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7356 let (n, remaining) = u32::try_parse(remaining)?;
7357 let (datum, remaining) = i32::try_parse(remaining)?;
7358 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7359 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
7360 if response_type != 1 {
7361 return Err(ParseError::InvalidValue);
7362 }
7363 let result = GetTexEnvivReply { sequence, length, datum, data };
7364 let _ = remaining;
7365 let remaining = initial_value.get(32 + length as usize * 4..)
7366 .ok_or(ParseError::InsufficientData)?;
7367 Ok((result, remaining))
7368 }
7369 }
7370 impl GetTexEnvivReply {
7371 /// Get the value of the `n` field.
7372 ///
7373 /// The `n` field is used as the length field of the `data` field.
7374 /// This function computes the field's value again based on the length of the list.
7375 ///
7376 /// # Panics
7377 ///
7378 /// Panics if the value cannot be represented in the target type. This
7379 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u327380 pub fn n(&self) -> u32 {
7381 self.data.len()
7382 .try_into().unwrap()
7383 }
7384 }
7385
7386 /// Opcode for the GetTexGendv request
7387 pub const GET_TEX_GENDV_REQUEST: u8 = 132;
7388 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7389 pub struct GetTexGendvRequest {
7390 pub context_tag: ContextTag,
7391 pub coord: u32,
7392 pub pname: u32,
7393 }
7394 impl GetTexGendvRequest {
7395 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7396 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7397 where
7398 Conn: RequestConnection + ?Sized,
7399 {
7400 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7401 .ok_or(ConnectionError::UnsupportedExtension)?;
7402 let length_so_far = 0;
7403 let context_tag_bytes = self.context_tag.serialize();
7404 let coord_bytes = self.coord.serialize();
7405 let pname_bytes = self.pname.serialize();
7406 let mut request0 = vec![
7407 extension_information.major_opcode,
7408 GET_TEX_GENDV_REQUEST,
7409 0,
7410 0,
7411 context_tag_bytes[0],
7412 context_tag_bytes[1],
7413 context_tag_bytes[2],
7414 context_tag_bytes[3],
7415 coord_bytes[0],
7416 coord_bytes[1],
7417 coord_bytes[2],
7418 coord_bytes[3],
7419 pname_bytes[0],
7420 pname_bytes[1],
7421 pname_bytes[2],
7422 pname_bytes[3],
7423 ];
7424 let length_so_far = length_so_far + request0.len();
7425 assert_eq!(length_so_far % 4, 0);
7426 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7427 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7428 Ok((vec![request0.into()], vec![]))
7429 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexGendvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7430 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexGendvReply>, ConnectionError>
7431 where
7432 Conn: RequestConnection + ?Sized,
7433 {
7434 let (bytes, fds) = self.serialize(conn)?;
7435 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7436 conn.send_request_with_reply(&slices, fds)
7437 }
7438 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7439 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7440 if header.minor_opcode != GET_TEX_GENDV_REQUEST {
7441 return Err(ParseError::InvalidValue);
7442 }
7443 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7444 let (coord, remaining) = u32::try_parse(remaining)?;
7445 let (pname, remaining) = u32::try_parse(remaining)?;
7446 let _ = remaining;
7447 Ok(GetTexGendvRequest {
7448 context_tag,
7449 coord,
7450 pname,
7451 })
7452 }
7453 }
7454 impl Request for GetTexGendvRequest {
7455 type Reply = GetTexGendvReply;
7456 }
get_tex_gendv<Conn>(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexGendvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7457 pub fn get_tex_gendv<Conn>(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexGendvReply>, ConnectionError>
7458 where
7459 Conn: RequestConnection + ?Sized,
7460 {
7461 let request0 = GetTexGendvRequest {
7462 context_tag,
7463 coord,
7464 pname,
7465 };
7466 request0.send(conn)
7467 }
7468
7469 #[derive(Debug, Clone, PartialEq)]
7470 pub struct GetTexGendvReply {
7471 pub sequence: u16,
7472 pub length: u32,
7473 pub datum: Float64,
7474 pub data: Vec<Float64>,
7475 }
7476 impl TryParse for GetTexGendvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>7477 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7478 let remaining = initial_value;
7479 let (response_type, remaining) = u8::try_parse(remaining)?;
7480 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7481 let (sequence, remaining) = u16::try_parse(remaining)?;
7482 let (length, remaining) = u32::try_parse(remaining)?;
7483 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7484 let (n, remaining) = u32::try_parse(remaining)?;
7485 let (datum, remaining) = Float64::try_parse(remaining)?;
7486 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
7487 let (data, remaining) = crate::x11_utils::parse_list::<Float64>(remaining, n.try_to_usize()?)?;
7488 if response_type != 1 {
7489 return Err(ParseError::InvalidValue);
7490 }
7491 let result = GetTexGendvReply { sequence, length, datum, data };
7492 let _ = remaining;
7493 let remaining = initial_value.get(32 + length as usize * 4..)
7494 .ok_or(ParseError::InsufficientData)?;
7495 Ok((result, remaining))
7496 }
7497 }
7498 impl GetTexGendvReply {
7499 /// Get the value of the `n` field.
7500 ///
7501 /// The `n` field is used as the length field of the `data` field.
7502 /// This function computes the field's value again based on the length of the list.
7503 ///
7504 /// # Panics
7505 ///
7506 /// Panics if the value cannot be represented in the target type. This
7507 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u327508 pub fn n(&self) -> u32 {
7509 self.data.len()
7510 .try_into().unwrap()
7511 }
7512 }
7513
7514 /// Opcode for the GetTexGenfv request
7515 pub const GET_TEX_GENFV_REQUEST: u8 = 133;
7516 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7517 pub struct GetTexGenfvRequest {
7518 pub context_tag: ContextTag,
7519 pub coord: u32,
7520 pub pname: u32,
7521 }
7522 impl GetTexGenfvRequest {
7523 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7524 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7525 where
7526 Conn: RequestConnection + ?Sized,
7527 {
7528 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7529 .ok_or(ConnectionError::UnsupportedExtension)?;
7530 let length_so_far = 0;
7531 let context_tag_bytes = self.context_tag.serialize();
7532 let coord_bytes = self.coord.serialize();
7533 let pname_bytes = self.pname.serialize();
7534 let mut request0 = vec![
7535 extension_information.major_opcode,
7536 GET_TEX_GENFV_REQUEST,
7537 0,
7538 0,
7539 context_tag_bytes[0],
7540 context_tag_bytes[1],
7541 context_tag_bytes[2],
7542 context_tag_bytes[3],
7543 coord_bytes[0],
7544 coord_bytes[1],
7545 coord_bytes[2],
7546 coord_bytes[3],
7547 pname_bytes[0],
7548 pname_bytes[1],
7549 pname_bytes[2],
7550 pname_bytes[3],
7551 ];
7552 let length_so_far = length_so_far + request0.len();
7553 assert_eq!(length_so_far % 4, 0);
7554 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7555 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7556 Ok((vec![request0.into()], vec![]))
7557 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexGenfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7558 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexGenfvReply>, ConnectionError>
7559 where
7560 Conn: RequestConnection + ?Sized,
7561 {
7562 let (bytes, fds) = self.serialize(conn)?;
7563 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7564 conn.send_request_with_reply(&slices, fds)
7565 }
7566 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7567 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7568 if header.minor_opcode != GET_TEX_GENFV_REQUEST {
7569 return Err(ParseError::InvalidValue);
7570 }
7571 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7572 let (coord, remaining) = u32::try_parse(remaining)?;
7573 let (pname, remaining) = u32::try_parse(remaining)?;
7574 let _ = remaining;
7575 Ok(GetTexGenfvRequest {
7576 context_tag,
7577 coord,
7578 pname,
7579 })
7580 }
7581 }
7582 impl Request for GetTexGenfvRequest {
7583 type Reply = GetTexGenfvReply;
7584 }
get_tex_genfv<Conn>(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexGenfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7585 pub fn get_tex_genfv<Conn>(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexGenfvReply>, ConnectionError>
7586 where
7587 Conn: RequestConnection + ?Sized,
7588 {
7589 let request0 = GetTexGenfvRequest {
7590 context_tag,
7591 coord,
7592 pname,
7593 };
7594 request0.send(conn)
7595 }
7596
7597 #[derive(Debug, Clone, PartialEq)]
7598 pub struct GetTexGenfvReply {
7599 pub sequence: u16,
7600 pub length: u32,
7601 pub datum: Float32,
7602 pub data: Vec<Float32>,
7603 }
7604 impl TryParse for GetTexGenfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>7605 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7606 let remaining = initial_value;
7607 let (response_type, remaining) = u8::try_parse(remaining)?;
7608 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7609 let (sequence, remaining) = u16::try_parse(remaining)?;
7610 let (length, remaining) = u32::try_parse(remaining)?;
7611 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7612 let (n, remaining) = u32::try_parse(remaining)?;
7613 let (datum, remaining) = Float32::try_parse(remaining)?;
7614 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7615 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
7616 if response_type != 1 {
7617 return Err(ParseError::InvalidValue);
7618 }
7619 let result = GetTexGenfvReply { sequence, length, datum, data };
7620 let _ = remaining;
7621 let remaining = initial_value.get(32 + length as usize * 4..)
7622 .ok_or(ParseError::InsufficientData)?;
7623 Ok((result, remaining))
7624 }
7625 }
7626 impl GetTexGenfvReply {
7627 /// Get the value of the `n` field.
7628 ///
7629 /// The `n` field is used as the length field of the `data` field.
7630 /// This function computes the field's value again based on the length of the list.
7631 ///
7632 /// # Panics
7633 ///
7634 /// Panics if the value cannot be represented in the target type. This
7635 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u327636 pub fn n(&self) -> u32 {
7637 self.data.len()
7638 .try_into().unwrap()
7639 }
7640 }
7641
7642 /// Opcode for the GetTexGeniv request
7643 pub const GET_TEX_GENIV_REQUEST: u8 = 134;
7644 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7645 pub struct GetTexGenivRequest {
7646 pub context_tag: ContextTag,
7647 pub coord: u32,
7648 pub pname: u32,
7649 }
7650 impl GetTexGenivRequest {
7651 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7652 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7653 where
7654 Conn: RequestConnection + ?Sized,
7655 {
7656 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7657 .ok_or(ConnectionError::UnsupportedExtension)?;
7658 let length_so_far = 0;
7659 let context_tag_bytes = self.context_tag.serialize();
7660 let coord_bytes = self.coord.serialize();
7661 let pname_bytes = self.pname.serialize();
7662 let mut request0 = vec![
7663 extension_information.major_opcode,
7664 GET_TEX_GENIV_REQUEST,
7665 0,
7666 0,
7667 context_tag_bytes[0],
7668 context_tag_bytes[1],
7669 context_tag_bytes[2],
7670 context_tag_bytes[3],
7671 coord_bytes[0],
7672 coord_bytes[1],
7673 coord_bytes[2],
7674 coord_bytes[3],
7675 pname_bytes[0],
7676 pname_bytes[1],
7677 pname_bytes[2],
7678 pname_bytes[3],
7679 ];
7680 let length_so_far = length_so_far + request0.len();
7681 assert_eq!(length_so_far % 4, 0);
7682 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7683 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7684 Ok((vec![request0.into()], vec![]))
7685 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexGenivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7686 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexGenivReply>, ConnectionError>
7687 where
7688 Conn: RequestConnection + ?Sized,
7689 {
7690 let (bytes, fds) = self.serialize(conn)?;
7691 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7692 conn.send_request_with_reply(&slices, fds)
7693 }
7694 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7695 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7696 if header.minor_opcode != GET_TEX_GENIV_REQUEST {
7697 return Err(ParseError::InvalidValue);
7698 }
7699 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7700 let (coord, remaining) = u32::try_parse(remaining)?;
7701 let (pname, remaining) = u32::try_parse(remaining)?;
7702 let _ = remaining;
7703 Ok(GetTexGenivRequest {
7704 context_tag,
7705 coord,
7706 pname,
7707 })
7708 }
7709 }
7710 impl Request for GetTexGenivRequest {
7711 type Reply = GetTexGenivReply;
7712 }
get_tex_geniv<Conn>(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexGenivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7713 pub fn get_tex_geniv<Conn>(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexGenivReply>, ConnectionError>
7714 where
7715 Conn: RequestConnection + ?Sized,
7716 {
7717 let request0 = GetTexGenivRequest {
7718 context_tag,
7719 coord,
7720 pname,
7721 };
7722 request0.send(conn)
7723 }
7724
7725 #[derive(Debug, Clone, PartialEq, Eq)]
7726 pub struct GetTexGenivReply {
7727 pub sequence: u16,
7728 pub length: u32,
7729 pub datum: i32,
7730 pub data: Vec<i32>,
7731 }
7732 impl TryParse for GetTexGenivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>7733 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7734 let remaining = initial_value;
7735 let (response_type, remaining) = u8::try_parse(remaining)?;
7736 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7737 let (sequence, remaining) = u16::try_parse(remaining)?;
7738 let (length, remaining) = u32::try_parse(remaining)?;
7739 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7740 let (n, remaining) = u32::try_parse(remaining)?;
7741 let (datum, remaining) = i32::try_parse(remaining)?;
7742 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
7743 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
7744 if response_type != 1 {
7745 return Err(ParseError::InvalidValue);
7746 }
7747 let result = GetTexGenivReply { sequence, length, datum, data };
7748 let _ = remaining;
7749 let remaining = initial_value.get(32 + length as usize * 4..)
7750 .ok_or(ParseError::InsufficientData)?;
7751 Ok((result, remaining))
7752 }
7753 }
7754 impl GetTexGenivReply {
7755 /// Get the value of the `n` field.
7756 ///
7757 /// The `n` field is used as the length field of the `data` field.
7758 /// This function computes the field's value again based on the length of the list.
7759 ///
7760 /// # Panics
7761 ///
7762 /// Panics if the value cannot be represented in the target type. This
7763 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u327764 pub fn n(&self) -> u32 {
7765 self.data.len()
7766 .try_into().unwrap()
7767 }
7768 }
7769
7770 /// Opcode for the GetTexImage request
7771 pub const GET_TEX_IMAGE_REQUEST: u8 = 135;
7772 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7773 pub struct GetTexImageRequest {
7774 pub context_tag: ContextTag,
7775 pub target: u32,
7776 pub level: i32,
7777 pub format: u32,
7778 pub type_: u32,
7779 pub swap_bytes: bool,
7780 }
7781 impl GetTexImageRequest {
7782 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7783 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7784 where
7785 Conn: RequestConnection + ?Sized,
7786 {
7787 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7788 .ok_or(ConnectionError::UnsupportedExtension)?;
7789 let length_so_far = 0;
7790 let context_tag_bytes = self.context_tag.serialize();
7791 let target_bytes = self.target.serialize();
7792 let level_bytes = self.level.serialize();
7793 let format_bytes = self.format.serialize();
7794 let type_bytes = self.type_.serialize();
7795 let swap_bytes_bytes = self.swap_bytes.serialize();
7796 let mut request0 = vec![
7797 extension_information.major_opcode,
7798 GET_TEX_IMAGE_REQUEST,
7799 0,
7800 0,
7801 context_tag_bytes[0],
7802 context_tag_bytes[1],
7803 context_tag_bytes[2],
7804 context_tag_bytes[3],
7805 target_bytes[0],
7806 target_bytes[1],
7807 target_bytes[2],
7808 target_bytes[3],
7809 level_bytes[0],
7810 level_bytes[1],
7811 level_bytes[2],
7812 level_bytes[3],
7813 format_bytes[0],
7814 format_bytes[1],
7815 format_bytes[2],
7816 format_bytes[3],
7817 type_bytes[0],
7818 type_bytes[1],
7819 type_bytes[2],
7820 type_bytes[3],
7821 swap_bytes_bytes[0],
7822 0,
7823 0,
7824 0,
7825 ];
7826 let length_so_far = length_so_far + request0.len();
7827 assert_eq!(length_so_far % 4, 0);
7828 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7829 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7830 Ok((vec![request0.into()], vec![]))
7831 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexImageReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7832 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexImageReply>, ConnectionError>
7833 where
7834 Conn: RequestConnection + ?Sized,
7835 {
7836 let (bytes, fds) = self.serialize(conn)?;
7837 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7838 conn.send_request_with_reply(&slices, fds)
7839 }
7840 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7841 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7842 if header.minor_opcode != GET_TEX_IMAGE_REQUEST {
7843 return Err(ParseError::InvalidValue);
7844 }
7845 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7846 let (target, remaining) = u32::try_parse(remaining)?;
7847 let (level, remaining) = i32::try_parse(remaining)?;
7848 let (format, remaining) = u32::try_parse(remaining)?;
7849 let (type_, remaining) = u32::try_parse(remaining)?;
7850 let (swap_bytes, remaining) = bool::try_parse(remaining)?;
7851 let _ = remaining;
7852 Ok(GetTexImageRequest {
7853 context_tag,
7854 target,
7855 level,
7856 format,
7857 type_,
7858 swap_bytes,
7859 })
7860 }
7861 }
7862 impl Request for GetTexImageRequest {
7863 type Reply = GetTexImageReply;
7864 }
get_tex_image<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetTexImageReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7865 pub fn get_tex_image<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetTexImageReply>, ConnectionError>
7866 where
7867 Conn: RequestConnection + ?Sized,
7868 {
7869 let request0 = GetTexImageRequest {
7870 context_tag,
7871 target,
7872 level,
7873 format,
7874 type_,
7875 swap_bytes,
7876 };
7877 request0.send(conn)
7878 }
7879
7880 #[derive(Debug, Clone, PartialEq, Eq)]
7881 pub struct GetTexImageReply {
7882 pub sequence: u16,
7883 pub width: i32,
7884 pub height: i32,
7885 pub depth: i32,
7886 pub data: Vec<u8>,
7887 }
7888 impl TryParse for GetTexImageReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>7889 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
7890 let remaining = initial_value;
7891 let (response_type, remaining) = u8::try_parse(remaining)?;
7892 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
7893 let (sequence, remaining) = u16::try_parse(remaining)?;
7894 let (length, remaining) = u32::try_parse(remaining)?;
7895 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
7896 let (width, remaining) = i32::try_parse(remaining)?;
7897 let (height, remaining) = i32::try_parse(remaining)?;
7898 let (depth, remaining) = i32::try_parse(remaining)?;
7899 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
7900 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
7901 let data = data.to_vec();
7902 if response_type != 1 {
7903 return Err(ParseError::InvalidValue);
7904 }
7905 let result = GetTexImageReply { sequence, width, height, depth, data };
7906 let _ = remaining;
7907 let remaining = initial_value.get(32 + length as usize * 4..)
7908 .ok_or(ParseError::InsufficientData)?;
7909 Ok((result, remaining))
7910 }
7911 }
7912 impl GetTexImageReply {
7913 /// Get the value of the `length` field.
7914 ///
7915 /// The `length` field is used as the length field of the `data` field.
7916 /// This function computes the field's value again based on the length of the list.
7917 ///
7918 /// # Panics
7919 ///
7920 /// Panics if the value cannot be represented in the target type. This
7921 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u327922 pub fn length(&self) -> u32 {
7923 self.data.len()
7924 .checked_div(4).unwrap()
7925 .try_into().unwrap()
7926 }
7927 }
7928
7929 /// Opcode for the GetTexParameterfv request
7930 pub const GET_TEX_PARAMETERFV_REQUEST: u8 = 136;
7931 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
7932 pub struct GetTexParameterfvRequest {
7933 pub context_tag: ContextTag,
7934 pub target: u32,
7935 pub pname: u32,
7936 }
7937 impl GetTexParameterfvRequest {
7938 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,7939 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
7940 where
7941 Conn: RequestConnection + ?Sized,
7942 {
7943 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
7944 .ok_or(ConnectionError::UnsupportedExtension)?;
7945 let length_so_far = 0;
7946 let context_tag_bytes = self.context_tag.serialize();
7947 let target_bytes = self.target.serialize();
7948 let pname_bytes = self.pname.serialize();
7949 let mut request0 = vec![
7950 extension_information.major_opcode,
7951 GET_TEX_PARAMETERFV_REQUEST,
7952 0,
7953 0,
7954 context_tag_bytes[0],
7955 context_tag_bytes[1],
7956 context_tag_bytes[2],
7957 context_tag_bytes[3],
7958 target_bytes[0],
7959 target_bytes[1],
7960 target_bytes[2],
7961 target_bytes[3],
7962 pname_bytes[0],
7963 pname_bytes[1],
7964 pname_bytes[2],
7965 pname_bytes[3],
7966 ];
7967 let length_so_far = length_so_far + request0.len();
7968 assert_eq!(length_so_far % 4, 0);
7969 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
7970 request0[2..4].copy_from_slice(&length.to_ne_bytes());
7971 Ok((vec![request0.into()], vec![]))
7972 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,7973 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexParameterfvReply>, ConnectionError>
7974 where
7975 Conn: RequestConnection + ?Sized,
7976 {
7977 let (bytes, fds) = self.serialize(conn)?;
7978 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
7979 conn.send_request_with_reply(&slices, fds)
7980 }
7981 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>7982 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
7983 if header.minor_opcode != GET_TEX_PARAMETERFV_REQUEST {
7984 return Err(ParseError::InvalidValue);
7985 }
7986 let (context_tag, remaining) = ContextTag::try_parse(value)?;
7987 let (target, remaining) = u32::try_parse(remaining)?;
7988 let (pname, remaining) = u32::try_parse(remaining)?;
7989 let _ = remaining;
7990 Ok(GetTexParameterfvRequest {
7991 context_tag,
7992 target,
7993 pname,
7994 })
7995 }
7996 }
7997 impl Request for GetTexParameterfvRequest {
7998 type Reply = GetTexParameterfvReply;
7999 }
get_tex_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8000 pub fn get_tex_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexParameterfvReply>, ConnectionError>
8001 where
8002 Conn: RequestConnection + ?Sized,
8003 {
8004 let request0 = GetTexParameterfvRequest {
8005 context_tag,
8006 target,
8007 pname,
8008 };
8009 request0.send(conn)
8010 }
8011
8012 #[derive(Debug, Clone, PartialEq)]
8013 pub struct GetTexParameterfvReply {
8014 pub sequence: u16,
8015 pub length: u32,
8016 pub datum: Float32,
8017 pub data: Vec<Float32>,
8018 }
8019 impl TryParse for GetTexParameterfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>8020 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8021 let remaining = initial_value;
8022 let (response_type, remaining) = u8::try_parse(remaining)?;
8023 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8024 let (sequence, remaining) = u16::try_parse(remaining)?;
8025 let (length, remaining) = u32::try_parse(remaining)?;
8026 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8027 let (n, remaining) = u32::try_parse(remaining)?;
8028 let (datum, remaining) = Float32::try_parse(remaining)?;
8029 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8030 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
8031 if response_type != 1 {
8032 return Err(ParseError::InvalidValue);
8033 }
8034 let result = GetTexParameterfvReply { sequence, length, datum, data };
8035 let _ = remaining;
8036 let remaining = initial_value.get(32 + length as usize * 4..)
8037 .ok_or(ParseError::InsufficientData)?;
8038 Ok((result, remaining))
8039 }
8040 }
8041 impl GetTexParameterfvReply {
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.
n(&self) -> u328051 pub fn n(&self) -> u32 {
8052 self.data.len()
8053 .try_into().unwrap()
8054 }
8055 }
8056
8057 /// Opcode for the GetTexParameteriv request
8058 pub const GET_TEX_PARAMETERIV_REQUEST: u8 = 137;
8059 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8060 pub struct GetTexParameterivRequest {
8061 pub context_tag: ContextTag,
8062 pub target: u32,
8063 pub pname: u32,
8064 }
8065 impl GetTexParameterivRequest {
8066 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8067 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8068 where
8069 Conn: RequestConnection + ?Sized,
8070 {
8071 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8072 .ok_or(ConnectionError::UnsupportedExtension)?;
8073 let length_so_far = 0;
8074 let context_tag_bytes = self.context_tag.serialize();
8075 let target_bytes = self.target.serialize();
8076 let pname_bytes = self.pname.serialize();
8077 let mut request0 = vec![
8078 extension_information.major_opcode,
8079 GET_TEX_PARAMETERIV_REQUEST,
8080 0,
8081 0,
8082 context_tag_bytes[0],
8083 context_tag_bytes[1],
8084 context_tag_bytes[2],
8085 context_tag_bytes[3],
8086 target_bytes[0],
8087 target_bytes[1],
8088 target_bytes[2],
8089 target_bytes[3],
8090 pname_bytes[0],
8091 pname_bytes[1],
8092 pname_bytes[2],
8093 pname_bytes[3],
8094 ];
8095 let length_so_far = length_so_far + request0.len();
8096 assert_eq!(length_so_far % 4, 0);
8097 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8098 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8099 Ok((vec![request0.into()], vec![]))
8100 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8101 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexParameterivReply>, ConnectionError>
8102 where
8103 Conn: RequestConnection + ?Sized,
8104 {
8105 let (bytes, fds) = self.serialize(conn)?;
8106 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8107 conn.send_request_with_reply(&slices, fds)
8108 }
8109 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>8110 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8111 if header.minor_opcode != GET_TEX_PARAMETERIV_REQUEST {
8112 return Err(ParseError::InvalidValue);
8113 }
8114 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8115 let (target, remaining) = u32::try_parse(remaining)?;
8116 let (pname, remaining) = u32::try_parse(remaining)?;
8117 let _ = remaining;
8118 Ok(GetTexParameterivRequest {
8119 context_tag,
8120 target,
8121 pname,
8122 })
8123 }
8124 }
8125 impl Request for GetTexParameterivRequest {
8126 type Reply = GetTexParameterivReply;
8127 }
get_tex_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8128 pub fn get_tex_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetTexParameterivReply>, ConnectionError>
8129 where
8130 Conn: RequestConnection + ?Sized,
8131 {
8132 let request0 = GetTexParameterivRequest {
8133 context_tag,
8134 target,
8135 pname,
8136 };
8137 request0.send(conn)
8138 }
8139
8140 #[derive(Debug, Clone, PartialEq, Eq)]
8141 pub struct GetTexParameterivReply {
8142 pub sequence: u16,
8143 pub length: u32,
8144 pub datum: i32,
8145 pub data: Vec<i32>,
8146 }
8147 impl TryParse for GetTexParameterivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>8148 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8149 let remaining = initial_value;
8150 let (response_type, remaining) = u8::try_parse(remaining)?;
8151 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8152 let (sequence, remaining) = u16::try_parse(remaining)?;
8153 let (length, remaining) = u32::try_parse(remaining)?;
8154 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8155 let (n, remaining) = u32::try_parse(remaining)?;
8156 let (datum, remaining) = i32::try_parse(remaining)?;
8157 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8158 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
8159 if response_type != 1 {
8160 return Err(ParseError::InvalidValue);
8161 }
8162 let result = GetTexParameterivReply { sequence, length, datum, data };
8163 let _ = remaining;
8164 let remaining = initial_value.get(32 + length as usize * 4..)
8165 .ok_or(ParseError::InsufficientData)?;
8166 Ok((result, remaining))
8167 }
8168 }
8169 impl GetTexParameterivReply {
8170 /// Get the value of the `n` field.
8171 ///
8172 /// The `n` field is used as the length field of the `data` field.
8173 /// This function computes the field's value again based on the length of the list.
8174 ///
8175 /// # Panics
8176 ///
8177 /// Panics if the value cannot be represented in the target type. This
8178 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u328179 pub fn n(&self) -> u32 {
8180 self.data.len()
8181 .try_into().unwrap()
8182 }
8183 }
8184
8185 /// Opcode for the GetTexLevelParameterfv request
8186 pub const GET_TEX_LEVEL_PARAMETERFV_REQUEST: u8 = 138;
8187 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8188 pub struct GetTexLevelParameterfvRequest {
8189 pub context_tag: ContextTag,
8190 pub target: u32,
8191 pub level: i32,
8192 pub pname: u32,
8193 }
8194 impl GetTexLevelParameterfvRequest {
8195 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8196 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8197 where
8198 Conn: RequestConnection + ?Sized,
8199 {
8200 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8201 .ok_or(ConnectionError::UnsupportedExtension)?;
8202 let length_so_far = 0;
8203 let context_tag_bytes = self.context_tag.serialize();
8204 let target_bytes = self.target.serialize();
8205 let level_bytes = self.level.serialize();
8206 let pname_bytes = self.pname.serialize();
8207 let mut request0 = vec![
8208 extension_information.major_opcode,
8209 GET_TEX_LEVEL_PARAMETERFV_REQUEST,
8210 0,
8211 0,
8212 context_tag_bytes[0],
8213 context_tag_bytes[1],
8214 context_tag_bytes[2],
8215 context_tag_bytes[3],
8216 target_bytes[0],
8217 target_bytes[1],
8218 target_bytes[2],
8219 target_bytes[3],
8220 level_bytes[0],
8221 level_bytes[1],
8222 level_bytes[2],
8223 level_bytes[3],
8224 pname_bytes[0],
8225 pname_bytes[1],
8226 pname_bytes[2],
8227 pname_bytes[3],
8228 ];
8229 let length_so_far = length_so_far + request0.len();
8230 assert_eq!(length_so_far % 4, 0);
8231 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8232 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8233 Ok((vec![request0.into()], vec![]))
8234 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexLevelParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8235 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexLevelParameterfvReply>, ConnectionError>
8236 where
8237 Conn: RequestConnection + ?Sized,
8238 {
8239 let (bytes, fds) = self.serialize(conn)?;
8240 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8241 conn.send_request_with_reply(&slices, fds)
8242 }
8243 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>8244 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8245 if header.minor_opcode != GET_TEX_LEVEL_PARAMETERFV_REQUEST {
8246 return Err(ParseError::InvalidValue);
8247 }
8248 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8249 let (target, remaining) = u32::try_parse(remaining)?;
8250 let (level, remaining) = i32::try_parse(remaining)?;
8251 let (pname, remaining) = u32::try_parse(remaining)?;
8252 let _ = remaining;
8253 Ok(GetTexLevelParameterfvRequest {
8254 context_tag,
8255 target,
8256 level,
8257 pname,
8258 })
8259 }
8260 }
8261 impl Request for GetTexLevelParameterfvRequest {
8262 type Reply = GetTexLevelParameterfvReply;
8263 }
get_tex_level_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Conn, GetTexLevelParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8264 pub fn get_tex_level_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Conn, GetTexLevelParameterfvReply>, ConnectionError>
8265 where
8266 Conn: RequestConnection + ?Sized,
8267 {
8268 let request0 = GetTexLevelParameterfvRequest {
8269 context_tag,
8270 target,
8271 level,
8272 pname,
8273 };
8274 request0.send(conn)
8275 }
8276
8277 #[derive(Debug, Clone, PartialEq)]
8278 pub struct GetTexLevelParameterfvReply {
8279 pub sequence: u16,
8280 pub length: u32,
8281 pub datum: Float32,
8282 pub data: Vec<Float32>,
8283 }
8284 impl TryParse for GetTexLevelParameterfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>8285 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8286 let remaining = initial_value;
8287 let (response_type, remaining) = u8::try_parse(remaining)?;
8288 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8289 let (sequence, remaining) = u16::try_parse(remaining)?;
8290 let (length, remaining) = u32::try_parse(remaining)?;
8291 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8292 let (n, remaining) = u32::try_parse(remaining)?;
8293 let (datum, remaining) = Float32::try_parse(remaining)?;
8294 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8295 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
8296 if response_type != 1 {
8297 return Err(ParseError::InvalidValue);
8298 }
8299 let result = GetTexLevelParameterfvReply { sequence, length, datum, data };
8300 let _ = remaining;
8301 let remaining = initial_value.get(32 + length as usize * 4..)
8302 .ok_or(ParseError::InsufficientData)?;
8303 Ok((result, remaining))
8304 }
8305 }
8306 impl GetTexLevelParameterfvReply {
8307 /// Get the value of the `n` field.
8308 ///
8309 /// The `n` field is used as the length field of the `data` field.
8310 /// This function computes the field's value again based on the length of the list.
8311 ///
8312 /// # Panics
8313 ///
8314 /// Panics if the value cannot be represented in the target type. This
8315 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u328316 pub fn n(&self) -> u32 {
8317 self.data.len()
8318 .try_into().unwrap()
8319 }
8320 }
8321
8322 /// Opcode for the GetTexLevelParameteriv request
8323 pub const GET_TEX_LEVEL_PARAMETERIV_REQUEST: u8 = 139;
8324 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8325 pub struct GetTexLevelParameterivRequest {
8326 pub context_tag: ContextTag,
8327 pub target: u32,
8328 pub level: i32,
8329 pub pname: u32,
8330 }
8331 impl GetTexLevelParameterivRequest {
8332 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8333 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8334 where
8335 Conn: RequestConnection + ?Sized,
8336 {
8337 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8338 .ok_or(ConnectionError::UnsupportedExtension)?;
8339 let length_so_far = 0;
8340 let context_tag_bytes = self.context_tag.serialize();
8341 let target_bytes = self.target.serialize();
8342 let level_bytes = self.level.serialize();
8343 let pname_bytes = self.pname.serialize();
8344 let mut request0 = vec![
8345 extension_information.major_opcode,
8346 GET_TEX_LEVEL_PARAMETERIV_REQUEST,
8347 0,
8348 0,
8349 context_tag_bytes[0],
8350 context_tag_bytes[1],
8351 context_tag_bytes[2],
8352 context_tag_bytes[3],
8353 target_bytes[0],
8354 target_bytes[1],
8355 target_bytes[2],
8356 target_bytes[3],
8357 level_bytes[0],
8358 level_bytes[1],
8359 level_bytes[2],
8360 level_bytes[3],
8361 pname_bytes[0],
8362 pname_bytes[1],
8363 pname_bytes[2],
8364 pname_bytes[3],
8365 ];
8366 let length_so_far = length_so_far + request0.len();
8367 assert_eq!(length_so_far % 4, 0);
8368 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8369 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8370 Ok((vec![request0.into()], vec![]))
8371 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexLevelParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8372 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetTexLevelParameterivReply>, ConnectionError>
8373 where
8374 Conn: RequestConnection + ?Sized,
8375 {
8376 let (bytes, fds) = self.serialize(conn)?;
8377 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8378 conn.send_request_with_reply(&slices, fds)
8379 }
8380 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>8381 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8382 if header.minor_opcode != GET_TEX_LEVEL_PARAMETERIV_REQUEST {
8383 return Err(ParseError::InvalidValue);
8384 }
8385 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8386 let (target, remaining) = u32::try_parse(remaining)?;
8387 let (level, remaining) = i32::try_parse(remaining)?;
8388 let (pname, remaining) = u32::try_parse(remaining)?;
8389 let _ = remaining;
8390 Ok(GetTexLevelParameterivRequest {
8391 context_tag,
8392 target,
8393 level,
8394 pname,
8395 })
8396 }
8397 }
8398 impl Request for GetTexLevelParameterivRequest {
8399 type Reply = GetTexLevelParameterivReply;
8400 }
get_tex_level_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Conn, GetTexLevelParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8401 pub fn get_tex_level_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Conn, GetTexLevelParameterivReply>, ConnectionError>
8402 where
8403 Conn: RequestConnection + ?Sized,
8404 {
8405 let request0 = GetTexLevelParameterivRequest {
8406 context_tag,
8407 target,
8408 level,
8409 pname,
8410 };
8411 request0.send(conn)
8412 }
8413
8414 #[derive(Debug, Clone, PartialEq, Eq)]
8415 pub struct GetTexLevelParameterivReply {
8416 pub sequence: u16,
8417 pub length: u32,
8418 pub datum: i32,
8419 pub data: Vec<i32>,
8420 }
8421 impl TryParse for GetTexLevelParameterivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>8422 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8423 let remaining = initial_value;
8424 let (response_type, remaining) = u8::try_parse(remaining)?;
8425 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8426 let (sequence, remaining) = u16::try_parse(remaining)?;
8427 let (length, remaining) = u32::try_parse(remaining)?;
8428 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
8429 let (n, remaining) = u32::try_parse(remaining)?;
8430 let (datum, remaining) = i32::try_parse(remaining)?;
8431 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
8432 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
8433 if response_type != 1 {
8434 return Err(ParseError::InvalidValue);
8435 }
8436 let result = GetTexLevelParameterivReply { sequence, length, datum, data };
8437 let _ = remaining;
8438 let remaining = initial_value.get(32 + length as usize * 4..)
8439 .ok_or(ParseError::InsufficientData)?;
8440 Ok((result, remaining))
8441 }
8442 }
8443 impl GetTexLevelParameterivReply {
8444 /// Get the value of the `n` field.
8445 ///
8446 /// The `n` field is used as the length field of the `data` field.
8447 /// This function computes the field's value again based on the length of the list.
8448 ///
8449 /// # Panics
8450 ///
8451 /// Panics if the value cannot be represented in the target type. This
8452 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u328453 pub fn n(&self) -> u32 {
8454 self.data.len()
8455 .try_into().unwrap()
8456 }
8457 }
8458
8459 /// Opcode for the IsEnabled request
8460 pub const IS_ENABLED_REQUEST: u8 = 140;
8461 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8462 pub struct IsEnabledRequest {
8463 pub context_tag: ContextTag,
8464 pub capability: u32,
8465 }
8466 impl IsEnabledRequest {
8467 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8468 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8469 where
8470 Conn: RequestConnection + ?Sized,
8471 {
8472 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8473 .ok_or(ConnectionError::UnsupportedExtension)?;
8474 let length_so_far = 0;
8475 let context_tag_bytes = self.context_tag.serialize();
8476 let capability_bytes = self.capability.serialize();
8477 let mut request0 = vec![
8478 extension_information.major_opcode,
8479 IS_ENABLED_REQUEST,
8480 0,
8481 0,
8482 context_tag_bytes[0],
8483 context_tag_bytes[1],
8484 context_tag_bytes[2],
8485 context_tag_bytes[3],
8486 capability_bytes[0],
8487 capability_bytes[1],
8488 capability_bytes[2],
8489 capability_bytes[3],
8490 ];
8491 let length_so_far = length_so_far + request0.len();
8492 assert_eq!(length_so_far % 4, 0);
8493 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8494 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8495 Ok((vec![request0.into()], vec![]))
8496 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsEnabledReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8497 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsEnabledReply>, ConnectionError>
8498 where
8499 Conn: RequestConnection + ?Sized,
8500 {
8501 let (bytes, fds) = self.serialize(conn)?;
8502 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8503 conn.send_request_with_reply(&slices, fds)
8504 }
8505 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>8506 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8507 if header.minor_opcode != IS_ENABLED_REQUEST {
8508 return Err(ParseError::InvalidValue);
8509 }
8510 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8511 let (capability, remaining) = u32::try_parse(remaining)?;
8512 let _ = remaining;
8513 Ok(IsEnabledRequest {
8514 context_tag,
8515 capability,
8516 })
8517 }
8518 }
8519 impl Request for IsEnabledRequest {
8520 type Reply = IsEnabledReply;
8521 }
is_enabled<Conn>(conn: &Conn, context_tag: ContextTag, capability: u32) -> Result<Cookie<'_, Conn, IsEnabledReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8522 pub fn is_enabled<Conn>(conn: &Conn, context_tag: ContextTag, capability: u32) -> Result<Cookie<'_, Conn, IsEnabledReply>, ConnectionError>
8523 where
8524 Conn: RequestConnection + ?Sized,
8525 {
8526 let request0 = IsEnabledRequest {
8527 context_tag,
8528 capability,
8529 };
8530 request0.send(conn)
8531 }
8532
8533 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8534 pub struct IsEnabledReply {
8535 pub sequence: u16,
8536 pub length: u32,
8537 pub ret_val: Bool32,
8538 }
8539 impl TryParse for IsEnabledReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>8540 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8541 let remaining = initial_value;
8542 let (response_type, remaining) = u8::try_parse(remaining)?;
8543 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8544 let (sequence, remaining) = u16::try_parse(remaining)?;
8545 let (length, remaining) = u32::try_parse(remaining)?;
8546 let (ret_val, remaining) = Bool32::try_parse(remaining)?;
8547 if response_type != 1 {
8548 return Err(ParseError::InvalidValue);
8549 }
8550 let result = IsEnabledReply { sequence, length, ret_val };
8551 let _ = remaining;
8552 let remaining = initial_value.get(32 + length as usize * 4..)
8553 .ok_or(ParseError::InsufficientData)?;
8554 Ok((result, remaining))
8555 }
8556 }
8557
8558 /// Opcode for the IsList request
8559 pub const IS_LIST_REQUEST: u8 = 141;
8560 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8561 pub struct IsListRequest {
8562 pub context_tag: ContextTag,
8563 pub list: u32,
8564 }
8565 impl IsListRequest {
8566 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8567 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8568 where
8569 Conn: RequestConnection + ?Sized,
8570 {
8571 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8572 .ok_or(ConnectionError::UnsupportedExtension)?;
8573 let length_so_far = 0;
8574 let context_tag_bytes = self.context_tag.serialize();
8575 let list_bytes = self.list.serialize();
8576 let mut request0 = vec![
8577 extension_information.major_opcode,
8578 IS_LIST_REQUEST,
8579 0,
8580 0,
8581 context_tag_bytes[0],
8582 context_tag_bytes[1],
8583 context_tag_bytes[2],
8584 context_tag_bytes[3],
8585 list_bytes[0],
8586 list_bytes[1],
8587 list_bytes[2],
8588 list_bytes[3],
8589 ];
8590 let length_so_far = length_so_far + request0.len();
8591 assert_eq!(length_so_far % 4, 0);
8592 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8593 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8594 Ok((vec![request0.into()], vec![]))
8595 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsListReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8596 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsListReply>, ConnectionError>
8597 where
8598 Conn: RequestConnection + ?Sized,
8599 {
8600 let (bytes, fds) = self.serialize(conn)?;
8601 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8602 conn.send_request_with_reply(&slices, fds)
8603 }
8604 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>8605 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8606 if header.minor_opcode != IS_LIST_REQUEST {
8607 return Err(ParseError::InvalidValue);
8608 }
8609 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8610 let (list, remaining) = u32::try_parse(remaining)?;
8611 let _ = remaining;
8612 Ok(IsListRequest {
8613 context_tag,
8614 list,
8615 })
8616 }
8617 }
8618 impl Request for IsListRequest {
8619 type Reply = IsListReply;
8620 }
is_list<Conn>(conn: &Conn, context_tag: ContextTag, list: u32) -> Result<Cookie<'_, Conn, IsListReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8621 pub fn is_list<Conn>(conn: &Conn, context_tag: ContextTag, list: u32) -> Result<Cookie<'_, Conn, IsListReply>, ConnectionError>
8622 where
8623 Conn: RequestConnection + ?Sized,
8624 {
8625 let request0 = IsListRequest {
8626 context_tag,
8627 list,
8628 };
8629 request0.send(conn)
8630 }
8631
8632 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8633 pub struct IsListReply {
8634 pub sequence: u16,
8635 pub length: u32,
8636 pub ret_val: Bool32,
8637 }
8638 impl TryParse for IsListReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>8639 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8640 let remaining = initial_value;
8641 let (response_type, remaining) = u8::try_parse(remaining)?;
8642 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8643 let (sequence, remaining) = u16::try_parse(remaining)?;
8644 let (length, remaining) = u32::try_parse(remaining)?;
8645 let (ret_val, remaining) = Bool32::try_parse(remaining)?;
8646 if response_type != 1 {
8647 return Err(ParseError::InvalidValue);
8648 }
8649 let result = IsListReply { sequence, length, ret_val };
8650 let _ = remaining;
8651 let remaining = initial_value.get(32 + length as usize * 4..)
8652 .ok_or(ParseError::InsufficientData)?;
8653 Ok((result, remaining))
8654 }
8655 }
8656
8657 /// Opcode for the Flush request
8658 pub const FLUSH_REQUEST: u8 = 142;
8659 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8660 pub struct FlushRequest {
8661 pub context_tag: ContextTag,
8662 }
8663 impl FlushRequest {
8664 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8665 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8666 where
8667 Conn: RequestConnection + ?Sized,
8668 {
8669 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8670 .ok_or(ConnectionError::UnsupportedExtension)?;
8671 let length_so_far = 0;
8672 let context_tag_bytes = self.context_tag.serialize();
8673 let mut request0 = vec![
8674 extension_information.major_opcode,
8675 FLUSH_REQUEST,
8676 0,
8677 0,
8678 context_tag_bytes[0],
8679 context_tag_bytes[1],
8680 context_tag_bytes[2],
8681 context_tag_bytes[3],
8682 ];
8683 let length_so_far = length_so_far + request0.len();
8684 assert_eq!(length_so_far % 4, 0);
8685 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8686 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8687 Ok((vec![request0.into()], vec![]))
8688 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,8689 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
8690 where
8691 Conn: RequestConnection + ?Sized,
8692 {
8693 let (bytes, fds) = self.serialize(conn)?;
8694 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8695 conn.send_request_without_reply(&slices, fds)
8696 }
8697 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>8698 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8699 if header.minor_opcode != FLUSH_REQUEST {
8700 return Err(ParseError::InvalidValue);
8701 }
8702 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8703 let _ = remaining;
8704 Ok(FlushRequest {
8705 context_tag,
8706 })
8707 }
8708 }
8709 impl Request for FlushRequest {
8710 type Reply = ();
8711 }
flush<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,8712 pub fn flush<Conn>(conn: &Conn, context_tag: ContextTag) -> Result<VoidCookie<'_, Conn>, ConnectionError>
8713 where
8714 Conn: RequestConnection + ?Sized,
8715 {
8716 let request0 = FlushRequest {
8717 context_tag,
8718 };
8719 request0.send(conn)
8720 }
8721
8722 /// Opcode for the AreTexturesResident request
8723 pub const ARE_TEXTURES_RESIDENT_REQUEST: u8 = 143;
8724 #[derive(Debug, Clone, PartialEq, Eq)]
8725 pub struct AreTexturesResidentRequest<'input> {
8726 pub context_tag: ContextTag,
8727 pub textures: Cow<'input, [u32]>,
8728 }
8729 impl<'input> AreTexturesResidentRequest<'input> {
8730 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8731 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8732 where
8733 Conn: RequestConnection + ?Sized,
8734 {
8735 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8736 .ok_or(ConnectionError::UnsupportedExtension)?;
8737 let length_so_far = 0;
8738 let context_tag_bytes = self.context_tag.serialize();
8739 let n = i32::try_from(self.textures.len()).expect("`textures` has too many elements");
8740 let n_bytes = n.serialize();
8741 let mut request0 = vec![
8742 extension_information.major_opcode,
8743 ARE_TEXTURES_RESIDENT_REQUEST,
8744 0,
8745 0,
8746 context_tag_bytes[0],
8747 context_tag_bytes[1],
8748 context_tag_bytes[2],
8749 context_tag_bytes[3],
8750 n_bytes[0],
8751 n_bytes[1],
8752 n_bytes[2],
8753 n_bytes[3],
8754 ];
8755 let length_so_far = length_so_far + request0.len();
8756 let textures_bytes = self.textures.serialize();
8757 let length_so_far = length_so_far + textures_bytes.len();
8758 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
8759 let length_so_far = length_so_far + padding0.len();
8760 assert_eq!(length_so_far % 4, 0);
8761 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8762 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8763 Ok((vec![request0.into(), textures_bytes.into(), padding0.into()], vec![]))
8764 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, AreTexturesResidentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8765 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, AreTexturesResidentReply>, ConnectionError>
8766 where
8767 Conn: RequestConnection + ?Sized,
8768 {
8769 let (bytes, fds) = self.serialize(conn)?;
8770 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8771 conn.send_request_with_reply(&slices, fds)
8772 }
8773 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>8774 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
8775 if header.minor_opcode != ARE_TEXTURES_RESIDENT_REQUEST {
8776 return Err(ParseError::InvalidValue);
8777 }
8778 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8779 let (n, remaining) = i32::try_parse(remaining)?;
8780 let (textures, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
8781 let _ = remaining;
8782 Ok(AreTexturesResidentRequest {
8783 context_tag,
8784 textures: Cow::Owned(textures),
8785 })
8786 }
8787 /// Clone all borrowed data in this AreTexturesResidentRequest.
into_owned(self) -> AreTexturesResidentRequest<'static>8788 pub fn into_owned(self) -> AreTexturesResidentRequest<'static> {
8789 AreTexturesResidentRequest {
8790 context_tag: self.context_tag,
8791 textures: Cow::Owned(self.textures.into_owned()),
8792 }
8793 }
8794 }
8795 impl<'input> Request for AreTexturesResidentRequest<'input> {
8796 type Reply = AreTexturesResidentReply;
8797 }
are_textures_resident<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, textures: &'input [u32]) -> Result<Cookie<'c, Conn, AreTexturesResidentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8798 pub fn are_textures_resident<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, textures: &'input [u32]) -> Result<Cookie<'c, Conn, AreTexturesResidentReply>, ConnectionError>
8799 where
8800 Conn: RequestConnection + ?Sized,
8801 {
8802 let request0 = AreTexturesResidentRequest {
8803 context_tag,
8804 textures: Cow::Borrowed(textures),
8805 };
8806 request0.send(conn)
8807 }
8808
8809 #[derive(Debug, Clone, PartialEq, Eq)]
8810 pub struct AreTexturesResidentReply {
8811 pub sequence: u16,
8812 pub ret_val: Bool32,
8813 pub data: Vec<bool>,
8814 }
8815 impl TryParse for AreTexturesResidentReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>8816 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
8817 let remaining = initial_value;
8818 let (response_type, remaining) = u8::try_parse(remaining)?;
8819 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
8820 let (sequence, remaining) = u16::try_parse(remaining)?;
8821 let (length, remaining) = u32::try_parse(remaining)?;
8822 let (ret_val, remaining) = Bool32::try_parse(remaining)?;
8823 let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
8824 let (data, remaining) = crate::x11_utils::parse_list::<bool>(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
8825 if response_type != 1 {
8826 return Err(ParseError::InvalidValue);
8827 }
8828 let result = AreTexturesResidentReply { sequence, ret_val, data };
8829 let _ = remaining;
8830 let remaining = initial_value.get(32 + length as usize * 4..)
8831 .ok_or(ParseError::InsufficientData)?;
8832 Ok((result, remaining))
8833 }
8834 }
8835 impl AreTexturesResidentReply {
8836 /// Get the value of the `length` field.
8837 ///
8838 /// The `length` field is used as the length field of the `data` field.
8839 /// This function computes the field's value again based on the length of the list.
8840 ///
8841 /// # Panics
8842 ///
8843 /// Panics if the value cannot be represented in the target type. This
8844 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u328845 pub fn length(&self) -> u32 {
8846 self.data.len()
8847 .checked_div(4).unwrap()
8848 .try_into().unwrap()
8849 }
8850 }
8851
8852 /// Opcode for the DeleteTextures request
8853 pub const DELETE_TEXTURES_REQUEST: u8 = 144;
8854 #[derive(Debug, Clone, PartialEq, Eq)]
8855 pub struct DeleteTexturesRequest<'input> {
8856 pub context_tag: ContextTag,
8857 pub textures: Cow<'input, [u32]>,
8858 }
8859 impl<'input> DeleteTexturesRequest<'input> {
8860 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8861 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8862 where
8863 Conn: RequestConnection + ?Sized,
8864 {
8865 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8866 .ok_or(ConnectionError::UnsupportedExtension)?;
8867 let length_so_far = 0;
8868 let context_tag_bytes = self.context_tag.serialize();
8869 let n = i32::try_from(self.textures.len()).expect("`textures` has too many elements");
8870 let n_bytes = n.serialize();
8871 let mut request0 = vec![
8872 extension_information.major_opcode,
8873 DELETE_TEXTURES_REQUEST,
8874 0,
8875 0,
8876 context_tag_bytes[0],
8877 context_tag_bytes[1],
8878 context_tag_bytes[2],
8879 context_tag_bytes[3],
8880 n_bytes[0],
8881 n_bytes[1],
8882 n_bytes[2],
8883 n_bytes[3],
8884 ];
8885 let length_so_far = length_so_far + request0.len();
8886 let textures_bytes = self.textures.serialize();
8887 let length_so_far = length_so_far + textures_bytes.len();
8888 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
8889 let length_so_far = length_so_far + padding0.len();
8890 assert_eq!(length_so_far % 4, 0);
8891 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8892 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8893 Ok((vec![request0.into(), textures_bytes.into(), padding0.into()], vec![]))
8894 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,8895 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
8896 where
8897 Conn: RequestConnection + ?Sized,
8898 {
8899 let (bytes, fds) = self.serialize(conn)?;
8900 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8901 conn.send_request_without_reply(&slices, fds)
8902 }
8903 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>8904 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
8905 if header.minor_opcode != DELETE_TEXTURES_REQUEST {
8906 return Err(ParseError::InvalidValue);
8907 }
8908 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8909 let (n, remaining) = i32::try_parse(remaining)?;
8910 let (textures, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
8911 let _ = remaining;
8912 Ok(DeleteTexturesRequest {
8913 context_tag,
8914 textures: Cow::Owned(textures),
8915 })
8916 }
8917 /// Clone all borrowed data in this DeleteTexturesRequest.
into_owned(self) -> DeleteTexturesRequest<'static>8918 pub fn into_owned(self) -> DeleteTexturesRequest<'static> {
8919 DeleteTexturesRequest {
8920 context_tag: self.context_tag,
8921 textures: Cow::Owned(self.textures.into_owned()),
8922 }
8923 }
8924 }
8925 impl<'input> Request for DeleteTexturesRequest<'input> {
8926 type Reply = ();
8927 }
delete_textures<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, textures: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,8928 pub fn delete_textures<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, textures: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
8929 where
8930 Conn: RequestConnection + ?Sized,
8931 {
8932 let request0 = DeleteTexturesRequest {
8933 context_tag,
8934 textures: Cow::Borrowed(textures),
8935 };
8936 request0.send(conn)
8937 }
8938
8939 /// Opcode for the GenTextures request
8940 pub const GEN_TEXTURES_REQUEST: u8 = 145;
8941 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8942 pub struct GenTexturesRequest {
8943 pub context_tag: ContextTag,
8944 pub n: i32,
8945 }
8946 impl GenTexturesRequest {
8947 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,8948 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
8949 where
8950 Conn: RequestConnection + ?Sized,
8951 {
8952 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
8953 .ok_or(ConnectionError::UnsupportedExtension)?;
8954 let length_so_far = 0;
8955 let context_tag_bytes = self.context_tag.serialize();
8956 let n_bytes = self.n.serialize();
8957 let mut request0 = vec![
8958 extension_information.major_opcode,
8959 GEN_TEXTURES_REQUEST,
8960 0,
8961 0,
8962 context_tag_bytes[0],
8963 context_tag_bytes[1],
8964 context_tag_bytes[2],
8965 context_tag_bytes[3],
8966 n_bytes[0],
8967 n_bytes[1],
8968 n_bytes[2],
8969 n_bytes[3],
8970 ];
8971 let length_so_far = length_so_far + request0.len();
8972 assert_eq!(length_so_far % 4, 0);
8973 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
8974 request0[2..4].copy_from_slice(&length.to_ne_bytes());
8975 Ok((vec![request0.into()], vec![]))
8976 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GenTexturesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,8977 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GenTexturesReply>, ConnectionError>
8978 where
8979 Conn: RequestConnection + ?Sized,
8980 {
8981 let (bytes, fds) = self.serialize(conn)?;
8982 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
8983 conn.send_request_with_reply(&slices, fds)
8984 }
8985 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>8986 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
8987 if header.minor_opcode != GEN_TEXTURES_REQUEST {
8988 return Err(ParseError::InvalidValue);
8989 }
8990 let (context_tag, remaining) = ContextTag::try_parse(value)?;
8991 let (n, remaining) = i32::try_parse(remaining)?;
8992 let _ = remaining;
8993 Ok(GenTexturesRequest {
8994 context_tag,
8995 n,
8996 })
8997 }
8998 }
8999 impl Request for GenTexturesRequest {
9000 type Reply = GenTexturesReply;
9001 }
gen_textures<Conn>(conn: &Conn, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Conn, GenTexturesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9002 pub fn gen_textures<Conn>(conn: &Conn, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Conn, GenTexturesReply>, ConnectionError>
9003 where
9004 Conn: RequestConnection + ?Sized,
9005 {
9006 let request0 = GenTexturesRequest {
9007 context_tag,
9008 n,
9009 };
9010 request0.send(conn)
9011 }
9012
9013 #[derive(Debug, Clone, PartialEq, Eq)]
9014 pub struct GenTexturesReply {
9015 pub sequence: u16,
9016 pub data: Vec<u32>,
9017 }
9018 impl TryParse for GenTexturesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9019 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9020 let remaining = initial_value;
9021 let (response_type, remaining) = u8::try_parse(remaining)?;
9022 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9023 let (sequence, remaining) = u16::try_parse(remaining)?;
9024 let (length, remaining) = u32::try_parse(remaining)?;
9025 let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
9026 let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
9027 if response_type != 1 {
9028 return Err(ParseError::InvalidValue);
9029 }
9030 let result = GenTexturesReply { sequence, data };
9031 let _ = remaining;
9032 let remaining = initial_value.get(32 + length as usize * 4..)
9033 .ok_or(ParseError::InsufficientData)?;
9034 Ok((result, remaining))
9035 }
9036 }
9037 impl GenTexturesReply {
9038 /// Get the value of the `length` field.
9039 ///
9040 /// The `length` field is used as the length field of the `data` field.
9041 /// This function computes the field's value again based on the length of the list.
9042 ///
9043 /// # Panics
9044 ///
9045 /// Panics if the value cannot be represented in the target type. This
9046 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u329047 pub fn length(&self) -> u32 {
9048 self.data.len()
9049 .try_into().unwrap()
9050 }
9051 }
9052
9053 /// Opcode for the IsTexture request
9054 pub const IS_TEXTURE_REQUEST: u8 = 146;
9055 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9056 pub struct IsTextureRequest {
9057 pub context_tag: ContextTag,
9058 pub texture: u32,
9059 }
9060 impl IsTextureRequest {
9061 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9062 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9063 where
9064 Conn: RequestConnection + ?Sized,
9065 {
9066 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9067 .ok_or(ConnectionError::UnsupportedExtension)?;
9068 let length_so_far = 0;
9069 let context_tag_bytes = self.context_tag.serialize();
9070 let texture_bytes = self.texture.serialize();
9071 let mut request0 = vec![
9072 extension_information.major_opcode,
9073 IS_TEXTURE_REQUEST,
9074 0,
9075 0,
9076 context_tag_bytes[0],
9077 context_tag_bytes[1],
9078 context_tag_bytes[2],
9079 context_tag_bytes[3],
9080 texture_bytes[0],
9081 texture_bytes[1],
9082 texture_bytes[2],
9083 texture_bytes[3],
9084 ];
9085 let length_so_far = length_so_far + request0.len();
9086 assert_eq!(length_so_far % 4, 0);
9087 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9088 request0[2..4].copy_from_slice(&length.to_ne_bytes());
9089 Ok((vec![request0.into()], vec![]))
9090 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsTextureReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9091 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsTextureReply>, ConnectionError>
9092 where
9093 Conn: RequestConnection + ?Sized,
9094 {
9095 let (bytes, fds) = self.serialize(conn)?;
9096 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
9097 conn.send_request_with_reply(&slices, fds)
9098 }
9099 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>9100 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9101 if header.minor_opcode != IS_TEXTURE_REQUEST {
9102 return Err(ParseError::InvalidValue);
9103 }
9104 let (context_tag, remaining) = ContextTag::try_parse(value)?;
9105 let (texture, remaining) = u32::try_parse(remaining)?;
9106 let _ = remaining;
9107 Ok(IsTextureRequest {
9108 context_tag,
9109 texture,
9110 })
9111 }
9112 }
9113 impl Request for IsTextureRequest {
9114 type Reply = IsTextureReply;
9115 }
is_texture<Conn>(conn: &Conn, context_tag: ContextTag, texture: u32) -> Result<Cookie<'_, Conn, IsTextureReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9116 pub fn is_texture<Conn>(conn: &Conn, context_tag: ContextTag, texture: u32) -> Result<Cookie<'_, Conn, IsTextureReply>, ConnectionError>
9117 where
9118 Conn: RequestConnection + ?Sized,
9119 {
9120 let request0 = IsTextureRequest {
9121 context_tag,
9122 texture,
9123 };
9124 request0.send(conn)
9125 }
9126
9127 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9128 pub struct IsTextureReply {
9129 pub sequence: u16,
9130 pub length: u32,
9131 pub ret_val: Bool32,
9132 }
9133 impl TryParse for IsTextureReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9134 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9135 let remaining = initial_value;
9136 let (response_type, remaining) = u8::try_parse(remaining)?;
9137 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9138 let (sequence, remaining) = u16::try_parse(remaining)?;
9139 let (length, remaining) = u32::try_parse(remaining)?;
9140 let (ret_val, remaining) = Bool32::try_parse(remaining)?;
9141 if response_type != 1 {
9142 return Err(ParseError::InvalidValue);
9143 }
9144 let result = IsTextureReply { sequence, length, ret_val };
9145 let _ = remaining;
9146 let remaining = initial_value.get(32 + length as usize * 4..)
9147 .ok_or(ParseError::InsufficientData)?;
9148 Ok((result, remaining))
9149 }
9150 }
9151
9152 /// Opcode for the GetColorTable request
9153 pub const GET_COLOR_TABLE_REQUEST: u8 = 147;
9154 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9155 pub struct GetColorTableRequest {
9156 pub context_tag: ContextTag,
9157 pub target: u32,
9158 pub format: u32,
9159 pub type_: u32,
9160 pub swap_bytes: bool,
9161 }
9162 impl GetColorTableRequest {
9163 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9164 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9165 where
9166 Conn: RequestConnection + ?Sized,
9167 {
9168 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9169 .ok_or(ConnectionError::UnsupportedExtension)?;
9170 let length_so_far = 0;
9171 let context_tag_bytes = self.context_tag.serialize();
9172 let target_bytes = self.target.serialize();
9173 let format_bytes = self.format.serialize();
9174 let type_bytes = self.type_.serialize();
9175 let swap_bytes_bytes = self.swap_bytes.serialize();
9176 let mut request0 = vec![
9177 extension_information.major_opcode,
9178 GET_COLOR_TABLE_REQUEST,
9179 0,
9180 0,
9181 context_tag_bytes[0],
9182 context_tag_bytes[1],
9183 context_tag_bytes[2],
9184 context_tag_bytes[3],
9185 target_bytes[0],
9186 target_bytes[1],
9187 target_bytes[2],
9188 target_bytes[3],
9189 format_bytes[0],
9190 format_bytes[1],
9191 format_bytes[2],
9192 format_bytes[3],
9193 type_bytes[0],
9194 type_bytes[1],
9195 type_bytes[2],
9196 type_bytes[3],
9197 swap_bytes_bytes[0],
9198 0,
9199 0,
9200 0,
9201 ];
9202 let length_so_far = length_so_far + request0.len();
9203 assert_eq!(length_so_far % 4, 0);
9204 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9205 request0[2..4].copy_from_slice(&length.to_ne_bytes());
9206 Ok((vec![request0.into()], vec![]))
9207 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetColorTableReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9208 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetColorTableReply>, ConnectionError>
9209 where
9210 Conn: RequestConnection + ?Sized,
9211 {
9212 let (bytes, fds) = self.serialize(conn)?;
9213 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
9214 conn.send_request_with_reply(&slices, fds)
9215 }
9216 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>9217 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9218 if header.minor_opcode != GET_COLOR_TABLE_REQUEST {
9219 return Err(ParseError::InvalidValue);
9220 }
9221 let (context_tag, remaining) = ContextTag::try_parse(value)?;
9222 let (target, remaining) = u32::try_parse(remaining)?;
9223 let (format, remaining) = u32::try_parse(remaining)?;
9224 let (type_, remaining) = u32::try_parse(remaining)?;
9225 let (swap_bytes, remaining) = bool::try_parse(remaining)?;
9226 let _ = remaining;
9227 Ok(GetColorTableRequest {
9228 context_tag,
9229 target,
9230 format,
9231 type_,
9232 swap_bytes,
9233 })
9234 }
9235 }
9236 impl Request for GetColorTableRequest {
9237 type Reply = GetColorTableReply;
9238 }
get_color_table<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetColorTableReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9239 pub fn get_color_table<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetColorTableReply>, ConnectionError>
9240 where
9241 Conn: RequestConnection + ?Sized,
9242 {
9243 let request0 = GetColorTableRequest {
9244 context_tag,
9245 target,
9246 format,
9247 type_,
9248 swap_bytes,
9249 };
9250 request0.send(conn)
9251 }
9252
9253 #[derive(Debug, Clone, PartialEq, Eq)]
9254 pub struct GetColorTableReply {
9255 pub sequence: u16,
9256 pub width: i32,
9257 pub data: Vec<u8>,
9258 }
9259 impl TryParse for GetColorTableReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9260 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9261 let remaining = initial_value;
9262 let (response_type, remaining) = u8::try_parse(remaining)?;
9263 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9264 let (sequence, remaining) = u16::try_parse(remaining)?;
9265 let (length, remaining) = u32::try_parse(remaining)?;
9266 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
9267 let (width, remaining) = i32::try_parse(remaining)?;
9268 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
9269 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
9270 let data = data.to_vec();
9271 if response_type != 1 {
9272 return Err(ParseError::InvalidValue);
9273 }
9274 let result = GetColorTableReply { sequence, width, data };
9275 let _ = remaining;
9276 let remaining = initial_value.get(32 + length as usize * 4..)
9277 .ok_or(ParseError::InsufficientData)?;
9278 Ok((result, remaining))
9279 }
9280 }
9281 impl GetColorTableReply {
9282 /// Get the value of the `length` field.
9283 ///
9284 /// The `length` field is used as the length field of the `data` field.
9285 /// This function computes the field's value again based on the length of the list.
9286 ///
9287 /// # Panics
9288 ///
9289 /// Panics if the value cannot be represented in the target type. This
9290 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u329291 pub fn length(&self) -> u32 {
9292 self.data.len()
9293 .checked_div(4).unwrap()
9294 .try_into().unwrap()
9295 }
9296 }
9297
9298 /// Opcode for the GetColorTableParameterfv request
9299 pub const GET_COLOR_TABLE_PARAMETERFV_REQUEST: u8 = 148;
9300 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9301 pub struct GetColorTableParameterfvRequest {
9302 pub context_tag: ContextTag,
9303 pub target: u32,
9304 pub pname: u32,
9305 }
9306 impl GetColorTableParameterfvRequest {
9307 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9308 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9309 where
9310 Conn: RequestConnection + ?Sized,
9311 {
9312 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9313 .ok_or(ConnectionError::UnsupportedExtension)?;
9314 let length_so_far = 0;
9315 let context_tag_bytes = self.context_tag.serialize();
9316 let target_bytes = self.target.serialize();
9317 let pname_bytes = self.pname.serialize();
9318 let mut request0 = vec![
9319 extension_information.major_opcode,
9320 GET_COLOR_TABLE_PARAMETERFV_REQUEST,
9321 0,
9322 0,
9323 context_tag_bytes[0],
9324 context_tag_bytes[1],
9325 context_tag_bytes[2],
9326 context_tag_bytes[3],
9327 target_bytes[0],
9328 target_bytes[1],
9329 target_bytes[2],
9330 target_bytes[3],
9331 pname_bytes[0],
9332 pname_bytes[1],
9333 pname_bytes[2],
9334 pname_bytes[3],
9335 ];
9336 let length_so_far = length_so_far + request0.len();
9337 assert_eq!(length_so_far % 4, 0);
9338 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9339 request0[2..4].copy_from_slice(&length.to_ne_bytes());
9340 Ok((vec![request0.into()], vec![]))
9341 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetColorTableParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9342 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetColorTableParameterfvReply>, ConnectionError>
9343 where
9344 Conn: RequestConnection + ?Sized,
9345 {
9346 let (bytes, fds) = self.serialize(conn)?;
9347 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
9348 conn.send_request_with_reply(&slices, fds)
9349 }
9350 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>9351 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9352 if header.minor_opcode != GET_COLOR_TABLE_PARAMETERFV_REQUEST {
9353 return Err(ParseError::InvalidValue);
9354 }
9355 let (context_tag, remaining) = ContextTag::try_parse(value)?;
9356 let (target, remaining) = u32::try_parse(remaining)?;
9357 let (pname, remaining) = u32::try_parse(remaining)?;
9358 let _ = remaining;
9359 Ok(GetColorTableParameterfvRequest {
9360 context_tag,
9361 target,
9362 pname,
9363 })
9364 }
9365 }
9366 impl Request for GetColorTableParameterfvRequest {
9367 type Reply = GetColorTableParameterfvReply;
9368 }
get_color_table_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetColorTableParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9369 pub fn get_color_table_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetColorTableParameterfvReply>, ConnectionError>
9370 where
9371 Conn: RequestConnection + ?Sized,
9372 {
9373 let request0 = GetColorTableParameterfvRequest {
9374 context_tag,
9375 target,
9376 pname,
9377 };
9378 request0.send(conn)
9379 }
9380
9381 #[derive(Debug, Clone, PartialEq)]
9382 pub struct GetColorTableParameterfvReply {
9383 pub sequence: u16,
9384 pub length: u32,
9385 pub datum: Float32,
9386 pub data: Vec<Float32>,
9387 }
9388 impl TryParse for GetColorTableParameterfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9389 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9390 let remaining = initial_value;
9391 let (response_type, remaining) = u8::try_parse(remaining)?;
9392 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9393 let (sequence, remaining) = u16::try_parse(remaining)?;
9394 let (length, remaining) = u32::try_parse(remaining)?;
9395 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
9396 let (n, remaining) = u32::try_parse(remaining)?;
9397 let (datum, remaining) = Float32::try_parse(remaining)?;
9398 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
9399 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
9400 if response_type != 1 {
9401 return Err(ParseError::InvalidValue);
9402 }
9403 let result = GetColorTableParameterfvReply { sequence, length, datum, data };
9404 let _ = remaining;
9405 let remaining = initial_value.get(32 + length as usize * 4..)
9406 .ok_or(ParseError::InsufficientData)?;
9407 Ok((result, remaining))
9408 }
9409 }
9410 impl GetColorTableParameterfvReply {
9411 /// Get the value of the `n` field.
9412 ///
9413 /// The `n` field is used as the length field of the `data` field.
9414 /// This function computes the field's value again based on the length of the list.
9415 ///
9416 /// # Panics
9417 ///
9418 /// Panics if the value cannot be represented in the target type. This
9419 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u329420 pub fn n(&self) -> u32 {
9421 self.data.len()
9422 .try_into().unwrap()
9423 }
9424 }
9425
9426 /// Opcode for the GetColorTableParameteriv request
9427 pub const GET_COLOR_TABLE_PARAMETERIV_REQUEST: u8 = 149;
9428 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9429 pub struct GetColorTableParameterivRequest {
9430 pub context_tag: ContextTag,
9431 pub target: u32,
9432 pub pname: u32,
9433 }
9434 impl GetColorTableParameterivRequest {
9435 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9436 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9437 where
9438 Conn: RequestConnection + ?Sized,
9439 {
9440 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9441 .ok_or(ConnectionError::UnsupportedExtension)?;
9442 let length_so_far = 0;
9443 let context_tag_bytes = self.context_tag.serialize();
9444 let target_bytes = self.target.serialize();
9445 let pname_bytes = self.pname.serialize();
9446 let mut request0 = vec![
9447 extension_information.major_opcode,
9448 GET_COLOR_TABLE_PARAMETERIV_REQUEST,
9449 0,
9450 0,
9451 context_tag_bytes[0],
9452 context_tag_bytes[1],
9453 context_tag_bytes[2],
9454 context_tag_bytes[3],
9455 target_bytes[0],
9456 target_bytes[1],
9457 target_bytes[2],
9458 target_bytes[3],
9459 pname_bytes[0],
9460 pname_bytes[1],
9461 pname_bytes[2],
9462 pname_bytes[3],
9463 ];
9464 let length_so_far = length_so_far + request0.len();
9465 assert_eq!(length_so_far % 4, 0);
9466 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9467 request0[2..4].copy_from_slice(&length.to_ne_bytes());
9468 Ok((vec![request0.into()], vec![]))
9469 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetColorTableParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9470 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetColorTableParameterivReply>, ConnectionError>
9471 where
9472 Conn: RequestConnection + ?Sized,
9473 {
9474 let (bytes, fds) = self.serialize(conn)?;
9475 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
9476 conn.send_request_with_reply(&slices, fds)
9477 }
9478 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>9479 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9480 if header.minor_opcode != GET_COLOR_TABLE_PARAMETERIV_REQUEST {
9481 return Err(ParseError::InvalidValue);
9482 }
9483 let (context_tag, remaining) = ContextTag::try_parse(value)?;
9484 let (target, remaining) = u32::try_parse(remaining)?;
9485 let (pname, remaining) = u32::try_parse(remaining)?;
9486 let _ = remaining;
9487 Ok(GetColorTableParameterivRequest {
9488 context_tag,
9489 target,
9490 pname,
9491 })
9492 }
9493 }
9494 impl Request for GetColorTableParameterivRequest {
9495 type Reply = GetColorTableParameterivReply;
9496 }
get_color_table_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetColorTableParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9497 pub fn get_color_table_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetColorTableParameterivReply>, ConnectionError>
9498 where
9499 Conn: RequestConnection + ?Sized,
9500 {
9501 let request0 = GetColorTableParameterivRequest {
9502 context_tag,
9503 target,
9504 pname,
9505 };
9506 request0.send(conn)
9507 }
9508
9509 #[derive(Debug, Clone, PartialEq, Eq)]
9510 pub struct GetColorTableParameterivReply {
9511 pub sequence: u16,
9512 pub length: u32,
9513 pub datum: i32,
9514 pub data: Vec<i32>,
9515 }
9516 impl TryParse for GetColorTableParameterivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9517 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9518 let remaining = initial_value;
9519 let (response_type, remaining) = u8::try_parse(remaining)?;
9520 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9521 let (sequence, remaining) = u16::try_parse(remaining)?;
9522 let (length, remaining) = u32::try_parse(remaining)?;
9523 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
9524 let (n, remaining) = u32::try_parse(remaining)?;
9525 let (datum, remaining) = i32::try_parse(remaining)?;
9526 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
9527 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
9528 if response_type != 1 {
9529 return Err(ParseError::InvalidValue);
9530 }
9531 let result = GetColorTableParameterivReply { sequence, length, datum, data };
9532 let _ = remaining;
9533 let remaining = initial_value.get(32 + length as usize * 4..)
9534 .ok_or(ParseError::InsufficientData)?;
9535 Ok((result, remaining))
9536 }
9537 }
9538 impl GetColorTableParameterivReply {
9539 /// Get the value of the `n` field.
9540 ///
9541 /// The `n` 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.
n(&self) -> u329548 pub fn n(&self) -> u32 {
9549 self.data.len()
9550 .try_into().unwrap()
9551 }
9552 }
9553
9554 /// Opcode for the GetConvolutionFilter request
9555 pub const GET_CONVOLUTION_FILTER_REQUEST: u8 = 150;
9556 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9557 pub struct GetConvolutionFilterRequest {
9558 pub context_tag: ContextTag,
9559 pub target: u32,
9560 pub format: u32,
9561 pub type_: u32,
9562 pub swap_bytes: bool,
9563 }
9564 impl GetConvolutionFilterRequest {
9565 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9566 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9567 where
9568 Conn: RequestConnection + ?Sized,
9569 {
9570 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9571 .ok_or(ConnectionError::UnsupportedExtension)?;
9572 let length_so_far = 0;
9573 let context_tag_bytes = self.context_tag.serialize();
9574 let target_bytes = self.target.serialize();
9575 let format_bytes = self.format.serialize();
9576 let type_bytes = self.type_.serialize();
9577 let swap_bytes_bytes = self.swap_bytes.serialize();
9578 let mut request0 = vec![
9579 extension_information.major_opcode,
9580 GET_CONVOLUTION_FILTER_REQUEST,
9581 0,
9582 0,
9583 context_tag_bytes[0],
9584 context_tag_bytes[1],
9585 context_tag_bytes[2],
9586 context_tag_bytes[3],
9587 target_bytes[0],
9588 target_bytes[1],
9589 target_bytes[2],
9590 target_bytes[3],
9591 format_bytes[0],
9592 format_bytes[1],
9593 format_bytes[2],
9594 format_bytes[3],
9595 type_bytes[0],
9596 type_bytes[1],
9597 type_bytes[2],
9598 type_bytes[3],
9599 swap_bytes_bytes[0],
9600 0,
9601 0,
9602 0,
9603 ];
9604 let length_so_far = length_so_far + request0.len();
9605 assert_eq!(length_so_far % 4, 0);
9606 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9607 request0[2..4].copy_from_slice(&length.to_ne_bytes());
9608 Ok((vec![request0.into()], vec![]))
9609 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetConvolutionFilterReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9610 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetConvolutionFilterReply>, ConnectionError>
9611 where
9612 Conn: RequestConnection + ?Sized,
9613 {
9614 let (bytes, fds) = self.serialize(conn)?;
9615 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
9616 conn.send_request_with_reply(&slices, fds)
9617 }
9618 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>9619 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9620 if header.minor_opcode != GET_CONVOLUTION_FILTER_REQUEST {
9621 return Err(ParseError::InvalidValue);
9622 }
9623 let (context_tag, remaining) = ContextTag::try_parse(value)?;
9624 let (target, remaining) = u32::try_parse(remaining)?;
9625 let (format, remaining) = u32::try_parse(remaining)?;
9626 let (type_, remaining) = u32::try_parse(remaining)?;
9627 let (swap_bytes, remaining) = bool::try_parse(remaining)?;
9628 let _ = remaining;
9629 Ok(GetConvolutionFilterRequest {
9630 context_tag,
9631 target,
9632 format,
9633 type_,
9634 swap_bytes,
9635 })
9636 }
9637 }
9638 impl Request for GetConvolutionFilterRequest {
9639 type Reply = GetConvolutionFilterReply;
9640 }
get_convolution_filter<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetConvolutionFilterReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9641 pub fn get_convolution_filter<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetConvolutionFilterReply>, ConnectionError>
9642 where
9643 Conn: RequestConnection + ?Sized,
9644 {
9645 let request0 = GetConvolutionFilterRequest {
9646 context_tag,
9647 target,
9648 format,
9649 type_,
9650 swap_bytes,
9651 };
9652 request0.send(conn)
9653 }
9654
9655 #[derive(Debug, Clone, PartialEq, Eq)]
9656 pub struct GetConvolutionFilterReply {
9657 pub sequence: u16,
9658 pub width: i32,
9659 pub height: i32,
9660 pub data: Vec<u8>,
9661 }
9662 impl TryParse for GetConvolutionFilterReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9663 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9664 let remaining = initial_value;
9665 let (response_type, remaining) = u8::try_parse(remaining)?;
9666 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9667 let (sequence, remaining) = u16::try_parse(remaining)?;
9668 let (length, remaining) = u32::try_parse(remaining)?;
9669 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
9670 let (width, remaining) = i32::try_parse(remaining)?;
9671 let (height, remaining) = i32::try_parse(remaining)?;
9672 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
9673 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
9674 let data = data.to_vec();
9675 if response_type != 1 {
9676 return Err(ParseError::InvalidValue);
9677 }
9678 let result = GetConvolutionFilterReply { sequence, width, height, data };
9679 let _ = remaining;
9680 let remaining = initial_value.get(32 + length as usize * 4..)
9681 .ok_or(ParseError::InsufficientData)?;
9682 Ok((result, remaining))
9683 }
9684 }
9685 impl GetConvolutionFilterReply {
9686 /// Get the value of the `length` field.
9687 ///
9688 /// The `length` field is used as the length field of the `data` field.
9689 /// This function computes the field's value again based on the length of the list.
9690 ///
9691 /// # Panics
9692 ///
9693 /// Panics if the value cannot be represented in the target type. This
9694 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u329695 pub fn length(&self) -> u32 {
9696 self.data.len()
9697 .checked_div(4).unwrap()
9698 .try_into().unwrap()
9699 }
9700 }
9701
9702 /// Opcode for the GetConvolutionParameterfv request
9703 pub const GET_CONVOLUTION_PARAMETERFV_REQUEST: u8 = 151;
9704 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9705 pub struct GetConvolutionParameterfvRequest {
9706 pub context_tag: ContextTag,
9707 pub target: u32,
9708 pub pname: u32,
9709 }
9710 impl GetConvolutionParameterfvRequest {
9711 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9712 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9713 where
9714 Conn: RequestConnection + ?Sized,
9715 {
9716 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9717 .ok_or(ConnectionError::UnsupportedExtension)?;
9718 let length_so_far = 0;
9719 let context_tag_bytes = self.context_tag.serialize();
9720 let target_bytes = self.target.serialize();
9721 let pname_bytes = self.pname.serialize();
9722 let mut request0 = vec![
9723 extension_information.major_opcode,
9724 GET_CONVOLUTION_PARAMETERFV_REQUEST,
9725 0,
9726 0,
9727 context_tag_bytes[0],
9728 context_tag_bytes[1],
9729 context_tag_bytes[2],
9730 context_tag_bytes[3],
9731 target_bytes[0],
9732 target_bytes[1],
9733 target_bytes[2],
9734 target_bytes[3],
9735 pname_bytes[0],
9736 pname_bytes[1],
9737 pname_bytes[2],
9738 pname_bytes[3],
9739 ];
9740 let length_so_far = length_so_far + request0.len();
9741 assert_eq!(length_so_far % 4, 0);
9742 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9743 request0[2..4].copy_from_slice(&length.to_ne_bytes());
9744 Ok((vec![request0.into()], vec![]))
9745 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetConvolutionParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9746 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetConvolutionParameterfvReply>, ConnectionError>
9747 where
9748 Conn: RequestConnection + ?Sized,
9749 {
9750 let (bytes, fds) = self.serialize(conn)?;
9751 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
9752 conn.send_request_with_reply(&slices, fds)
9753 }
9754 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>9755 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9756 if header.minor_opcode != GET_CONVOLUTION_PARAMETERFV_REQUEST {
9757 return Err(ParseError::InvalidValue);
9758 }
9759 let (context_tag, remaining) = ContextTag::try_parse(value)?;
9760 let (target, remaining) = u32::try_parse(remaining)?;
9761 let (pname, remaining) = u32::try_parse(remaining)?;
9762 let _ = remaining;
9763 Ok(GetConvolutionParameterfvRequest {
9764 context_tag,
9765 target,
9766 pname,
9767 })
9768 }
9769 }
9770 impl Request for GetConvolutionParameterfvRequest {
9771 type Reply = GetConvolutionParameterfvReply;
9772 }
get_convolution_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetConvolutionParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9773 pub fn get_convolution_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetConvolutionParameterfvReply>, ConnectionError>
9774 where
9775 Conn: RequestConnection + ?Sized,
9776 {
9777 let request0 = GetConvolutionParameterfvRequest {
9778 context_tag,
9779 target,
9780 pname,
9781 };
9782 request0.send(conn)
9783 }
9784
9785 #[derive(Debug, Clone, PartialEq)]
9786 pub struct GetConvolutionParameterfvReply {
9787 pub sequence: u16,
9788 pub length: u32,
9789 pub datum: Float32,
9790 pub data: Vec<Float32>,
9791 }
9792 impl TryParse for GetConvolutionParameterfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9793 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9794 let remaining = initial_value;
9795 let (response_type, remaining) = u8::try_parse(remaining)?;
9796 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9797 let (sequence, remaining) = u16::try_parse(remaining)?;
9798 let (length, remaining) = u32::try_parse(remaining)?;
9799 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
9800 let (n, remaining) = u32::try_parse(remaining)?;
9801 let (datum, remaining) = Float32::try_parse(remaining)?;
9802 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
9803 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
9804 if response_type != 1 {
9805 return Err(ParseError::InvalidValue);
9806 }
9807 let result = GetConvolutionParameterfvReply { sequence, length, datum, data };
9808 let _ = remaining;
9809 let remaining = initial_value.get(32 + length as usize * 4..)
9810 .ok_or(ParseError::InsufficientData)?;
9811 Ok((result, remaining))
9812 }
9813 }
9814 impl GetConvolutionParameterfvReply {
9815 /// Get the value of the `n` field.
9816 ///
9817 /// The `n` field is used as the length field of the `data` field.
9818 /// This function computes the field's value again based on the length of the list.
9819 ///
9820 /// # Panics
9821 ///
9822 /// Panics if the value cannot be represented in the target type. This
9823 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u329824 pub fn n(&self) -> u32 {
9825 self.data.len()
9826 .try_into().unwrap()
9827 }
9828 }
9829
9830 /// Opcode for the GetConvolutionParameteriv request
9831 pub const GET_CONVOLUTION_PARAMETERIV_REQUEST: u8 = 152;
9832 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9833 pub struct GetConvolutionParameterivRequest {
9834 pub context_tag: ContextTag,
9835 pub target: u32,
9836 pub pname: u32,
9837 }
9838 impl GetConvolutionParameterivRequest {
9839 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9840 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9841 where
9842 Conn: RequestConnection + ?Sized,
9843 {
9844 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9845 .ok_or(ConnectionError::UnsupportedExtension)?;
9846 let length_so_far = 0;
9847 let context_tag_bytes = self.context_tag.serialize();
9848 let target_bytes = self.target.serialize();
9849 let pname_bytes = self.pname.serialize();
9850 let mut request0 = vec![
9851 extension_information.major_opcode,
9852 GET_CONVOLUTION_PARAMETERIV_REQUEST,
9853 0,
9854 0,
9855 context_tag_bytes[0],
9856 context_tag_bytes[1],
9857 context_tag_bytes[2],
9858 context_tag_bytes[3],
9859 target_bytes[0],
9860 target_bytes[1],
9861 target_bytes[2],
9862 target_bytes[3],
9863 pname_bytes[0],
9864 pname_bytes[1],
9865 pname_bytes[2],
9866 pname_bytes[3],
9867 ];
9868 let length_so_far = length_so_far + request0.len();
9869 assert_eq!(length_so_far % 4, 0);
9870 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
9871 request0[2..4].copy_from_slice(&length.to_ne_bytes());
9872 Ok((vec![request0.into()], vec![]))
9873 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetConvolutionParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9874 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetConvolutionParameterivReply>, ConnectionError>
9875 where
9876 Conn: RequestConnection + ?Sized,
9877 {
9878 let (bytes, fds) = self.serialize(conn)?;
9879 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
9880 conn.send_request_with_reply(&slices, fds)
9881 }
9882 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>9883 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
9884 if header.minor_opcode != GET_CONVOLUTION_PARAMETERIV_REQUEST {
9885 return Err(ParseError::InvalidValue);
9886 }
9887 let (context_tag, remaining) = ContextTag::try_parse(value)?;
9888 let (target, remaining) = u32::try_parse(remaining)?;
9889 let (pname, remaining) = u32::try_parse(remaining)?;
9890 let _ = remaining;
9891 Ok(GetConvolutionParameterivRequest {
9892 context_tag,
9893 target,
9894 pname,
9895 })
9896 }
9897 }
9898 impl Request for GetConvolutionParameterivRequest {
9899 type Reply = GetConvolutionParameterivReply;
9900 }
get_convolution_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetConvolutionParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,9901 pub fn get_convolution_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetConvolutionParameterivReply>, ConnectionError>
9902 where
9903 Conn: RequestConnection + ?Sized,
9904 {
9905 let request0 = GetConvolutionParameterivRequest {
9906 context_tag,
9907 target,
9908 pname,
9909 };
9910 request0.send(conn)
9911 }
9912
9913 #[derive(Debug, Clone, PartialEq, Eq)]
9914 pub struct GetConvolutionParameterivReply {
9915 pub sequence: u16,
9916 pub length: u32,
9917 pub datum: i32,
9918 pub data: Vec<i32>,
9919 }
9920 impl TryParse for GetConvolutionParameterivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>9921 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
9922 let remaining = initial_value;
9923 let (response_type, remaining) = u8::try_parse(remaining)?;
9924 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
9925 let (sequence, remaining) = u16::try_parse(remaining)?;
9926 let (length, remaining) = u32::try_parse(remaining)?;
9927 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
9928 let (n, remaining) = u32::try_parse(remaining)?;
9929 let (datum, remaining) = i32::try_parse(remaining)?;
9930 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
9931 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
9932 if response_type != 1 {
9933 return Err(ParseError::InvalidValue);
9934 }
9935 let result = GetConvolutionParameterivReply { sequence, length, datum, data };
9936 let _ = remaining;
9937 let remaining = initial_value.get(32 + length as usize * 4..)
9938 .ok_or(ParseError::InsufficientData)?;
9939 Ok((result, remaining))
9940 }
9941 }
9942 impl GetConvolutionParameterivReply {
9943 /// Get the value of the `n` field.
9944 ///
9945 /// The `n` field is used as the length field of the `data` field.
9946 /// This function computes the field's value again based on the length of the list.
9947 ///
9948 /// # Panics
9949 ///
9950 /// Panics if the value cannot be represented in the target type. This
9951 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u329952 pub fn n(&self) -> u32 {
9953 self.data.len()
9954 .try_into().unwrap()
9955 }
9956 }
9957
9958 /// Opcode for the GetSeparableFilter request
9959 pub const GET_SEPARABLE_FILTER_REQUEST: u8 = 153;
9960 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
9961 pub struct GetSeparableFilterRequest {
9962 pub context_tag: ContextTag,
9963 pub target: u32,
9964 pub format: u32,
9965 pub type_: u32,
9966 pub swap_bytes: bool,
9967 }
9968 impl GetSeparableFilterRequest {
9969 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,9970 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
9971 where
9972 Conn: RequestConnection + ?Sized,
9973 {
9974 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
9975 .ok_or(ConnectionError::UnsupportedExtension)?;
9976 let length_so_far = 0;
9977 let context_tag_bytes = self.context_tag.serialize();
9978 let target_bytes = self.target.serialize();
9979 let format_bytes = self.format.serialize();
9980 let type_bytes = self.type_.serialize();
9981 let swap_bytes_bytes = self.swap_bytes.serialize();
9982 let mut request0 = vec![
9983 extension_information.major_opcode,
9984 GET_SEPARABLE_FILTER_REQUEST,
9985 0,
9986 0,
9987 context_tag_bytes[0],
9988 context_tag_bytes[1],
9989 context_tag_bytes[2],
9990 context_tag_bytes[3],
9991 target_bytes[0],
9992 target_bytes[1],
9993 target_bytes[2],
9994 target_bytes[3],
9995 format_bytes[0],
9996 format_bytes[1],
9997 format_bytes[2],
9998 format_bytes[3],
9999 type_bytes[0],
10000 type_bytes[1],
10001 type_bytes[2],
10002 type_bytes[3],
10003 swap_bytes_bytes[0],
10004 0,
10005 0,
10006 0,
10007 ];
10008 let length_so_far = length_so_far + request0.len();
10009 assert_eq!(length_so_far % 4, 0);
10010 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10011 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10012 Ok((vec![request0.into()], vec![]))
10013 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSeparableFilterReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10014 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetSeparableFilterReply>, ConnectionError>
10015 where
10016 Conn: RequestConnection + ?Sized,
10017 {
10018 let (bytes, fds) = self.serialize(conn)?;
10019 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10020 conn.send_request_with_reply(&slices, fds)
10021 }
10022 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10023 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10024 if header.minor_opcode != GET_SEPARABLE_FILTER_REQUEST {
10025 return Err(ParseError::InvalidValue);
10026 }
10027 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10028 let (target, remaining) = u32::try_parse(remaining)?;
10029 let (format, remaining) = u32::try_parse(remaining)?;
10030 let (type_, remaining) = u32::try_parse(remaining)?;
10031 let (swap_bytes, remaining) = bool::try_parse(remaining)?;
10032 let _ = remaining;
10033 Ok(GetSeparableFilterRequest {
10034 context_tag,
10035 target,
10036 format,
10037 type_,
10038 swap_bytes,
10039 })
10040 }
10041 }
10042 impl Request for GetSeparableFilterRequest {
10043 type Reply = GetSeparableFilterReply;
10044 }
get_separable_filter<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetSeparableFilterReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10045 pub fn get_separable_filter<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Conn, GetSeparableFilterReply>, ConnectionError>
10046 where
10047 Conn: RequestConnection + ?Sized,
10048 {
10049 let request0 = GetSeparableFilterRequest {
10050 context_tag,
10051 target,
10052 format,
10053 type_,
10054 swap_bytes,
10055 };
10056 request0.send(conn)
10057 }
10058
10059 #[derive(Debug, Clone, PartialEq, Eq)]
10060 pub struct GetSeparableFilterReply {
10061 pub sequence: u16,
10062 pub row_w: i32,
10063 pub col_h: i32,
10064 pub rows_and_cols: Vec<u8>,
10065 }
10066 impl TryParse for GetSeparableFilterReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>10067 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10068 let remaining = initial_value;
10069 let (response_type, remaining) = u8::try_parse(remaining)?;
10070 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10071 let (sequence, remaining) = u16::try_parse(remaining)?;
10072 let (length, remaining) = u32::try_parse(remaining)?;
10073 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
10074 let (row_w, remaining) = i32::try_parse(remaining)?;
10075 let (col_h, remaining) = i32::try_parse(remaining)?;
10076 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
10077 let (rows_and_cols, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
10078 let rows_and_cols = rows_and_cols.to_vec();
10079 if response_type != 1 {
10080 return Err(ParseError::InvalidValue);
10081 }
10082 let result = GetSeparableFilterReply { sequence, row_w, col_h, rows_and_cols };
10083 let _ = remaining;
10084 let remaining = initial_value.get(32 + length as usize * 4..)
10085 .ok_or(ParseError::InsufficientData)?;
10086 Ok((result, remaining))
10087 }
10088 }
10089 impl GetSeparableFilterReply {
10090 /// Get the value of the `length` field.
10091 ///
10092 /// The `length` field is used as the length field of the `rows_and_cols` field.
10093 /// This function computes the field's value again based on the length of the list.
10094 ///
10095 /// # Panics
10096 ///
10097 /// Panics if the value cannot be represented in the target type. This
10098 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u3210099 pub fn length(&self) -> u32 {
10100 self.rows_and_cols.len()
10101 .checked_div(4).unwrap()
10102 .try_into().unwrap()
10103 }
10104 }
10105
10106 /// Opcode for the GetHistogram request
10107 pub const GET_HISTOGRAM_REQUEST: u8 = 154;
10108 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10109 pub struct GetHistogramRequest {
10110 pub context_tag: ContextTag,
10111 pub target: u32,
10112 pub format: u32,
10113 pub type_: u32,
10114 pub swap_bytes: bool,
10115 pub reset: bool,
10116 }
10117 impl GetHistogramRequest {
10118 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,10119 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
10120 where
10121 Conn: RequestConnection + ?Sized,
10122 {
10123 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
10124 .ok_or(ConnectionError::UnsupportedExtension)?;
10125 let length_so_far = 0;
10126 let context_tag_bytes = self.context_tag.serialize();
10127 let target_bytes = self.target.serialize();
10128 let format_bytes = self.format.serialize();
10129 let type_bytes = self.type_.serialize();
10130 let swap_bytes_bytes = self.swap_bytes.serialize();
10131 let reset_bytes = self.reset.serialize();
10132 let mut request0 = vec![
10133 extension_information.major_opcode,
10134 GET_HISTOGRAM_REQUEST,
10135 0,
10136 0,
10137 context_tag_bytes[0],
10138 context_tag_bytes[1],
10139 context_tag_bytes[2],
10140 context_tag_bytes[3],
10141 target_bytes[0],
10142 target_bytes[1],
10143 target_bytes[2],
10144 target_bytes[3],
10145 format_bytes[0],
10146 format_bytes[1],
10147 format_bytes[2],
10148 format_bytes[3],
10149 type_bytes[0],
10150 type_bytes[1],
10151 type_bytes[2],
10152 type_bytes[3],
10153 swap_bytes_bytes[0],
10154 reset_bytes[0],
10155 0,
10156 0,
10157 ];
10158 let length_so_far = length_so_far + request0.len();
10159 assert_eq!(length_so_far % 4, 0);
10160 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10161 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10162 Ok((vec![request0.into()], vec![]))
10163 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetHistogramReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10164 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetHistogramReply>, ConnectionError>
10165 where
10166 Conn: RequestConnection + ?Sized,
10167 {
10168 let (bytes, fds) = self.serialize(conn)?;
10169 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10170 conn.send_request_with_reply(&slices, fds)
10171 }
10172 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10173 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10174 if header.minor_opcode != GET_HISTOGRAM_REQUEST {
10175 return Err(ParseError::InvalidValue);
10176 }
10177 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10178 let (target, remaining) = u32::try_parse(remaining)?;
10179 let (format, remaining) = u32::try_parse(remaining)?;
10180 let (type_, remaining) = u32::try_parse(remaining)?;
10181 let (swap_bytes, remaining) = bool::try_parse(remaining)?;
10182 let (reset, remaining) = bool::try_parse(remaining)?;
10183 let _ = remaining;
10184 Ok(GetHistogramRequest {
10185 context_tag,
10186 target,
10187 format,
10188 type_,
10189 swap_bytes,
10190 reset,
10191 })
10192 }
10193 }
10194 impl Request for GetHistogramRequest {
10195 type Reply = GetHistogramReply;
10196 }
get_histogram<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Conn, GetHistogramReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10197 pub fn get_histogram<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Conn, GetHistogramReply>, ConnectionError>
10198 where
10199 Conn: RequestConnection + ?Sized,
10200 {
10201 let request0 = GetHistogramRequest {
10202 context_tag,
10203 target,
10204 format,
10205 type_,
10206 swap_bytes,
10207 reset,
10208 };
10209 request0.send(conn)
10210 }
10211
10212 #[derive(Debug, Clone, PartialEq, Eq)]
10213 pub struct GetHistogramReply {
10214 pub sequence: u16,
10215 pub width: i32,
10216 pub data: Vec<u8>,
10217 }
10218 impl TryParse for GetHistogramReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>10219 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10220 let remaining = initial_value;
10221 let (response_type, remaining) = u8::try_parse(remaining)?;
10222 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10223 let (sequence, remaining) = u16::try_parse(remaining)?;
10224 let (length, remaining) = u32::try_parse(remaining)?;
10225 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
10226 let (width, remaining) = i32::try_parse(remaining)?;
10227 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10228 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
10229 let data = data.to_vec();
10230 if response_type != 1 {
10231 return Err(ParseError::InvalidValue);
10232 }
10233 let result = GetHistogramReply { sequence, width, data };
10234 let _ = remaining;
10235 let remaining = initial_value.get(32 + length as usize * 4..)
10236 .ok_or(ParseError::InsufficientData)?;
10237 Ok((result, remaining))
10238 }
10239 }
10240 impl GetHistogramReply {
10241 /// Get the value of the `length` field.
10242 ///
10243 /// The `length` field is used as the length field of the `data` field.
10244 /// This function computes the field's value again based on the length of the list.
10245 ///
10246 /// # Panics
10247 ///
10248 /// Panics if the value cannot be represented in the target type. This
10249 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u3210250 pub fn length(&self) -> u32 {
10251 self.data.len()
10252 .checked_div(4).unwrap()
10253 .try_into().unwrap()
10254 }
10255 }
10256
10257 /// Opcode for the GetHistogramParameterfv request
10258 pub const GET_HISTOGRAM_PARAMETERFV_REQUEST: u8 = 155;
10259 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10260 pub struct GetHistogramParameterfvRequest {
10261 pub context_tag: ContextTag,
10262 pub target: u32,
10263 pub pname: u32,
10264 }
10265 impl GetHistogramParameterfvRequest {
10266 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,10267 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
10268 where
10269 Conn: RequestConnection + ?Sized,
10270 {
10271 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
10272 .ok_or(ConnectionError::UnsupportedExtension)?;
10273 let length_so_far = 0;
10274 let context_tag_bytes = self.context_tag.serialize();
10275 let target_bytes = self.target.serialize();
10276 let pname_bytes = self.pname.serialize();
10277 let mut request0 = vec![
10278 extension_information.major_opcode,
10279 GET_HISTOGRAM_PARAMETERFV_REQUEST,
10280 0,
10281 0,
10282 context_tag_bytes[0],
10283 context_tag_bytes[1],
10284 context_tag_bytes[2],
10285 context_tag_bytes[3],
10286 target_bytes[0],
10287 target_bytes[1],
10288 target_bytes[2],
10289 target_bytes[3],
10290 pname_bytes[0],
10291 pname_bytes[1],
10292 pname_bytes[2],
10293 pname_bytes[3],
10294 ];
10295 let length_so_far = length_so_far + request0.len();
10296 assert_eq!(length_so_far % 4, 0);
10297 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10298 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10299 Ok((vec![request0.into()], vec![]))
10300 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetHistogramParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10301 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetHistogramParameterfvReply>, ConnectionError>
10302 where
10303 Conn: RequestConnection + ?Sized,
10304 {
10305 let (bytes, fds) = self.serialize(conn)?;
10306 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10307 conn.send_request_with_reply(&slices, fds)
10308 }
10309 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10310 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10311 if header.minor_opcode != GET_HISTOGRAM_PARAMETERFV_REQUEST {
10312 return Err(ParseError::InvalidValue);
10313 }
10314 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10315 let (target, remaining) = u32::try_parse(remaining)?;
10316 let (pname, remaining) = u32::try_parse(remaining)?;
10317 let _ = remaining;
10318 Ok(GetHistogramParameterfvRequest {
10319 context_tag,
10320 target,
10321 pname,
10322 })
10323 }
10324 }
10325 impl Request for GetHistogramParameterfvRequest {
10326 type Reply = GetHistogramParameterfvReply;
10327 }
get_histogram_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetHistogramParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10328 pub fn get_histogram_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetHistogramParameterfvReply>, ConnectionError>
10329 where
10330 Conn: RequestConnection + ?Sized,
10331 {
10332 let request0 = GetHistogramParameterfvRequest {
10333 context_tag,
10334 target,
10335 pname,
10336 };
10337 request0.send(conn)
10338 }
10339
10340 #[derive(Debug, Clone, PartialEq)]
10341 pub struct GetHistogramParameterfvReply {
10342 pub sequence: u16,
10343 pub length: u32,
10344 pub datum: Float32,
10345 pub data: Vec<Float32>,
10346 }
10347 impl TryParse for GetHistogramParameterfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>10348 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10349 let remaining = initial_value;
10350 let (response_type, remaining) = u8::try_parse(remaining)?;
10351 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10352 let (sequence, remaining) = u16::try_parse(remaining)?;
10353 let (length, remaining) = u32::try_parse(remaining)?;
10354 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10355 let (n, remaining) = u32::try_parse(remaining)?;
10356 let (datum, remaining) = Float32::try_parse(remaining)?;
10357 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10358 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
10359 if response_type != 1 {
10360 return Err(ParseError::InvalidValue);
10361 }
10362 let result = GetHistogramParameterfvReply { sequence, length, datum, data };
10363 let _ = remaining;
10364 let remaining = initial_value.get(32 + length as usize * 4..)
10365 .ok_or(ParseError::InsufficientData)?;
10366 Ok((result, remaining))
10367 }
10368 }
10369 impl GetHistogramParameterfvReply {
10370 /// Get the value of the `n` field.
10371 ///
10372 /// The `n` field is used as the length field of the `data` field.
10373 /// This function computes the field's value again based on the length of the list.
10374 ///
10375 /// # Panics
10376 ///
10377 /// Panics if the value cannot be represented in the target type. This
10378 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u3210379 pub fn n(&self) -> u32 {
10380 self.data.len()
10381 .try_into().unwrap()
10382 }
10383 }
10384
10385 /// Opcode for the GetHistogramParameteriv request
10386 pub const GET_HISTOGRAM_PARAMETERIV_REQUEST: u8 = 156;
10387 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10388 pub struct GetHistogramParameterivRequest {
10389 pub context_tag: ContextTag,
10390 pub target: u32,
10391 pub pname: u32,
10392 }
10393 impl GetHistogramParameterivRequest {
10394 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,10395 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
10396 where
10397 Conn: RequestConnection + ?Sized,
10398 {
10399 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
10400 .ok_or(ConnectionError::UnsupportedExtension)?;
10401 let length_so_far = 0;
10402 let context_tag_bytes = self.context_tag.serialize();
10403 let target_bytes = self.target.serialize();
10404 let pname_bytes = self.pname.serialize();
10405 let mut request0 = vec![
10406 extension_information.major_opcode,
10407 GET_HISTOGRAM_PARAMETERIV_REQUEST,
10408 0,
10409 0,
10410 context_tag_bytes[0],
10411 context_tag_bytes[1],
10412 context_tag_bytes[2],
10413 context_tag_bytes[3],
10414 target_bytes[0],
10415 target_bytes[1],
10416 target_bytes[2],
10417 target_bytes[3],
10418 pname_bytes[0],
10419 pname_bytes[1],
10420 pname_bytes[2],
10421 pname_bytes[3],
10422 ];
10423 let length_so_far = length_so_far + request0.len();
10424 assert_eq!(length_so_far % 4, 0);
10425 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10426 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10427 Ok((vec![request0.into()], vec![]))
10428 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetHistogramParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10429 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetHistogramParameterivReply>, ConnectionError>
10430 where
10431 Conn: RequestConnection + ?Sized,
10432 {
10433 let (bytes, fds) = self.serialize(conn)?;
10434 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10435 conn.send_request_with_reply(&slices, fds)
10436 }
10437 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10438 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10439 if header.minor_opcode != GET_HISTOGRAM_PARAMETERIV_REQUEST {
10440 return Err(ParseError::InvalidValue);
10441 }
10442 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10443 let (target, remaining) = u32::try_parse(remaining)?;
10444 let (pname, remaining) = u32::try_parse(remaining)?;
10445 let _ = remaining;
10446 Ok(GetHistogramParameterivRequest {
10447 context_tag,
10448 target,
10449 pname,
10450 })
10451 }
10452 }
10453 impl Request for GetHistogramParameterivRequest {
10454 type Reply = GetHistogramParameterivReply;
10455 }
get_histogram_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetHistogramParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10456 pub fn get_histogram_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetHistogramParameterivReply>, ConnectionError>
10457 where
10458 Conn: RequestConnection + ?Sized,
10459 {
10460 let request0 = GetHistogramParameterivRequest {
10461 context_tag,
10462 target,
10463 pname,
10464 };
10465 request0.send(conn)
10466 }
10467
10468 #[derive(Debug, Clone, PartialEq, Eq)]
10469 pub struct GetHistogramParameterivReply {
10470 pub sequence: u16,
10471 pub length: u32,
10472 pub datum: i32,
10473 pub data: Vec<i32>,
10474 }
10475 impl TryParse for GetHistogramParameterivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>10476 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10477 let remaining = initial_value;
10478 let (response_type, remaining) = u8::try_parse(remaining)?;
10479 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10480 let (sequence, remaining) = u16::try_parse(remaining)?;
10481 let (length, remaining) = u32::try_parse(remaining)?;
10482 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10483 let (n, remaining) = u32::try_parse(remaining)?;
10484 let (datum, remaining) = i32::try_parse(remaining)?;
10485 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10486 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
10487 if response_type != 1 {
10488 return Err(ParseError::InvalidValue);
10489 }
10490 let result = GetHistogramParameterivReply { sequence, length, datum, data };
10491 let _ = remaining;
10492 let remaining = initial_value.get(32 + length as usize * 4..)
10493 .ok_or(ParseError::InsufficientData)?;
10494 Ok((result, remaining))
10495 }
10496 }
10497 impl GetHistogramParameterivReply {
10498 /// Get the value of the `n` field.
10499 ///
10500 /// The `n` field is used as the length field of the `data` field.
10501 /// This function computes the field's value again based on the length of the list.
10502 ///
10503 /// # Panics
10504 ///
10505 /// Panics if the value cannot be represented in the target type. This
10506 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u3210507 pub fn n(&self) -> u32 {
10508 self.data.len()
10509 .try_into().unwrap()
10510 }
10511 }
10512
10513 /// Opcode for the GetMinmax request
10514 pub const GET_MINMAX_REQUEST: u8 = 157;
10515 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10516 pub struct GetMinmaxRequest {
10517 pub context_tag: ContextTag,
10518 pub target: u32,
10519 pub format: u32,
10520 pub type_: u32,
10521 pub swap_bytes: bool,
10522 pub reset: bool,
10523 }
10524 impl GetMinmaxRequest {
10525 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,10526 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
10527 where
10528 Conn: RequestConnection + ?Sized,
10529 {
10530 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
10531 .ok_or(ConnectionError::UnsupportedExtension)?;
10532 let length_so_far = 0;
10533 let context_tag_bytes = self.context_tag.serialize();
10534 let target_bytes = self.target.serialize();
10535 let format_bytes = self.format.serialize();
10536 let type_bytes = self.type_.serialize();
10537 let swap_bytes_bytes = self.swap_bytes.serialize();
10538 let reset_bytes = self.reset.serialize();
10539 let mut request0 = vec![
10540 extension_information.major_opcode,
10541 GET_MINMAX_REQUEST,
10542 0,
10543 0,
10544 context_tag_bytes[0],
10545 context_tag_bytes[1],
10546 context_tag_bytes[2],
10547 context_tag_bytes[3],
10548 target_bytes[0],
10549 target_bytes[1],
10550 target_bytes[2],
10551 target_bytes[3],
10552 format_bytes[0],
10553 format_bytes[1],
10554 format_bytes[2],
10555 format_bytes[3],
10556 type_bytes[0],
10557 type_bytes[1],
10558 type_bytes[2],
10559 type_bytes[3],
10560 swap_bytes_bytes[0],
10561 reset_bytes[0],
10562 0,
10563 0,
10564 ];
10565 let length_so_far = length_so_far + request0.len();
10566 assert_eq!(length_so_far % 4, 0);
10567 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10568 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10569 Ok((vec![request0.into()], vec![]))
10570 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMinmaxReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10571 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMinmaxReply>, ConnectionError>
10572 where
10573 Conn: RequestConnection + ?Sized,
10574 {
10575 let (bytes, fds) = self.serialize(conn)?;
10576 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10577 conn.send_request_with_reply(&slices, fds)
10578 }
10579 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10580 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10581 if header.minor_opcode != GET_MINMAX_REQUEST {
10582 return Err(ParseError::InvalidValue);
10583 }
10584 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10585 let (target, remaining) = u32::try_parse(remaining)?;
10586 let (format, remaining) = u32::try_parse(remaining)?;
10587 let (type_, remaining) = u32::try_parse(remaining)?;
10588 let (swap_bytes, remaining) = bool::try_parse(remaining)?;
10589 let (reset, remaining) = bool::try_parse(remaining)?;
10590 let _ = remaining;
10591 Ok(GetMinmaxRequest {
10592 context_tag,
10593 target,
10594 format,
10595 type_,
10596 swap_bytes,
10597 reset,
10598 })
10599 }
10600 }
10601 impl Request for GetMinmaxRequest {
10602 type Reply = GetMinmaxReply;
10603 }
get_minmax<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Conn, GetMinmaxReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10604 pub fn get_minmax<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Conn, GetMinmaxReply>, ConnectionError>
10605 where
10606 Conn: RequestConnection + ?Sized,
10607 {
10608 let request0 = GetMinmaxRequest {
10609 context_tag,
10610 target,
10611 format,
10612 type_,
10613 swap_bytes,
10614 reset,
10615 };
10616 request0.send(conn)
10617 }
10618
10619 #[derive(Debug, Clone, PartialEq, Eq)]
10620 pub struct GetMinmaxReply {
10621 pub sequence: u16,
10622 pub data: Vec<u8>,
10623 }
10624 impl TryParse for GetMinmaxReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>10625 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10626 let remaining = initial_value;
10627 let (response_type, remaining) = u8::try_parse(remaining)?;
10628 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10629 let (sequence, remaining) = u16::try_parse(remaining)?;
10630 let (length, remaining) = u32::try_parse(remaining)?;
10631 let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
10632 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
10633 let data = data.to_vec();
10634 if response_type != 1 {
10635 return Err(ParseError::InvalidValue);
10636 }
10637 let result = GetMinmaxReply { sequence, data };
10638 let _ = remaining;
10639 let remaining = initial_value.get(32 + length as usize * 4..)
10640 .ok_or(ParseError::InsufficientData)?;
10641 Ok((result, remaining))
10642 }
10643 }
10644 impl GetMinmaxReply {
10645 /// Get the value of the `length` field.
10646 ///
10647 /// The `length` field is used as the length field of the `data` field.
10648 /// This function computes the field's value again based on the length of the list.
10649 ///
10650 /// # Panics
10651 ///
10652 /// Panics if the value cannot be represented in the target type. This
10653 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u3210654 pub fn length(&self) -> u32 {
10655 self.data.len()
10656 .checked_div(4).unwrap()
10657 .try_into().unwrap()
10658 }
10659 }
10660
10661 /// Opcode for the GetMinmaxParameterfv request
10662 pub const GET_MINMAX_PARAMETERFV_REQUEST: u8 = 158;
10663 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10664 pub struct GetMinmaxParameterfvRequest {
10665 pub context_tag: ContextTag,
10666 pub target: u32,
10667 pub pname: u32,
10668 }
10669 impl GetMinmaxParameterfvRequest {
10670 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,10671 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
10672 where
10673 Conn: RequestConnection + ?Sized,
10674 {
10675 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
10676 .ok_or(ConnectionError::UnsupportedExtension)?;
10677 let length_so_far = 0;
10678 let context_tag_bytes = self.context_tag.serialize();
10679 let target_bytes = self.target.serialize();
10680 let pname_bytes = self.pname.serialize();
10681 let mut request0 = vec![
10682 extension_information.major_opcode,
10683 GET_MINMAX_PARAMETERFV_REQUEST,
10684 0,
10685 0,
10686 context_tag_bytes[0],
10687 context_tag_bytes[1],
10688 context_tag_bytes[2],
10689 context_tag_bytes[3],
10690 target_bytes[0],
10691 target_bytes[1],
10692 target_bytes[2],
10693 target_bytes[3],
10694 pname_bytes[0],
10695 pname_bytes[1],
10696 pname_bytes[2],
10697 pname_bytes[3],
10698 ];
10699 let length_so_far = length_so_far + request0.len();
10700 assert_eq!(length_so_far % 4, 0);
10701 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10702 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10703 Ok((vec![request0.into()], vec![]))
10704 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMinmaxParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10705 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMinmaxParameterfvReply>, ConnectionError>
10706 where
10707 Conn: RequestConnection + ?Sized,
10708 {
10709 let (bytes, fds) = self.serialize(conn)?;
10710 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10711 conn.send_request_with_reply(&slices, fds)
10712 }
10713 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10714 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10715 if header.minor_opcode != GET_MINMAX_PARAMETERFV_REQUEST {
10716 return Err(ParseError::InvalidValue);
10717 }
10718 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10719 let (target, remaining) = u32::try_parse(remaining)?;
10720 let (pname, remaining) = u32::try_parse(remaining)?;
10721 let _ = remaining;
10722 Ok(GetMinmaxParameterfvRequest {
10723 context_tag,
10724 target,
10725 pname,
10726 })
10727 }
10728 }
10729 impl Request for GetMinmaxParameterfvRequest {
10730 type Reply = GetMinmaxParameterfvReply;
10731 }
get_minmax_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMinmaxParameterfvReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10732 pub fn get_minmax_parameterfv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMinmaxParameterfvReply>, ConnectionError>
10733 where
10734 Conn: RequestConnection + ?Sized,
10735 {
10736 let request0 = GetMinmaxParameterfvRequest {
10737 context_tag,
10738 target,
10739 pname,
10740 };
10741 request0.send(conn)
10742 }
10743
10744 #[derive(Debug, Clone, PartialEq)]
10745 pub struct GetMinmaxParameterfvReply {
10746 pub sequence: u16,
10747 pub length: u32,
10748 pub datum: Float32,
10749 pub data: Vec<Float32>,
10750 }
10751 impl TryParse for GetMinmaxParameterfvReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>10752 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10753 let remaining = initial_value;
10754 let (response_type, remaining) = u8::try_parse(remaining)?;
10755 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10756 let (sequence, remaining) = u16::try_parse(remaining)?;
10757 let (length, remaining) = u32::try_parse(remaining)?;
10758 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10759 let (n, remaining) = u32::try_parse(remaining)?;
10760 let (datum, remaining) = Float32::try_parse(remaining)?;
10761 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10762 let (data, remaining) = crate::x11_utils::parse_list::<Float32>(remaining, n.try_to_usize()?)?;
10763 if response_type != 1 {
10764 return Err(ParseError::InvalidValue);
10765 }
10766 let result = GetMinmaxParameterfvReply { sequence, length, datum, data };
10767 let _ = remaining;
10768 let remaining = initial_value.get(32 + length as usize * 4..)
10769 .ok_or(ParseError::InsufficientData)?;
10770 Ok((result, remaining))
10771 }
10772 }
10773 impl GetMinmaxParameterfvReply {
10774 /// Get the value of the `n` field.
10775 ///
10776 /// The `n` field is used as the length field of the `data` field.
10777 /// This function computes the field's value again based on the length of the list.
10778 ///
10779 /// # Panics
10780 ///
10781 /// Panics if the value cannot be represented in the target type. This
10782 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u3210783 pub fn n(&self) -> u32 {
10784 self.data.len()
10785 .try_into().unwrap()
10786 }
10787 }
10788
10789 /// Opcode for the GetMinmaxParameteriv request
10790 pub const GET_MINMAX_PARAMETERIV_REQUEST: u8 = 159;
10791 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10792 pub struct GetMinmaxParameterivRequest {
10793 pub context_tag: ContextTag,
10794 pub target: u32,
10795 pub pname: u32,
10796 }
10797 impl GetMinmaxParameterivRequest {
10798 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,10799 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
10800 where
10801 Conn: RequestConnection + ?Sized,
10802 {
10803 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
10804 .ok_or(ConnectionError::UnsupportedExtension)?;
10805 let length_so_far = 0;
10806 let context_tag_bytes = self.context_tag.serialize();
10807 let target_bytes = self.target.serialize();
10808 let pname_bytes = self.pname.serialize();
10809 let mut request0 = vec![
10810 extension_information.major_opcode,
10811 GET_MINMAX_PARAMETERIV_REQUEST,
10812 0,
10813 0,
10814 context_tag_bytes[0],
10815 context_tag_bytes[1],
10816 context_tag_bytes[2],
10817 context_tag_bytes[3],
10818 target_bytes[0],
10819 target_bytes[1],
10820 target_bytes[2],
10821 target_bytes[3],
10822 pname_bytes[0],
10823 pname_bytes[1],
10824 pname_bytes[2],
10825 pname_bytes[3],
10826 ];
10827 let length_so_far = length_so_far + request0.len();
10828 assert_eq!(length_so_far % 4, 0);
10829 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10830 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10831 Ok((vec![request0.into()], vec![]))
10832 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMinmaxParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10833 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetMinmaxParameterivReply>, ConnectionError>
10834 where
10835 Conn: RequestConnection + ?Sized,
10836 {
10837 let (bytes, fds) = self.serialize(conn)?;
10838 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10839 conn.send_request_with_reply(&slices, fds)
10840 }
10841 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10842 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10843 if header.minor_opcode != GET_MINMAX_PARAMETERIV_REQUEST {
10844 return Err(ParseError::InvalidValue);
10845 }
10846 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10847 let (target, remaining) = u32::try_parse(remaining)?;
10848 let (pname, remaining) = u32::try_parse(remaining)?;
10849 let _ = remaining;
10850 Ok(GetMinmaxParameterivRequest {
10851 context_tag,
10852 target,
10853 pname,
10854 })
10855 }
10856 }
10857 impl Request for GetMinmaxParameterivRequest {
10858 type Reply = GetMinmaxParameterivReply;
10859 }
get_minmax_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMinmaxParameterivReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10860 pub fn get_minmax_parameteriv<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetMinmaxParameterivReply>, ConnectionError>
10861 where
10862 Conn: RequestConnection + ?Sized,
10863 {
10864 let request0 = GetMinmaxParameterivRequest {
10865 context_tag,
10866 target,
10867 pname,
10868 };
10869 request0.send(conn)
10870 }
10871
10872 #[derive(Debug, Clone, PartialEq, Eq)]
10873 pub struct GetMinmaxParameterivReply {
10874 pub sequence: u16,
10875 pub length: u32,
10876 pub datum: i32,
10877 pub data: Vec<i32>,
10878 }
10879 impl TryParse for GetMinmaxParameterivReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>10880 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
10881 let remaining = initial_value;
10882 let (response_type, remaining) = u8::try_parse(remaining)?;
10883 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
10884 let (sequence, remaining) = u16::try_parse(remaining)?;
10885 let (length, remaining) = u32::try_parse(remaining)?;
10886 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
10887 let (n, remaining) = u32::try_parse(remaining)?;
10888 let (datum, remaining) = i32::try_parse(remaining)?;
10889 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
10890 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
10891 if response_type != 1 {
10892 return Err(ParseError::InvalidValue);
10893 }
10894 let result = GetMinmaxParameterivReply { sequence, length, datum, data };
10895 let _ = remaining;
10896 let remaining = initial_value.get(32 + length as usize * 4..)
10897 .ok_or(ParseError::InsufficientData)?;
10898 Ok((result, remaining))
10899 }
10900 }
10901 impl GetMinmaxParameterivReply {
10902 /// Get the value of the `n` field.
10903 ///
10904 /// The `n` field is used as the length field of the `data` field.
10905 /// This function computes the field's value again based on the length of the list.
10906 ///
10907 /// # Panics
10908 ///
10909 /// Panics if the value cannot be represented in the target type. This
10910 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u3210911 pub fn n(&self) -> u32 {
10912 self.data.len()
10913 .try_into().unwrap()
10914 }
10915 }
10916
10917 /// Opcode for the GetCompressedTexImageARB request
10918 pub const GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST: u8 = 160;
10919 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10920 pub struct GetCompressedTexImageARBRequest {
10921 pub context_tag: ContextTag,
10922 pub target: u32,
10923 pub level: i32,
10924 }
10925 impl GetCompressedTexImageARBRequest {
10926 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,10927 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
10928 where
10929 Conn: RequestConnection + ?Sized,
10930 {
10931 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
10932 .ok_or(ConnectionError::UnsupportedExtension)?;
10933 let length_so_far = 0;
10934 let context_tag_bytes = self.context_tag.serialize();
10935 let target_bytes = self.target.serialize();
10936 let level_bytes = self.level.serialize();
10937 let mut request0 = vec![
10938 extension_information.major_opcode,
10939 GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST,
10940 0,
10941 0,
10942 context_tag_bytes[0],
10943 context_tag_bytes[1],
10944 context_tag_bytes[2],
10945 context_tag_bytes[3],
10946 target_bytes[0],
10947 target_bytes[1],
10948 target_bytes[2],
10949 target_bytes[3],
10950 level_bytes[0],
10951 level_bytes[1],
10952 level_bytes[2],
10953 level_bytes[3],
10954 ];
10955 let length_so_far = length_so_far + request0.len();
10956 assert_eq!(length_so_far % 4, 0);
10957 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
10958 request0[2..4].copy_from_slice(&length.to_ne_bytes());
10959 Ok((vec![request0.into()], vec![]))
10960 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetCompressedTexImageARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10961 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetCompressedTexImageARBReply>, ConnectionError>
10962 where
10963 Conn: RequestConnection + ?Sized,
10964 {
10965 let (bytes, fds) = self.serialize(conn)?;
10966 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
10967 conn.send_request_with_reply(&slices, fds)
10968 }
10969 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>10970 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
10971 if header.minor_opcode != GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST {
10972 return Err(ParseError::InvalidValue);
10973 }
10974 let (context_tag, remaining) = ContextTag::try_parse(value)?;
10975 let (target, remaining) = u32::try_parse(remaining)?;
10976 let (level, remaining) = i32::try_parse(remaining)?;
10977 let _ = remaining;
10978 Ok(GetCompressedTexImageARBRequest {
10979 context_tag,
10980 target,
10981 level,
10982 })
10983 }
10984 }
10985 impl Request for GetCompressedTexImageARBRequest {
10986 type Reply = GetCompressedTexImageARBReply;
10987 }
get_compressed_tex_image_arb<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32) -> Result<Cookie<'_, Conn, GetCompressedTexImageARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,10988 pub fn get_compressed_tex_image_arb<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, level: i32) -> Result<Cookie<'_, Conn, GetCompressedTexImageARBReply>, ConnectionError>
10989 where
10990 Conn: RequestConnection + ?Sized,
10991 {
10992 let request0 = GetCompressedTexImageARBRequest {
10993 context_tag,
10994 target,
10995 level,
10996 };
10997 request0.send(conn)
10998 }
10999
11000 #[derive(Debug, Clone, PartialEq, Eq)]
11001 pub struct GetCompressedTexImageARBReply {
11002 pub sequence: u16,
11003 pub size: i32,
11004 pub data: Vec<u8>,
11005 }
11006 impl TryParse for GetCompressedTexImageARBReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>11007 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11008 let remaining = initial_value;
11009 let (response_type, remaining) = u8::try_parse(remaining)?;
11010 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11011 let (sequence, remaining) = u16::try_parse(remaining)?;
11012 let (length, remaining) = u32::try_parse(remaining)?;
11013 let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?;
11014 let (size, remaining) = i32::try_parse(remaining)?;
11015 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11016 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, length.checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?;
11017 let data = data.to_vec();
11018 if response_type != 1 {
11019 return Err(ParseError::InvalidValue);
11020 }
11021 let result = GetCompressedTexImageARBReply { sequence, size, data };
11022 let _ = remaining;
11023 let remaining = initial_value.get(32 + length as usize * 4..)
11024 .ok_or(ParseError::InsufficientData)?;
11025 Ok((result, remaining))
11026 }
11027 }
11028 impl GetCompressedTexImageARBReply {
11029 /// Get the value of the `length` field.
11030 ///
11031 /// The `length` field is used as the length field of the `data` field.
11032 /// This function computes the field's value again based on the length of the list.
11033 ///
11034 /// # Panics
11035 ///
11036 /// Panics if the value cannot be represented in the target type. This
11037 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u3211038 pub fn length(&self) -> u32 {
11039 self.data.len()
11040 .checked_div(4).unwrap()
11041 .try_into().unwrap()
11042 }
11043 }
11044
11045 /// Opcode for the DeleteQueriesARB request
11046 pub const DELETE_QUERIES_ARB_REQUEST: u8 = 161;
11047 #[derive(Debug, Clone, PartialEq, Eq)]
11048 pub struct DeleteQueriesARBRequest<'input> {
11049 pub context_tag: ContextTag,
11050 pub ids: Cow<'input, [u32]>,
11051 }
11052 impl<'input> DeleteQueriesARBRequest<'input> {
11053 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,11054 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
11055 where
11056 Conn: RequestConnection + ?Sized,
11057 {
11058 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
11059 .ok_or(ConnectionError::UnsupportedExtension)?;
11060 let length_so_far = 0;
11061 let context_tag_bytes = self.context_tag.serialize();
11062 let n = i32::try_from(self.ids.len()).expect("`ids` has too many elements");
11063 let n_bytes = n.serialize();
11064 let mut request0 = vec![
11065 extension_information.major_opcode,
11066 DELETE_QUERIES_ARB_REQUEST,
11067 0,
11068 0,
11069 context_tag_bytes[0],
11070 context_tag_bytes[1],
11071 context_tag_bytes[2],
11072 context_tag_bytes[3],
11073 n_bytes[0],
11074 n_bytes[1],
11075 n_bytes[2],
11076 n_bytes[3],
11077 ];
11078 let length_so_far = length_so_far + request0.len();
11079 let ids_bytes = self.ids.serialize();
11080 let length_so_far = length_so_far + ids_bytes.len();
11081 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
11082 let length_so_far = length_so_far + padding0.len();
11083 assert_eq!(length_so_far % 4, 0);
11084 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11085 request0[2..4].copy_from_slice(&length.to_ne_bytes());
11086 Ok((vec![request0.into(), ids_bytes.into(), padding0.into()], vec![]))
11087 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,11088 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
11089 where
11090 Conn: RequestConnection + ?Sized,
11091 {
11092 let (bytes, fds) = self.serialize(conn)?;
11093 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
11094 conn.send_request_without_reply(&slices, fds)
11095 }
11096 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError>11097 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
11098 if header.minor_opcode != DELETE_QUERIES_ARB_REQUEST {
11099 return Err(ParseError::InvalidValue);
11100 }
11101 let (context_tag, remaining) = ContextTag::try_parse(value)?;
11102 let (n, remaining) = i32::try_parse(remaining)?;
11103 let (ids, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
11104 let _ = remaining;
11105 Ok(DeleteQueriesARBRequest {
11106 context_tag,
11107 ids: Cow::Owned(ids),
11108 })
11109 }
11110 /// Clone all borrowed data in this DeleteQueriesARBRequest.
into_owned(self) -> DeleteQueriesARBRequest<'static>11111 pub fn into_owned(self) -> DeleteQueriesARBRequest<'static> {
11112 DeleteQueriesARBRequest {
11113 context_tag: self.context_tag,
11114 ids: Cow::Owned(self.ids.into_owned()),
11115 }
11116 }
11117 }
11118 impl<'input> Request for DeleteQueriesARBRequest<'input> {
11119 type Reply = ();
11120 }
delete_queries_arb<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, ids: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,11121 pub fn delete_queries_arb<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, ids: &'input [u32]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
11122 where
11123 Conn: RequestConnection + ?Sized,
11124 {
11125 let request0 = DeleteQueriesARBRequest {
11126 context_tag,
11127 ids: Cow::Borrowed(ids),
11128 };
11129 request0.send(conn)
11130 }
11131
11132 /// Opcode for the GenQueriesARB request
11133 pub const GEN_QUERIES_ARB_REQUEST: u8 = 162;
11134 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
11135 pub struct GenQueriesARBRequest {
11136 pub context_tag: ContextTag,
11137 pub n: i32,
11138 }
11139 impl GenQueriesARBRequest {
11140 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,11141 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
11142 where
11143 Conn: RequestConnection + ?Sized,
11144 {
11145 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
11146 .ok_or(ConnectionError::UnsupportedExtension)?;
11147 let length_so_far = 0;
11148 let context_tag_bytes = self.context_tag.serialize();
11149 let n_bytes = self.n.serialize();
11150 let mut request0 = vec![
11151 extension_information.major_opcode,
11152 GEN_QUERIES_ARB_REQUEST,
11153 0,
11154 0,
11155 context_tag_bytes[0],
11156 context_tag_bytes[1],
11157 context_tag_bytes[2],
11158 context_tag_bytes[3],
11159 n_bytes[0],
11160 n_bytes[1],
11161 n_bytes[2],
11162 n_bytes[3],
11163 ];
11164 let length_so_far = length_so_far + request0.len();
11165 assert_eq!(length_so_far % 4, 0);
11166 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11167 request0[2..4].copy_from_slice(&length.to_ne_bytes());
11168 Ok((vec![request0.into()], vec![]))
11169 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GenQueriesARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11170 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GenQueriesARBReply>, ConnectionError>
11171 where
11172 Conn: RequestConnection + ?Sized,
11173 {
11174 let (bytes, fds) = self.serialize(conn)?;
11175 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
11176 conn.send_request_with_reply(&slices, fds)
11177 }
11178 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>11179 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11180 if header.minor_opcode != GEN_QUERIES_ARB_REQUEST {
11181 return Err(ParseError::InvalidValue);
11182 }
11183 let (context_tag, remaining) = ContextTag::try_parse(value)?;
11184 let (n, remaining) = i32::try_parse(remaining)?;
11185 let _ = remaining;
11186 Ok(GenQueriesARBRequest {
11187 context_tag,
11188 n,
11189 })
11190 }
11191 }
11192 impl Request for GenQueriesARBRequest {
11193 type Reply = GenQueriesARBReply;
11194 }
gen_queries_arb<Conn>(conn: &Conn, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Conn, GenQueriesARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11195 pub fn gen_queries_arb<Conn>(conn: &Conn, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Conn, GenQueriesARBReply>, ConnectionError>
11196 where
11197 Conn: RequestConnection + ?Sized,
11198 {
11199 let request0 = GenQueriesARBRequest {
11200 context_tag,
11201 n,
11202 };
11203 request0.send(conn)
11204 }
11205
11206 #[derive(Debug, Clone, PartialEq, Eq)]
11207 pub struct GenQueriesARBReply {
11208 pub sequence: u16,
11209 pub data: Vec<u32>,
11210 }
11211 impl TryParse for GenQueriesARBReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>11212 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11213 let remaining = initial_value;
11214 let (response_type, remaining) = u8::try_parse(remaining)?;
11215 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11216 let (sequence, remaining) = u16::try_parse(remaining)?;
11217 let (length, remaining) = u32::try_parse(remaining)?;
11218 let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
11219 let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, length.try_to_usize()?)?;
11220 if response_type != 1 {
11221 return Err(ParseError::InvalidValue);
11222 }
11223 let result = GenQueriesARBReply { sequence, data };
11224 let _ = remaining;
11225 let remaining = initial_value.get(32 + length as usize * 4..)
11226 .ok_or(ParseError::InsufficientData)?;
11227 Ok((result, remaining))
11228 }
11229 }
11230 impl GenQueriesARBReply {
11231 /// Get the value of the `length` field.
11232 ///
11233 /// The `length` field is used as the length field of the `data` field.
11234 /// This function computes the field's value again based on the length of the list.
11235 ///
11236 /// # Panics
11237 ///
11238 /// Panics if the value cannot be represented in the target type. This
11239 /// cannot happen with values of the struct received from the X11 server.
length(&self) -> u3211240 pub fn length(&self) -> u32 {
11241 self.data.len()
11242 .try_into().unwrap()
11243 }
11244 }
11245
11246 /// Opcode for the IsQueryARB request
11247 pub const IS_QUERY_ARB_REQUEST: u8 = 163;
11248 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
11249 pub struct IsQueryARBRequest {
11250 pub context_tag: ContextTag,
11251 pub id: u32,
11252 }
11253 impl IsQueryARBRequest {
11254 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,11255 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
11256 where
11257 Conn: RequestConnection + ?Sized,
11258 {
11259 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
11260 .ok_or(ConnectionError::UnsupportedExtension)?;
11261 let length_so_far = 0;
11262 let context_tag_bytes = self.context_tag.serialize();
11263 let id_bytes = self.id.serialize();
11264 let mut request0 = vec![
11265 extension_information.major_opcode,
11266 IS_QUERY_ARB_REQUEST,
11267 0,
11268 0,
11269 context_tag_bytes[0],
11270 context_tag_bytes[1],
11271 context_tag_bytes[2],
11272 context_tag_bytes[3],
11273 id_bytes[0],
11274 id_bytes[1],
11275 id_bytes[2],
11276 id_bytes[3],
11277 ];
11278 let length_so_far = length_so_far + request0.len();
11279 assert_eq!(length_so_far % 4, 0);
11280 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11281 request0[2..4].copy_from_slice(&length.to_ne_bytes());
11282 Ok((vec![request0.into()], vec![]))
11283 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsQueryARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11284 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, IsQueryARBReply>, ConnectionError>
11285 where
11286 Conn: RequestConnection + ?Sized,
11287 {
11288 let (bytes, fds) = self.serialize(conn)?;
11289 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
11290 conn.send_request_with_reply(&slices, fds)
11291 }
11292 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>11293 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11294 if header.minor_opcode != IS_QUERY_ARB_REQUEST {
11295 return Err(ParseError::InvalidValue);
11296 }
11297 let (context_tag, remaining) = ContextTag::try_parse(value)?;
11298 let (id, remaining) = u32::try_parse(remaining)?;
11299 let _ = remaining;
11300 Ok(IsQueryARBRequest {
11301 context_tag,
11302 id,
11303 })
11304 }
11305 }
11306 impl Request for IsQueryARBRequest {
11307 type Reply = IsQueryARBReply;
11308 }
is_query_arb<Conn>(conn: &Conn, context_tag: ContextTag, id: u32) -> Result<Cookie<'_, Conn, IsQueryARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11309 pub fn is_query_arb<Conn>(conn: &Conn, context_tag: ContextTag, id: u32) -> Result<Cookie<'_, Conn, IsQueryARBReply>, ConnectionError>
11310 where
11311 Conn: RequestConnection + ?Sized,
11312 {
11313 let request0 = IsQueryARBRequest {
11314 context_tag,
11315 id,
11316 };
11317 request0.send(conn)
11318 }
11319
11320 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
11321 pub struct IsQueryARBReply {
11322 pub sequence: u16,
11323 pub length: u32,
11324 pub ret_val: Bool32,
11325 }
11326 impl TryParse for IsQueryARBReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>11327 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11328 let remaining = initial_value;
11329 let (response_type, remaining) = u8::try_parse(remaining)?;
11330 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11331 let (sequence, remaining) = u16::try_parse(remaining)?;
11332 let (length, remaining) = u32::try_parse(remaining)?;
11333 let (ret_val, remaining) = Bool32::try_parse(remaining)?;
11334 if response_type != 1 {
11335 return Err(ParseError::InvalidValue);
11336 }
11337 let result = IsQueryARBReply { sequence, length, ret_val };
11338 let _ = remaining;
11339 let remaining = initial_value.get(32 + length as usize * 4..)
11340 .ok_or(ParseError::InsufficientData)?;
11341 Ok((result, remaining))
11342 }
11343 }
11344
11345 /// Opcode for the GetQueryivARB request
11346 pub const GET_QUERYIV_ARB_REQUEST: u8 = 164;
11347 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
11348 pub struct GetQueryivARBRequest {
11349 pub context_tag: ContextTag,
11350 pub target: u32,
11351 pub pname: u32,
11352 }
11353 impl GetQueryivARBRequest {
11354 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,11355 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
11356 where
11357 Conn: RequestConnection + ?Sized,
11358 {
11359 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
11360 .ok_or(ConnectionError::UnsupportedExtension)?;
11361 let length_so_far = 0;
11362 let context_tag_bytes = self.context_tag.serialize();
11363 let target_bytes = self.target.serialize();
11364 let pname_bytes = self.pname.serialize();
11365 let mut request0 = vec![
11366 extension_information.major_opcode,
11367 GET_QUERYIV_ARB_REQUEST,
11368 0,
11369 0,
11370 context_tag_bytes[0],
11371 context_tag_bytes[1],
11372 context_tag_bytes[2],
11373 context_tag_bytes[3],
11374 target_bytes[0],
11375 target_bytes[1],
11376 target_bytes[2],
11377 target_bytes[3],
11378 pname_bytes[0],
11379 pname_bytes[1],
11380 pname_bytes[2],
11381 pname_bytes[3],
11382 ];
11383 let length_so_far = length_so_far + request0.len();
11384 assert_eq!(length_so_far % 4, 0);
11385 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11386 request0[2..4].copy_from_slice(&length.to_ne_bytes());
11387 Ok((vec![request0.into()], vec![]))
11388 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetQueryivARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11389 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetQueryivARBReply>, ConnectionError>
11390 where
11391 Conn: RequestConnection + ?Sized,
11392 {
11393 let (bytes, fds) = self.serialize(conn)?;
11394 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
11395 conn.send_request_with_reply(&slices, fds)
11396 }
11397 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>11398 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11399 if header.minor_opcode != GET_QUERYIV_ARB_REQUEST {
11400 return Err(ParseError::InvalidValue);
11401 }
11402 let (context_tag, remaining) = ContextTag::try_parse(value)?;
11403 let (target, remaining) = u32::try_parse(remaining)?;
11404 let (pname, remaining) = u32::try_parse(remaining)?;
11405 let _ = remaining;
11406 Ok(GetQueryivARBRequest {
11407 context_tag,
11408 target,
11409 pname,
11410 })
11411 }
11412 }
11413 impl Request for GetQueryivARBRequest {
11414 type Reply = GetQueryivARBReply;
11415 }
get_queryiv_arb<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetQueryivARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11416 pub fn get_queryiv_arb<Conn>(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Conn, GetQueryivARBReply>, ConnectionError>
11417 where
11418 Conn: RequestConnection + ?Sized,
11419 {
11420 let request0 = GetQueryivARBRequest {
11421 context_tag,
11422 target,
11423 pname,
11424 };
11425 request0.send(conn)
11426 }
11427
11428 #[derive(Debug, Clone, PartialEq, Eq)]
11429 pub struct GetQueryivARBReply {
11430 pub sequence: u16,
11431 pub length: u32,
11432 pub datum: i32,
11433 pub data: Vec<i32>,
11434 }
11435 impl TryParse for GetQueryivARBReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>11436 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11437 let remaining = initial_value;
11438 let (response_type, remaining) = u8::try_parse(remaining)?;
11439 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11440 let (sequence, remaining) = u16::try_parse(remaining)?;
11441 let (length, remaining) = u32::try_parse(remaining)?;
11442 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
11443 let (n, remaining) = u32::try_parse(remaining)?;
11444 let (datum, remaining) = i32::try_parse(remaining)?;
11445 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11446 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
11447 if response_type != 1 {
11448 return Err(ParseError::InvalidValue);
11449 }
11450 let result = GetQueryivARBReply { sequence, length, datum, data };
11451 let _ = remaining;
11452 let remaining = initial_value.get(32 + length as usize * 4..)
11453 .ok_or(ParseError::InsufficientData)?;
11454 Ok((result, remaining))
11455 }
11456 }
11457 impl GetQueryivARBReply {
11458 /// Get the value of the `n` field.
11459 ///
11460 /// The `n` field is used as the length field of the `data` field.
11461 /// This function computes the field's value again based on the length of the list.
11462 ///
11463 /// # Panics
11464 ///
11465 /// Panics if the value cannot be represented in the target type. This
11466 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u3211467 pub fn n(&self) -> u32 {
11468 self.data.len()
11469 .try_into().unwrap()
11470 }
11471 }
11472
11473 /// Opcode for the GetQueryObjectivARB request
11474 pub const GET_QUERY_OBJECTIV_ARB_REQUEST: u8 = 165;
11475 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
11476 pub struct GetQueryObjectivARBRequest {
11477 pub context_tag: ContextTag,
11478 pub id: u32,
11479 pub pname: u32,
11480 }
11481 impl GetQueryObjectivARBRequest {
11482 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,11483 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
11484 where
11485 Conn: RequestConnection + ?Sized,
11486 {
11487 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
11488 .ok_or(ConnectionError::UnsupportedExtension)?;
11489 let length_so_far = 0;
11490 let context_tag_bytes = self.context_tag.serialize();
11491 let id_bytes = self.id.serialize();
11492 let pname_bytes = self.pname.serialize();
11493 let mut request0 = vec![
11494 extension_information.major_opcode,
11495 GET_QUERY_OBJECTIV_ARB_REQUEST,
11496 0,
11497 0,
11498 context_tag_bytes[0],
11499 context_tag_bytes[1],
11500 context_tag_bytes[2],
11501 context_tag_bytes[3],
11502 id_bytes[0],
11503 id_bytes[1],
11504 id_bytes[2],
11505 id_bytes[3],
11506 pname_bytes[0],
11507 pname_bytes[1],
11508 pname_bytes[2],
11509 pname_bytes[3],
11510 ];
11511 let length_so_far = length_so_far + request0.len();
11512 assert_eq!(length_so_far % 4, 0);
11513 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11514 request0[2..4].copy_from_slice(&length.to_ne_bytes());
11515 Ok((vec![request0.into()], vec![]))
11516 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetQueryObjectivARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11517 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetQueryObjectivARBReply>, ConnectionError>
11518 where
11519 Conn: RequestConnection + ?Sized,
11520 {
11521 let (bytes, fds) = self.serialize(conn)?;
11522 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
11523 conn.send_request_with_reply(&slices, fds)
11524 }
11525 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>11526 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11527 if header.minor_opcode != GET_QUERY_OBJECTIV_ARB_REQUEST {
11528 return Err(ParseError::InvalidValue);
11529 }
11530 let (context_tag, remaining) = ContextTag::try_parse(value)?;
11531 let (id, remaining) = u32::try_parse(remaining)?;
11532 let (pname, remaining) = u32::try_parse(remaining)?;
11533 let _ = remaining;
11534 Ok(GetQueryObjectivARBRequest {
11535 context_tag,
11536 id,
11537 pname,
11538 })
11539 }
11540 }
11541 impl Request for GetQueryObjectivARBRequest {
11542 type Reply = GetQueryObjectivARBReply;
11543 }
get_query_objectiv_arb<Conn>(conn: &Conn, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Conn, GetQueryObjectivARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11544 pub fn get_query_objectiv_arb<Conn>(conn: &Conn, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Conn, GetQueryObjectivARBReply>, ConnectionError>
11545 where
11546 Conn: RequestConnection + ?Sized,
11547 {
11548 let request0 = GetQueryObjectivARBRequest {
11549 context_tag,
11550 id,
11551 pname,
11552 };
11553 request0.send(conn)
11554 }
11555
11556 #[derive(Debug, Clone, PartialEq, Eq)]
11557 pub struct GetQueryObjectivARBReply {
11558 pub sequence: u16,
11559 pub length: u32,
11560 pub datum: i32,
11561 pub data: Vec<i32>,
11562 }
11563 impl TryParse for GetQueryObjectivARBReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>11564 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11565 let remaining = initial_value;
11566 let (response_type, remaining) = u8::try_parse(remaining)?;
11567 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11568 let (sequence, remaining) = u16::try_parse(remaining)?;
11569 let (length, remaining) = u32::try_parse(remaining)?;
11570 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
11571 let (n, remaining) = u32::try_parse(remaining)?;
11572 let (datum, remaining) = i32::try_parse(remaining)?;
11573 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11574 let (data, remaining) = crate::x11_utils::parse_list::<i32>(remaining, n.try_to_usize()?)?;
11575 if response_type != 1 {
11576 return Err(ParseError::InvalidValue);
11577 }
11578 let result = GetQueryObjectivARBReply { sequence, length, datum, data };
11579 let _ = remaining;
11580 let remaining = initial_value.get(32 + length as usize * 4..)
11581 .ok_or(ParseError::InsufficientData)?;
11582 Ok((result, remaining))
11583 }
11584 }
11585 impl GetQueryObjectivARBReply {
11586 /// Get the value of the `n` field.
11587 ///
11588 /// The `n` field is used as the length field of the `data` field.
11589 /// This function computes the field's value again based on the length of the list.
11590 ///
11591 /// # Panics
11592 ///
11593 /// Panics if the value cannot be represented in the target type. This
11594 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u3211595 pub fn n(&self) -> u32 {
11596 self.data.len()
11597 .try_into().unwrap()
11598 }
11599 }
11600
11601 /// Opcode for the GetQueryObjectuivARB request
11602 pub const GET_QUERY_OBJECTUIV_ARB_REQUEST: u8 = 166;
11603 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
11604 pub struct GetQueryObjectuivARBRequest {
11605 pub context_tag: ContextTag,
11606 pub id: u32,
11607 pub pname: u32,
11608 }
11609 impl GetQueryObjectuivARBRequest {
11610 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,11611 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
11612 where
11613 Conn: RequestConnection + ?Sized,
11614 {
11615 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
11616 .ok_or(ConnectionError::UnsupportedExtension)?;
11617 let length_so_far = 0;
11618 let context_tag_bytes = self.context_tag.serialize();
11619 let id_bytes = self.id.serialize();
11620 let pname_bytes = self.pname.serialize();
11621 let mut request0 = vec![
11622 extension_information.major_opcode,
11623 GET_QUERY_OBJECTUIV_ARB_REQUEST,
11624 0,
11625 0,
11626 context_tag_bytes[0],
11627 context_tag_bytes[1],
11628 context_tag_bytes[2],
11629 context_tag_bytes[3],
11630 id_bytes[0],
11631 id_bytes[1],
11632 id_bytes[2],
11633 id_bytes[3],
11634 pname_bytes[0],
11635 pname_bytes[1],
11636 pname_bytes[2],
11637 pname_bytes[3],
11638 ];
11639 let length_so_far = length_so_far + request0.len();
11640 assert_eq!(length_so_far % 4, 0);
11641 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
11642 request0[2..4].copy_from_slice(&length.to_ne_bytes());
11643 Ok((vec![request0.into()], vec![]))
11644 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetQueryObjectuivARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11645 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetQueryObjectuivARBReply>, ConnectionError>
11646 where
11647 Conn: RequestConnection + ?Sized,
11648 {
11649 let (bytes, fds) = self.serialize(conn)?;
11650 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
11651 conn.send_request_with_reply(&slices, fds)
11652 }
11653 /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError>11654 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
11655 if header.minor_opcode != GET_QUERY_OBJECTUIV_ARB_REQUEST {
11656 return Err(ParseError::InvalidValue);
11657 }
11658 let (context_tag, remaining) = ContextTag::try_parse(value)?;
11659 let (id, remaining) = u32::try_parse(remaining)?;
11660 let (pname, remaining) = u32::try_parse(remaining)?;
11661 let _ = remaining;
11662 Ok(GetQueryObjectuivARBRequest {
11663 context_tag,
11664 id,
11665 pname,
11666 })
11667 }
11668 }
11669 impl Request for GetQueryObjectuivARBRequest {
11670 type Reply = GetQueryObjectuivARBReply;
11671 }
get_query_objectuiv_arb<Conn>(conn: &Conn, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Conn, GetQueryObjectuivARBReply>, ConnectionError> where Conn: RequestConnection + ?Sized,11672 pub fn get_query_objectuiv_arb<Conn>(conn: &Conn, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Conn, GetQueryObjectuivARBReply>, ConnectionError>
11673 where
11674 Conn: RequestConnection + ?Sized,
11675 {
11676 let request0 = GetQueryObjectuivARBRequest {
11677 context_tag,
11678 id,
11679 pname,
11680 };
11681 request0.send(conn)
11682 }
11683
11684 #[derive(Debug, Clone, PartialEq, Eq)]
11685 pub struct GetQueryObjectuivARBReply {
11686 pub sequence: u16,
11687 pub length: u32,
11688 pub datum: u32,
11689 pub data: Vec<u32>,
11690 }
11691 impl TryParse for GetQueryObjectuivARBReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>11692 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
11693 let remaining = initial_value;
11694 let (response_type, remaining) = u8::try_parse(remaining)?;
11695 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
11696 let (sequence, remaining) = u16::try_parse(remaining)?;
11697 let (length, remaining) = u32::try_parse(remaining)?;
11698 let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?;
11699 let (n, remaining) = u32::try_parse(remaining)?;
11700 let (datum, remaining) = u32::try_parse(remaining)?;
11701 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
11702 let (data, remaining) = crate::x11_utils::parse_list::<u32>(remaining, n.try_to_usize()?)?;
11703 if response_type != 1 {
11704 return Err(ParseError::InvalidValue);
11705 }
11706 let result = GetQueryObjectuivARBReply { sequence, length, datum, data };
11707 let _ = remaining;
11708 let remaining = initial_value.get(32 + length as usize * 4..)
11709 .ok_or(ParseError::InsufficientData)?;
11710 Ok((result, remaining))
11711 }
11712 }
11713 impl GetQueryObjectuivARBReply {
11714 /// Get the value of the `n` field.
11715 ///
11716 /// The `n` field is used as the length field of the `data` field.
11717 /// This function computes the field's value again based on the length of the list.
11718 ///
11719 /// # Panics
11720 ///
11721 /// Panics if the value cannot be represented in the target type. This
11722 /// cannot happen with values of the struct received from the X11 server.
n(&self) -> u3211723 pub fn n(&self) -> u32 {
11724 self.data.len()
11725 .try_into().unwrap()
11726 }
11727 }
11728
11729 /// Extension trait defining the requests of this extension.
11730 pub trait ConnectionExt: RequestConnection {
glx_render<'c, 'input>(&'c self, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>11731 fn glx_render<'c, 'input>(&'c self, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11732 {
11733 render(self, context_tag, data)
11734 }
glx_render_large<'c, 'input>(&'c self, context_tag: ContextTag, request_num: u16, request_total: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>11735 fn glx_render_large<'c, 'input>(&'c self, context_tag: ContextTag, request_num: u16, request_total: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11736 {
11737 render_large(self, context_tag, request_num, request_total, data)
11738 }
glx_create_context(&self, context: Context, visual: xproto::Visualid, screen: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>11739 fn glx_create_context(&self, context: Context, visual: xproto::Visualid, screen: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
11740 {
11741 create_context(self, context, visual, screen, share_list, is_direct)
11742 }
glx_destroy_context(&self, context: Context) -> Result<VoidCookie<'_, Self>, ConnectionError>11743 fn glx_destroy_context(&self, context: Context) -> Result<VoidCookie<'_, Self>, ConnectionError>
11744 {
11745 destroy_context(self, context)
11746 }
glx_make_current(&self, drawable: Drawable, context: Context, old_context_tag: ContextTag) -> Result<Cookie<'_, Self, MakeCurrentReply>, ConnectionError>11747 fn glx_make_current(&self, drawable: Drawable, context: Context, old_context_tag: ContextTag) -> Result<Cookie<'_, Self, MakeCurrentReply>, ConnectionError>
11748 {
11749 make_current(self, drawable, context, old_context_tag)
11750 }
glx_is_direct(&self, context: Context) -> Result<Cookie<'_, Self, IsDirectReply>, ConnectionError>11751 fn glx_is_direct(&self, context: Context) -> Result<Cookie<'_, Self, IsDirectReply>, ConnectionError>
11752 {
11753 is_direct(self, context)
11754 }
glx_query_version(&self, major_version: u32, minor_version: u32) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>11755 fn glx_query_version(&self, major_version: u32, minor_version: u32) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>
11756 {
11757 query_version(self, major_version, minor_version)
11758 }
glx_wait_gl(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>11759 fn glx_wait_gl(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>
11760 {
11761 wait_gl(self, context_tag)
11762 }
glx_wait_x(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>11763 fn glx_wait_x(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>
11764 {
11765 wait_x(self, context_tag)
11766 }
glx_copy_context(&self, src: Context, dest: Context, mask: u32, src_context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>11767 fn glx_copy_context(&self, src: Context, dest: Context, mask: u32, src_context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>
11768 {
11769 copy_context(self, src, dest, mask, src_context_tag)
11770 }
glx_swap_buffers(&self, context_tag: ContextTag, drawable: Drawable) -> Result<VoidCookie<'_, Self>, ConnectionError>11771 fn glx_swap_buffers(&self, context_tag: ContextTag, drawable: Drawable) -> Result<VoidCookie<'_, Self>, ConnectionError>
11772 {
11773 swap_buffers(self, context_tag, drawable)
11774 }
glx_use_x_font(&self, context_tag: ContextTag, font: xproto::Font, first: u32, count: u32, list_base: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>11775 fn glx_use_x_font(&self, context_tag: ContextTag, font: xproto::Font, first: u32, count: u32, list_base: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
11776 {
11777 use_x_font(self, context_tag, font, first, count, list_base)
11778 }
glx_create_glx_pixmap(&self, screen: u32, visual: xproto::Visualid, pixmap: xproto::Pixmap, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>11779 fn glx_create_glx_pixmap(&self, screen: u32, visual: xproto::Visualid, pixmap: xproto::Pixmap, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>
11780 {
11781 create_glx_pixmap(self, screen, visual, pixmap, glx_pixmap)
11782 }
glx_get_visual_configs(&self, screen: u32) -> Result<Cookie<'_, Self, GetVisualConfigsReply>, ConnectionError>11783 fn glx_get_visual_configs(&self, screen: u32) -> Result<Cookie<'_, Self, GetVisualConfigsReply>, ConnectionError>
11784 {
11785 get_visual_configs(self, screen)
11786 }
glx_destroy_glx_pixmap(&self, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>11787 fn glx_destroy_glx_pixmap(&self, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>
11788 {
11789 destroy_glx_pixmap(self, glx_pixmap)
11790 }
glx_vendor_private<'c, 'input>(&'c self, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>11791 fn glx_vendor_private<'c, 'input>(&'c self, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11792 {
11793 vendor_private(self, vendor_code, context_tag, data)
11794 }
glx_vendor_private_with_reply<'c, 'input>(&'c self, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<Cookie<'c, Self, VendorPrivateWithReplyReply>, ConnectionError>11795 fn glx_vendor_private_with_reply<'c, 'input>(&'c self, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result<Cookie<'c, Self, VendorPrivateWithReplyReply>, ConnectionError>
11796 {
11797 vendor_private_with_reply(self, vendor_code, context_tag, data)
11798 }
glx_query_extensions_string(&self, screen: u32) -> Result<Cookie<'_, Self, QueryExtensionsStringReply>, ConnectionError>11799 fn glx_query_extensions_string(&self, screen: u32) -> Result<Cookie<'_, Self, QueryExtensionsStringReply>, ConnectionError>
11800 {
11801 query_extensions_string(self, screen)
11802 }
glx_query_server_string(&self, screen: u32, name: u32) -> Result<Cookie<'_, Self, QueryServerStringReply>, ConnectionError>11803 fn glx_query_server_string(&self, screen: u32, name: u32) -> Result<Cookie<'_, Self, QueryServerStringReply>, ConnectionError>
11804 {
11805 query_server_string(self, screen, name)
11806 }
glx_client_info<'c, 'input>(&'c self, major_version: u32, minor_version: u32, string: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>11807 fn glx_client_info<'c, 'input>(&'c self, major_version: u32, minor_version: u32, string: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11808 {
11809 client_info(self, major_version, minor_version, string)
11810 }
glx_get_fb_configs(&self, screen: u32) -> Result<Cookie<'_, Self, GetFBConfigsReply>, ConnectionError>11811 fn glx_get_fb_configs(&self, screen: u32) -> Result<Cookie<'_, Self, GetFBConfigsReply>, ConnectionError>
11812 {
11813 get_fb_configs(self, screen)
11814 }
glx_create_pixmap<'c, 'input>(&'c self, screen: u32, fbconfig: Fbconfig, pixmap: xproto::Pixmap, glx_pixmap: Pixmap, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>11815 fn glx_create_pixmap<'c, 'input>(&'c self, screen: u32, fbconfig: Fbconfig, pixmap: xproto::Pixmap, glx_pixmap: Pixmap, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11816 {
11817 create_pixmap(self, screen, fbconfig, pixmap, glx_pixmap, attribs)
11818 }
glx_destroy_pixmap(&self, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>11819 fn glx_destroy_pixmap(&self, glx_pixmap: Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>
11820 {
11821 destroy_pixmap(self, glx_pixmap)
11822 }
glx_create_new_context(&self, context: Context, fbconfig: Fbconfig, screen: u32, render_type: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>11823 fn glx_create_new_context(&self, context: Context, fbconfig: Fbconfig, screen: u32, render_type: u32, share_list: Context, is_direct: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
11824 {
11825 create_new_context(self, context, fbconfig, screen, render_type, share_list, is_direct)
11826 }
glx_query_context(&self, context: Context) -> Result<Cookie<'_, Self, QueryContextReply>, ConnectionError>11827 fn glx_query_context(&self, context: Context) -> Result<Cookie<'_, Self, QueryContextReply>, ConnectionError>
11828 {
11829 query_context(self, context)
11830 }
glx_make_context_current(&self, old_context_tag: ContextTag, drawable: Drawable, read_drawable: Drawable, context: Context) -> Result<Cookie<'_, Self, MakeContextCurrentReply>, ConnectionError>11831 fn glx_make_context_current(&self, old_context_tag: ContextTag, drawable: Drawable, read_drawable: Drawable, context: Context) -> Result<Cookie<'_, Self, MakeContextCurrentReply>, ConnectionError>
11832 {
11833 make_context_current(self, old_context_tag, drawable, read_drawable, context)
11834 }
glx_create_pbuffer<'c, 'input>(&'c self, screen: u32, fbconfig: Fbconfig, pbuffer: Pbuffer, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>11835 fn glx_create_pbuffer<'c, 'input>(&'c self, screen: u32, fbconfig: Fbconfig, pbuffer: Pbuffer, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11836 {
11837 create_pbuffer(self, screen, fbconfig, pbuffer, attribs)
11838 }
glx_destroy_pbuffer(&self, pbuffer: Pbuffer) -> Result<VoidCookie<'_, Self>, ConnectionError>11839 fn glx_destroy_pbuffer(&self, pbuffer: Pbuffer) -> Result<VoidCookie<'_, Self>, ConnectionError>
11840 {
11841 destroy_pbuffer(self, pbuffer)
11842 }
glx_get_drawable_attributes(&self, drawable: Drawable) -> Result<Cookie<'_, Self, GetDrawableAttributesReply>, ConnectionError>11843 fn glx_get_drawable_attributes(&self, drawable: Drawable) -> Result<Cookie<'_, Self, GetDrawableAttributesReply>, ConnectionError>
11844 {
11845 get_drawable_attributes(self, drawable)
11846 }
glx_change_drawable_attributes<'c, 'input>(&'c self, drawable: Drawable, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>11847 fn glx_change_drawable_attributes<'c, 'input>(&'c self, drawable: Drawable, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11848 {
11849 change_drawable_attributes(self, drawable, attribs)
11850 }
glx_create_window<'c, 'input>(&'c self, screen: u32, fbconfig: Fbconfig, window: xproto::Window, glx_window: Window, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>11851 fn glx_create_window<'c, 'input>(&'c self, screen: u32, fbconfig: Fbconfig, window: xproto::Window, glx_window: Window, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11852 {
11853 create_window(self, screen, fbconfig, window, glx_window, attribs)
11854 }
glx_delete_window(&self, glxwindow: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>11855 fn glx_delete_window(&self, glxwindow: Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
11856 {
11857 delete_window(self, glxwindow)
11858 }
glx_set_client_info_arb<'c, 'input>(&'c self, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>11859 fn glx_set_client_info_arb<'c, 'input>(&'c self, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11860 {
11861 set_client_info_arb(self, major_version, minor_version, gl_versions, gl_extension_string, glx_extension_string)
11862 }
glx_create_context_attribs_arb<'c, 'input>(&'c self, context: Context, fbconfig: Fbconfig, screen: u32, share_list: Context, is_direct: bool, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>11863 fn glx_create_context_attribs_arb<'c, 'input>(&'c self, context: Context, fbconfig: Fbconfig, screen: u32, share_list: Context, is_direct: bool, attribs: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11864 {
11865 create_context_attribs_arb(self, context, fbconfig, screen, share_list, is_direct, attribs)
11866 }
glx_set_client_info2_arb<'c, 'input>(&'c self, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>11867 fn glx_set_client_info2_arb<'c, 'input>(&'c self, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
11868 {
11869 set_client_info2_arb(self, major_version, minor_version, gl_versions, gl_extension_string, glx_extension_string)
11870 }
glx_new_list(&self, context_tag: ContextTag, list: u32, mode: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>11871 fn glx_new_list(&self, context_tag: ContextTag, list: u32, mode: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
11872 {
11873 new_list(self, context_tag, list, mode)
11874 }
glx_end_list(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>11875 fn glx_end_list(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>
11876 {
11877 end_list(self, context_tag)
11878 }
glx_delete_lists(&self, context_tag: ContextTag, list: u32, range: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>11879 fn glx_delete_lists(&self, context_tag: ContextTag, list: u32, range: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>
11880 {
11881 delete_lists(self, context_tag, list, range)
11882 }
glx_gen_lists(&self, context_tag: ContextTag, range: i32) -> Result<Cookie<'_, Self, GenListsReply>, ConnectionError>11883 fn glx_gen_lists(&self, context_tag: ContextTag, range: i32) -> Result<Cookie<'_, Self, GenListsReply>, ConnectionError>
11884 {
11885 gen_lists(self, context_tag, range)
11886 }
glx_feedback_buffer(&self, context_tag: ContextTag, size: i32, type_: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>11887 fn glx_feedback_buffer(&self, context_tag: ContextTag, size: i32, type_: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>
11888 {
11889 feedback_buffer(self, context_tag, size, type_)
11890 }
glx_select_buffer(&self, context_tag: ContextTag, size: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>11891 fn glx_select_buffer(&self, context_tag: ContextTag, size: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>
11892 {
11893 select_buffer(self, context_tag, size)
11894 }
glx_render_mode(&self, context_tag: ContextTag, mode: u32) -> Result<Cookie<'_, Self, RenderModeReply>, ConnectionError>11895 fn glx_render_mode(&self, context_tag: ContextTag, mode: u32) -> Result<Cookie<'_, Self, RenderModeReply>, ConnectionError>
11896 {
11897 render_mode(self, context_tag, mode)
11898 }
glx_finish(&self, context_tag: ContextTag) -> Result<Cookie<'_, Self, FinishReply>, ConnectionError>11899 fn glx_finish(&self, context_tag: ContextTag) -> Result<Cookie<'_, Self, FinishReply>, ConnectionError>
11900 {
11901 finish(self, context_tag)
11902 }
glx_pixel_storef(&self, context_tag: ContextTag, pname: u32, datum: Float32) -> Result<VoidCookie<'_, Self>, ConnectionError>11903 fn glx_pixel_storef(&self, context_tag: ContextTag, pname: u32, datum: Float32) -> Result<VoidCookie<'_, Self>, ConnectionError>
11904 {
11905 pixel_storef(self, context_tag, pname, datum)
11906 }
glx_pixel_storei(&self, context_tag: ContextTag, pname: u32, datum: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>11907 fn glx_pixel_storei(&self, context_tag: ContextTag, pname: u32, datum: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>
11908 {
11909 pixel_storei(self, context_tag, pname, datum)
11910 }
glx_read_pixels(&self, context_tag: ContextTag, x: i32, y: i32, width: i32, height: i32, format: u32, type_: u32, swap_bytes: bool, lsb_first: bool) -> Result<Cookie<'_, Self, ReadPixelsReply>, ConnectionError>11911 fn glx_read_pixels(&self, context_tag: ContextTag, x: i32, y: i32, width: i32, height: i32, format: u32, type_: u32, swap_bytes: bool, lsb_first: bool) -> Result<Cookie<'_, Self, ReadPixelsReply>, ConnectionError>
11912 {
11913 read_pixels(self, context_tag, x, y, width, height, format, type_, swap_bytes, lsb_first)
11914 }
glx_get_booleanv(&self, context_tag: ContextTag, pname: i32) -> Result<Cookie<'_, Self, GetBooleanvReply>, ConnectionError>11915 fn glx_get_booleanv(&self, context_tag: ContextTag, pname: i32) -> Result<Cookie<'_, Self, GetBooleanvReply>, ConnectionError>
11916 {
11917 get_booleanv(self, context_tag, pname)
11918 }
glx_get_clip_plane(&self, context_tag: ContextTag, plane: i32) -> Result<Cookie<'_, Self, GetClipPlaneReply>, ConnectionError>11919 fn glx_get_clip_plane(&self, context_tag: ContextTag, plane: i32) -> Result<Cookie<'_, Self, GetClipPlaneReply>, ConnectionError>
11920 {
11921 get_clip_plane(self, context_tag, plane)
11922 }
glx_get_doublev(&self, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Self, GetDoublevReply>, ConnectionError>11923 fn glx_get_doublev(&self, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Self, GetDoublevReply>, ConnectionError>
11924 {
11925 get_doublev(self, context_tag, pname)
11926 }
glx_get_error(&self, context_tag: ContextTag) -> Result<Cookie<'_, Self, GetErrorReply>, ConnectionError>11927 fn glx_get_error(&self, context_tag: ContextTag) -> Result<Cookie<'_, Self, GetErrorReply>, ConnectionError>
11928 {
11929 get_error(self, context_tag)
11930 }
glx_get_floatv(&self, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Self, GetFloatvReply>, ConnectionError>11931 fn glx_get_floatv(&self, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Self, GetFloatvReply>, ConnectionError>
11932 {
11933 get_floatv(self, context_tag, pname)
11934 }
glx_get_integerv(&self, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Self, GetIntegervReply>, ConnectionError>11935 fn glx_get_integerv(&self, context_tag: ContextTag, pname: u32) -> Result<Cookie<'_, Self, GetIntegervReply>, ConnectionError>
11936 {
11937 get_integerv(self, context_tag, pname)
11938 }
glx_get_lightfv(&self, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Self, GetLightfvReply>, ConnectionError>11939 fn glx_get_lightfv(&self, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Self, GetLightfvReply>, ConnectionError>
11940 {
11941 get_lightfv(self, context_tag, light, pname)
11942 }
glx_get_lightiv(&self, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Self, GetLightivReply>, ConnectionError>11943 fn glx_get_lightiv(&self, context_tag: ContextTag, light: u32, pname: u32) -> Result<Cookie<'_, Self, GetLightivReply>, ConnectionError>
11944 {
11945 get_lightiv(self, context_tag, light, pname)
11946 }
glx_get_mapdv(&self, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Self, GetMapdvReply>, ConnectionError>11947 fn glx_get_mapdv(&self, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Self, GetMapdvReply>, ConnectionError>
11948 {
11949 get_mapdv(self, context_tag, target, query)
11950 }
glx_get_mapfv(&self, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Self, GetMapfvReply>, ConnectionError>11951 fn glx_get_mapfv(&self, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Self, GetMapfvReply>, ConnectionError>
11952 {
11953 get_mapfv(self, context_tag, target, query)
11954 }
glx_get_mapiv(&self, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Self, GetMapivReply>, ConnectionError>11955 fn glx_get_mapiv(&self, context_tag: ContextTag, target: u32, query: u32) -> Result<Cookie<'_, Self, GetMapivReply>, ConnectionError>
11956 {
11957 get_mapiv(self, context_tag, target, query)
11958 }
glx_get_materialfv(&self, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Self, GetMaterialfvReply>, ConnectionError>11959 fn glx_get_materialfv(&self, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Self, GetMaterialfvReply>, ConnectionError>
11960 {
11961 get_materialfv(self, context_tag, face, pname)
11962 }
glx_get_materialiv(&self, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Self, GetMaterialivReply>, ConnectionError>11963 fn glx_get_materialiv(&self, context_tag: ContextTag, face: u32, pname: u32) -> Result<Cookie<'_, Self, GetMaterialivReply>, ConnectionError>
11964 {
11965 get_materialiv(self, context_tag, face, pname)
11966 }
glx_get_pixel_mapfv(&self, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Self, GetPixelMapfvReply>, ConnectionError>11967 fn glx_get_pixel_mapfv(&self, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Self, GetPixelMapfvReply>, ConnectionError>
11968 {
11969 get_pixel_mapfv(self, context_tag, map)
11970 }
glx_get_pixel_mapuiv(&self, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Self, GetPixelMapuivReply>, ConnectionError>11971 fn glx_get_pixel_mapuiv(&self, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Self, GetPixelMapuivReply>, ConnectionError>
11972 {
11973 get_pixel_mapuiv(self, context_tag, map)
11974 }
glx_get_pixel_mapusv(&self, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Self, GetPixelMapusvReply>, ConnectionError>11975 fn glx_get_pixel_mapusv(&self, context_tag: ContextTag, map: u32) -> Result<Cookie<'_, Self, GetPixelMapusvReply>, ConnectionError>
11976 {
11977 get_pixel_mapusv(self, context_tag, map)
11978 }
glx_get_polygon_stipple(&self, context_tag: ContextTag, lsb_first: bool) -> Result<Cookie<'_, Self, GetPolygonStippleReply>, ConnectionError>11979 fn glx_get_polygon_stipple(&self, context_tag: ContextTag, lsb_first: bool) -> Result<Cookie<'_, Self, GetPolygonStippleReply>, ConnectionError>
11980 {
11981 get_polygon_stipple(self, context_tag, lsb_first)
11982 }
glx_get_string(&self, context_tag: ContextTag, name: u32) -> Result<Cookie<'_, Self, GetStringReply>, ConnectionError>11983 fn glx_get_string(&self, context_tag: ContextTag, name: u32) -> Result<Cookie<'_, Self, GetStringReply>, ConnectionError>
11984 {
11985 get_string(self, context_tag, name)
11986 }
glx_get_tex_envfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexEnvfvReply>, ConnectionError>11987 fn glx_get_tex_envfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexEnvfvReply>, ConnectionError>
11988 {
11989 get_tex_envfv(self, context_tag, target, pname)
11990 }
glx_get_tex_enviv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexEnvivReply>, ConnectionError>11991 fn glx_get_tex_enviv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexEnvivReply>, ConnectionError>
11992 {
11993 get_tex_enviv(self, context_tag, target, pname)
11994 }
glx_get_tex_gendv(&self, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexGendvReply>, ConnectionError>11995 fn glx_get_tex_gendv(&self, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexGendvReply>, ConnectionError>
11996 {
11997 get_tex_gendv(self, context_tag, coord, pname)
11998 }
glx_get_tex_genfv(&self, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexGenfvReply>, ConnectionError>11999 fn glx_get_tex_genfv(&self, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexGenfvReply>, ConnectionError>
12000 {
12001 get_tex_genfv(self, context_tag, coord, pname)
12002 }
glx_get_tex_geniv(&self, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexGenivReply>, ConnectionError>12003 fn glx_get_tex_geniv(&self, context_tag: ContextTag, coord: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexGenivReply>, ConnectionError>
12004 {
12005 get_tex_geniv(self, context_tag, coord, pname)
12006 }
glx_get_tex_image(&self, context_tag: ContextTag, target: u32, level: i32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetTexImageReply>, ConnectionError>12007 fn glx_get_tex_image(&self, context_tag: ContextTag, target: u32, level: i32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetTexImageReply>, ConnectionError>
12008 {
12009 get_tex_image(self, context_tag, target, level, format, type_, swap_bytes)
12010 }
glx_get_tex_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexParameterfvReply>, ConnectionError>12011 fn glx_get_tex_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexParameterfvReply>, ConnectionError>
12012 {
12013 get_tex_parameterfv(self, context_tag, target, pname)
12014 }
glx_get_tex_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexParameterivReply>, ConnectionError>12015 fn glx_get_tex_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetTexParameterivReply>, ConnectionError>
12016 {
12017 get_tex_parameteriv(self, context_tag, target, pname)
12018 }
glx_get_tex_level_parameterfv(&self, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Self, GetTexLevelParameterfvReply>, ConnectionError>12019 fn glx_get_tex_level_parameterfv(&self, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Self, GetTexLevelParameterfvReply>, ConnectionError>
12020 {
12021 get_tex_level_parameterfv(self, context_tag, target, level, pname)
12022 }
glx_get_tex_level_parameteriv(&self, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Self, GetTexLevelParameterivReply>, ConnectionError>12023 fn glx_get_tex_level_parameteriv(&self, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result<Cookie<'_, Self, GetTexLevelParameterivReply>, ConnectionError>
12024 {
12025 get_tex_level_parameteriv(self, context_tag, target, level, pname)
12026 }
glx_is_enabled(&self, context_tag: ContextTag, capability: u32) -> Result<Cookie<'_, Self, IsEnabledReply>, ConnectionError>12027 fn glx_is_enabled(&self, context_tag: ContextTag, capability: u32) -> Result<Cookie<'_, Self, IsEnabledReply>, ConnectionError>
12028 {
12029 is_enabled(self, context_tag, capability)
12030 }
glx_is_list(&self, context_tag: ContextTag, list: u32) -> Result<Cookie<'_, Self, IsListReply>, ConnectionError>12031 fn glx_is_list(&self, context_tag: ContextTag, list: u32) -> Result<Cookie<'_, Self, IsListReply>, ConnectionError>
12032 {
12033 is_list(self, context_tag, list)
12034 }
glx_flush(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>12035 fn glx_flush(&self, context_tag: ContextTag) -> Result<VoidCookie<'_, Self>, ConnectionError>
12036 {
12037 flush(self, context_tag)
12038 }
glx_are_textures_resident<'c, 'input>(&'c self, context_tag: ContextTag, textures: &'input [u32]) -> Result<Cookie<'c, Self, AreTexturesResidentReply>, ConnectionError>12039 fn glx_are_textures_resident<'c, 'input>(&'c self, context_tag: ContextTag, textures: &'input [u32]) -> Result<Cookie<'c, Self, AreTexturesResidentReply>, ConnectionError>
12040 {
12041 are_textures_resident(self, context_tag, textures)
12042 }
glx_delete_textures<'c, 'input>(&'c self, context_tag: ContextTag, textures: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>12043 fn glx_delete_textures<'c, 'input>(&'c self, context_tag: ContextTag, textures: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
12044 {
12045 delete_textures(self, context_tag, textures)
12046 }
glx_gen_textures(&self, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Self, GenTexturesReply>, ConnectionError>12047 fn glx_gen_textures(&self, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Self, GenTexturesReply>, ConnectionError>
12048 {
12049 gen_textures(self, context_tag, n)
12050 }
glx_is_texture(&self, context_tag: ContextTag, texture: u32) -> Result<Cookie<'_, Self, IsTextureReply>, ConnectionError>12051 fn glx_is_texture(&self, context_tag: ContextTag, texture: u32) -> Result<Cookie<'_, Self, IsTextureReply>, ConnectionError>
12052 {
12053 is_texture(self, context_tag, texture)
12054 }
glx_get_color_table(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetColorTableReply>, ConnectionError>12055 fn glx_get_color_table(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetColorTableReply>, ConnectionError>
12056 {
12057 get_color_table(self, context_tag, target, format, type_, swap_bytes)
12058 }
glx_get_color_table_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetColorTableParameterfvReply>, ConnectionError>12059 fn glx_get_color_table_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetColorTableParameterfvReply>, ConnectionError>
12060 {
12061 get_color_table_parameterfv(self, context_tag, target, pname)
12062 }
glx_get_color_table_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetColorTableParameterivReply>, ConnectionError>12063 fn glx_get_color_table_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetColorTableParameterivReply>, ConnectionError>
12064 {
12065 get_color_table_parameteriv(self, context_tag, target, pname)
12066 }
glx_get_convolution_filter(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetConvolutionFilterReply>, ConnectionError>12067 fn glx_get_convolution_filter(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetConvolutionFilterReply>, ConnectionError>
12068 {
12069 get_convolution_filter(self, context_tag, target, format, type_, swap_bytes)
12070 }
glx_get_convolution_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetConvolutionParameterfvReply>, ConnectionError>12071 fn glx_get_convolution_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetConvolutionParameterfvReply>, ConnectionError>
12072 {
12073 get_convolution_parameterfv(self, context_tag, target, pname)
12074 }
glx_get_convolution_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetConvolutionParameterivReply>, ConnectionError>12075 fn glx_get_convolution_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetConvolutionParameterivReply>, ConnectionError>
12076 {
12077 get_convolution_parameteriv(self, context_tag, target, pname)
12078 }
glx_get_separable_filter(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetSeparableFilterReply>, ConnectionError>12079 fn glx_get_separable_filter(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result<Cookie<'_, Self, GetSeparableFilterReply>, ConnectionError>
12080 {
12081 get_separable_filter(self, context_tag, target, format, type_, swap_bytes)
12082 }
glx_get_histogram(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Self, GetHistogramReply>, ConnectionError>12083 fn glx_get_histogram(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Self, GetHistogramReply>, ConnectionError>
12084 {
12085 get_histogram(self, context_tag, target, format, type_, swap_bytes, reset)
12086 }
glx_get_histogram_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetHistogramParameterfvReply>, ConnectionError>12087 fn glx_get_histogram_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetHistogramParameterfvReply>, ConnectionError>
12088 {
12089 get_histogram_parameterfv(self, context_tag, target, pname)
12090 }
glx_get_histogram_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetHistogramParameterivReply>, ConnectionError>12091 fn glx_get_histogram_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetHistogramParameterivReply>, ConnectionError>
12092 {
12093 get_histogram_parameteriv(self, context_tag, target, pname)
12094 }
glx_get_minmax(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Self, GetMinmaxReply>, ConnectionError>12095 fn glx_get_minmax(&self, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result<Cookie<'_, Self, GetMinmaxReply>, ConnectionError>
12096 {
12097 get_minmax(self, context_tag, target, format, type_, swap_bytes, reset)
12098 }
glx_get_minmax_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetMinmaxParameterfvReply>, ConnectionError>12099 fn glx_get_minmax_parameterfv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetMinmaxParameterfvReply>, ConnectionError>
12100 {
12101 get_minmax_parameterfv(self, context_tag, target, pname)
12102 }
glx_get_minmax_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetMinmaxParameterivReply>, ConnectionError>12103 fn glx_get_minmax_parameteriv(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetMinmaxParameterivReply>, ConnectionError>
12104 {
12105 get_minmax_parameteriv(self, context_tag, target, pname)
12106 }
glx_get_compressed_tex_image_arb(&self, context_tag: ContextTag, target: u32, level: i32) -> Result<Cookie<'_, Self, GetCompressedTexImageARBReply>, ConnectionError>12107 fn glx_get_compressed_tex_image_arb(&self, context_tag: ContextTag, target: u32, level: i32) -> Result<Cookie<'_, Self, GetCompressedTexImageARBReply>, ConnectionError>
12108 {
12109 get_compressed_tex_image_arb(self, context_tag, target, level)
12110 }
glx_delete_queries_arb<'c, 'input>(&'c self, context_tag: ContextTag, ids: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>12111 fn glx_delete_queries_arb<'c, 'input>(&'c self, context_tag: ContextTag, ids: &'input [u32]) -> Result<VoidCookie<'c, Self>, ConnectionError>
12112 {
12113 delete_queries_arb(self, context_tag, ids)
12114 }
glx_gen_queries_arb(&self, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Self, GenQueriesARBReply>, ConnectionError>12115 fn glx_gen_queries_arb(&self, context_tag: ContextTag, n: i32) -> Result<Cookie<'_, Self, GenQueriesARBReply>, ConnectionError>
12116 {
12117 gen_queries_arb(self, context_tag, n)
12118 }
glx_is_query_arb(&self, context_tag: ContextTag, id: u32) -> Result<Cookie<'_, Self, IsQueryARBReply>, ConnectionError>12119 fn glx_is_query_arb(&self, context_tag: ContextTag, id: u32) -> Result<Cookie<'_, Self, IsQueryARBReply>, ConnectionError>
12120 {
12121 is_query_arb(self, context_tag, id)
12122 }
glx_get_queryiv_arb(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetQueryivARBReply>, ConnectionError>12123 fn glx_get_queryiv_arb(&self, context_tag: ContextTag, target: u32, pname: u32) -> Result<Cookie<'_, Self, GetQueryivARBReply>, ConnectionError>
12124 {
12125 get_queryiv_arb(self, context_tag, target, pname)
12126 }
glx_get_query_objectiv_arb(&self, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Self, GetQueryObjectivARBReply>, ConnectionError>12127 fn glx_get_query_objectiv_arb(&self, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Self, GetQueryObjectivARBReply>, ConnectionError>
12128 {
12129 get_query_objectiv_arb(self, context_tag, id, pname)
12130 }
glx_get_query_objectuiv_arb(&self, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Self, GetQueryObjectuivARBReply>, ConnectionError>12131 fn glx_get_query_objectuiv_arb(&self, context_tag: ContextTag, id: u32, pname: u32) -> Result<Cookie<'_, Self, GetQueryObjectuivARBReply>, ConnectionError>
12132 {
12133 get_query_objectuiv_arb(self, context_tag, id, pname)
12134 }
12135 }
12136
12137 impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
12138