1 // This file contains generated code. Do not edit directly.
2 // To regenerate this, run 'make'.
3 
4 //! Bindings to the `Shm` X11 extension.
5 
6 #![allow(clippy::too_many_arguments)]
7 
8 #[allow(unused_imports)]
9 use std::borrow::Cow;
10 use std::convert::TryFrom;
11 #[allow(unused_imports)]
12 use std::convert::TryInto;
13 use std::io::IoSlice;
14 #[allow(unused_imports)]
15 use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum};
16 #[allow(unused_imports)]
17 use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize};
18 use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection};
19 #[allow(unused_imports)]
20 use crate::cookie::{Cookie, CookieWithFds, VoidCookie};
21 use crate::errors::{ConnectionError, ParseError};
22 use super::xproto;
23 
24 /// The X11 name of the extension for QueryExtension
25 pub const X11_EXTENSION_NAME: &str = "MIT-SHM";
26 
27 /// The version number of this extension that this client library supports.
28 ///
29 /// This constant contains the version number of this extension that is supported
30 /// by this build of x11rb. For most things, it does not make sense to use this
31 /// information. If you need to send a `QueryVersion`, it is recommended to instead
32 /// send the maximum version of the extension that you need.
33 pub const X11_XML_VERSION: (u32, u32) = (1, 2);
34 
35 pub type Seg = u32;
36 
37 /// Opcode for the Completion event
38 pub const COMPLETION_EVENT: u8 = 0;
39 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
40 pub struct CompletionEvent {
41     pub response_type: u8,
42     pub sequence: u16,
43     pub drawable: xproto::Drawable,
44     pub minor_event: u16,
45     pub major_event: u8,
46     pub shmseg: Seg,
47     pub offset: u32,
48 }
49 impl TryParse for CompletionEvent {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>50     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
51         let remaining = initial_value;
52         let (response_type, remaining) = u8::try_parse(remaining)?;
53         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
54         let (sequence, remaining) = u16::try_parse(remaining)?;
55         let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
56         let (minor_event, remaining) = u16::try_parse(remaining)?;
57         let (major_event, remaining) = u8::try_parse(remaining)?;
58         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
59         let (shmseg, remaining) = Seg::try_parse(remaining)?;
60         let (offset, remaining) = u32::try_parse(remaining)?;
61         let result = CompletionEvent { response_type, sequence, drawable, minor_event, major_event, shmseg, offset };
62         let _ = remaining;
63         let remaining = initial_value.get(32..)
64             .ok_or(ParseError::InsufficientData)?;
65         Ok((result, remaining))
66     }
67 }
68 impl From<&CompletionEvent> for [u8; 32] {
from(input: &CompletionEvent) -> Self69     fn from(input: &CompletionEvent) -> Self {
70         let response_type_bytes = input.response_type.serialize();
71         let sequence_bytes = input.sequence.serialize();
72         let drawable_bytes = input.drawable.serialize();
73         let minor_event_bytes = input.minor_event.serialize();
74         let major_event_bytes = input.major_event.serialize();
75         let shmseg_bytes = input.shmseg.serialize();
76         let offset_bytes = input.offset.serialize();
77         [
78             response_type_bytes[0],
79             0,
80             sequence_bytes[0],
81             sequence_bytes[1],
82             drawable_bytes[0],
83             drawable_bytes[1],
84             drawable_bytes[2],
85             drawable_bytes[3],
86             minor_event_bytes[0],
87             minor_event_bytes[1],
88             major_event_bytes[0],
89             0,
90             shmseg_bytes[0],
91             shmseg_bytes[1],
92             shmseg_bytes[2],
93             shmseg_bytes[3],
94             offset_bytes[0],
95             offset_bytes[1],
96             offset_bytes[2],
97             offset_bytes[3],
98             // trailing padding
99             0,
100             0,
101             0,
102             0,
103             0,
104             0,
105             0,
106             0,
107             0,
108             0,
109             0,
110             0,
111         ]
112     }
113 }
114 impl From<CompletionEvent> for [u8; 32] {
from(input: CompletionEvent) -> Self115     fn from(input: CompletionEvent) -> Self {
116         Self::from(&input)
117     }
118 }
119 
120 /// Opcode for the BadSeg error
121 pub const BAD_SEG_ERROR: u8 = 0;
122 
123 /// Opcode for the QueryVersion request
124 pub const QUERY_VERSION_REQUEST: u8 = 0;
125 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
126 pub struct QueryVersionRequest;
127 impl QueryVersionRequest {
128     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,129     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
130     where
131         Conn: RequestConnection + ?Sized,
132     {
133         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
134             .ok_or(ConnectionError::UnsupportedExtension)?;
135         let length_so_far = 0;
136         let mut request0 = vec![
137             extension_information.major_opcode,
138             QUERY_VERSION_REQUEST,
139             0,
140             0,
141         ];
142         let length_so_far = length_so_far + request0.len();
143         assert_eq!(length_so_far % 4, 0);
144         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
145         request0[2..4].copy_from_slice(&length.to_ne_bytes());
146         Ok((vec![request0.into()], vec![]))
147     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,148     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
149     where
150         Conn: RequestConnection + ?Sized,
151     {
152         let (bytes, fds) = self.serialize(conn)?;
153         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
154         conn.send_request_with_reply(&slices, fds)
155     }
156     /// 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>157     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
158         if header.minor_opcode != QUERY_VERSION_REQUEST {
159             return Err(ParseError::InvalidValue);
160         }
161         let _ = value;
162         Ok(QueryVersionRequest
163         )
164     }
165 }
166 impl Request for QueryVersionRequest {
167     type Reply = QueryVersionReply;
168 }
query_version<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> where Conn: RequestConnection + ?Sized,169 pub fn query_version<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
170 where
171     Conn: RequestConnection + ?Sized,
172 {
173     let request0 = QueryVersionRequest;
174     request0.send(conn)
175 }
176 
177 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
178 pub struct QueryVersionReply {
179     pub shared_pixmaps: bool,
180     pub sequence: u16,
181     pub length: u32,
182     pub major_version: u16,
183     pub minor_version: u16,
184     pub uid: u16,
185     pub gid: u16,
186     pub pixmap_format: u8,
187 }
188 impl TryParse for QueryVersionReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>189     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
190         let remaining = initial_value;
191         let (response_type, remaining) = u8::try_parse(remaining)?;
192         let (shared_pixmaps, remaining) = bool::try_parse(remaining)?;
193         let (sequence, remaining) = u16::try_parse(remaining)?;
194         let (length, remaining) = u32::try_parse(remaining)?;
195         let (major_version, remaining) = u16::try_parse(remaining)?;
196         let (minor_version, remaining) = u16::try_parse(remaining)?;
197         let (uid, remaining) = u16::try_parse(remaining)?;
198         let (gid, remaining) = u16::try_parse(remaining)?;
199         let (pixmap_format, remaining) = u8::try_parse(remaining)?;
200         let remaining = remaining.get(15..).ok_or(ParseError::InsufficientData)?;
201         if response_type != 1 {
202             return Err(ParseError::InvalidValue);
203         }
204         let result = QueryVersionReply { shared_pixmaps, sequence, length, major_version, minor_version, uid, gid, pixmap_format };
205         let _ = remaining;
206         let remaining = initial_value.get(32 + length as usize * 4..)
207             .ok_or(ParseError::InsufficientData)?;
208         Ok((result, remaining))
209     }
210 }
211 
212 /// Opcode for the Attach request
213 pub const ATTACH_REQUEST: u8 = 1;
214 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
215 pub struct AttachRequest {
216     pub shmseg: Seg,
217     pub shmid: u32,
218     pub read_only: bool,
219 }
220 impl AttachRequest {
221     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,222     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
223     where
224         Conn: RequestConnection + ?Sized,
225     {
226         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
227             .ok_or(ConnectionError::UnsupportedExtension)?;
228         let length_so_far = 0;
229         let shmseg_bytes = self.shmseg.serialize();
230         let shmid_bytes = self.shmid.serialize();
231         let read_only_bytes = self.read_only.serialize();
232         let mut request0 = vec![
233             extension_information.major_opcode,
234             ATTACH_REQUEST,
235             0,
236             0,
237             shmseg_bytes[0],
238             shmseg_bytes[1],
239             shmseg_bytes[2],
240             shmseg_bytes[3],
241             shmid_bytes[0],
242             shmid_bytes[1],
243             shmid_bytes[2],
244             shmid_bytes[3],
245             read_only_bytes[0],
246             0,
247             0,
248             0,
249         ];
250         let length_so_far = length_so_far + request0.len();
251         assert_eq!(length_so_far % 4, 0);
252         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
253         request0[2..4].copy_from_slice(&length.to_ne_bytes());
254         Ok((vec![request0.into()], vec![]))
255     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,256     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
257     where
258         Conn: RequestConnection + ?Sized,
259     {
260         let (bytes, fds) = self.serialize(conn)?;
261         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
262         conn.send_request_without_reply(&slices, fds)
263     }
264     /// 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>265     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
266         if header.minor_opcode != ATTACH_REQUEST {
267             return Err(ParseError::InvalidValue);
268         }
269         let (shmseg, remaining) = Seg::try_parse(value)?;
270         let (shmid, remaining) = u32::try_parse(remaining)?;
271         let (read_only, remaining) = bool::try_parse(remaining)?;
272         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
273         let _ = remaining;
274         Ok(AttachRequest {
275             shmseg,
276             shmid,
277             read_only,
278         })
279     }
280 }
281 impl Request for AttachRequest {
282     type Reply = ();
283 }
attach<Conn>(conn: &Conn, shmseg: Seg, shmid: u32, read_only: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,284 pub fn attach<Conn>(conn: &Conn, shmseg: Seg, shmid: u32, read_only: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
285 where
286     Conn: RequestConnection + ?Sized,
287 {
288     let request0 = AttachRequest {
289         shmseg,
290         shmid,
291         read_only,
292     };
293     request0.send(conn)
294 }
295 
296 /// Opcode for the Detach request
297 pub const DETACH_REQUEST: u8 = 2;
298 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
299 pub struct DetachRequest {
300     pub shmseg: Seg,
301 }
302 impl DetachRequest {
303     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,304     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
305     where
306         Conn: RequestConnection + ?Sized,
307     {
308         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
309             .ok_or(ConnectionError::UnsupportedExtension)?;
310         let length_so_far = 0;
311         let shmseg_bytes = self.shmseg.serialize();
312         let mut request0 = vec![
313             extension_information.major_opcode,
314             DETACH_REQUEST,
315             0,
316             0,
317             shmseg_bytes[0],
318             shmseg_bytes[1],
319             shmseg_bytes[2],
320             shmseg_bytes[3],
321         ];
322         let length_so_far = length_so_far + request0.len();
323         assert_eq!(length_so_far % 4, 0);
324         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
325         request0[2..4].copy_from_slice(&length.to_ne_bytes());
326         Ok((vec![request0.into()], vec![]))
327     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,328     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
329     where
330         Conn: RequestConnection + ?Sized,
331     {
332         let (bytes, fds) = self.serialize(conn)?;
333         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
334         conn.send_request_without_reply(&slices, fds)
335     }
336     /// 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>337     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
338         if header.minor_opcode != DETACH_REQUEST {
339             return Err(ParseError::InvalidValue);
340         }
341         let (shmseg, remaining) = Seg::try_parse(value)?;
342         let _ = remaining;
343         Ok(DetachRequest {
344             shmseg,
345         })
346     }
347 }
348 impl Request for DetachRequest {
349     type Reply = ();
350 }
detach<Conn>(conn: &Conn, shmseg: Seg) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,351 pub fn detach<Conn>(conn: &Conn, shmseg: Seg) -> Result<VoidCookie<'_, Conn>, ConnectionError>
352 where
353     Conn: RequestConnection + ?Sized,
354 {
355     let request0 = DetachRequest {
356         shmseg,
357     };
358     request0.send(conn)
359 }
360 
361 /// Opcode for the PutImage request
362 pub const PUT_IMAGE_REQUEST: u8 = 3;
363 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
364 pub struct PutImageRequest {
365     pub drawable: xproto::Drawable,
366     pub gc: xproto::Gcontext,
367     pub total_width: u16,
368     pub total_height: u16,
369     pub src_x: u16,
370     pub src_y: u16,
371     pub src_width: u16,
372     pub src_height: u16,
373     pub dst_x: i16,
374     pub dst_y: i16,
375     pub depth: u8,
376     pub format: u8,
377     pub send_event: bool,
378     pub shmseg: Seg,
379     pub offset: u32,
380 }
381 impl PutImageRequest {
382     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,383     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
384     where
385         Conn: RequestConnection + ?Sized,
386     {
387         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
388             .ok_or(ConnectionError::UnsupportedExtension)?;
389         let length_so_far = 0;
390         let drawable_bytes = self.drawable.serialize();
391         let gc_bytes = self.gc.serialize();
392         let total_width_bytes = self.total_width.serialize();
393         let total_height_bytes = self.total_height.serialize();
394         let src_x_bytes = self.src_x.serialize();
395         let src_y_bytes = self.src_y.serialize();
396         let src_width_bytes = self.src_width.serialize();
397         let src_height_bytes = self.src_height.serialize();
398         let dst_x_bytes = self.dst_x.serialize();
399         let dst_y_bytes = self.dst_y.serialize();
400         let depth_bytes = self.depth.serialize();
401         let format_bytes = self.format.serialize();
402         let send_event_bytes = self.send_event.serialize();
403         let shmseg_bytes = self.shmseg.serialize();
404         let offset_bytes = self.offset.serialize();
405         let mut request0 = vec![
406             extension_information.major_opcode,
407             PUT_IMAGE_REQUEST,
408             0,
409             0,
410             drawable_bytes[0],
411             drawable_bytes[1],
412             drawable_bytes[2],
413             drawable_bytes[3],
414             gc_bytes[0],
415             gc_bytes[1],
416             gc_bytes[2],
417             gc_bytes[3],
418             total_width_bytes[0],
419             total_width_bytes[1],
420             total_height_bytes[0],
421             total_height_bytes[1],
422             src_x_bytes[0],
423             src_x_bytes[1],
424             src_y_bytes[0],
425             src_y_bytes[1],
426             src_width_bytes[0],
427             src_width_bytes[1],
428             src_height_bytes[0],
429             src_height_bytes[1],
430             dst_x_bytes[0],
431             dst_x_bytes[1],
432             dst_y_bytes[0],
433             dst_y_bytes[1],
434             depth_bytes[0],
435             format_bytes[0],
436             send_event_bytes[0],
437             0,
438             shmseg_bytes[0],
439             shmseg_bytes[1],
440             shmseg_bytes[2],
441             shmseg_bytes[3],
442             offset_bytes[0],
443             offset_bytes[1],
444             offset_bytes[2],
445             offset_bytes[3],
446         ];
447         let length_so_far = length_so_far + request0.len();
448         assert_eq!(length_so_far % 4, 0);
449         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
450         request0[2..4].copy_from_slice(&length.to_ne_bytes());
451         Ok((vec![request0.into()], vec![]))
452     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,453     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
454     where
455         Conn: RequestConnection + ?Sized,
456     {
457         let (bytes, fds) = self.serialize(conn)?;
458         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
459         conn.send_request_without_reply(&slices, fds)
460     }
461     /// 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>462     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
463         if header.minor_opcode != PUT_IMAGE_REQUEST {
464             return Err(ParseError::InvalidValue);
465         }
466         let (drawable, remaining) = xproto::Drawable::try_parse(value)?;
467         let (gc, remaining) = xproto::Gcontext::try_parse(remaining)?;
468         let (total_width, remaining) = u16::try_parse(remaining)?;
469         let (total_height, remaining) = u16::try_parse(remaining)?;
470         let (src_x, remaining) = u16::try_parse(remaining)?;
471         let (src_y, remaining) = u16::try_parse(remaining)?;
472         let (src_width, remaining) = u16::try_parse(remaining)?;
473         let (src_height, remaining) = u16::try_parse(remaining)?;
474         let (dst_x, remaining) = i16::try_parse(remaining)?;
475         let (dst_y, remaining) = i16::try_parse(remaining)?;
476         let (depth, remaining) = u8::try_parse(remaining)?;
477         let (format, remaining) = u8::try_parse(remaining)?;
478         let (send_event, remaining) = bool::try_parse(remaining)?;
479         let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
480         let (shmseg, remaining) = Seg::try_parse(remaining)?;
481         let (offset, remaining) = u32::try_parse(remaining)?;
482         let _ = remaining;
483         Ok(PutImageRequest {
484             drawable,
485             gc,
486             total_width,
487             total_height,
488             src_x,
489             src_y,
490             src_width,
491             src_height,
492             dst_x,
493             dst_y,
494             depth,
495             format,
496             send_event,
497             shmseg,
498             offset,
499         })
500     }
501 }
502 impl Request for PutImageRequest {
503     type Reply = ();
504 }
put_image<Conn>(conn: &Conn, drawable: xproto::Drawable, gc: xproto::Gcontext, total_width: u16, total_height: u16, src_x: u16, src_y: u16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16, depth: u8, format: u8, send_event: bool, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,505 pub fn put_image<Conn>(conn: &Conn, drawable: xproto::Drawable, gc: xproto::Gcontext, total_width: u16, total_height: u16, src_x: u16, src_y: u16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16, depth: u8, format: u8, send_event: bool, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
506 where
507     Conn: RequestConnection + ?Sized,
508 {
509     let request0 = PutImageRequest {
510         drawable,
511         gc,
512         total_width,
513         total_height,
514         src_x,
515         src_y,
516         src_width,
517         src_height,
518         dst_x,
519         dst_y,
520         depth,
521         format,
522         send_event,
523         shmseg,
524         offset,
525     };
526     request0.send(conn)
527 }
528 
529 /// Opcode for the GetImage request
530 pub const GET_IMAGE_REQUEST: u8 = 4;
531 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
532 pub struct GetImageRequest {
533     pub drawable: xproto::Drawable,
534     pub x: i16,
535     pub y: i16,
536     pub width: u16,
537     pub height: u16,
538     pub plane_mask: u32,
539     pub format: u8,
540     pub shmseg: Seg,
541     pub offset: u32,
542 }
543 impl GetImageRequest {
544     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,545     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
546     where
547         Conn: RequestConnection + ?Sized,
548     {
549         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
550             .ok_or(ConnectionError::UnsupportedExtension)?;
551         let length_so_far = 0;
552         let drawable_bytes = self.drawable.serialize();
553         let x_bytes = self.x.serialize();
554         let y_bytes = self.y.serialize();
555         let width_bytes = self.width.serialize();
556         let height_bytes = self.height.serialize();
557         let plane_mask_bytes = self.plane_mask.serialize();
558         let format_bytes = self.format.serialize();
559         let shmseg_bytes = self.shmseg.serialize();
560         let offset_bytes = self.offset.serialize();
561         let mut request0 = vec![
562             extension_information.major_opcode,
563             GET_IMAGE_REQUEST,
564             0,
565             0,
566             drawable_bytes[0],
567             drawable_bytes[1],
568             drawable_bytes[2],
569             drawable_bytes[3],
570             x_bytes[0],
571             x_bytes[1],
572             y_bytes[0],
573             y_bytes[1],
574             width_bytes[0],
575             width_bytes[1],
576             height_bytes[0],
577             height_bytes[1],
578             plane_mask_bytes[0],
579             plane_mask_bytes[1],
580             plane_mask_bytes[2],
581             plane_mask_bytes[3],
582             format_bytes[0],
583             0,
584             0,
585             0,
586             shmseg_bytes[0],
587             shmseg_bytes[1],
588             shmseg_bytes[2],
589             shmseg_bytes[3],
590             offset_bytes[0],
591             offset_bytes[1],
592             offset_bytes[2],
593             offset_bytes[3],
594         ];
595         let length_so_far = length_so_far + request0.len();
596         assert_eq!(length_so_far % 4, 0);
597         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
598         request0[2..4].copy_from_slice(&length.to_ne_bytes());
599         Ok((vec![request0.into()], vec![]))
600     }
send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetImageReply>, ConnectionError> where Conn: RequestConnection + ?Sized,601     pub fn send<Conn>(self, conn: &Conn) -> Result<Cookie<'_, Conn, GetImageReply>, ConnectionError>
602     where
603         Conn: RequestConnection + ?Sized,
604     {
605         let (bytes, fds) = self.serialize(conn)?;
606         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
607         conn.send_request_with_reply(&slices, fds)
608     }
609     /// 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>610     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
611         if header.minor_opcode != GET_IMAGE_REQUEST {
612             return Err(ParseError::InvalidValue);
613         }
614         let (drawable, remaining) = xproto::Drawable::try_parse(value)?;
615         let (x, remaining) = i16::try_parse(remaining)?;
616         let (y, remaining) = i16::try_parse(remaining)?;
617         let (width, remaining) = u16::try_parse(remaining)?;
618         let (height, remaining) = u16::try_parse(remaining)?;
619         let (plane_mask, remaining) = u32::try_parse(remaining)?;
620         let (format, remaining) = u8::try_parse(remaining)?;
621         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
622         let (shmseg, remaining) = Seg::try_parse(remaining)?;
623         let (offset, remaining) = u32::try_parse(remaining)?;
624         let _ = remaining;
625         Ok(GetImageRequest {
626             drawable,
627             x,
628             y,
629             width,
630             height,
631             plane_mask,
632             format,
633             shmseg,
634             offset,
635         })
636     }
637 }
638 impl Request for GetImageRequest {
639     type Reply = GetImageReply;
640 }
get_image<Conn>(conn: &Conn, drawable: xproto::Drawable, x: i16, y: i16, width: u16, height: u16, plane_mask: u32, format: u8, shmseg: Seg, offset: u32) -> Result<Cookie<'_, Conn, GetImageReply>, ConnectionError> where Conn: RequestConnection + ?Sized,641 pub fn get_image<Conn>(conn: &Conn, drawable: xproto::Drawable, x: i16, y: i16, width: u16, height: u16, plane_mask: u32, format: u8, shmseg: Seg, offset: u32) -> Result<Cookie<'_, Conn, GetImageReply>, ConnectionError>
642 where
643     Conn: RequestConnection + ?Sized,
644 {
645     let request0 = GetImageRequest {
646         drawable,
647         x,
648         y,
649         width,
650         height,
651         plane_mask,
652         format,
653         shmseg,
654         offset,
655     };
656     request0.send(conn)
657 }
658 
659 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
660 pub struct GetImageReply {
661     pub depth: u8,
662     pub sequence: u16,
663     pub length: u32,
664     pub visual: xproto::Visualid,
665     pub size: u32,
666 }
667 impl TryParse for GetImageReply {
try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError>668     fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
669         let remaining = initial_value;
670         let (response_type, remaining) = u8::try_parse(remaining)?;
671         let (depth, remaining) = u8::try_parse(remaining)?;
672         let (sequence, remaining) = u16::try_parse(remaining)?;
673         let (length, remaining) = u32::try_parse(remaining)?;
674         let (visual, remaining) = xproto::Visualid::try_parse(remaining)?;
675         let (size, remaining) = u32::try_parse(remaining)?;
676         if response_type != 1 {
677             return Err(ParseError::InvalidValue);
678         }
679         let result = GetImageReply { depth, sequence, length, visual, size };
680         let _ = remaining;
681         let remaining = initial_value.get(32 + length as usize * 4..)
682             .ok_or(ParseError::InsufficientData)?;
683         Ok((result, remaining))
684     }
685 }
686 
687 /// Opcode for the CreatePixmap request
688 pub const CREATE_PIXMAP_REQUEST: u8 = 5;
689 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
690 pub struct CreatePixmapRequest {
691     pub pid: xproto::Pixmap,
692     pub drawable: xproto::Drawable,
693     pub width: u16,
694     pub height: u16,
695     pub depth: u8,
696     pub shmseg: Seg,
697     pub offset: u32,
698 }
699 impl CreatePixmapRequest {
700     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,701     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
702     where
703         Conn: RequestConnection + ?Sized,
704     {
705         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
706             .ok_or(ConnectionError::UnsupportedExtension)?;
707         let length_so_far = 0;
708         let pid_bytes = self.pid.serialize();
709         let drawable_bytes = self.drawable.serialize();
710         let width_bytes = self.width.serialize();
711         let height_bytes = self.height.serialize();
712         let depth_bytes = self.depth.serialize();
713         let shmseg_bytes = self.shmseg.serialize();
714         let offset_bytes = self.offset.serialize();
715         let mut request0 = vec![
716             extension_information.major_opcode,
717             CREATE_PIXMAP_REQUEST,
718             0,
719             0,
720             pid_bytes[0],
721             pid_bytes[1],
722             pid_bytes[2],
723             pid_bytes[3],
724             drawable_bytes[0],
725             drawable_bytes[1],
726             drawable_bytes[2],
727             drawable_bytes[3],
728             width_bytes[0],
729             width_bytes[1],
730             height_bytes[0],
731             height_bytes[1],
732             depth_bytes[0],
733             0,
734             0,
735             0,
736             shmseg_bytes[0],
737             shmseg_bytes[1],
738             shmseg_bytes[2],
739             shmseg_bytes[3],
740             offset_bytes[0],
741             offset_bytes[1],
742             offset_bytes[2],
743             offset_bytes[3],
744         ];
745         let length_so_far = length_so_far + request0.len();
746         assert_eq!(length_so_far % 4, 0);
747         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
748         request0[2..4].copy_from_slice(&length.to_ne_bytes());
749         Ok((vec![request0.into()], vec![]))
750     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,751     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
752     where
753         Conn: RequestConnection + ?Sized,
754     {
755         let (bytes, fds) = self.serialize(conn)?;
756         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
757         conn.send_request_without_reply(&slices, fds)
758     }
759     /// 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>760     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
761         if header.minor_opcode != CREATE_PIXMAP_REQUEST {
762             return Err(ParseError::InvalidValue);
763         }
764         let (pid, remaining) = xproto::Pixmap::try_parse(value)?;
765         let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?;
766         let (width, remaining) = u16::try_parse(remaining)?;
767         let (height, remaining) = u16::try_parse(remaining)?;
768         let (depth, remaining) = u8::try_parse(remaining)?;
769         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
770         let (shmseg, remaining) = Seg::try_parse(remaining)?;
771         let (offset, remaining) = u32::try_parse(remaining)?;
772         let _ = remaining;
773         Ok(CreatePixmapRequest {
774             pid,
775             drawable,
776             width,
777             height,
778             depth,
779             shmseg,
780             offset,
781         })
782     }
783 }
784 impl Request for CreatePixmapRequest {
785     type Reply = ();
786 }
create_pixmap<Conn>(conn: &Conn, pid: xproto::Pixmap, drawable: xproto::Drawable, width: u16, height: u16, depth: u8, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,787 pub fn create_pixmap<Conn>(conn: &Conn, pid: xproto::Pixmap, drawable: xproto::Drawable, width: u16, height: u16, depth: u8, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Conn>, ConnectionError>
788 where
789     Conn: RequestConnection + ?Sized,
790 {
791     let request0 = CreatePixmapRequest {
792         pid,
793         drawable,
794         width,
795         height,
796         depth,
797         shmseg,
798         offset,
799     };
800     request0.send(conn)
801 }
802 
803 /// Opcode for the AttachFd request
804 pub const ATTACH_FD_REQUEST: u8 = 6;
805 #[derive(Debug, PartialEq, Eq)]
806 pub struct AttachFdRequest {
807     pub shmseg: Seg,
808     pub shm_fd: RawFdContainer,
809     pub read_only: bool,
810 }
811 impl AttachFdRequest {
812     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,813     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
814     where
815         Conn: RequestConnection + ?Sized,
816     {
817         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
818             .ok_or(ConnectionError::UnsupportedExtension)?;
819         let length_so_far = 0;
820         let shmseg_bytes = self.shmseg.serialize();
821         let read_only_bytes = self.read_only.serialize();
822         let mut request0 = vec![
823             extension_information.major_opcode,
824             ATTACH_FD_REQUEST,
825             0,
826             0,
827             shmseg_bytes[0],
828             shmseg_bytes[1],
829             shmseg_bytes[2],
830             shmseg_bytes[3],
831             read_only_bytes[0],
832             0,
833             0,
834             0,
835         ];
836         let length_so_far = length_so_far + request0.len();
837         assert_eq!(length_so_far % 4, 0);
838         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
839         request0[2..4].copy_from_slice(&length.to_ne_bytes());
840         Ok((vec![request0.into()], vec![self.shm_fd]))
841     }
send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized,842     pub fn send<Conn>(self, conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
843     where
844         Conn: RequestConnection + ?Sized,
845     {
846         let (bytes, fds) = self.serialize(conn)?;
847         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
848         conn.send_request_without_reply(&slices, fds)
849     }
850     /// Parse this request given its header, its body, and any fds that go along with it
try_parse_request_fd(header: RequestHeader, value: &[u8], fds: &mut Vec<RawFdContainer>) -> Result<Self, ParseError>851     pub fn try_parse_request_fd(header: RequestHeader, value: &[u8], fds: &mut Vec<RawFdContainer>) -> Result<Self, ParseError> {
852         if header.minor_opcode != ATTACH_FD_REQUEST {
853             return Err(ParseError::InvalidValue);
854         }
855         let (shmseg, remaining) = Seg::try_parse(value)?;
856         if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) }
857         let shm_fd = fds.remove(0);
858         let (read_only, remaining) = bool::try_parse(remaining)?;
859         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
860         let _ = remaining;
861         Ok(AttachFdRequest {
862             shmseg,
863             shm_fd,
864             read_only,
865         })
866     }
867 }
868 impl Request for AttachFdRequest {
869     type Reply = ();
870 }
attach_fd<Conn, A>(conn: &Conn, shmseg: Seg, shm_fd: A, read_only: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> where Conn: RequestConnection + ?Sized, A: Into<RawFdContainer>,871 pub fn attach_fd<Conn, A>(conn: &Conn, shmseg: Seg, shm_fd: A, read_only: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError>
872 where
873     Conn: RequestConnection + ?Sized,
874     A: Into<RawFdContainer>,
875 {
876     let shm_fd: RawFdContainer = shm_fd.into();
877     let request0 = AttachFdRequest {
878         shmseg,
879         shm_fd,
880         read_only,
881     };
882     request0.send(conn)
883 }
884 
885 /// Opcode for the CreateSegment request
886 pub const CREATE_SEGMENT_REQUEST: u8 = 7;
887 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
888 pub struct CreateSegmentRequest {
889     pub shmseg: Seg,
890     pub size: u32,
891     pub read_only: bool,
892 }
893 impl CreateSegmentRequest {
894     /// Serialize this request into bytes for the provided connection
serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError> where Conn: RequestConnection + ?Sized,895     fn serialize<'input, Conn>(self, conn: &Conn) -> Result<BufWithFds<PiecewiseBuf<'input>>, ConnectionError>
896     where
897         Conn: RequestConnection + ?Sized,
898     {
899         let extension_information = conn.extension_information(X11_EXTENSION_NAME)?
900             .ok_or(ConnectionError::UnsupportedExtension)?;
901         let length_so_far = 0;
902         let shmseg_bytes = self.shmseg.serialize();
903         let size_bytes = self.size.serialize();
904         let read_only_bytes = self.read_only.serialize();
905         let mut request0 = vec![
906             extension_information.major_opcode,
907             CREATE_SEGMENT_REQUEST,
908             0,
909             0,
910             shmseg_bytes[0],
911             shmseg_bytes[1],
912             shmseg_bytes[2],
913             shmseg_bytes[3],
914             size_bytes[0],
915             size_bytes[1],
916             size_bytes[2],
917             size_bytes[3],
918             read_only_bytes[0],
919             0,
920             0,
921             0,
922         ];
923         let length_so_far = length_so_far + request0.len();
924         assert_eq!(length_so_far % 4, 0);
925         let length = u16::try_from(length_so_far / 4).unwrap_or(0);
926         request0[2..4].copy_from_slice(&length.to_ne_bytes());
927         Ok((vec![request0.into()], vec![]))
928     }
send<Conn>(self, conn: &Conn) -> Result<CookieWithFds<'_, Conn, CreateSegmentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,929     pub fn send<Conn>(self, conn: &Conn) -> Result<CookieWithFds<'_, Conn, CreateSegmentReply>, ConnectionError>
930     where
931         Conn: RequestConnection + ?Sized,
932     {
933         let (bytes, fds) = self.serialize(conn)?;
934         let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::<Vec<_>>();
935         conn.send_request_with_reply_with_fds(&slices, fds)
936     }
937     /// 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>938     pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
939         if header.minor_opcode != CREATE_SEGMENT_REQUEST {
940             return Err(ParseError::InvalidValue);
941         }
942         let (shmseg, remaining) = Seg::try_parse(value)?;
943         let (size, remaining) = u32::try_parse(remaining)?;
944         let (read_only, remaining) = bool::try_parse(remaining)?;
945         let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
946         let _ = remaining;
947         Ok(CreateSegmentRequest {
948             shmseg,
949             size,
950             read_only,
951         })
952     }
953 }
954 impl Request for CreateSegmentRequest {
955     type Reply = CreateSegmentReply;
956 }
create_segment<Conn>(conn: &Conn, shmseg: Seg, size: u32, read_only: bool) -> Result<CookieWithFds<'_, Conn, CreateSegmentReply>, ConnectionError> where Conn: RequestConnection + ?Sized,957 pub fn create_segment<Conn>(conn: &Conn, shmseg: Seg, size: u32, read_only: bool) -> Result<CookieWithFds<'_, Conn, CreateSegmentReply>, ConnectionError>
958 where
959     Conn: RequestConnection + ?Sized,
960 {
961     let request0 = CreateSegmentRequest {
962         shmseg,
963         size,
964         read_only,
965     };
966     request0.send(conn)
967 }
968 
969 #[derive(Debug, PartialEq, Eq)]
970 pub struct CreateSegmentReply {
971     pub nfd: u8,
972     pub sequence: u16,
973     pub length: u32,
974     pub shm_fd: RawFdContainer,
975 }
976 impl TryParseFd for CreateSegmentReply {
try_parse_fd<'a>(initial_value: &'a [u8], fds: &mut Vec<RawFdContainer>) -> Result<(Self, &'a [u8]), ParseError>977     fn try_parse_fd<'a>(initial_value: &'a [u8], fds: &mut Vec<RawFdContainer>) -> Result<(Self, &'a [u8]), ParseError> {
978         let remaining = initial_value;
979         let (response_type, remaining) = u8::try_parse(remaining)?;
980         let (nfd, remaining) = u8::try_parse(remaining)?;
981         let (sequence, remaining) = u16::try_parse(remaining)?;
982         let (length, remaining) = u32::try_parse(remaining)?;
983         if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) }
984         let shm_fd = fds.remove(0);
985         let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?;
986         if response_type != 1 {
987             return Err(ParseError::InvalidValue);
988         }
989         let result = CreateSegmentReply { nfd, sequence, length, shm_fd };
990         let _ = remaining;
991         let remaining = initial_value.get(32 + length as usize * 4..)
992             .ok_or(ParseError::InsufficientData)?;
993         Ok((result, remaining))
994     }
995 }
996 
997 /// Extension trait defining the requests of this extension.
998 pub trait ConnectionExt: RequestConnection {
shm_query_version(&self) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>999     fn shm_query_version(&self) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>
1000     {
1001         query_version(self)
1002     }
shm_attach(&self, shmseg: Seg, shmid: u32, read_only: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>1003     fn shm_attach(&self, shmseg: Seg, shmid: u32, read_only: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
1004     {
1005         attach(self, shmseg, shmid, read_only)
1006     }
shm_detach(&self, shmseg: Seg) -> Result<VoidCookie<'_, Self>, ConnectionError>1007     fn shm_detach(&self, shmseg: Seg) -> Result<VoidCookie<'_, Self>, ConnectionError>
1008     {
1009         detach(self, shmseg)
1010     }
shm_put_image(&self, drawable: xproto::Drawable, gc: xproto::Gcontext, total_width: u16, total_height: u16, src_x: u16, src_y: u16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16, depth: u8, format: u8, send_event: bool, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>1011     fn shm_put_image(&self, drawable: xproto::Drawable, gc: xproto::Gcontext, total_width: u16, total_height: u16, src_x: u16, src_y: u16, src_width: u16, src_height: u16, dst_x: i16, dst_y: i16, depth: u8, format: u8, send_event: bool, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
1012     {
1013         put_image(self, drawable, gc, total_width, total_height, src_x, src_y, src_width, src_height, dst_x, dst_y, depth, format, send_event, shmseg, offset)
1014     }
shm_get_image(&self, drawable: xproto::Drawable, x: i16, y: i16, width: u16, height: u16, plane_mask: u32, format: u8, shmseg: Seg, offset: u32) -> Result<Cookie<'_, Self, GetImageReply>, ConnectionError>1015     fn shm_get_image(&self, drawable: xproto::Drawable, x: i16, y: i16, width: u16, height: u16, plane_mask: u32, format: u8, shmseg: Seg, offset: u32) -> Result<Cookie<'_, Self, GetImageReply>, ConnectionError>
1016     {
1017         get_image(self, drawable, x, y, width, height, plane_mask, format, shmseg, offset)
1018     }
shm_create_pixmap(&self, pid: xproto::Pixmap, drawable: xproto::Drawable, width: u16, height: u16, depth: u8, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>1019     fn shm_create_pixmap(&self, pid: xproto::Pixmap, drawable: xproto::Drawable, width: u16, height: u16, depth: u8, shmseg: Seg, offset: u32) -> Result<VoidCookie<'_, Self>, ConnectionError>
1020     {
1021         create_pixmap(self, pid, drawable, width, height, depth, shmseg, offset)
1022     }
shm_attach_fd<A>(&self, shmseg: Seg, shm_fd: A, read_only: bool) -> Result<VoidCookie<'_, Self>, ConnectionError> where A: Into<RawFdContainer>,1023     fn shm_attach_fd<A>(&self, shmseg: Seg, shm_fd: A, read_only: bool) -> Result<VoidCookie<'_, Self>, ConnectionError>
1024     where
1025         A: Into<RawFdContainer>,
1026     {
1027         attach_fd(self, shmseg, shm_fd, read_only)
1028     }
shm_create_segment(&self, shmseg: Seg, size: u32, read_only: bool) -> Result<CookieWithFds<'_, Self, CreateSegmentReply>, ConnectionError>1029     fn shm_create_segment(&self, shmseg: Seg, size: u32, read_only: bool) -> Result<CookieWithFds<'_, Self, CreateSegmentReply>, ConnectionError>
1030     {
1031         create_segment(self, shmseg, size, read_only)
1032     }
1033 }
1034 
1035 impl<C: RequestConnection + ?Sized> ConnectionExt for C {}
1036