1 // This file contains generated code. Do not edit directly.
2 // To regenerate this, run 'make'.
3
4 //! Bindings to the `Xv` 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::shm;
23 use super::xproto;
24
25 /// The X11 name of the extension for QueryExtension
26 pub const X11_EXTENSION_NAME: &str = "XVideo";
27
28 /// The version number of this extension that this client library supports.
29 ///
30 /// This constant contains the version number of this extension that is supported
31 /// by this build of x11rb. For most things, it does not make sense to use this
32 /// information. If you need to send a `QueryVersion`, it is recommended to instead
33 /// send the maximum version of the extension that you need.
34 pub const X11_XML_VERSION: (u32, u32) = (2, 2);
35
36 pub type Port = u32;
37
38 pub type Encoding = u32;
39
40 #[derive(Clone, Copy, PartialEq, Eq)]
41 pub struct Type(u8);
42 impl Type {
43 pub const INPUT_MASK: Self = Self(1 << 0);
44 pub const OUTPUT_MASK: Self = Self(1 << 1);
45 pub const VIDEO_MASK: Self = Self(1 << 2);
46 pub const STILL_MASK: Self = Self(1 << 3);
47 pub const IMAGE_MASK: Self = Self(1 << 4);
48 }
49 impl From<Type> for u8 {
50 #[inline]
from(input: Type) -> Self51 fn from(input: Type) -> Self {
52 input.0
53 }
54 }
55 impl From<Type> for Option<u8> {
56 #[inline]
from(input: Type) -> Self57 fn from(input: Type) -> Self {
58 Some(input.0)
59 }
60 }
61 impl From<Type> for u16 {
62 #[inline]
from(input: Type) -> Self63 fn from(input: Type) -> Self {
64 u16::from(input.0)
65 }
66 }
67 impl From<Type> for Option<u16> {
68 #[inline]
from(input: Type) -> Self69 fn from(input: Type) -> Self {
70 Some(u16::from(input.0))
71 }
72 }
73 impl From<Type> for u32 {
74 #[inline]
from(input: Type) -> Self75 fn from(input: Type) -> Self {
76 u32::from(input.0)
77 }
78 }
79 impl From<Type> for Option<u32> {
80 #[inline]
from(input: Type) -> Self81 fn from(input: Type) -> Self {
82 Some(u32::from(input.0))
83 }
84 }
85 impl From<u8> for Type {
86 #[inline]
from(value: u8) -> Self87 fn from(value: u8) -> Self {
88 Self(value)
89 }
90 }
91 impl std::fmt::Debug for Type {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result92 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
93 let variants = [
94 (Self::INPUT_MASK.0.into(), "INPUT_MASK", "InputMask"),
95 (Self::OUTPUT_MASK.0.into(), "OUTPUT_MASK", "OutputMask"),
96 (Self::VIDEO_MASK.0.into(), "VIDEO_MASK", "VideoMask"),
97 (Self::STILL_MASK.0.into(), "STILL_MASK", "StillMask"),
98 (Self::IMAGE_MASK.0.into(), "IMAGE_MASK", "ImageMask"),
99 ];
100 pretty_print_bitmask(fmt, self.0.into(), &variants)
101 }
102 }
103 bitmask_binop!(Type, u8);
104
105 #[derive(Clone, Copy, PartialEq, Eq)]
106 pub struct ImageFormatInfoType(u8);
107 impl ImageFormatInfoType {
108 pub const RGB: Self = Self(0);
109 pub const YUV: Self = Self(1);
110 }
111 impl From<ImageFormatInfoType> for u8 {
112 #[inline]
from(input: ImageFormatInfoType) -> Self113 fn from(input: ImageFormatInfoType) -> Self {
114 input.0
115 }
116 }
117 impl From<ImageFormatInfoType> for Option<u8> {
118 #[inline]
from(input: ImageFormatInfoType) -> Self119 fn from(input: ImageFormatInfoType) -> Self {
120 Some(input.0)
121 }
122 }
123 impl From<ImageFormatInfoType> for u16 {
124 #[inline]
from(input: ImageFormatInfoType) -> Self125 fn from(input: ImageFormatInfoType) -> Self {
126 u16::from(input.0)
127 }
128 }
129 impl From<ImageFormatInfoType> for Option<u16> {
130 #[inline]
from(input: ImageFormatInfoType) -> Self131 fn from(input: ImageFormatInfoType) -> Self {
132 Some(u16::from(input.0))
133 }
134 }
135 impl From<ImageFormatInfoType> for u32 {
136 #[inline]
from(input: ImageFormatInfoType) -> Self137 fn from(input: ImageFormatInfoType) -> Self {
138 u32::from(input.0)
139 }
140 }
141 impl From<ImageFormatInfoType> for Option<u32> {
142 #[inline]
from(input: ImageFormatInfoType) -> Self143 fn from(input: ImageFormatInfoType) -> Self {
144 Some(u32::from(input.0))
145 }
146 }
147 impl From<u8> for ImageFormatInfoType {
148 #[inline]
from(value: u8) -> Self149 fn from(value: u8) -> Self {
150 Self(value)
151 }
152 }
153 impl std::fmt::Debug for ImageFormatInfoType {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result154 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
155 let variants = [
156 (Self::RGB.0.into(), "RGB", "RGB"),
157 (Self::YUV.0.into(), "YUV", "YUV"),
158 ];
159 pretty_print_enum(fmt, self.0.into(), &variants)
160 }
161 }
162
163 #[derive(Clone, Copy, PartialEq, Eq)]
164 pub struct ImageFormatInfoFormat(u8);
165 impl ImageFormatInfoFormat {
166 pub const PACKED: Self = Self(0);
167 pub const PLANAR: Self = Self(1);
168 }
169 impl From<ImageFormatInfoFormat> for u8 {
170 #[inline]
from(input: ImageFormatInfoFormat) -> Self171 fn from(input: ImageFormatInfoFormat) -> Self {
172 input.0
173 }
174 }
175 impl From<ImageFormatInfoFormat> for Option<u8> {
176 #[inline]
from(input: ImageFormatInfoFormat) -> Self177 fn from(input: ImageFormatInfoFormat) -> Self {
178 Some(input.0)
179 }
180 }
181 impl From<ImageFormatInfoFormat> for u16 {
182 #[inline]
from(input: ImageFormatInfoFormat) -> Self183 fn from(input: ImageFormatInfoFormat) -> Self {
184 u16::from(input.0)
185 }
186 }
187 impl From<ImageFormatInfoFormat> for Option<u16> {
188 #[inline]
from(input: ImageFormatInfoFormat) -> Self189 fn from(input: ImageFormatInfoFormat) -> Self {
190 Some(u16::from(input.0))
191 }
192 }
193 impl From<ImageFormatInfoFormat> for u32 {
194 #[inline]
from(input: ImageFormatInfoFormat) -> Self195 fn from(input: ImageFormatInfoFormat) -> Self {
196 u32::from(input.0)
197 }
198 }
199 impl From<ImageFormatInfoFormat> for Option<u32> {
200 #[inline]
from(input: ImageFormatInfoFormat) -> Self201 fn from(input: ImageFormatInfoFormat) -> Self {
202 Some(u32::from(input.0))
203 }
204 }
205 impl From<u8> for ImageFormatInfoFormat {
206 #[inline]
from(value: u8) -> Self207 fn from(value: u8) -> Self {
208 Self(value)
209 }
210 }
211 impl std::fmt::Debug for ImageFormatInfoFormat {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result212 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
213 let variants = [
214 (Self::PACKED.0.into(), "PACKED", "Packed"),
215 (Self::PLANAR.0.into(), "PLANAR", "Planar"),
216 ];
217 pretty_print_enum(fmt, self.0.into(), &variants)
218 }
219 }
220
221 #[derive(Clone, Copy, PartialEq, Eq)]
222 pub struct AttributeFlag(u8);
223 impl AttributeFlag {
224 pub const GETTABLE: Self = Self(1 << 0);
225 pub const SETTABLE: Self = Self(1 << 1);
226 }
227 impl From<AttributeFlag> for u8 {
228 #[inline]
from(input: AttributeFlag) -> Self229 fn from(input: AttributeFlag) -> Self {
230 input.0
231 }
232 }
233 impl From<AttributeFlag> for Option<u8> {
234 #[inline]
from(input: AttributeFlag) -> Self235 fn from(input: AttributeFlag) -> Self {
236 Some(input.0)
237 }
238 }
239 impl From<AttributeFlag> for u16 {
240 #[inline]
from(input: AttributeFlag) -> Self241 fn from(input: AttributeFlag) -> Self {
242 u16::from(input.0)
243 }
244 }
245 impl From<AttributeFlag> for Option<u16> {
246 #[inline]
from(input: AttributeFlag) -> Self247 fn from(input: AttributeFlag) -> Self {
248 Some(u16::from(input.0))
249 }
250 }
251 impl From<AttributeFlag> for u32 {
252 #[inline]
from(input: AttributeFlag) -> Self253 fn from(input: AttributeFlag) -> Self {
254 u32::from(input.0)
255 }
256 }
257 impl From<AttributeFlag> for Option<u32> {
258 #[inline]
from(input: AttributeFlag) -> Self259 fn from(input: AttributeFlag) -> Self {
260 Some(u32::from(input.0))
261 }
262 }
263 impl From<u8> for AttributeFlag {
264 #[inline]
from(value: u8) -> Self265 fn from(value: u8) -> Self {
266 Self(value)
267 }
268 }
269 impl std::fmt::Debug for AttributeFlag {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result270 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
271 let variants = [
272 (Self::GETTABLE.0.into(), "GETTABLE", "Gettable"),
273 (Self::SETTABLE.0.into(), "SETTABLE", "Settable"),
274 ];
275 pretty_print_bitmask(fmt, self.0.into(), &variants)
276 }
277 }
278 bitmask_binop!(AttributeFlag, u8);
279
280 #[derive(Clone, Copy, PartialEq, Eq)]
281 pub struct VideoNotifyReason(u8);
282 impl VideoNotifyReason {
283 pub const STARTED: Self = Self(0);
284 pub const STOPPED: Self = Self(1);
285 pub const BUSY: Self = Self(2);
286 pub const PREEMPTED: Self = Self(3);
287 pub const HARD_ERROR: Self = Self(4);
288 }
289 impl From<VideoNotifyReason> for u8 {
290 #[inline]
from(input: VideoNotifyReason) -> Self291 fn from(input: VideoNotifyReason) -> Self {
292 input.0
293 }
294 }
295 impl From<VideoNotifyReason> for Option<u8> {
296 #[inline]
from(input: VideoNotifyReason) -> Self297 fn from(input: VideoNotifyReason) -> Self {
298 Some(input.0)
299 }
300 }
301 impl From<VideoNotifyReason> for u16 {
302 #[inline]
from(input: VideoNotifyReason) -> Self303 fn from(input: VideoNotifyReason) -> Self {
304 u16::from(input.0)
305 }
306 }
307 impl From<VideoNotifyReason> for Option<u16> {
308 #[inline]
from(input: VideoNotifyReason) -> Self309 fn from(input: VideoNotifyReason) -> Self {
310 Some(u16::from(input.0))
311 }
312 }
313 impl From<VideoNotifyReason> for u32 {
314 #[inline]
from(input: VideoNotifyReason) -> Self315 fn from(input: VideoNotifyReason) -> Self {
316 u32::from(input.0)
317 }
318 }
319 impl From<VideoNotifyReason> for Option<u32> {
320 #[inline]
from(input: VideoNotifyReason) -> Self321 fn from(input: VideoNotifyReason) -> Self {
322 Some(u32::from(input.0))
323 }
324 }
325 impl From<u8> for VideoNotifyReason {
326 #[inline]
from(value: u8) -> Self327 fn from(value: u8) -> Self {
328 Self(value)
329 }
330 }
331 impl std::fmt::Debug for VideoNotifyReason {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result332 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
333 let variants = [
334 (Self::STARTED.0.into(), "STARTED", "Started"),
335 (Self::STOPPED.0.into(), "STOPPED", "Stopped"),
336 (Self::BUSY.0.into(), "BUSY", "Busy"),
337 (Self::PREEMPTED.0.into(), "PREEMPTED", "Preempted"),
338 (Self::HARD_ERROR.0.into(), "HARD_ERROR", "HardError"),
339 ];
340 pretty_print_enum(fmt, self.0.into(), &variants)
341 }
342 }
343
344 #[derive(Clone, Copy, PartialEq, Eq)]
345 pub struct ScanlineOrder(u8);
346 impl ScanlineOrder {
347 pub const TOP_TO_BOTTOM: Self = Self(0);
348 pub const BOTTOM_TO_TOP: Self = Self(1);
349 }
350 impl From<ScanlineOrder> for u8 {
351 #[inline]
from(input: ScanlineOrder) -> Self352 fn from(input: ScanlineOrder) -> Self {
353 input.0
354 }
355 }
356 impl From<ScanlineOrder> for Option<u8> {
357 #[inline]
from(input: ScanlineOrder) -> Self358 fn from(input: ScanlineOrder) -> Self {
359 Some(input.0)
360 }
361 }
362 impl From<ScanlineOrder> for u16 {
363 #[inline]
from(input: ScanlineOrder) -> Self364 fn from(input: ScanlineOrder) -> Self {
365 u16::from(input.0)
366 }
367 }
368 impl From<ScanlineOrder> for Option<u16> {
369 #[inline]
from(input: ScanlineOrder) -> Self370 fn from(input: ScanlineOrder) -> Self {
371 Some(u16::from(input.0))
372 }
373 }
374 impl From<ScanlineOrder> for u32 {
375 #[inline]
from(input: ScanlineOrder) -> Self376 fn from(input: ScanlineOrder) -> Self {
377 u32::from(input.0)
378 }
379 }
380 impl From<ScanlineOrder> for Option<u32> {
381 #[inline]
from(input: ScanlineOrder) -> Self382 fn from(input: ScanlineOrder) -> Self {
383 Some(u32::from(input.0))
384 }
385 }
386 impl From<u8> for ScanlineOrder {
387 #[inline]
from(value: u8) -> Self388 fn from(value: u8) -> Self {
389 Self(value)
390 }
391 }
392 impl std::fmt::Debug for ScanlineOrder {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result393 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
394 let variants = [
395 (Self::TOP_TO_BOTTOM.0.into(), "TOP_TO_BOTTOM", "TopToBottom"),
396 (Self::BOTTOM_TO_TOP.0.into(), "BOTTOM_TO_TOP", "BottomToTop"),
397 ];
398 pretty_print_enum(fmt, self.0.into(), &variants)
399 }
400 }
401
402 #[derive(Clone, Copy, PartialEq, Eq)]
403 pub struct GrabPortStatus(u8);
404 impl GrabPortStatus {
405 pub const SUCCESS: Self = Self(0);
406 pub const BAD_EXTENSION: Self = Self(1);
407 pub const ALREADY_GRABBED: Self = Self(2);
408 pub const INVALID_TIME: Self = Self(3);
409 pub const BAD_REPLY: Self = Self(4);
410 pub const BAD_ALLOC: Self = Self(5);
411 }
412 impl From<GrabPortStatus> for u8 {
413 #[inline]
from(input: GrabPortStatus) -> Self414 fn from(input: GrabPortStatus) -> Self {
415 input.0
416 }
417 }
418 impl From<GrabPortStatus> for Option<u8> {
419 #[inline]
from(input: GrabPortStatus) -> Self420 fn from(input: GrabPortStatus) -> Self {
421 Some(input.0)
422 }
423 }
424 impl From<GrabPortStatus> for u16 {
425 #[inline]
from(input: GrabPortStatus) -> Self426 fn from(input: GrabPortStatus) -> Self {
427 u16::from(input.0)
428 }
429 }
430 impl From<GrabPortStatus> for Option<u16> {
431 #[inline]
from(input: GrabPortStatus) -> Self432 fn from(input: GrabPortStatus) -> Self {
433 Some(u16::from(input.0))
434 }
435 }
436 impl From<GrabPortStatus> for u32 {
437 #[inline]
from(input: GrabPortStatus) -> Self438 fn from(input: GrabPortStatus) -> Self {
439 u32::from(input.0)
440 }
441 }
442 impl From<GrabPortStatus> for Option<u32> {
443 #[inline]
from(input: GrabPortStatus) -> Self444 fn from(input: GrabPortStatus) -> Self {
445 Some(u32::from(input.0))
446 }
447 }
448 impl From<u8> for GrabPortStatus {
449 #[inline]
from(value: u8) -> Self450 fn from(value: u8) -> Self {
451 Self(value)
452 }
453 }
454 impl std::fmt::Debug for GrabPortStatus {
fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result455 fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
456 let variants = [
457 (Self::SUCCESS.0.into(), "SUCCESS", "Success"),
458 (Self::BAD_EXTENSION.0.into(), "BAD_EXTENSION", "BadExtension"),
459 (Self::ALREADY_GRABBED.0.into(), "ALREADY_GRABBED", "AlreadyGrabbed"),
460 (Self::INVALID_TIME.0.into(), "INVALID_TIME", "InvalidTime"),
461 (Self::BAD_REPLY.0.into(), "BAD_REPLY", "BadReply"),
462 (Self::BAD_ALLOC.0.into(), "BAD_ALLOC", "BadAlloc"),
463 ];
464 pretty_print_enum(fmt, self.0.into(), &variants)
465 }
466 }
467
468 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
469 pub struct Rational {
470 pub numerator: i32,
471 pub denominator: i32,
472 }
473 impl TryParse for Rational {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>474 fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
475 let (numerator, remaining) = i32::try_parse(remaining)?;
476 let (denominator, remaining) = i32::try_parse(remaining)?;
477 let result = Rational { numerator, denominator };
478 Ok((result, remaining))
479 }
480 }
481 impl Serialize for Rational {
482 type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]483 fn serialize(&self) -> [u8; 8] {
484 let numerator_bytes = self.numerator.serialize();
485 let denominator_bytes = self.denominator.serialize();
486 [
487 numerator_bytes[0],
488 numerator_bytes[1],
489 numerator_bytes[2],
490 numerator_bytes[3],
491 denominator_bytes[0],
492 denominator_bytes[1],
493 denominator_bytes[2],
494 denominator_bytes[3],
495 ]
496 }
serialize_into(&self, bytes: &mut Vec<u8>)497 fn serialize_into(&self, bytes: &mut Vec<u8>) {
498 bytes.reserve(8);
499 self.numerator.serialize_into(bytes);
500 self.denominator.serialize_into(bytes);
501 }
502 }
503
504 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
505 pub struct Format {
506 pub visual: xproto::Visualid,
507 pub depth: u8,
508 }
509 impl TryParse for Format {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>510 fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
511 let (visual, remaining) = xproto::Visualid::try_parse(remaining)?;
512 let (depth, remaining) = u8::try_parse(remaining)?;
513 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
514 let result = Format { visual, depth };
515 Ok((result, remaining))
516 }
517 }
518 impl Serialize for Format {
519 type Bytes = [u8; 8];
serialize(&self) -> [u8; 8]520 fn serialize(&self) -> [u8; 8] {
521 let visual_bytes = self.visual.serialize();
522 let depth_bytes = self.depth.serialize();
523 [
524 visual_bytes[0],
525 visual_bytes[1],
526 visual_bytes[2],
527 visual_bytes[3],
528 depth_bytes[0],
529 0,
530 0,
531 0,
532 ]
533 }
serialize_into(&self, bytes: &mut Vec<u8>)534 fn serialize_into(&self, bytes: &mut Vec<u8>) {
535 bytes.reserve(8);
536 self.visual.serialize_into(bytes);
537 self.depth.serialize_into(bytes);
538 bytes.extend_from_slice(&[0; 3]);
539 }
540 }
541
542 #[derive(Debug, Clone, PartialEq, Eq)]
543 pub struct AdaptorInfo {
544 pub base_id: Port,
545 pub num_ports: u16,
546 pub type_: u8,
547 pub name: Vec<u8>,
548 pub formats: Vec<Format>,
549 }
550 impl TryParse for AdaptorInfo {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>551 fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
552 let value = remaining;
553 let (base_id, remaining) = Port::try_parse(remaining)?;
554 let (name_size, remaining) = u16::try_parse(remaining)?;
555 let (num_ports, remaining) = u16::try_parse(remaining)?;
556 let (num_formats, remaining) = u16::try_parse(remaining)?;
557 let (type_, remaining) = u8::try_parse(remaining)?;
558 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
559 let (name, remaining) = crate::x11_utils::parse_u8_list(remaining, name_size.try_to_usize()?)?;
560 let name = name.to_vec();
561 // Align offset to multiple of 4
562 let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
563 let misalignment = (4 - (offset % 4)) % 4;
564 let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
565 let (formats, remaining) = crate::x11_utils::parse_list::<Format>(remaining, num_formats.try_to_usize()?)?;
566 let result = AdaptorInfo { base_id, num_ports, type_, name, formats };
567 Ok((result, remaining))
568 }
569 }
570 impl Serialize for AdaptorInfo {
571 type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>572 fn serialize(&self) -> Vec<u8> {
573 let mut result = Vec::new();
574 self.serialize_into(&mut result);
575 result
576 }
serialize_into(&self, bytes: &mut Vec<u8>)577 fn serialize_into(&self, bytes: &mut Vec<u8>) {
578 bytes.reserve(12);
579 self.base_id.serialize_into(bytes);
580 let name_size = u16::try_from(self.name.len()).expect("`name` has too many elements");
581 name_size.serialize_into(bytes);
582 self.num_ports.serialize_into(bytes);
583 let num_formats = u16::try_from(self.formats.len()).expect("`formats` has too many elements");
584 num_formats.serialize_into(bytes);
585 self.type_.serialize_into(bytes);
586 bytes.extend_from_slice(&[0; 1]);
587 bytes.extend_from_slice(&self.name);
588 bytes.extend_from_slice(&[0; 3][..(4 - (bytes.len() % 4)) % 4]);
589 self.formats.serialize_into(bytes);
590 }
591 }
592 impl AdaptorInfo {
593 /// Get the value of the `name_size` field.
594 ///
595 /// The `name_size` field is used as the length field of the `name` field.
596 /// This function computes the field's value again based on the length of the list.
597 ///
598 /// # Panics
599 ///
600 /// Panics if the value cannot be represented in the target type. This
601 /// cannot happen with values of the struct received from the X11 server.
name_size(&self) -> u16602 pub fn name_size(&self) -> u16 {
603 self.name.len()
604 .try_into().unwrap()
605 }
606 /// Get the value of the `num_formats` field.
607 ///
608 /// The `num_formats` field is used as the length field of the `formats` field.
609 /// This function computes the field's value again based on the length of the list.
610 ///
611 /// # Panics
612 ///
613 /// Panics if the value cannot be represented in the target type. This
614 /// cannot happen with values of the struct received from the X11 server.
num_formats(&self) -> u16615 pub fn num_formats(&self) -> u16 {
616 self.formats.len()
617 .try_into().unwrap()
618 }
619 }
620
621 #[derive(Debug, Clone, PartialEq, Eq)]
622 pub struct EncodingInfo {
623 pub encoding: Encoding,
624 pub width: u16,
625 pub height: u16,
626 pub rate: Rational,
627 pub name: Vec<u8>,
628 }
629 impl TryParse for EncodingInfo {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>630 fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
631 let value = remaining;
632 let (encoding, remaining) = Encoding::try_parse(remaining)?;
633 let (name_size, remaining) = u16::try_parse(remaining)?;
634 let (width, remaining) = u16::try_parse(remaining)?;
635 let (height, remaining) = u16::try_parse(remaining)?;
636 let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
637 let (rate, remaining) = Rational::try_parse(remaining)?;
638 let (name, remaining) = crate::x11_utils::parse_u8_list(remaining, name_size.try_to_usize()?)?;
639 let name = name.to_vec();
640 // Align offset to multiple of 4
641 let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
642 let misalignment = (4 - (offset % 4)) % 4;
643 let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
644 let result = EncodingInfo { encoding, width, height, rate, name };
645 Ok((result, remaining))
646 }
647 }
648 impl Serialize for EncodingInfo {
649 type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>650 fn serialize(&self) -> Vec<u8> {
651 let mut result = Vec::new();
652 self.serialize_into(&mut result);
653 result
654 }
serialize_into(&self, bytes: &mut Vec<u8>)655 fn serialize_into(&self, bytes: &mut Vec<u8>) {
656 bytes.reserve(20);
657 self.encoding.serialize_into(bytes);
658 let name_size = u16::try_from(self.name.len()).expect("`name` has too many elements");
659 name_size.serialize_into(bytes);
660 self.width.serialize_into(bytes);
661 self.height.serialize_into(bytes);
662 bytes.extend_from_slice(&[0; 2]);
663 self.rate.serialize_into(bytes);
664 bytes.extend_from_slice(&self.name);
665 bytes.extend_from_slice(&[0; 3][..(4 - (bytes.len() % 4)) % 4]);
666 }
667 }
668 impl EncodingInfo {
669 /// Get the value of the `name_size` field.
670 ///
671 /// The `name_size` field is used as the length field of the `name` field.
672 /// This function computes the field's value again based on the length of the list.
673 ///
674 /// # Panics
675 ///
676 /// Panics if the value cannot be represented in the target type. This
677 /// cannot happen with values of the struct received from the X11 server.
name_size(&self) -> u16678 pub fn name_size(&self) -> u16 {
679 self.name.len()
680 .try_into().unwrap()
681 }
682 }
683
684 #[derive(Debug, Clone, PartialEq, Eq)]
685 pub struct Image {
686 pub id: u32,
687 pub width: u16,
688 pub height: u16,
689 pub pitches: Vec<u32>,
690 pub offsets: Vec<u32>,
691 pub data: Vec<u8>,
692 }
693 impl TryParse for Image {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>694 fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
695 let (id, remaining) = u32::try_parse(remaining)?;
696 let (width, remaining) = u16::try_parse(remaining)?;
697 let (height, remaining) = u16::try_parse(remaining)?;
698 let (data_size, remaining) = u32::try_parse(remaining)?;
699 let (num_planes, remaining) = u32::try_parse(remaining)?;
700 let (pitches, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_planes.try_to_usize()?)?;
701 let (offsets, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_planes.try_to_usize()?)?;
702 let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, data_size.try_to_usize()?)?;
703 let data = data.to_vec();
704 let result = Image { id, width, height, pitches, offsets, data };
705 Ok((result, remaining))
706 }
707 }
708 impl Serialize for Image {
709 type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>710 fn serialize(&self) -> Vec<u8> {
711 let mut result = Vec::new();
712 self.serialize_into(&mut result);
713 result
714 }
serialize_into(&self, bytes: &mut Vec<u8>)715 fn serialize_into(&self, bytes: &mut Vec<u8>) {
716 bytes.reserve(16);
717 self.id.serialize_into(bytes);
718 self.width.serialize_into(bytes);
719 self.height.serialize_into(bytes);
720 let data_size = u32::try_from(self.data.len()).expect("`data` has too many elements");
721 data_size.serialize_into(bytes);
722 let num_planes = u32::try_from(self.pitches.len()).expect("`pitches` has too many elements");
723 num_planes.serialize_into(bytes);
724 self.pitches.serialize_into(bytes);
725 assert_eq!(self.offsets.len(), usize::try_from(num_planes).unwrap(), "`offsets` has an incorrect length");
726 self.offsets.serialize_into(bytes);
727 bytes.extend_from_slice(&self.data);
728 }
729 }
730 impl Image {
731 /// Get the value of the `data_size` field.
732 ///
733 /// The `data_size` field is used as the length field of the `data` field.
734 /// This function computes the field's value again based on the length of the list.
735 ///
736 /// # Panics
737 ///
738 /// Panics if the value cannot be represented in the target type. This
739 /// cannot happen with values of the struct received from the X11 server.
data_size(&self) -> u32740 pub fn data_size(&self) -> u32 {
741 self.data.len()
742 .try_into().unwrap()
743 }
744 /// Get the value of the `num_planes` field.
745 ///
746 /// The `num_planes` field is used as the length field of the `pitches` field.
747 /// This function computes the field's value again based on the length of the list.
748 ///
749 /// # Panics
750 ///
751 /// Panics if the value cannot be represented in the target type. This
752 /// cannot happen with values of the struct received from the X11 server.
num_planes(&self) -> u32753 pub fn num_planes(&self) -> u32 {
754 self.pitches.len()
755 .try_into().unwrap()
756 }
757 }
758
759 #[derive(Debug, Clone, PartialEq, Eq)]
760 pub struct AttributeInfo {
761 pub flags: u32,
762 pub min: i32,
763 pub max: i32,
764 pub name: Vec<u8>,
765 }
766 impl TryParse for AttributeInfo {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>767 fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
768 let value = remaining;
769 let (flags, remaining) = u32::try_parse(remaining)?;
770 let (min, remaining) = i32::try_parse(remaining)?;
771 let (max, remaining) = i32::try_parse(remaining)?;
772 let (size, remaining) = u32::try_parse(remaining)?;
773 let (name, remaining) = crate::x11_utils::parse_u8_list(remaining, size.try_to_usize()?)?;
774 let name = name.to_vec();
775 // Align offset to multiple of 4
776 let offset = remaining.as_ptr() as usize - value.as_ptr() as usize;
777 let misalignment = (4 - (offset % 4)) % 4;
778 let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?;
779 let result = AttributeInfo { flags, min, max, name };
780 Ok((result, remaining))
781 }
782 }
783 impl Serialize for AttributeInfo {
784 type Bytes = Vec<u8>;
serialize(&self) -> Vec<u8>785 fn serialize(&self) -> Vec<u8> {
786 let mut result = Vec::new();
787 self.serialize_into(&mut result);
788 result
789 }
serialize_into(&self, bytes: &mut Vec<u8>)790 fn serialize_into(&self, bytes: &mut Vec<u8>) {
791 bytes.reserve(16);
792 self.flags.serialize_into(bytes);
793 self.min.serialize_into(bytes);
794 self.max.serialize_into(bytes);
795 let size = u32::try_from(self.name.len()).expect("`name` has too many elements");
796 size.serialize_into(bytes);
797 bytes.extend_from_slice(&self.name);
798 bytes.extend_from_slice(&[0; 3][..(4 - (bytes.len() % 4)) % 4]);
799 }
800 }
801 impl AttributeInfo {
802 /// Get the value of the `size` field.
803 ///
804 /// The `size` field is used as the length field of the `name` field.
805 /// This function computes the field's value again based on the length of the list.
806 ///
807 /// # Panics
808 ///
809 /// Panics if the value cannot be represented in the target type. This
810 /// cannot happen with values of the struct received from the X11 server.
size(&self) -> u32811 pub fn size(&self) -> u32 {
812 self.name.len()
813 .try_into().unwrap()
814 }
815 }
816
817 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
818 pub struct ImageFormatInfo {
819 pub id: u32,
820 pub type_: ImageFormatInfoType,
821 pub byte_order: xproto::ImageOrder,
822 pub guid: [u8; 16],
823 pub bpp: u8,
824 pub num_planes: u8,
825 pub depth: u8,
826 pub red_mask: u32,
827 pub green_mask: u32,
828 pub blue_mask: u32,
829 pub format: ImageFormatInfoFormat,
830 pub y_sample_bits: u32,
831 pub u_sample_bits: u32,
832 pub v_sample_bits: u32,
833 pub vhorz_y_period: u32,
834 pub vhorz_u_period: u32,
835 pub vhorz_v_period: u32,
836 pub vvert_y_period: u32,
837 pub vvert_u_period: u32,
838 pub vvert_v_period: u32,
839 pub vcomp_order: [u8; 32],
840 pub vscanline_order: ScanlineOrder,
841 }
842 impl TryParse for ImageFormatInfo {
try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError>843 fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> {
844 let (id, remaining) = u32::try_parse(remaining)?;
845 let (type_, remaining) = u8::try_parse(remaining)?;
846 let (byte_order, remaining) = u8::try_parse(remaining)?;
847 let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
848 let (guid, remaining) = crate::x11_utils::parse_u8_list(remaining, 16)?;
849 let guid = <[u8; 16]>::try_from(guid).unwrap();
850 let (bpp, remaining) = u8::try_parse(remaining)?;
851 let (num_planes, remaining) = u8::try_parse(remaining)?;
852 let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?;
853 let (depth, remaining) = u8::try_parse(remaining)?;
854 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
855 let (red_mask, remaining) = u32::try_parse(remaining)?;
856 let (green_mask, remaining) = u32::try_parse(remaining)?;
857 let (blue_mask, remaining) = u32::try_parse(remaining)?;
858 let (format, remaining) = u8::try_parse(remaining)?;
859 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
860 let (y_sample_bits, remaining) = u32::try_parse(remaining)?;
861 let (u_sample_bits, remaining) = u32::try_parse(remaining)?;
862 let (v_sample_bits, remaining) = u32::try_parse(remaining)?;
863 let (vhorz_y_period, remaining) = u32::try_parse(remaining)?;
864 let (vhorz_u_period, remaining) = u32::try_parse(remaining)?;
865 let (vhorz_v_period, remaining) = u32::try_parse(remaining)?;
866 let (vvert_y_period, remaining) = u32::try_parse(remaining)?;
867 let (vvert_u_period, remaining) = u32::try_parse(remaining)?;
868 let (vvert_v_period, remaining) = u32::try_parse(remaining)?;
869 let (vcomp_order, remaining) = crate::x11_utils::parse_u8_list(remaining, 32)?;
870 let vcomp_order = <[u8; 32]>::try_from(vcomp_order).unwrap();
871 let (vscanline_order, remaining) = u8::try_parse(remaining)?;
872 let remaining = remaining.get(11..).ok_or(ParseError::InsufficientData)?;
873 let type_ = type_.into();
874 let byte_order = byte_order.into();
875 let format = format.into();
876 let vscanline_order = vscanline_order.into();
877 let result = ImageFormatInfo { id, type_, byte_order, guid, bpp, num_planes, depth, red_mask, green_mask, blue_mask, format, y_sample_bits, u_sample_bits, v_sample_bits, vhorz_y_period, vhorz_u_period, vhorz_v_period, vvert_y_period, vvert_u_period, vvert_v_period, vcomp_order, vscanline_order };
878 Ok((result, remaining))
879 }
880 }
881 impl Serialize for ImageFormatInfo {
882 type Bytes = [u8; 128];
serialize(&self) -> [u8; 128]883 fn serialize(&self) -> [u8; 128] {
884 let id_bytes = self.id.serialize();
885 let type_bytes = u8::from(self.type_).serialize();
886 let byte_order_bytes = u8::from(self.byte_order).serialize();
887 let bpp_bytes = self.bpp.serialize();
888 let num_planes_bytes = self.num_planes.serialize();
889 let depth_bytes = self.depth.serialize();
890 let red_mask_bytes = self.red_mask.serialize();
891 let green_mask_bytes = self.green_mask.serialize();
892 let blue_mask_bytes = self.blue_mask.serialize();
893 let format_bytes = u8::from(self.format).serialize();
894 let y_sample_bits_bytes = self.y_sample_bits.serialize();
895 let u_sample_bits_bytes = self.u_sample_bits.serialize();
896 let v_sample_bits_bytes = self.v_sample_bits.serialize();
897 let vhorz_y_period_bytes = self.vhorz_y_period.serialize();
898 let vhorz_u_period_bytes = self.vhorz_u_period.serialize();
899 let vhorz_v_period_bytes = self.vhorz_v_period.serialize();
900 let vvert_y_period_bytes = self.vvert_y_period.serialize();
901 let vvert_u_period_bytes = self.vvert_u_period.serialize();
902 let vvert_v_period_bytes = self.vvert_v_period.serialize();
903 let vscanline_order_bytes = u8::from(self.vscanline_order).serialize();
904 [
905 id_bytes[0],
906 id_bytes[1],
907 id_bytes[2],
908 id_bytes[3],
909 type_bytes[0],
910 byte_order_bytes[0],
911 0,
912 0,
913 self.guid[0],
914 self.guid[1],
915 self.guid[2],
916 self.guid[3],
917 self.guid[4],
918 self.guid[5],
919 self.guid[6],
920 self.guid[7],
921 self.guid[8],
922 self.guid[9],
923 self.guid[10],
924 self.guid[11],
925 self.guid[12],
926 self.guid[13],
927 self.guid[14],
928 self.guid[15],
929 bpp_bytes[0],
930 num_planes_bytes[0],
931 0,
932 0,
933 depth_bytes[0],
934 0,
935 0,
936 0,
937 red_mask_bytes[0],
938 red_mask_bytes[1],
939 red_mask_bytes[2],
940 red_mask_bytes[3],
941 green_mask_bytes[0],
942 green_mask_bytes[1],
943 green_mask_bytes[2],
944 green_mask_bytes[3],
945 blue_mask_bytes[0],
946 blue_mask_bytes[1],
947 blue_mask_bytes[2],
948 blue_mask_bytes[3],
949 format_bytes[0],
950 0,
951 0,
952 0,
953 y_sample_bits_bytes[0],
954 y_sample_bits_bytes[1],
955 y_sample_bits_bytes[2],
956 y_sample_bits_bytes[3],
957 u_sample_bits_bytes[0],
958 u_sample_bits_bytes[1],
959 u_sample_bits_bytes[2],
960 u_sample_bits_bytes[3],
961 v_sample_bits_bytes[0],
962 v_sample_bits_bytes[1],
963 v_sample_bits_bytes[2],
964 v_sample_bits_bytes[3],
965 vhorz_y_period_bytes[0],
966 vhorz_y_period_bytes[1],
967 vhorz_y_period_bytes[2],
968 vhorz_y_period_bytes[3],
969 vhorz_u_period_bytes[0],
970 vhorz_u_period_bytes[1],
971 vhorz_u_period_bytes[2],
972 vhorz_u_period_bytes[3],
973 vhorz_v_period_bytes[0],
974 vhorz_v_period_bytes[1],
975 vhorz_v_period_bytes[2],
976 vhorz_v_period_bytes[3],
977 vvert_y_period_bytes[0],
978 vvert_y_period_bytes[1],
979 vvert_y_period_bytes[2],
980 vvert_y_period_bytes[3],
981 vvert_u_period_bytes[0],
982 vvert_u_period_bytes[1],
983 vvert_u_period_bytes[2],
984 vvert_u_period_bytes[3],
985 vvert_v_period_bytes[0],
986 vvert_v_period_bytes[1],
987 vvert_v_period_bytes[2],
988 vvert_v_period_bytes[3],
989 self.vcomp_order[0],
990 self.vcomp_order[1],
991 self.vcomp_order[2],
992 self.vcomp_order[3],
993 self.vcomp_order[4],
994 self.vcomp_order[5],
995 self.vcomp_order[6],
996 self.vcomp_order[7],
997 self.vcomp_order[8],
998 self.vcomp_order[9],
999 self.vcomp_order[10],
1000 self.vcomp_order[11],
1001 self.vcomp_order[12],
1002 self.vcomp_order[13],
1003 self.vcomp_order[14],
1004 self.vcomp_order[15],
1005 self.vcomp_order[16],
1006 self.vcomp_order[17],
1007 self.vcomp_order[18],
1008 self.vcomp_order[19],
1009 self.vcomp_order[20],
1010 self.vcomp_order[21],
1011 self.vcomp_order[22],
1012 self.vcomp_order[23],
1013 self.vcomp_order[24],
1014 self.vcomp_order[25],
1015 self.vcomp_order[26],
1016 self.vcomp_order[27],
1017 self.vcomp_order[28],
1018 self.vcomp_order[29],
1019 self.vcomp_order[30],
1020 self.vcomp_order[31],
1021 vscanline_order_bytes[0],
1022 0,
1023 0,
1024 0,
1025 0,
1026 0,
1027 0,
1028 0,
1029 0,
1030 0,
1031 0,
1032 0,
1033 ]
1034 }
serialize_into(&self, bytes: &mut Vec<u8>)1035 fn serialize_into(&self, bytes: &mut Vec<u8>) {
1036 bytes.reserve(128);
1037 self.id.serialize_into(bytes);
1038 u8::from(self.type_).serialize_into(bytes);
1039 u8::from(self.byte_order).serialize_into(bytes);
1040 bytes.extend_from_slice(&[0; 2]);
1041 bytes.extend_from_slice(&self.guid);
1042 self.bpp.serialize_into(bytes);
1043 self.num_planes.serialize_into(bytes);
1044 bytes.extend_from_slice(&[0; 2]);
1045 self.depth.serialize_into(bytes);
1046 bytes.extend_from_slice(&[0; 3]);
1047 self.red_mask.serialize_into(bytes);
1048 self.green_mask.serialize_into(bytes);
1049 self.blue_mask.serialize_into(bytes);
1050 u8::from(self.format).serialize_into(bytes);
1051 bytes.extend_from_slice(&[0; 3]);
1052 self.y_sample_bits.serialize_into(bytes);
1053 self.u_sample_bits.serialize_into(bytes);
1054 self.v_sample_bits.serialize_into(bytes);
1055 self.vhorz_y_period.serialize_into(bytes);
1056 self.vhorz_u_period.serialize_into(bytes);
1057 self.vhorz_v_period.serialize_into(bytes);
1058 self.vvert_y_period.serialize_into(bytes);
1059 self.vvert_u_period.serialize_into(bytes);
1060 self.vvert_v_period.serialize_into(bytes);
1061 bytes.extend_from_slice(&self.vcomp_order);
1062 u8::from(self.vscanline_order).serialize_into(bytes);
1063 bytes.extend_from_slice(&[0; 11]);
1064 }
1065 }
1066
1067 /// Opcode for the BadPort error
1068 pub const BAD_PORT_ERROR: u8 = 0;
1069
1070 /// Opcode for the BadEncoding error
1071 pub const BAD_ENCODING_ERROR: u8 = 1;
1072
1073 /// Opcode for the BadControl error
1074 pub const BAD_CONTROL_ERROR: u8 = 2;
1075
1076 /// Opcode for the VideoNotify event
1077 pub const VIDEO_NOTIFY_EVENT: u8 = 0;
1078 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1079 pub struct VideoNotifyEvent {
1080 pub response_type: u8,
1081 pub reason: VideoNotifyReason,
1082 pub sequence: u16,
1083 pub time: xproto::Timestamp,
1084 pub drawable: xproto::Drawable,
1085 pub port: Port,
1086 }
1087 impl TryParse for VideoNotifyEvent {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1088 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1089 let remaining = initial_value;
1090 let (response_type, remaining) = u8::try_parse(remaining)?;
1091 let (reason, remaining) = u8::try_parse(remaining)?;
1092 let (sequence, remaining) = u16::try_parse(remaining)?;
1093 let (time, remaining) = xproto::Timestamp::try_parse(remaining)?;
1094 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
1095 let (port, remaining) = Port::try_parse(remaining)?;
1096 let reason = reason.into();
1097 let result = VideoNotifyEvent { response_type, reason, sequence, time, drawable, port };
1098 let _ = remaining;
1099 let remaining = initial_value.get(32..)
1100 .ok_or(ParseError::InsufficientData)?;
1101 Ok((result, remaining))
1102 }
1103 }
1104 impl From<&VideoNotifyEvent> for [u8; 32] {
from(input: &VideoNotifyEvent) -> Self1105 fn from(input: &VideoNotifyEvent) -> Self {
1106 let response_type_bytes = input.response_type.serialize();
1107 let reason_bytes = u8::from(input.reason).serialize();
1108 let sequence_bytes = input.sequence.serialize();
1109 let time_bytes = input.time.serialize();
1110 let drawable_bytes = input.drawable.serialize();
1111 let port_bytes = input.port.serialize();
1112 [
1113 response_type_bytes[0],
1114 reason_bytes[0],
1115 sequence_bytes[0],
1116 sequence_bytes[1],
1117 time_bytes[0],
1118 time_bytes[1],
1119 time_bytes[2],
1120 time_bytes[3],
1121 drawable_bytes[0],
1122 drawable_bytes[1],
1123 drawable_bytes[2],
1124 drawable_bytes[3],
1125 port_bytes[0],
1126 port_bytes[1],
1127 port_bytes[2],
1128 port_bytes[3],
1129 // trailing padding
1130 0,
1131 0,
1132 0,
1133 0,
1134 0,
1135 0,
1136 0,
1137 0,
1138 0,
1139 0,
1140 0,
1141 0,
1142 0,
1143 0,
1144 0,
1145 0,
1146 ]
1147 }
1148 }
1149 impl From<VideoNotifyEvent> for [u8; 32] {
from(input: VideoNotifyEvent) -> Self1150 fn from(input: VideoNotifyEvent) -> Self {
1151 Self::from(&input)
1152 }
1153 }
1154
1155 /// Opcode for the PortNotify event
1156 pub const PORT_NOTIFY_EVENT: u8 = 1;
1157 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1158 pub struct PortNotifyEvent {
1159 pub response_type: u8,
1160 pub sequence: u16,
1161 pub time: xproto::Timestamp,
1162 pub port: Port,
1163 pub attribute: xproto::Atom,
1164 pub value: i32,
1165 }
1166 impl TryParse for PortNotifyEvent {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1167 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1168 let remaining = initial_value;
1169 let (response_type, remaining) = u8::try_parse(remaining)?;
1170 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1171 let (sequence, remaining) = u16::try_parse(remaining)?;
1172 let (time, remaining) = xproto::Timestamp::try_parse(remaining)?;
1173 let (port, remaining) = Port::try_parse(remaining)?;
1174 let (attribute, remaining) = xproto::Atom::try_parse(remaining)?;
1175 let (value, remaining) = i32::try_parse(remaining)?;
1176 let result = PortNotifyEvent { response_type, sequence, time, port, attribute, value };
1177 let _ = remaining;
1178 let remaining = initial_value.get(32..)
1179 .ok_or(ParseError::InsufficientData)?;
1180 Ok((result, remaining))
1181 }
1182 }
1183 impl From<&PortNotifyEvent> for [u8; 32] {
from(input: &PortNotifyEvent) -> Self1184 fn from(input: &PortNotifyEvent) -> Self {
1185 let response_type_bytes = input.response_type.serialize();
1186 let sequence_bytes = input.sequence.serialize();
1187 let time_bytes = input.time.serialize();
1188 let port_bytes = input.port.serialize();
1189 let attribute_bytes = input.attribute.serialize();
1190 let value_bytes = input.value.serialize();
1191 [
1192 response_type_bytes[0],
1193 0,
1194 sequence_bytes[0],
1195 sequence_bytes[1],
1196 time_bytes[0],
1197 time_bytes[1],
1198 time_bytes[2],
1199 time_bytes[3],
1200 port_bytes[0],
1201 port_bytes[1],
1202 port_bytes[2],
1203 port_bytes[3],
1204 attribute_bytes[0],
1205 attribute_bytes[1],
1206 attribute_bytes[2],
1207 attribute_bytes[3],
1208 value_bytes[0],
1209 value_bytes[1],
1210 value_bytes[2],
1211 value_bytes[3],
1212 // trailing padding
1213 0,
1214 0,
1215 0,
1216 0,
1217 0,
1218 0,
1219 0,
1220 0,
1221 0,
1222 0,
1223 0,
1224 0,
1225 ]
1226 }
1227 }
1228 impl From<PortNotifyEvent> for [u8; 32] {
from(input: PortNotifyEvent) -> Self1229 fn from(input: PortNotifyEvent) -> Self {
1230 Self::from(&input)
1231 }
1232 }
1233
1234 /// Opcode for the QueryExtension request
1235 pub const QUERY_EXTENSION_REQUEST: u8 = 0;
1236 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1237 pub struct QueryExtensionRequest;
1238 impl QueryExtensionRequest {
1239 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1240 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1241 where
1242 Conn: RequestConnection + ?Sized,
1243 {
1244 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1245 .ok_or(ConnectionError::UnsupportedExtension)?;
1246 let length_so_far = 0;
1247 let mut request0 = vec![
1248 extension_information.major_opcode,
1249 QUERY_EXTENSION_REQUEST,
1250 0,
1251 0,
1252 ];
1253 let length_so_far = length_so_far + request0.len();
1254 assert_eq!(length_so_far % 4, 0);
1255 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1256 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1257 Ok((vec![request0.into()], vec![]))
1258 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryExtensionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1259 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryExtensionReply>, ConnectionError>
1260 where
1261 Conn: RequestConnection + ?Sized,
1262 {
1263 let (bytes, fds) = self.serialize(conn)?;
1264 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1265 conn.send_request_with_reply(&slices, fds)
1266 }
1267 /// 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>1268 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1269 if header.minor_opcode != QUERY_EXTENSION_REQUEST {
1270 return Err(ParseError::InvalidValue);
1271 }
1272 let _ = value;
1273 Ok(QueryExtensionRequest
1274 )
1275 }
1276 }
1277 impl Request for QueryExtensionRequest {
1278 type Reply = QueryExtensionReply;
1279 }
query_extension<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryExtensionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1280 pub fn query_extension<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryExtensionReply>, ConnectionError>
1281 where
1282 Conn: RequestConnection + ?Sized,
1283 {
1284 let request0 = QueryExtensionRequest;
1285 request0.send(conn)
1286 }
1287
1288 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1289 pub struct QueryExtensionReply {
1290 pub sequence: u16,
1291 pub length: u32,
1292 pub major: u16,
1293 pub minor: u16,
1294 }
1295 impl TryParse for QueryExtensionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1296 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1297 let remaining = initial_value;
1298 let (response_type, remaining) = u8::try_parse(remaining)?;
1299 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1300 let (sequence, remaining) = u16::try_parse(remaining)?;
1301 let (length, remaining) = u32::try_parse(remaining)?;
1302 let (major, remaining) = u16::try_parse(remaining)?;
1303 let (minor, remaining) = u16::try_parse(remaining)?;
1304 if response_type != 1 {
1305 return Err(ParseError::InvalidValue);
1306 }
1307 let result = QueryExtensionReply { sequence, length, major, minor };
1308 let _ = remaining;
1309 let remaining = initial_value.get(32 + length as usize * 4..)
1310 .ok_or(ParseError::InsufficientData)?;
1311 Ok((result, remaining))
1312 }
1313 }
1314
1315 /// Opcode for the QueryAdaptors request
1316 pub const QUERY_ADAPTORS_REQUEST: u8 = 1;
1317 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1318 pub struct QueryAdaptorsRequest {
1319 pub window: xproto::Window,
1320 }
1321 impl QueryAdaptorsRequest {
1322 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1323 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1324 where
1325 Conn: RequestConnection + ?Sized,
1326 {
1327 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1328 .ok_or(ConnectionError::UnsupportedExtension)?;
1329 let length_so_far = 0;
1330 let window_bytes = self.window.serialize();
1331 let mut request0 = vec![
1332 extension_information.major_opcode,
1333 QUERY_ADAPTORS_REQUEST,
1334 0,
1335 0,
1336 window_bytes[0],
1337 window_bytes[1],
1338 window_bytes[2],
1339 window_bytes[3],
1340 ];
1341 let length_so_far = length_so_far + request0.len();
1342 assert_eq!(length_so_far % 4, 0);
1343 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1344 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1345 Ok((vec![request0.into()], vec![]))
1346 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryAdaptorsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1347 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryAdaptorsReply>, ConnectionError>
1348 where
1349 Conn: RequestConnection + ?Sized,
1350 {
1351 let (bytes, fds) = self.serialize(conn)?;
1352 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1353 conn.send_request_with_reply(&slices, fds)
1354 }
1355 /// 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>1356 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1357 if header.minor_opcode != QUERY_ADAPTORS_REQUEST {
1358 return Err(ParseError::InvalidValue);
1359 }
1360 let (window, remaining) = xproto::Window::try_parse(value)?;
1361 let _ = remaining;
1362 Ok(QueryAdaptorsRequest {
1363 window,
1364 })
1365 }
1366 }
1367 impl Request for QueryAdaptorsRequest {
1368 type Reply = QueryAdaptorsReply;
1369 }
query_adaptors<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, QueryAdaptorsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1370 pub fn query_adaptors<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, QueryAdaptorsReply>, ConnectionError>
1371 where
1372 Conn: RequestConnection + ?Sized,
1373 {
1374 let request0 = QueryAdaptorsRequest {
1375 window,
1376 };
1377 request0.send(conn)
1378 }
1379
1380 #[derive(Debug, Clone, PartialEq, Eq)]
1381 pub struct QueryAdaptorsReply {
1382 pub sequence: u16,
1383 pub length: u32,
1384 pub info: Vec<AdaptorInfo>,
1385 }
1386 impl TryParse for QueryAdaptorsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1387 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1388 let remaining = initial_value;
1389 let (response_type, remaining) = u8::try_parse(remaining)?;
1390 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1391 let (sequence, remaining) = u16::try_parse(remaining)?;
1392 let (length, remaining) = u32::try_parse(remaining)?;
1393 let (num_adaptors, remaining) = u16::try_parse(remaining)?;
1394 let remaining = remaining.get(22..).ok_or(ParseError::InsufficientData)?;
1395 let (info, remaining) = crate::x11_utils::parse_list::<AdaptorInfo>(remaining, num_adaptors.try_to_usize()?)?;
1396 if response_type != 1 {
1397 return Err(ParseError::InvalidValue);
1398 }
1399 let result = QueryAdaptorsReply { sequence, length, info };
1400 let _ = remaining;
1401 let remaining = initial_value.get(32 + length as usize * 4..)
1402 .ok_or(ParseError::InsufficientData)?;
1403 Ok((result, remaining))
1404 }
1405 }
1406 impl QueryAdaptorsReply {
1407 /// Get the value of the `num_adaptors` field.
1408 ///
1409 /// The `num_adaptors` field is used as the length field of the `info` field.
1410 /// This function computes the field's value again based on the length of the list.
1411 ///
1412 /// # Panics
1413 ///
1414 /// Panics if the value cannot be represented in the target type. This
1415 /// cannot happen with values of the struct received from the X11 server.
num_adaptors(&self) -> u161416 pub fn num_adaptors(&self) -> u16 {
1417 self.info.len()
1418 .try_into().unwrap()
1419 }
1420 }
1421
1422 /// Opcode for the QueryEncodings request
1423 pub const QUERY_ENCODINGS_REQUEST: u8 = 2;
1424 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1425 pub struct QueryEncodingsRequest {
1426 pub port: Port,
1427 }
1428 impl QueryEncodingsRequest {
1429 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1430 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1431 where
1432 Conn: RequestConnection + ?Sized,
1433 {
1434 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1435 .ok_or(ConnectionError::UnsupportedExtension)?;
1436 let length_so_far = 0;
1437 let port_bytes = self.port.serialize();
1438 let mut request0 = vec![
1439 extension_information.major_opcode,
1440 QUERY_ENCODINGS_REQUEST,
1441 0,
1442 0,
1443 port_bytes[0],
1444 port_bytes[1],
1445 port_bytes[2],
1446 port_bytes[3],
1447 ];
1448 let length_so_far = length_so_far + request0.len();
1449 assert_eq!(length_so_far % 4, 0);
1450 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1451 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1452 Ok((vec![request0.into()], vec![]))
1453 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryEncodingsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1454 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryEncodingsReply>, ConnectionError>
1455 where
1456 Conn: RequestConnection + ?Sized,
1457 {
1458 let (bytes, fds) = self.serialize(conn)?;
1459 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1460 conn.send_request_with_reply(&slices, fds)
1461 }
1462 /// 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>1463 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1464 if header.minor_opcode != QUERY_ENCODINGS_REQUEST {
1465 return Err(ParseError::InvalidValue);
1466 }
1467 let (port, remaining) = Port::try_parse(value)?;
1468 let _ = remaining;
1469 Ok(QueryEncodingsRequest {
1470 port,
1471 })
1472 }
1473 }
1474 impl Request for QueryEncodingsRequest {
1475 type Reply = QueryEncodingsReply;
1476 }
query_encodings<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, QueryEncodingsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1477 pub fn query_encodings<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, QueryEncodingsReply>, ConnectionError>
1478 where
1479 Conn: RequestConnection + ?Sized,
1480 {
1481 let request0 = QueryEncodingsRequest {
1482 port,
1483 };
1484 request0.send(conn)
1485 }
1486
1487 #[derive(Debug, Clone, PartialEq, Eq)]
1488 pub struct QueryEncodingsReply {
1489 pub sequence: u16,
1490 pub length: u32,
1491 pub info: Vec<EncodingInfo>,
1492 }
1493 impl TryParse for QueryEncodingsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1494 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1495 let remaining = initial_value;
1496 let (response_type, remaining) = u8::try_parse(remaining)?;
1497 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
1498 let (sequence, remaining) = u16::try_parse(remaining)?;
1499 let (length, remaining) = u32::try_parse(remaining)?;
1500 let (num_encodings, remaining) = u16::try_parse(remaining)?;
1501 let remaining = remaining.get(22..).ok_or(ParseError::InsufficientData)?;
1502 let (info, remaining) = crate::x11_utils::parse_list::<EncodingInfo>(remaining, num_encodings.try_to_usize()?)?;
1503 if response_type != 1 {
1504 return Err(ParseError::InvalidValue);
1505 }
1506 let result = QueryEncodingsReply { sequence, length, info };
1507 let _ = remaining;
1508 let remaining = initial_value.get(32 + length as usize * 4..)
1509 .ok_or(ParseError::InsufficientData)?;
1510 Ok((result, remaining))
1511 }
1512 }
1513 impl QueryEncodingsReply {
1514 /// Get the value of the `num_encodings` field.
1515 ///
1516 /// The `num_encodings` field is used as the length field of the `info` field.
1517 /// This function computes the field's value again based on the length of the list.
1518 ///
1519 /// # Panics
1520 ///
1521 /// Panics if the value cannot be represented in the target type. This
1522 /// cannot happen with values of the struct received from the X11 server.
num_encodings(&self) -> u161523 pub fn num_encodings(&self) -> u16 {
1524 self.info.len()
1525 .try_into().unwrap()
1526 }
1527 }
1528
1529 /// Opcode for the GrabPort request
1530 pub const GRAB_PORT_REQUEST: u8 = 3;
1531 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1532 pub struct GrabPortRequest {
1533 pub port: Port,
1534 pub time: xproto::Timestamp,
1535 }
1536 impl GrabPortRequest {
1537 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1538 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1539 where
1540 Conn: RequestConnection + ?Sized,
1541 {
1542 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1543 .ok_or(ConnectionError::UnsupportedExtension)?;
1544 let length_so_far = 0;
1545 let port_bytes = self.port.serialize();
1546 let time_bytes = self.time.serialize();
1547 let mut request0 = vec![
1548 extension_information.major_opcode,
1549 GRAB_PORT_REQUEST,
1550 0,
1551 0,
1552 port_bytes[0],
1553 port_bytes[1],
1554 port_bytes[2],
1555 port_bytes[3],
1556 time_bytes[0],
1557 time_bytes[1],
1558 time_bytes[2],
1559 time_bytes[3],
1560 ];
1561 let length_so_far = length_so_far + request0.len();
1562 assert_eq!(length_so_far % 4, 0);
1563 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1564 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1565 Ok((vec![request0.into()], vec![]))
1566 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GrabPortReply>, ConnectionError> where Conn: RequestConnection + ?Sized,1567 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GrabPortReply>, ConnectionError>
1568 where
1569 Conn: RequestConnection + ?Sized,
1570 {
1571 let (bytes, fds) = self.serialize(conn)?;
1572 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1573 conn.send_request_with_reply(&slices, fds)
1574 }
1575 /// 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>1576 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1577 if header.minor_opcode != GRAB_PORT_REQUEST {
1578 return Err(ParseError::InvalidValue);
1579 }
1580 let (port, remaining) = Port::try_parse(value)?;
1581 let (time, remaining) = xproto::Timestamp::try_parse(remaining)?;
1582 let _ = remaining;
1583 Ok(GrabPortRequest {
1584 port,
1585 time,
1586 })
1587 }
1588 }
1589 impl Request for GrabPortRequest {
1590 type Reply = GrabPortReply;
1591 }
grab_port<Conn, A>(conn: &Conn, port: Port, time: A) -> Result<Cookie<'_, Conn, GrabPortReply>, ConnectionError> where Conn: RequestConnection + ?Sized, A: Into<xproto::Timestamp>,1592 pub fn grab_port<Conn, A>(conn: &Conn, port: Port, time: A) -> Result<Cookie<'_, Conn, GrabPortReply>, ConnectionError>
1593 where
1594 Conn: RequestConnection + ?Sized,
1595 A: Into<xproto::Timestamp>,
1596 {
1597 let time: xproto::Timestamp = time.into();
1598 let request0 = GrabPortRequest {
1599 port,
1600 time,
1601 };
1602 request0.send(conn)
1603 }
1604
1605 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1606 pub struct GrabPortReply {
1607 pub result: GrabPortStatus,
1608 pub sequence: u16,
1609 pub length: u32,
1610 }
1611 impl TryParse for GrabPortReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>1612 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
1613 let remaining = initial_value;
1614 let (response_type, remaining) = u8::try_parse(remaining)?;
1615 let (result, remaining) = u8::try_parse(remaining)?;
1616 let (sequence, remaining) = u16::try_parse(remaining)?;
1617 let (length, remaining) = u32::try_parse(remaining)?;
1618 if response_type != 1 {
1619 return Err(ParseError::InvalidValue);
1620 }
1621 let result = result.into();
1622 let result = GrabPortReply { result, sequence, length };
1623 let _ = remaining;
1624 let remaining = initial_value.get(32 + length as usize * 4..)
1625 .ok_or(ParseError::InsufficientData)?;
1626 Ok((result, remaining))
1627 }
1628 }
1629
1630 /// Opcode for the UngrabPort request
1631 pub const UNGRAB_PORT_REQUEST: u8 = 4;
1632 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1633 pub struct UngrabPortRequest {
1634 pub port: Port,
1635 pub time: xproto::Timestamp,
1636 }
1637 impl UngrabPortRequest {
1638 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1639 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1640 where
1641 Conn: RequestConnection + ?Sized,
1642 {
1643 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1644 .ok_or(ConnectionError::UnsupportedExtension)?;
1645 let length_so_far = 0;
1646 let port_bytes = self.port.serialize();
1647 let time_bytes = self.time.serialize();
1648 let mut request0 = vec![
1649 extension_information.major_opcode,
1650 UNGRAB_PORT_REQUEST,
1651 0,
1652 0,
1653 port_bytes[0],
1654 port_bytes[1],
1655 port_bytes[2],
1656 port_bytes[3],
1657 time_bytes[0],
1658 time_bytes[1],
1659 time_bytes[2],
1660 time_bytes[3],
1661 ];
1662 let length_so_far = length_so_far + request0.len();
1663 assert_eq!(length_so_far % 4, 0);
1664 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1665 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1666 Ok((vec![request0.into()], vec![]))
1667 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1668 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1669 where
1670 Conn: RequestConnection + ?Sized,
1671 {
1672 let (bytes, fds) = self.serialize(conn)?;
1673 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1674 conn.send_request_without_reply(&slices, fds)
1675 }
1676 /// 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>1677 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1678 if header.minor_opcode != UNGRAB_PORT_REQUEST {
1679 return Err(ParseError::InvalidValue);
1680 }
1681 let (port, remaining) = Port::try_parse(value)?;
1682 let (time, remaining) = xproto::Timestamp::try_parse(remaining)?;
1683 let _ = remaining;
1684 Ok(UngrabPortRequest {
1685 port,
1686 time,
1687 })
1688 }
1689 }
1690 impl Request for UngrabPortRequest {
1691 type Reply = ();
1692 }
ungrab_port<Conn, A>(conn: &Conn, port: Port, time: A) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized, A: Into<xproto::Timestamp>,1693 pub fn ungrab_port<Conn, A>(conn: &Conn, port: Port, time: A) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1694 where
1695 Conn: RequestConnection + ?Sized,
1696 A: Into<xproto::Timestamp>,
1697 {
1698 let time: xproto::Timestamp = time.into();
1699 let request0 = UngrabPortRequest {
1700 port,
1701 time,
1702 };
1703 request0.send(conn)
1704 }
1705
1706 /// Opcode for the PutVideo request
1707 pub const PUT_VIDEO_REQUEST: u8 = 5;
1708 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1709 pub struct PutVideoRequest {
1710 pub port: Port,
1711 pub drawable: xproto::Drawable,
1712 pub gc: xproto::Gcontext,
1713 pub vid_x: i16,
1714 pub vid_y: i16,
1715 pub vid_w: u16,
1716 pub vid_h: u16,
1717 pub drw_x: i16,
1718 pub drw_y: i16,
1719 pub drw_w: u16,
1720 pub drw_h: u16,
1721 }
1722 impl PutVideoRequest {
1723 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1724 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1725 where
1726 Conn: RequestConnection + ?Sized,
1727 {
1728 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1729 .ok_or(ConnectionError::UnsupportedExtension)?;
1730 let length_so_far = 0;
1731 let port_bytes = self.port.serialize();
1732 let drawable_bytes = self.drawable.serialize();
1733 let gc_bytes = self.gc.serialize();
1734 let vid_x_bytes = self.vid_x.serialize();
1735 let vid_y_bytes = self.vid_y.serialize();
1736 let vid_w_bytes = self.vid_w.serialize();
1737 let vid_h_bytes = self.vid_h.serialize();
1738 let drw_x_bytes = self.drw_x.serialize();
1739 let drw_y_bytes = self.drw_y.serialize();
1740 let drw_w_bytes = self.drw_w.serialize();
1741 let drw_h_bytes = self.drw_h.serialize();
1742 let mut request0 = vec![
1743 extension_information.major_opcode,
1744 PUT_VIDEO_REQUEST,
1745 0,
1746 0,
1747 port_bytes[0],
1748 port_bytes[1],
1749 port_bytes[2],
1750 port_bytes[3],
1751 drawable_bytes[0],
1752 drawable_bytes[1],
1753 drawable_bytes[2],
1754 drawable_bytes[3],
1755 gc_bytes[0],
1756 gc_bytes[1],
1757 gc_bytes[2],
1758 gc_bytes[3],
1759 vid_x_bytes[0],
1760 vid_x_bytes[1],
1761 vid_y_bytes[0],
1762 vid_y_bytes[1],
1763 vid_w_bytes[0],
1764 vid_w_bytes[1],
1765 vid_h_bytes[0],
1766 vid_h_bytes[1],
1767 drw_x_bytes[0],
1768 drw_x_bytes[1],
1769 drw_y_bytes[0],
1770 drw_y_bytes[1],
1771 drw_w_bytes[0],
1772 drw_w_bytes[1],
1773 drw_h_bytes[0],
1774 drw_h_bytes[1],
1775 ];
1776 let length_so_far = length_so_far + request0.len();
1777 assert_eq!(length_so_far % 4, 0);
1778 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1779 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1780 Ok((vec![request0.into()], vec![]))
1781 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1782 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1783 where
1784 Conn: RequestConnection + ?Sized,
1785 {
1786 let (bytes, fds) = self.serialize(conn)?;
1787 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1788 conn.send_request_without_reply(&slices, fds)
1789 }
1790 /// 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>1791 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1792 if header.minor_opcode != PUT_VIDEO_REQUEST {
1793 return Err(ParseError::InvalidValue);
1794 }
1795 let (port, remaining) = Port::try_parse(value)?;
1796 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
1797 let (gc, remaining) = xproto::Gcontext::try_parse(remaining)?;
1798 let (vid_x, remaining) = i16::try_parse(remaining)?;
1799 let (vid_y, remaining) = i16::try_parse(remaining)?;
1800 let (vid_w, remaining) = u16::try_parse(remaining)?;
1801 let (vid_h, remaining) = u16::try_parse(remaining)?;
1802 let (drw_x, remaining) = i16::try_parse(remaining)?;
1803 let (drw_y, remaining) = i16::try_parse(remaining)?;
1804 let (drw_w, remaining) = u16::try_parse(remaining)?;
1805 let (drw_h, remaining) = u16::try_parse(remaining)?;
1806 let _ = remaining;
1807 Ok(PutVideoRequest {
1808 port,
1809 drawable,
1810 gc,
1811 vid_x,
1812 vid_y,
1813 vid_w,
1814 vid_h,
1815 drw_x,
1816 drw_y,
1817 drw_w,
1818 drw_h,
1819 })
1820 }
1821 }
1822 impl Request for PutVideoRequest {
1823 type Reply = ();
1824 }
put_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1825 pub fn put_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1826 where
1827 Conn: RequestConnection + ?Sized,
1828 {
1829 let request0 = PutVideoRequest {
1830 port,
1831 drawable,
1832 gc,
1833 vid_x,
1834 vid_y,
1835 vid_w,
1836 vid_h,
1837 drw_x,
1838 drw_y,
1839 drw_w,
1840 drw_h,
1841 };
1842 request0.send(conn)
1843 }
1844
1845 /// Opcode for the PutStill request
1846 pub const PUT_STILL_REQUEST: u8 = 6;
1847 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1848 pub struct PutStillRequest {
1849 pub port: Port,
1850 pub drawable: xproto::Drawable,
1851 pub gc: xproto::Gcontext,
1852 pub vid_x: i16,
1853 pub vid_y: i16,
1854 pub vid_w: u16,
1855 pub vid_h: u16,
1856 pub drw_x: i16,
1857 pub drw_y: i16,
1858 pub drw_w: u16,
1859 pub drw_h: u16,
1860 }
1861 impl PutStillRequest {
1862 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,1863 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
1864 where
1865 Conn: RequestConnection + ?Sized,
1866 {
1867 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
1868 .ok_or(ConnectionError::UnsupportedExtension)?;
1869 let length_so_far = 0;
1870 let port_bytes = self.port.serialize();
1871 let drawable_bytes = self.drawable.serialize();
1872 let gc_bytes = self.gc.serialize();
1873 let vid_x_bytes = self.vid_x.serialize();
1874 let vid_y_bytes = self.vid_y.serialize();
1875 let vid_w_bytes = self.vid_w.serialize();
1876 let vid_h_bytes = self.vid_h.serialize();
1877 let drw_x_bytes = self.drw_x.serialize();
1878 let drw_y_bytes = self.drw_y.serialize();
1879 let drw_w_bytes = self.drw_w.serialize();
1880 let drw_h_bytes = self.drw_h.serialize();
1881 let mut request0 = vec![
1882 extension_information.major_opcode,
1883 PUT_STILL_REQUEST,
1884 0,
1885 0,
1886 port_bytes[0],
1887 port_bytes[1],
1888 port_bytes[2],
1889 port_bytes[3],
1890 drawable_bytes[0],
1891 drawable_bytes[1],
1892 drawable_bytes[2],
1893 drawable_bytes[3],
1894 gc_bytes[0],
1895 gc_bytes[1],
1896 gc_bytes[2],
1897 gc_bytes[3],
1898 vid_x_bytes[0],
1899 vid_x_bytes[1],
1900 vid_y_bytes[0],
1901 vid_y_bytes[1],
1902 vid_w_bytes[0],
1903 vid_w_bytes[1],
1904 vid_h_bytes[0],
1905 vid_h_bytes[1],
1906 drw_x_bytes[0],
1907 drw_x_bytes[1],
1908 drw_y_bytes[0],
1909 drw_y_bytes[1],
1910 drw_w_bytes[0],
1911 drw_w_bytes[1],
1912 drw_h_bytes[0],
1913 drw_h_bytes[1],
1914 ];
1915 let length_so_far = length_so_far + request0.len();
1916 assert_eq!(length_so_far % 4, 0);
1917 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
1918 request0[2..4].copy_from_slice(&length.to_ne_bytes());
1919 Ok((vec![request0.into()], vec![]))
1920 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1921 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1922 where
1923 Conn: RequestConnection + ?Sized,
1924 {
1925 let (bytes, fds) = self.serialize(conn)?;
1926 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
1927 conn.send_request_without_reply(&slices, fds)
1928 }
1929 /// 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>1930 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
1931 if header.minor_opcode != PUT_STILL_REQUEST {
1932 return Err(ParseError::InvalidValue);
1933 }
1934 let (port, remaining) = Port::try_parse(value)?;
1935 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
1936 let (gc, remaining) = xproto::Gcontext::try_parse(remaining)?;
1937 let (vid_x, remaining) = i16::try_parse(remaining)?;
1938 let (vid_y, remaining) = i16::try_parse(remaining)?;
1939 let (vid_w, remaining) = u16::try_parse(remaining)?;
1940 let (vid_h, remaining) = u16::try_parse(remaining)?;
1941 let (drw_x, remaining) = i16::try_parse(remaining)?;
1942 let (drw_y, remaining) = i16::try_parse(remaining)?;
1943 let (drw_w, remaining) = u16::try_parse(remaining)?;
1944 let (drw_h, remaining) = u16::try_parse(remaining)?;
1945 let _ = remaining;
1946 Ok(PutStillRequest {
1947 port,
1948 drawable,
1949 gc,
1950 vid_x,
1951 vid_y,
1952 vid_w,
1953 vid_h,
1954 drw_x,
1955 drw_y,
1956 drw_w,
1957 drw_h,
1958 })
1959 }
1960 }
1961 impl Request for PutStillRequest {
1962 type Reply = ();
1963 }
put_still<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,1964 pub fn put_still<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
1965 where
1966 Conn: RequestConnection + ?Sized,
1967 {
1968 let request0 = PutStillRequest {
1969 port,
1970 drawable,
1971 gc,
1972 vid_x,
1973 vid_y,
1974 vid_w,
1975 vid_h,
1976 drw_x,
1977 drw_y,
1978 drw_w,
1979 drw_h,
1980 };
1981 request0.send(conn)
1982 }
1983
1984 /// Opcode for the GetVideo request
1985 pub const GET_VIDEO_REQUEST: u8 = 7;
1986 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
1987 pub struct GetVideoRequest {
1988 pub port: Port,
1989 pub drawable: xproto::Drawable,
1990 pub gc: xproto::Gcontext,
1991 pub vid_x: i16,
1992 pub vid_y: i16,
1993 pub vid_w: u16,
1994 pub vid_h: u16,
1995 pub drw_x: i16,
1996 pub drw_y: i16,
1997 pub drw_w: u16,
1998 pub drw_h: u16,
1999 }
2000 impl GetVideoRequest {
2001 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2002 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2003 where
2004 Conn: RequestConnection + ?Sized,
2005 {
2006 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2007 .ok_or(ConnectionError::UnsupportedExtension)?;
2008 let length_so_far = 0;
2009 let port_bytes = self.port.serialize();
2010 let drawable_bytes = self.drawable.serialize();
2011 let gc_bytes = self.gc.serialize();
2012 let vid_x_bytes = self.vid_x.serialize();
2013 let vid_y_bytes = self.vid_y.serialize();
2014 let vid_w_bytes = self.vid_w.serialize();
2015 let vid_h_bytes = self.vid_h.serialize();
2016 let drw_x_bytes = self.drw_x.serialize();
2017 let drw_y_bytes = self.drw_y.serialize();
2018 let drw_w_bytes = self.drw_w.serialize();
2019 let drw_h_bytes = self.drw_h.serialize();
2020 let mut request0 = vec![
2021 extension_information.major_opcode,
2022 GET_VIDEO_REQUEST,
2023 0,
2024 0,
2025 port_bytes[0],
2026 port_bytes[1],
2027 port_bytes[2],
2028 port_bytes[3],
2029 drawable_bytes[0],
2030 drawable_bytes[1],
2031 drawable_bytes[2],
2032 drawable_bytes[3],
2033 gc_bytes[0],
2034 gc_bytes[1],
2035 gc_bytes[2],
2036 gc_bytes[3],
2037 vid_x_bytes[0],
2038 vid_x_bytes[1],
2039 vid_y_bytes[0],
2040 vid_y_bytes[1],
2041 vid_w_bytes[0],
2042 vid_w_bytes[1],
2043 vid_h_bytes[0],
2044 vid_h_bytes[1],
2045 drw_x_bytes[0],
2046 drw_x_bytes[1],
2047 drw_y_bytes[0],
2048 drw_y_bytes[1],
2049 drw_w_bytes[0],
2050 drw_w_bytes[1],
2051 drw_h_bytes[0],
2052 drw_h_bytes[1],
2053 ];
2054 let length_so_far = length_so_far + request0.len();
2055 assert_eq!(length_so_far % 4, 0);
2056 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2057 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2058 Ok((vec![request0.into()], vec![]))
2059 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2060 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2061 where
2062 Conn: RequestConnection + ?Sized,
2063 {
2064 let (bytes, fds) = self.serialize(conn)?;
2065 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2066 conn.send_request_without_reply(&slices, fds)
2067 }
2068 /// 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>2069 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2070 if header.minor_opcode != GET_VIDEO_REQUEST {
2071 return Err(ParseError::InvalidValue);
2072 }
2073 let (port, remaining) = Port::try_parse(value)?;
2074 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
2075 let (gc, remaining) = xproto::Gcontext::try_parse(remaining)?;
2076 let (vid_x, remaining) = i16::try_parse(remaining)?;
2077 let (vid_y, remaining) = i16::try_parse(remaining)?;
2078 let (vid_w, remaining) = u16::try_parse(remaining)?;
2079 let (vid_h, remaining) = u16::try_parse(remaining)?;
2080 let (drw_x, remaining) = i16::try_parse(remaining)?;
2081 let (drw_y, remaining) = i16::try_parse(remaining)?;
2082 let (drw_w, remaining) = u16::try_parse(remaining)?;
2083 let (drw_h, remaining) = u16::try_parse(remaining)?;
2084 let _ = remaining;
2085 Ok(GetVideoRequest {
2086 port,
2087 drawable,
2088 gc,
2089 vid_x,
2090 vid_y,
2091 vid_w,
2092 vid_h,
2093 drw_x,
2094 drw_y,
2095 drw_w,
2096 drw_h,
2097 })
2098 }
2099 }
2100 impl Request for GetVideoRequest {
2101 type Reply = ();
2102 }
get_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2103 pub fn get_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2104 where
2105 Conn: RequestConnection + ?Sized,
2106 {
2107 let request0 = GetVideoRequest {
2108 port,
2109 drawable,
2110 gc,
2111 vid_x,
2112 vid_y,
2113 vid_w,
2114 vid_h,
2115 drw_x,
2116 drw_y,
2117 drw_w,
2118 drw_h,
2119 };
2120 request0.send(conn)
2121 }
2122
2123 /// Opcode for the GetStill request
2124 pub const GET_STILL_REQUEST: u8 = 8;
2125 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2126 pub struct GetStillRequest {
2127 pub port: Port,
2128 pub drawable: xproto::Drawable,
2129 pub gc: xproto::Gcontext,
2130 pub vid_x: i16,
2131 pub vid_y: i16,
2132 pub vid_w: u16,
2133 pub vid_h: u16,
2134 pub drw_x: i16,
2135 pub drw_y: i16,
2136 pub drw_w: u16,
2137 pub drw_h: u16,
2138 }
2139 impl GetStillRequest {
2140 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2141 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2142 where
2143 Conn: RequestConnection + ?Sized,
2144 {
2145 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2146 .ok_or(ConnectionError::UnsupportedExtension)?;
2147 let length_so_far = 0;
2148 let port_bytes = self.port.serialize();
2149 let drawable_bytes = self.drawable.serialize();
2150 let gc_bytes = self.gc.serialize();
2151 let vid_x_bytes = self.vid_x.serialize();
2152 let vid_y_bytes = self.vid_y.serialize();
2153 let vid_w_bytes = self.vid_w.serialize();
2154 let vid_h_bytes = self.vid_h.serialize();
2155 let drw_x_bytes = self.drw_x.serialize();
2156 let drw_y_bytes = self.drw_y.serialize();
2157 let drw_w_bytes = self.drw_w.serialize();
2158 let drw_h_bytes = self.drw_h.serialize();
2159 let mut request0 = vec![
2160 extension_information.major_opcode,
2161 GET_STILL_REQUEST,
2162 0,
2163 0,
2164 port_bytes[0],
2165 port_bytes[1],
2166 port_bytes[2],
2167 port_bytes[3],
2168 drawable_bytes[0],
2169 drawable_bytes[1],
2170 drawable_bytes[2],
2171 drawable_bytes[3],
2172 gc_bytes[0],
2173 gc_bytes[1],
2174 gc_bytes[2],
2175 gc_bytes[3],
2176 vid_x_bytes[0],
2177 vid_x_bytes[1],
2178 vid_y_bytes[0],
2179 vid_y_bytes[1],
2180 vid_w_bytes[0],
2181 vid_w_bytes[1],
2182 vid_h_bytes[0],
2183 vid_h_bytes[1],
2184 drw_x_bytes[0],
2185 drw_x_bytes[1],
2186 drw_y_bytes[0],
2187 drw_y_bytes[1],
2188 drw_w_bytes[0],
2189 drw_w_bytes[1],
2190 drw_h_bytes[0],
2191 drw_h_bytes[1],
2192 ];
2193 let length_so_far = length_so_far + request0.len();
2194 assert_eq!(length_so_far % 4, 0);
2195 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2196 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2197 Ok((vec![request0.into()], vec![]))
2198 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2199 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2200 where
2201 Conn: RequestConnection + ?Sized,
2202 {
2203 let (bytes, fds) = self.serialize(conn)?;
2204 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2205 conn.send_request_without_reply(&slices, fds)
2206 }
2207 /// 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>2208 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2209 if header.minor_opcode != GET_STILL_REQUEST {
2210 return Err(ParseError::InvalidValue);
2211 }
2212 let (port, remaining) = Port::try_parse(value)?;
2213 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
2214 let (gc, remaining) = xproto::Gcontext::try_parse(remaining)?;
2215 let (vid_x, remaining) = i16::try_parse(remaining)?;
2216 let (vid_y, remaining) = i16::try_parse(remaining)?;
2217 let (vid_w, remaining) = u16::try_parse(remaining)?;
2218 let (vid_h, remaining) = u16::try_parse(remaining)?;
2219 let (drw_x, remaining) = i16::try_parse(remaining)?;
2220 let (drw_y, remaining) = i16::try_parse(remaining)?;
2221 let (drw_w, remaining) = u16::try_parse(remaining)?;
2222 let (drw_h, remaining) = u16::try_parse(remaining)?;
2223 let _ = remaining;
2224 Ok(GetStillRequest {
2225 port,
2226 drawable,
2227 gc,
2228 vid_x,
2229 vid_y,
2230 vid_w,
2231 vid_h,
2232 drw_x,
2233 drw_y,
2234 drw_w,
2235 drw_h,
2236 })
2237 }
2238 }
2239 impl Request for GetStillRequest {
2240 type Reply = ();
2241 }
get_still<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2242 pub fn get_still<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2243 where
2244 Conn: RequestConnection + ?Sized,
2245 {
2246 let request0 = GetStillRequest {
2247 port,
2248 drawable,
2249 gc,
2250 vid_x,
2251 vid_y,
2252 vid_w,
2253 vid_h,
2254 drw_x,
2255 drw_y,
2256 drw_w,
2257 drw_h,
2258 };
2259 request0.send(conn)
2260 }
2261
2262 /// Opcode for the StopVideo request
2263 pub const STOP_VIDEO_REQUEST: u8 = 9;
2264 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2265 pub struct StopVideoRequest {
2266 pub port: Port,
2267 pub drawable: xproto::Drawable,
2268 }
2269 impl StopVideoRequest {
2270 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2271 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2272 where
2273 Conn: RequestConnection + ?Sized,
2274 {
2275 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2276 .ok_or(ConnectionError::UnsupportedExtension)?;
2277 let length_so_far = 0;
2278 let port_bytes = self.port.serialize();
2279 let drawable_bytes = self.drawable.serialize();
2280 let mut request0 = vec![
2281 extension_information.major_opcode,
2282 STOP_VIDEO_REQUEST,
2283 0,
2284 0,
2285 port_bytes[0],
2286 port_bytes[1],
2287 port_bytes[2],
2288 port_bytes[3],
2289 drawable_bytes[0],
2290 drawable_bytes[1],
2291 drawable_bytes[2],
2292 drawable_bytes[3],
2293 ];
2294 let length_so_far = length_so_far + request0.len();
2295 assert_eq!(length_so_far % 4, 0);
2296 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2297 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2298 Ok((vec![request0.into()], vec![]))
2299 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2300 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2301 where
2302 Conn: RequestConnection + ?Sized,
2303 {
2304 let (bytes, fds) = self.serialize(conn)?;
2305 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2306 conn.send_request_without_reply(&slices, fds)
2307 }
2308 /// 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>2309 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2310 if header.minor_opcode != STOP_VIDEO_REQUEST {
2311 return Err(ParseError::InvalidValue);
2312 }
2313 let (port, remaining) = Port::try_parse(value)?;
2314 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
2315 let _ = remaining;
2316 Ok(StopVideoRequest {
2317 port,
2318 drawable,
2319 })
2320 }
2321 }
2322 impl Request for StopVideoRequest {
2323 type Reply = ();
2324 }
stop_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2325 pub fn stop_video<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2326 where
2327 Conn: RequestConnection + ?Sized,
2328 {
2329 let request0 = StopVideoRequest {
2330 port,
2331 drawable,
2332 };
2333 request0.send(conn)
2334 }
2335
2336 /// Opcode for the SelectVideoNotify request
2337 pub const SELECT_VIDEO_NOTIFY_REQUEST: u8 = 10;
2338 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2339 pub struct SelectVideoNotifyRequest {
2340 pub drawable: xproto::Drawable,
2341 pub onoff: bool,
2342 }
2343 impl SelectVideoNotifyRequest {
2344 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2345 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2346 where
2347 Conn: RequestConnection + ?Sized,
2348 {
2349 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2350 .ok_or(ConnectionError::UnsupportedExtension)?;
2351 let length_so_far = 0;
2352 let drawable_bytes = self.drawable.serialize();
2353 let onoff_bytes = self.onoff.serialize();
2354 let mut request0 = vec![
2355 extension_information.major_opcode,
2356 SELECT_VIDEO_NOTIFY_REQUEST,
2357 0,
2358 0,
2359 drawable_bytes[0],
2360 drawable_bytes[1],
2361 drawable_bytes[2],
2362 drawable_bytes[3],
2363 onoff_bytes[0],
2364 0,
2365 0,
2366 0,
2367 ];
2368 let length_so_far = length_so_far + request0.len();
2369 assert_eq!(length_so_far % 4, 0);
2370 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2371 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2372 Ok((vec![request0.into()], vec![]))
2373 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2374 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2375 where
2376 Conn: RequestConnection + ?Sized,
2377 {
2378 let (bytes, fds) = self.serialize(conn)?;
2379 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2380 conn.send_request_without_reply(&slices, fds)
2381 }
2382 /// 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>2383 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2384 if header.minor_opcode != SELECT_VIDEO_NOTIFY_REQUEST {
2385 return Err(ParseError::InvalidValue);
2386 }
2387 let (drawable, remaining) = xproto::Drawable::try_parse(value)?;
2388 let (onoff, remaining) = bool::try_parse(remaining)?;
2389 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2390 let _ = remaining;
2391 Ok(SelectVideoNotifyRequest {
2392 drawable,
2393 onoff,
2394 })
2395 }
2396 }
2397 impl Request for SelectVideoNotifyRequest {
2398 type Reply = ();
2399 }
select_video_notify<Conn>(conn: &Conn, drawable: xproto::Drawable, onoff: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2400 pub fn select_video_notify<Conn>(conn: &Conn, drawable: xproto::Drawable, onoff: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2401 where
2402 Conn: RequestConnection + ?Sized,
2403 {
2404 let request0 = SelectVideoNotifyRequest {
2405 drawable,
2406 onoff,
2407 };
2408 request0.send(conn)
2409 }
2410
2411 /// Opcode for the SelectPortNotify request
2412 pub const SELECT_PORT_NOTIFY_REQUEST: u8 = 11;
2413 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2414 pub struct SelectPortNotifyRequest {
2415 pub port: Port,
2416 pub onoff: bool,
2417 }
2418 impl SelectPortNotifyRequest {
2419 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2420 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2421 where
2422 Conn: RequestConnection + ?Sized,
2423 {
2424 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2425 .ok_or(ConnectionError::UnsupportedExtension)?;
2426 let length_so_far = 0;
2427 let port_bytes = self.port.serialize();
2428 let onoff_bytes = self.onoff.serialize();
2429 let mut request0 = vec![
2430 extension_information.major_opcode,
2431 SELECT_PORT_NOTIFY_REQUEST,
2432 0,
2433 0,
2434 port_bytes[0],
2435 port_bytes[1],
2436 port_bytes[2],
2437 port_bytes[3],
2438 onoff_bytes[0],
2439 0,
2440 0,
2441 0,
2442 ];
2443 let length_so_far = length_so_far + request0.len();
2444 assert_eq!(length_so_far % 4, 0);
2445 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2446 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2447 Ok((vec![request0.into()], vec![]))
2448 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2449 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2450 where
2451 Conn: RequestConnection + ?Sized,
2452 {
2453 let (bytes, fds) = self.serialize(conn)?;
2454 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2455 conn.send_request_without_reply(&slices, fds)
2456 }
2457 /// 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>2458 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2459 if header.minor_opcode != SELECT_PORT_NOTIFY_REQUEST {
2460 return Err(ParseError::InvalidValue);
2461 }
2462 let (port, remaining) = Port::try_parse(value)?;
2463 let (onoff, remaining) = bool::try_parse(remaining)?;
2464 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2465 let _ = remaining;
2466 Ok(SelectPortNotifyRequest {
2467 port,
2468 onoff,
2469 })
2470 }
2471 }
2472 impl Request for SelectPortNotifyRequest {
2473 type Reply = ();
2474 }
select_port_notify<Conn>(conn: &Conn, port: Port, onoff: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2475 pub fn select_port_notify<Conn>(conn: &Conn, port: Port, onoff: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2476 where
2477 Conn: RequestConnection + ?Sized,
2478 {
2479 let request0 = SelectPortNotifyRequest {
2480 port,
2481 onoff,
2482 };
2483 request0.send(conn)
2484 }
2485
2486 /// Opcode for the QueryBestSize request
2487 pub const QUERY_BEST_SIZE_REQUEST: u8 = 12;
2488 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2489 pub struct QueryBestSizeRequest {
2490 pub port: Port,
2491 pub vid_w: u16,
2492 pub vid_h: u16,
2493 pub drw_w: u16,
2494 pub drw_h: u16,
2495 pub motion: bool,
2496 }
2497 impl QueryBestSizeRequest {
2498 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2499 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2500 where
2501 Conn: RequestConnection + ?Sized,
2502 {
2503 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2504 .ok_or(ConnectionError::UnsupportedExtension)?;
2505 let length_so_far = 0;
2506 let port_bytes = self.port.serialize();
2507 let vid_w_bytes = self.vid_w.serialize();
2508 let vid_h_bytes = self.vid_h.serialize();
2509 let drw_w_bytes = self.drw_w.serialize();
2510 let drw_h_bytes = self.drw_h.serialize();
2511 let motion_bytes = self.motion.serialize();
2512 let mut request0 = vec![
2513 extension_information.major_opcode,
2514 QUERY_BEST_SIZE_REQUEST,
2515 0,
2516 0,
2517 port_bytes[0],
2518 port_bytes[1],
2519 port_bytes[2],
2520 port_bytes[3],
2521 vid_w_bytes[0],
2522 vid_w_bytes[1],
2523 vid_h_bytes[0],
2524 vid_h_bytes[1],
2525 drw_w_bytes[0],
2526 drw_w_bytes[1],
2527 drw_h_bytes[0],
2528 drw_h_bytes[1],
2529 motion_bytes[0],
2530 0,
2531 0,
2532 0,
2533 ];
2534 let length_so_far = length_so_far + request0.len();
2535 assert_eq!(length_so_far % 4, 0);
2536 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2537 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2538 Ok((vec![request0.into()], vec![]))
2539 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryBestSizeReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2540 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryBestSizeReply>, ConnectionError>
2541 where
2542 Conn: RequestConnection + ?Sized,
2543 {
2544 let (bytes, fds) = self.serialize(conn)?;
2545 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2546 conn.send_request_with_reply(&slices, fds)
2547 }
2548 /// 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>2549 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2550 if header.minor_opcode != QUERY_BEST_SIZE_REQUEST {
2551 return Err(ParseError::InvalidValue);
2552 }
2553 let (port, remaining) = Port::try_parse(value)?;
2554 let (vid_w, remaining) = u16::try_parse(remaining)?;
2555 let (vid_h, remaining) = u16::try_parse(remaining)?;
2556 let (drw_w, remaining) = u16::try_parse(remaining)?;
2557 let (drw_h, remaining) = u16::try_parse(remaining)?;
2558 let (motion, remaining) = bool::try_parse(remaining)?;
2559 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
2560 let _ = remaining;
2561 Ok(QueryBestSizeRequest {
2562 port,
2563 vid_w,
2564 vid_h,
2565 drw_w,
2566 drw_h,
2567 motion,
2568 })
2569 }
2570 }
2571 impl Request for QueryBestSizeRequest {
2572 type Reply = QueryBestSizeReply;
2573 }
query_best_size<Conn>(conn: &Conn, port: Port, vid_w: u16, vid_h: u16, drw_w: u16, drw_h: u16, motion: bool) -> Result<Cookie<'_, Conn, QueryBestSizeReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2574 pub fn query_best_size<Conn>(conn: &Conn, port: Port, vid_w: u16, vid_h: u16, drw_w: u16, drw_h: u16, motion: bool) -> Result<Cookie<'_, Conn, QueryBestSizeReply>, ConnectionError>
2575 where
2576 Conn: RequestConnection + ?Sized,
2577 {
2578 let request0 = QueryBestSizeRequest {
2579 port,
2580 vid_w,
2581 vid_h,
2582 drw_w,
2583 drw_h,
2584 motion,
2585 };
2586 request0.send(conn)
2587 }
2588
2589 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2590 pub struct QueryBestSizeReply {
2591 pub sequence: u16,
2592 pub length: u32,
2593 pub actual_width: u16,
2594 pub actual_height: u16,
2595 }
2596 impl TryParse for QueryBestSizeReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2597 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2598 let remaining = initial_value;
2599 let (response_type, remaining) = u8::try_parse(remaining)?;
2600 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2601 let (sequence, remaining) = u16::try_parse(remaining)?;
2602 let (length, remaining) = u32::try_parse(remaining)?;
2603 let (actual_width, remaining) = u16::try_parse(remaining)?;
2604 let (actual_height, remaining) = u16::try_parse(remaining)?;
2605 if response_type != 1 {
2606 return Err(ParseError::InvalidValue);
2607 }
2608 let result = QueryBestSizeReply { sequence, length, actual_width, actual_height };
2609 let _ = remaining;
2610 let remaining = initial_value.get(32 + length as usize * 4..)
2611 .ok_or(ParseError::InsufficientData)?;
2612 Ok((result, remaining))
2613 }
2614 }
2615
2616 /// Opcode for the SetPortAttribute request
2617 pub const SET_PORT_ATTRIBUTE_REQUEST: u8 = 13;
2618 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2619 pub struct SetPortAttributeRequest {
2620 pub port: Port,
2621 pub attribute: xproto::Atom,
2622 pub value: i32,
2623 }
2624 impl SetPortAttributeRequest {
2625 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2626 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2627 where
2628 Conn: RequestConnection + ?Sized,
2629 {
2630 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2631 .ok_or(ConnectionError::UnsupportedExtension)?;
2632 let length_so_far = 0;
2633 let port_bytes = self.port.serialize();
2634 let attribute_bytes = self.attribute.serialize();
2635 let value_bytes = self.value.serialize();
2636 let mut request0 = vec![
2637 extension_information.major_opcode,
2638 SET_PORT_ATTRIBUTE_REQUEST,
2639 0,
2640 0,
2641 port_bytes[0],
2642 port_bytes[1],
2643 port_bytes[2],
2644 port_bytes[3],
2645 attribute_bytes[0],
2646 attribute_bytes[1],
2647 attribute_bytes[2],
2648 attribute_bytes[3],
2649 value_bytes[0],
2650 value_bytes[1],
2651 value_bytes[2],
2652 value_bytes[3],
2653 ];
2654 let length_so_far = length_so_far + request0.len();
2655 assert_eq!(length_so_far % 4, 0);
2656 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2657 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2658 Ok((vec![request0.into()], vec![]))
2659 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2660 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2661 where
2662 Conn: RequestConnection + ?Sized,
2663 {
2664 let (bytes, fds) = self.serialize(conn)?;
2665 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2666 conn.send_request_without_reply(&slices, fds)
2667 }
2668 /// 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>2669 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2670 if header.minor_opcode != SET_PORT_ATTRIBUTE_REQUEST {
2671 return Err(ParseError::InvalidValue);
2672 }
2673 let (port, remaining) = Port::try_parse(value)?;
2674 let (attribute, remaining) = xproto::Atom::try_parse(remaining)?;
2675 let (value, remaining) = i32::try_parse(remaining)?;
2676 let _ = remaining;
2677 Ok(SetPortAttributeRequest {
2678 port,
2679 attribute,
2680 value,
2681 })
2682 }
2683 }
2684 impl Request for SetPortAttributeRequest {
2685 type Reply = ();
2686 }
set_port_attribute<Conn>(conn: &Conn, port: Port, attribute: xproto::Atom, value: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,2687 pub fn set_port_attribute<Conn>(conn: &Conn, port: Port, attribute: xproto::Atom, value: i32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
2688 where
2689 Conn: RequestConnection + ?Sized,
2690 {
2691 let request0 = SetPortAttributeRequest {
2692 port,
2693 attribute,
2694 value,
2695 };
2696 request0.send(conn)
2697 }
2698
2699 /// Opcode for the GetPortAttribute request
2700 pub const GET_PORT_ATTRIBUTE_REQUEST: u8 = 14;
2701 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2702 pub struct GetPortAttributeRequest {
2703 pub port: Port,
2704 pub attribute: xproto::Atom,
2705 }
2706 impl GetPortAttributeRequest {
2707 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2708 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2709 where
2710 Conn: RequestConnection + ?Sized,
2711 {
2712 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2713 .ok_or(ConnectionError::UnsupportedExtension)?;
2714 let length_so_far = 0;
2715 let port_bytes = self.port.serialize();
2716 let attribute_bytes = self.attribute.serialize();
2717 let mut request0 = vec![
2718 extension_information.major_opcode,
2719 GET_PORT_ATTRIBUTE_REQUEST,
2720 0,
2721 0,
2722 port_bytes[0],
2723 port_bytes[1],
2724 port_bytes[2],
2725 port_bytes[3],
2726 attribute_bytes[0],
2727 attribute_bytes[1],
2728 attribute_bytes[2],
2729 attribute_bytes[3],
2730 ];
2731 let length_so_far = length_so_far + request0.len();
2732 assert_eq!(length_so_far % 4, 0);
2733 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2734 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2735 Ok((vec![request0.into()], vec![]))
2736 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPortAttributeReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2737 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetPortAttributeReply>, ConnectionError>
2738 where
2739 Conn: RequestConnection + ?Sized,
2740 {
2741 let (bytes, fds) = self.serialize(conn)?;
2742 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2743 conn.send_request_with_reply(&slices, fds)
2744 }
2745 /// 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>2746 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2747 if header.minor_opcode != GET_PORT_ATTRIBUTE_REQUEST {
2748 return Err(ParseError::InvalidValue);
2749 }
2750 let (port, remaining) = Port::try_parse(value)?;
2751 let (attribute, remaining) = xproto::Atom::try_parse(remaining)?;
2752 let _ = remaining;
2753 Ok(GetPortAttributeRequest {
2754 port,
2755 attribute,
2756 })
2757 }
2758 }
2759 impl Request for GetPortAttributeRequest {
2760 type Reply = GetPortAttributeReply;
2761 }
get_port_attribute<Conn>(conn: &Conn, port: Port, attribute: xproto::Atom) -> Result<Cookie<'_, Conn, GetPortAttributeReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2762 pub fn get_port_attribute<Conn>(conn: &Conn, port: Port, attribute: xproto::Atom) -> Result<Cookie<'_, Conn, GetPortAttributeReply>, ConnectionError>
2763 where
2764 Conn: RequestConnection + ?Sized,
2765 {
2766 let request0 = GetPortAttributeRequest {
2767 port,
2768 attribute,
2769 };
2770 request0.send(conn)
2771 }
2772
2773 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2774 pub struct GetPortAttributeReply {
2775 pub sequence: u16,
2776 pub length: u32,
2777 pub value: i32,
2778 }
2779 impl TryParse for GetPortAttributeReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2780 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2781 let remaining = initial_value;
2782 let (response_type, remaining) = u8::try_parse(remaining)?;
2783 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2784 let (sequence, remaining) = u16::try_parse(remaining)?;
2785 let (length, remaining) = u32::try_parse(remaining)?;
2786 let (value, remaining) = i32::try_parse(remaining)?;
2787 if response_type != 1 {
2788 return Err(ParseError::InvalidValue);
2789 }
2790 let result = GetPortAttributeReply { sequence, length, value };
2791 let _ = remaining;
2792 let remaining = initial_value.get(32 + length as usize * 4..)
2793 .ok_or(ParseError::InsufficientData)?;
2794 Ok((result, remaining))
2795 }
2796 }
2797
2798 /// Opcode for the QueryPortAttributes request
2799 pub const QUERY_PORT_ATTRIBUTES_REQUEST: u8 = 15;
2800 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2801 pub struct QueryPortAttributesRequest {
2802 pub port: Port,
2803 }
2804 impl QueryPortAttributesRequest {
2805 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2806 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2807 where
2808 Conn: RequestConnection + ?Sized,
2809 {
2810 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2811 .ok_or(ConnectionError::UnsupportedExtension)?;
2812 let length_so_far = 0;
2813 let port_bytes = self.port.serialize();
2814 let mut request0 = vec![
2815 extension_information.major_opcode,
2816 QUERY_PORT_ATTRIBUTES_REQUEST,
2817 0,
2818 0,
2819 port_bytes[0],
2820 port_bytes[1],
2821 port_bytes[2],
2822 port_bytes[3],
2823 ];
2824 let length_so_far = length_so_far + request0.len();
2825 assert_eq!(length_so_far % 4, 0);
2826 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2827 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2828 Ok((vec![request0.into()], vec![]))
2829 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryPortAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2830 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryPortAttributesReply>, ConnectionError>
2831 where
2832 Conn: RequestConnection + ?Sized,
2833 {
2834 let (bytes, fds) = self.serialize(conn)?;
2835 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2836 conn.send_request_with_reply(&slices, fds)
2837 }
2838 /// 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>2839 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2840 if header.minor_opcode != QUERY_PORT_ATTRIBUTES_REQUEST {
2841 return Err(ParseError::InvalidValue);
2842 }
2843 let (port, remaining) = Port::try_parse(value)?;
2844 let _ = remaining;
2845 Ok(QueryPortAttributesRequest {
2846 port,
2847 })
2848 }
2849 }
2850 impl Request for QueryPortAttributesRequest {
2851 type Reply = QueryPortAttributesReply;
2852 }
query_port_attributes<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, QueryPortAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2853 pub fn query_port_attributes<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, QueryPortAttributesReply>, ConnectionError>
2854 where
2855 Conn: RequestConnection + ?Sized,
2856 {
2857 let request0 = QueryPortAttributesRequest {
2858 port,
2859 };
2860 request0.send(conn)
2861 }
2862
2863 #[derive(Debug, Clone, PartialEq, Eq)]
2864 pub struct QueryPortAttributesReply {
2865 pub sequence: u16,
2866 pub length: u32,
2867 pub text_size: u32,
2868 pub attributes: Vec<AttributeInfo>,
2869 }
2870 impl TryParse for QueryPortAttributesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2871 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2872 let remaining = initial_value;
2873 let (response_type, remaining) = u8::try_parse(remaining)?;
2874 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2875 let (sequence, remaining) = u16::try_parse(remaining)?;
2876 let (length, remaining) = u32::try_parse(remaining)?;
2877 let (num_attributes, remaining) = u32::try_parse(remaining)?;
2878 let (text_size, remaining) = u32::try_parse(remaining)?;
2879 let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
2880 let (attributes, remaining) = crate::x11_utils::parse_list::<AttributeInfo>(remaining, num_attributes.try_to_usize()?)?;
2881 if response_type != 1 {
2882 return Err(ParseError::InvalidValue);
2883 }
2884 let result = QueryPortAttributesReply { sequence, length, text_size, attributes };
2885 let _ = remaining;
2886 let remaining = initial_value.get(32 + length as usize * 4..)
2887 .ok_or(ParseError::InsufficientData)?;
2888 Ok((result, remaining))
2889 }
2890 }
2891 impl QueryPortAttributesReply {
2892 /// Get the value of the `num_attributes` field.
2893 ///
2894 /// The `num_attributes` field is used as the length field of the `attributes` field.
2895 /// This function computes the field's value again based on the length of the list.
2896 ///
2897 /// # Panics
2898 ///
2899 /// Panics if the value cannot be represented in the target type. This
2900 /// cannot happen with values of the struct received from the X11 server.
num_attributes(&self) -> u322901 pub fn num_attributes(&self) -> u32 {
2902 self.attributes.len()
2903 .try_into().unwrap()
2904 }
2905 }
2906
2907 /// Opcode for the ListImageFormats request
2908 pub const LIST_IMAGE_FORMATS_REQUEST: u8 = 16;
2909 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
2910 pub struct ListImageFormatsRequest {
2911 pub port: Port,
2912 }
2913 impl ListImageFormatsRequest {
2914 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,2915 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
2916 where
2917 Conn: RequestConnection + ?Sized,
2918 {
2919 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
2920 .ok_or(ConnectionError::UnsupportedExtension)?;
2921 let length_so_far = 0;
2922 let port_bytes = self.port.serialize();
2923 let mut request0 = vec![
2924 extension_information.major_opcode,
2925 LIST_IMAGE_FORMATS_REQUEST,
2926 0,
2927 0,
2928 port_bytes[0],
2929 port_bytes[1],
2930 port_bytes[2],
2931 port_bytes[3],
2932 ];
2933 let length_so_far = length_so_far + request0.len();
2934 assert_eq!(length_so_far % 4, 0);
2935 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
2936 request0[2..4].copy_from_slice(&length.to_ne_bytes());
2937 Ok((vec![request0.into()], vec![]))
2938 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ListImageFormatsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2939 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, ListImageFormatsReply>, ConnectionError>
2940 where
2941 Conn: RequestConnection + ?Sized,
2942 {
2943 let (bytes, fds) = self.serialize(conn)?;
2944 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
2945 conn.send_request_with_reply(&slices, fds)
2946 }
2947 /// 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>2948 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
2949 if header.minor_opcode != LIST_IMAGE_FORMATS_REQUEST {
2950 return Err(ParseError::InvalidValue);
2951 }
2952 let (port, remaining) = Port::try_parse(value)?;
2953 let _ = remaining;
2954 Ok(ListImageFormatsRequest {
2955 port,
2956 })
2957 }
2958 }
2959 impl Request for ListImageFormatsRequest {
2960 type Reply = ListImageFormatsReply;
2961 }
list_image_formats<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, ListImageFormatsReply>, ConnectionError> where Conn: RequestConnection + ?Sized,2962 pub fn list_image_formats<Conn>(conn: &Conn, port: Port) -> Result<Cookie<'_, Conn, ListImageFormatsReply>, ConnectionError>
2963 where
2964 Conn: RequestConnection + ?Sized,
2965 {
2966 let request0 = ListImageFormatsRequest {
2967 port,
2968 };
2969 request0.send(conn)
2970 }
2971
2972 #[derive(Debug, Clone, PartialEq, Eq)]
2973 pub struct ListImageFormatsReply {
2974 pub sequence: u16,
2975 pub length: u32,
2976 pub format: Vec<ImageFormatInfo>,
2977 }
2978 impl TryParse for ListImageFormatsReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>2979 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
2980 let remaining = initial_value;
2981 let (response_type, remaining) = u8::try_parse(remaining)?;
2982 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
2983 let (sequence, remaining) = u16::try_parse(remaining)?;
2984 let (length, remaining) = u32::try_parse(remaining)?;
2985 let (num_formats, remaining) = u32::try_parse(remaining)?;
2986 let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
2987 let (format, remaining) = crate::x11_utils::parse_list::<ImageFormatInfo>(remaining, num_formats.try_to_usize()?)?;
2988 if response_type != 1 {
2989 return Err(ParseError::InvalidValue);
2990 }
2991 let result = ListImageFormatsReply { sequence, length, format };
2992 let _ = remaining;
2993 let remaining = initial_value.get(32 + length as usize * 4..)
2994 .ok_or(ParseError::InsufficientData)?;
2995 Ok((result, remaining))
2996 }
2997 }
2998 impl ListImageFormatsReply {
2999 /// Get the value of the `num_formats` field.
3000 ///
3001 /// The `num_formats` field is used as the length field of the `format` field.
3002 /// This function computes the field's value again based on the length of the list.
3003 ///
3004 /// # Panics
3005 ///
3006 /// Panics if the value cannot be represented in the target type. This
3007 /// cannot happen with values of the struct received from the X11 server.
num_formats(&self) -> u323008 pub fn num_formats(&self) -> u32 {
3009 self.format.len()
3010 .try_into().unwrap()
3011 }
3012 }
3013
3014 /// Opcode for the QueryImageAttributes request
3015 pub const QUERY_IMAGE_ATTRIBUTES_REQUEST: u8 = 17;
3016 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3017 pub struct QueryImageAttributesRequest {
3018 pub port: Port,
3019 pub id: u32,
3020 pub width: u16,
3021 pub height: u16,
3022 }
3023 impl QueryImageAttributesRequest {
3024 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3025 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3026 where
3027 Conn: RequestConnection + ?Sized,
3028 {
3029 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3030 .ok_or(ConnectionError::UnsupportedExtension)?;
3031 let length_so_far = 0;
3032 let port_bytes = self.port.serialize();
3033 let id_bytes = self.id.serialize();
3034 let width_bytes = self.width.serialize();
3035 let height_bytes = self.height.serialize();
3036 let mut request0 = vec![
3037 extension_information.major_opcode,
3038 QUERY_IMAGE_ATTRIBUTES_REQUEST,
3039 0,
3040 0,
3041 port_bytes[0],
3042 port_bytes[1],
3043 port_bytes[2],
3044 port_bytes[3],
3045 id_bytes[0],
3046 id_bytes[1],
3047 id_bytes[2],
3048 id_bytes[3],
3049 width_bytes[0],
3050 width_bytes[1],
3051 height_bytes[0],
3052 height_bytes[1],
3053 ];
3054 let length_so_far = length_so_far + request0.len();
3055 assert_eq!(length_so_far % 4, 0);
3056 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3057 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3058 Ok((vec![request0.into()], vec![]))
3059 }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryImageAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,3060 pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryImageAttributesReply>, ConnectionError>
3061 where
3062 Conn: RequestConnection + ?Sized,
3063 {
3064 let (bytes, fds) = self.serialize(conn)?;
3065 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3066 conn.send_request_with_reply(&slices, fds)
3067 }
3068 /// 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>3069 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3070 if header.minor_opcode != QUERY_IMAGE_ATTRIBUTES_REQUEST {
3071 return Err(ParseError::InvalidValue);
3072 }
3073 let (port, remaining) = Port::try_parse(value)?;
3074 let (id, remaining) = u32::try_parse(remaining)?;
3075 let (width, remaining) = u16::try_parse(remaining)?;
3076 let (height, remaining) = u16::try_parse(remaining)?;
3077 let _ = remaining;
3078 Ok(QueryImageAttributesRequest {
3079 port,
3080 id,
3081 width,
3082 height,
3083 })
3084 }
3085 }
3086 impl Request for QueryImageAttributesRequest {
3087 type Reply = QueryImageAttributesReply;
3088 }
query_image_attributes<Conn>(conn: &Conn, port: Port, id: u32, width: u16, height: u16) -> Result<Cookie<'_, Conn, QueryImageAttributesReply>, ConnectionError> where Conn: RequestConnection + ?Sized,3089 pub fn query_image_attributes<Conn>(conn: &Conn, port: Port, id: u32, width: u16, height: u16) -> Result<Cookie<'_, Conn, QueryImageAttributesReply>, ConnectionError>
3090 where
3091 Conn: RequestConnection + ?Sized,
3092 {
3093 let request0 = QueryImageAttributesRequest {
3094 port,
3095 id,
3096 width,
3097 height,
3098 };
3099 request0.send(conn)
3100 }
3101
3102 #[derive(Debug, Clone, PartialEq, Eq)]
3103 pub struct QueryImageAttributesReply {
3104 pub sequence: u16,
3105 pub length: u32,
3106 pub data_size: u32,
3107 pub width: u16,
3108 pub height: u16,
3109 pub pitches: Vec<u32>,
3110 pub offsets: Vec<u32>,
3111 }
3112 impl TryParse for QueryImageAttributesReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>3113 fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
3114 let remaining = initial_value;
3115 let (response_type, remaining) = u8::try_parse(remaining)?;
3116 let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
3117 let (sequence, remaining) = u16::try_parse(remaining)?;
3118 let (length, remaining) = u32::try_parse(remaining)?;
3119 let (num_planes, remaining) = u32::try_parse(remaining)?;
3120 let (data_size, remaining) = u32::try_parse(remaining)?;
3121 let (width, remaining) = u16::try_parse(remaining)?;
3122 let (height, remaining) = u16::try_parse(remaining)?;
3123 let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?;
3124 let (pitches, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_planes.try_to_usize()?)?;
3125 let (offsets, remaining) = crate::x11_utils::parse_list::<u32>(remaining, num_planes.try_to_usize()?)?;
3126 if response_type != 1 {
3127 return Err(ParseError::InvalidValue);
3128 }
3129 let result = QueryImageAttributesReply { sequence, length, data_size, width, height, pitches, offsets };
3130 let _ = remaining;
3131 let remaining = initial_value.get(32 + length as usize * 4..)
3132 .ok_or(ParseError::InsufficientData)?;
3133 Ok((result, remaining))
3134 }
3135 }
3136 impl QueryImageAttributesReply {
3137 /// Get the value of the `num_planes` field.
3138 ///
3139 /// The `num_planes` field is used as the length field of the `pitches` field.
3140 /// This function computes the field's value again based on the length of the list.
3141 ///
3142 /// # Panics
3143 ///
3144 /// Panics if the value cannot be represented in the target type. This
3145 /// cannot happen with values of the struct received from the X11 server.
num_planes(&self) -> u323146 pub fn num_planes(&self) -> u32 {
3147 self.pitches.len()
3148 .try_into().unwrap()
3149 }
3150 }
3151
3152 /// Opcode for the PutImage request
3153 pub const PUT_IMAGE_REQUEST: u8 = 18;
3154 #[derive(Debug, Clone, PartialEq, Eq)]
3155 pub struct PutImageRequest<'input> {
3156 pub port: Port,
3157 pub drawable: xproto::Drawable,
3158 pub gc: xproto::Gcontext,
3159 pub id: u32,
3160 pub src_x: i16,
3161 pub src_y: i16,
3162 pub src_w: u16,
3163 pub src_h: u16,
3164 pub drw_x: i16,
3165 pub drw_y: i16,
3166 pub drw_w: u16,
3167 pub drw_h: u16,
3168 pub width: u16,
3169 pub height: u16,
3170 pub data: Cow<'input, [u8]>,
3171 }
3172 impl<'input> PutImageRequest<'input> {
3173 /// Serialize this request into bytes for the provided connection
serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3174 fn serialize<Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3175 where
3176 Conn: RequestConnection + ?Sized,
3177 {
3178 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3179 .ok_or(ConnectionError::UnsupportedExtension)?;
3180 let length_so_far = 0;
3181 let port_bytes = self.port.serialize();
3182 let drawable_bytes = self.drawable.serialize();
3183 let gc_bytes = self.gc.serialize();
3184 let id_bytes = self.id.serialize();
3185 let src_x_bytes = self.src_x.serialize();
3186 let src_y_bytes = self.src_y.serialize();
3187 let src_w_bytes = self.src_w.serialize();
3188 let src_h_bytes = self.src_h.serialize();
3189 let drw_x_bytes = self.drw_x.serialize();
3190 let drw_y_bytes = self.drw_y.serialize();
3191 let drw_w_bytes = self.drw_w.serialize();
3192 let drw_h_bytes = self.drw_h.serialize();
3193 let width_bytes = self.width.serialize();
3194 let height_bytes = self.height.serialize();
3195 let mut request0 = vec![
3196 extension_information.major_opcode,
3197 PUT_IMAGE_REQUEST,
3198 0,
3199 0,
3200 port_bytes[0],
3201 port_bytes[1],
3202 port_bytes[2],
3203 port_bytes[3],
3204 drawable_bytes[0],
3205 drawable_bytes[1],
3206 drawable_bytes[2],
3207 drawable_bytes[3],
3208 gc_bytes[0],
3209 gc_bytes[1],
3210 gc_bytes[2],
3211 gc_bytes[3],
3212 id_bytes[0],
3213 id_bytes[1],
3214 id_bytes[2],
3215 id_bytes[3],
3216 src_x_bytes[0],
3217 src_x_bytes[1],
3218 src_y_bytes[0],
3219 src_y_bytes[1],
3220 src_w_bytes[0],
3221 src_w_bytes[1],
3222 src_h_bytes[0],
3223 src_h_bytes[1],
3224 drw_x_bytes[0],
3225 drw_x_bytes[1],
3226 drw_y_bytes[0],
3227 drw_y_bytes[1],
3228 drw_w_bytes[0],
3229 drw_w_bytes[1],
3230 drw_h_bytes[0],
3231 drw_h_bytes[1],
3232 width_bytes[0],
3233 width_bytes[1],
3234 height_bytes[0],
3235 height_bytes[1],
3236 ];
3237 let length_so_far = length_so_far + request0.len();
3238 let length_so_far = length_so_far + self.data.len();
3239 let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4];
3240 let length_so_far = length_so_far + padding0.len();
3241 assert_eq!(length_so_far % 4, 0);
3242 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3243 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3244 Ok((vec![request0.into(), self.data, padding0.into()], vec![]))
3245 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3246 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3247 where
3248 Conn: RequestConnection + ?Sized,
3249 {
3250 let (bytes, fds) = self.serialize(conn)?;
3251 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3252 conn.send_request_without_reply(&slices, fds)
3253 }
3254 /// 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>3255 pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result<Self, ParseError> {
3256 if header.minor_opcode != PUT_IMAGE_REQUEST {
3257 return Err(ParseError::InvalidValue);
3258 }
3259 let (port, remaining) = Port::try_parse(value)?;
3260 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
3261 let (gc, remaining) = xproto::Gcontext::try_parse(remaining)?;
3262 let (id, remaining) = u32::try_parse(remaining)?;
3263 let (src_x, remaining) = i16::try_parse(remaining)?;
3264 let (src_y, remaining) = i16::try_parse(remaining)?;
3265 let (src_w, remaining) = u16::try_parse(remaining)?;
3266 let (src_h, remaining) = u16::try_parse(remaining)?;
3267 let (drw_x, remaining) = i16::try_parse(remaining)?;
3268 let (drw_y, remaining) = i16::try_parse(remaining)?;
3269 let (drw_w, remaining) = u16::try_parse(remaining)?;
3270 let (drw_h, remaining) = u16::try_parse(remaining)?;
3271 let (width, remaining) = u16::try_parse(remaining)?;
3272 let (height, remaining) = u16::try_parse(remaining)?;
3273 let (data, remaining) = remaining.split_at(remaining.len());
3274 let _ = remaining;
3275 Ok(PutImageRequest {
3276 port,
3277 drawable,
3278 gc,
3279 id,
3280 src_x,
3281 src_y,
3282 src_w,
3283 src_h,
3284 drw_x,
3285 drw_y,
3286 drw_w,
3287 drw_h,
3288 width,
3289 height,
3290 data: Cow::Borrowed(data),
3291 })
3292 }
3293 /// Clone all borrowed data in this PutImageRequest.
into_owned(self) -> PutImageRequest<'static>3294 pub fn into_owned(self) -> PutImageRequest<'static> {
3295 PutImageRequest {
3296 port: self.port,
3297 drawable: self.drawable,
3298 gc: self.gc,
3299 id: self.id,
3300 src_x: self.src_x,
3301 src_y: self.src_y,
3302 src_w: self.src_w,
3303 src_h: self.src_h,
3304 drw_x: self.drw_x,
3305 drw_y: self.drw_y,
3306 drw_w: self.drw_w,
3307 drw_h: self.drw_h,
3308 width: self.width,
3309 height: self.height,
3310 data: Cow::Owned(self.data.into_owned()),
3311 }
3312 }
3313 }
3314 impl<'input> Request for PutImageRequest<'input> {
3315 type Reply = ();
3316 }
put_image<'c, 'input, Conn>(conn: &'c Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, id: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3317 pub fn put_image<'c, 'input, Conn>(conn: &'c Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, id: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
3318 where
3319 Conn: RequestConnection + ?Sized,
3320 {
3321 let request0 = PutImageRequest {
3322 port,
3323 drawable,
3324 gc,
3325 id,
3326 src_x,
3327 src_y,
3328 src_w,
3329 src_h,
3330 drw_x,
3331 drw_y,
3332 drw_w,
3333 drw_h,
3334 width,
3335 height,
3336 data: Cow::Borrowed(data),
3337 };
3338 request0.send(conn)
3339 }
3340
3341 /// Opcode for the ShmPutImage request
3342 pub const SHM_PUT_IMAGE_REQUEST: u8 = 19;
3343 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
3344 pub struct ShmPutImageRequest {
3345 pub port: Port,
3346 pub drawable: xproto::Drawable,
3347 pub gc: xproto::Gcontext,
3348 pub shmseg: shm::Seg,
3349 pub id: u32,
3350 pub offset: u32,
3351 pub src_x: i16,
3352 pub src_y: i16,
3353 pub src_w: u16,
3354 pub src_h: u16,
3355 pub drw_x: i16,
3356 pub drw_y: i16,
3357 pub drw_w: u16,
3358 pub drw_h: u16,
3359 pub width: u16,
3360 pub height: u16,
3361 pub send_event: u8,
3362 }
3363 impl ShmPutImageRequest {
3364 /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,3365 fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
3366 where
3367 Conn: RequestConnection + ?Sized,
3368 {
3369 let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
3370 .ok_or(ConnectionError::UnsupportedExtension)?;
3371 let length_so_far = 0;
3372 let port_bytes = self.port.serialize();
3373 let drawable_bytes = self.drawable.serialize();
3374 let gc_bytes = self.gc.serialize();
3375 let shmseg_bytes = self.shmseg.serialize();
3376 let id_bytes = self.id.serialize();
3377 let offset_bytes = self.offset.serialize();
3378 let src_x_bytes = self.src_x.serialize();
3379 let src_y_bytes = self.src_y.serialize();
3380 let src_w_bytes = self.src_w.serialize();
3381 let src_h_bytes = self.src_h.serialize();
3382 let drw_x_bytes = self.drw_x.serialize();
3383 let drw_y_bytes = self.drw_y.serialize();
3384 let drw_w_bytes = self.drw_w.serialize();
3385 let drw_h_bytes = self.drw_h.serialize();
3386 let width_bytes = self.width.serialize();
3387 let height_bytes = self.height.serialize();
3388 let send_event_bytes = self.send_event.serialize();
3389 let mut request0 = vec![
3390 extension_information.major_opcode,
3391 SHM_PUT_IMAGE_REQUEST,
3392 0,
3393 0,
3394 port_bytes[0],
3395 port_bytes[1],
3396 port_bytes[2],
3397 port_bytes[3],
3398 drawable_bytes[0],
3399 drawable_bytes[1],
3400 drawable_bytes[2],
3401 drawable_bytes[3],
3402 gc_bytes[0],
3403 gc_bytes[1],
3404 gc_bytes[2],
3405 gc_bytes[3],
3406 shmseg_bytes[0],
3407 shmseg_bytes[1],
3408 shmseg_bytes[2],
3409 shmseg_bytes[3],
3410 id_bytes[0],
3411 id_bytes[1],
3412 id_bytes[2],
3413 id_bytes[3],
3414 offset_bytes[0],
3415 offset_bytes[1],
3416 offset_bytes[2],
3417 offset_bytes[3],
3418 src_x_bytes[0],
3419 src_x_bytes[1],
3420 src_y_bytes[0],
3421 src_y_bytes[1],
3422 src_w_bytes[0],
3423 src_w_bytes[1],
3424 src_h_bytes[0],
3425 src_h_bytes[1],
3426 drw_x_bytes[0],
3427 drw_x_bytes[1],
3428 drw_y_bytes[0],
3429 drw_y_bytes[1],
3430 drw_w_bytes[0],
3431 drw_w_bytes[1],
3432 drw_h_bytes[0],
3433 drw_h_bytes[1],
3434 width_bytes[0],
3435 width_bytes[1],
3436 height_bytes[0],
3437 height_bytes[1],
3438 send_event_bytes[0],
3439 0,
3440 0,
3441 0,
3442 ];
3443 let length_so_far = length_so_far + request0.len();
3444 assert_eq!(length_so_far % 4, 0);
3445 let length = u16::try_from(length_so_far / 4).unwrap_or(0);
3446 request0[2..4].copy_from_slice(&length.to_ne_bytes());
3447 Ok((vec![request0.into()], vec![]))
3448 }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3449 pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3450 where
3451 Conn: RequestConnection + ?Sized,
3452 {
3453 let (bytes, fds) = self.serialize(conn)?;
3454 let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
3455 conn.send_request_without_reply(&slices, fds)
3456 }
3457 /// 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>3458 pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
3459 if header.minor_opcode != SHM_PUT_IMAGE_REQUEST {
3460 return Err(ParseError::InvalidValue);
3461 }
3462 let (port, remaining) = Port::try_parse(value)?;
3463 let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
3464 let (gc, remaining) = xproto::Gcontext::try_parse(remaining)?;
3465 let (shmseg, remaining) = shm::Seg::try_parse(remaining)?;
3466 let (id, remaining) = u32::try_parse(remaining)?;
3467 let (offset, remaining) = u32::try_parse(remaining)?;
3468 let (src_x, remaining) = i16::try_parse(remaining)?;
3469 let (src_y, remaining) = i16::try_parse(remaining)?;
3470 let (src_w, remaining) = u16::try_parse(remaining)?;
3471 let (src_h, remaining) = u16::try_parse(remaining)?;
3472 let (drw_x, remaining) = i16::try_parse(remaining)?;
3473 let (drw_y, remaining) = i16::try_parse(remaining)?;
3474 let (drw_w, remaining) = u16::try_parse(remaining)?;
3475 let (drw_h, remaining) = u16::try_parse(remaining)?;
3476 let (width, remaining) = u16::try_parse(remaining)?;
3477 let (height, remaining) = u16::try_parse(remaining)?;
3478 let (send_event, remaining) = u8::try_parse(remaining)?;
3479 let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
3480 let _ = remaining;
3481 Ok(ShmPutImageRequest {
3482 port,
3483 drawable,
3484 gc,
3485 shmseg,
3486 id,
3487 offset,
3488 src_x,
3489 src_y,
3490 src_w,
3491 src_h,
3492 drw_x,
3493 drw_y,
3494 drw_w,
3495 drw_h,
3496 width,
3497 height,
3498 send_event,
3499 })
3500 }
3501 }
3502 impl Request for ShmPutImageRequest {
3503 type Reply = ();
3504 }
shm_put_image<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, shmseg: shm::Seg, id: u32, offset: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, send_event: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,3505 pub fn shm_put_image<Conn>(conn: &Conn, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, shmseg: shm::Seg, id: u32, offset: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, send_event: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError>
3506 where
3507 Conn: RequestConnection + ?Sized,
3508 {
3509 let request0 = ShmPutImageRequest {
3510 port,
3511 drawable,
3512 gc,
3513 shmseg,
3514 id,
3515 offset,
3516 src_x,
3517 src_y,
3518 src_w,
3519 src_h,
3520 drw_x,
3521 drw_y,
3522 drw_w,
3523 drw_h,
3524 width,
3525 height,
3526 send_event,
3527 };
3528 request0.send(conn)
3529 }
3530
3531 /// Extension trait defining the requests of this extension.
3532 pub trait ConnectionExt: RequestConnection {
xv_query_extension(&self) -> Result<Cookie<'_, Self, QueryExtensionReply>, ConnectionError>3533 fn xv_query_extension(&self) -> Result<Cookie<'_, Self, QueryExtensionReply>, ConnectionError>
3534 {
3535 query_extension(self)
3536 }
xv_query_adaptors(&self, window: xproto::Window) -> Result<Cookie<'_, Self, QueryAdaptorsReply>, ConnectionError>3537 fn xv_query_adaptors(&self, window: xproto::Window) -> Result<Cookie<'_, Self, QueryAdaptorsReply>, ConnectionError>
3538 {
3539 query_adaptors(self, window)
3540 }
xv_query_encodings(&self, port: Port) -> Result<Cookie<'_, Self, QueryEncodingsReply>, ConnectionError>3541 fn xv_query_encodings(&self, port: Port) -> Result<Cookie<'_, Self, QueryEncodingsReply>, ConnectionError>
3542 {
3543 query_encodings(self, port)
3544 }
xv_grab_port<A>(&self, port: Port, time: A) -> Result<Cookie<'_, Self, GrabPortReply>, ConnectionError> where A: Into<xproto::Timestamp>,3545 fn xv_grab_port<A>(&self, port: Port, time: A) -> Result<Cookie<'_, Self, GrabPortReply>, ConnectionError>
3546 where
3547 A: Into<xproto::Timestamp>,
3548 {
3549 grab_port(self, port, time)
3550 }
xv_ungrab_port<A>(&self, port: Port, time: A) -> Result<VoidCookie<'_, Self>, ConnectionError> where A: Into<xproto::Timestamp>,3551 fn xv_ungrab_port<A>(&self, port: Port, time: A) -> Result<VoidCookie<'_, Self>, ConnectionError>
3552 where
3553 A: Into<xproto::Timestamp>,
3554 {
3555 ungrab_port(self, port, time)
3556 }
xv_put_video(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>3557 fn xv_put_video(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
3558 {
3559 put_video(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h)
3560 }
xv_put_still(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>3561 fn xv_put_still(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
3562 {
3563 put_still(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h)
3564 }
xv_get_video(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>3565 fn xv_get_video(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
3566 {
3567 get_video(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h)
3568 }
xv_get_still(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>3569 fn xv_get_still(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, vid_x: i16, vid_y: i16, vid_w: u16, vid_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16) -> Result<VoidCookie<'_, Self>, ConnectionError>
3570 {
3571 get_still(self, port, drawable, gc, vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h)
3572 }
xv_stop_video(&self, port: Port, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Self>, ConnectionError>3573 fn xv_stop_video(&self, port: Port, drawable: xproto::Drawable) -> Result<VoidCookie<'_, Self>, ConnectionError>
3574 {
3575 stop_video(self, port, drawable)
3576 }
xv_select_video_notify(&self, drawable: xproto::Drawable, onoff: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>3577 fn xv_select_video_notify(&self, drawable: xproto::Drawable, onoff: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
3578 {
3579 select_video_notify(self, drawable, onoff)
3580 }
xv_select_port_notify(&self, port: Port, onoff: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>3581 fn xv_select_port_notify(&self, port: Port, onoff: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
3582 {
3583 select_port_notify(self, port, onoff)
3584 }
xv_query_best_size(&self, port: Port, vid_w: u16, vid_h: u16, drw_w: u16, drw_h: u16, motion: bool) -> Result<Cookie<'_, Self, QueryBestSizeReply>, ConnectionError>3585 fn xv_query_best_size(&self, port: Port, vid_w: u16, vid_h: u16, drw_w: u16, drw_h: u16, motion: bool) -> Result<Cookie<'_, Self, QueryBestSizeReply>, ConnectionError>
3586 {
3587 query_best_size(self, port, vid_w, vid_h, drw_w, drw_h, motion)
3588 }
xv_set_port_attribute(&self, port: Port, attribute: xproto::Atom, value: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>3589 fn xv_set_port_attribute(&self, port: Port, attribute: xproto::Atom, value: i32) -> Result<VoidCookie<'_, Self>, ConnectionError>
3590 {
3591 set_port_attribute(self, port, attribute, value)
3592 }
xv_get_port_attribute(&self, port: Port, attribute: xproto::Atom) -> Result<Cookie<'_, Self, GetPortAttributeReply>, ConnectionError>3593 fn xv_get_port_attribute(&self, port: Port, attribute: xproto::Atom) -> Result<Cookie<'_, Self, GetPortAttributeReply>, ConnectionError>
3594 {
3595 get_port_attribute(self, port, attribute)
3596 }
xv_query_port_attributes(&self, port: Port) -> Result<Cookie<'_, Self, QueryPortAttributesReply>, ConnectionError>3597 fn xv_query_port_attributes(&self, port: Port) -> Result<Cookie<'_, Self, QueryPortAttributesReply>, ConnectionError>
3598 {
3599 query_port_attributes(self, port)
3600 }
xv_list_image_formats(&self, port: Port) -> Result<Cookie<'_, Self, ListImageFormatsReply>, ConnectionError>3601 fn xv_list_image_formats(&self, port: Port) -> Result<Cookie<'_, Self, ListImageFormatsReply>, ConnectionError>
3602 {
3603 list_image_formats(self, port)
3604 }
xv_query_image_attributes(&self, port: Port, id: u32, width: u16, height: u16) -> Result<Cookie<'_, Self, QueryImageAttributesReply>, ConnectionError>3605 fn xv_query_image_attributes(&self, port: Port, id: u32, width: u16, height: u16) -> Result<Cookie<'_, Self, QueryImageAttributesReply>, ConnectionError>
3606 {
3607 query_image_attributes(self, port, id, width, height)
3608 }
xv_put_image<'c, 'input>(&'c self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, id: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>3609 fn xv_put_image<'c, 'input>(&'c self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, id: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, data: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError>
3610 {
3611 put_image(self, port, drawable, gc, id, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, width, height, data)
3612 }
xv_shm_put_image(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, shmseg: shm::Seg, id: u32, offset: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, send_event: u8) -> Result<VoidCookie<'_, Self>, ConnectionError>3613 fn xv_shm_put_image(&self, port: Port, drawable: xproto::Drawable, gc: xproto::Gcontext, shmseg: shm::Seg, id: u32, offset: u32, src_x: i16, src_y: i16, src_w: u16, src_h: u16, drw_x: i16, drw_y: i16, drw_w: u16, drw_h: u16, width: u16, height: u16, send_event: u8) -> Result<VoidCookie<'_, Self>, ConnectionError>
3614 {
3615 shm_put_image(self, port, drawable, gc, shmseg, id, offset, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, width, height, send_event)
3616 }
3617 }
3618
3619 impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
3620