1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11pub const SIGNAL_STREAM_CONNECTED: u32 = USER_SIGNAL_3 as u32;
15
16pub const SIGNAL_STREAM_INCOMING: u32 = USER_SIGNAL_0 as u32;
19
20pub const USER_SIGNAL_0: u32 = 16777216;
21
22pub const USER_SIGNAL_3: u32 = 134217728;
23
24pub const VMADDR_CID_ANY: u32 = fidl_fuchsia_hardware_vsock__common::VMADDR_CID_ANY as u32;
26
27pub const VMADDR_CID_HOST: u32 = fidl_fuchsia_hardware_vsock__common::VMADDR_CID_HOST as u32;
28
29pub const VMADDR_CID_HYPERVISOR: u32 =
30 fidl_fuchsia_hardware_vsock__common::VMADDR_CID_HYPERVISOR as u32;
31
32pub const VMADDR_CID_LOCAL: u32 = fidl_fuchsia_hardware_vsock__common::VMADDR_CID_LOCAL as u32;
33
34#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub enum Error {
36 AlreadyBound,
37 AlreadyConnected,
38 ConnectionReset,
39 ConnectInProgress,
40 NotBound,
41 NotConnected,
42 NotListening,
43 NoConnectionsInQueue,
44 OutOfPorts,
45 #[doc(hidden)]
46 __SourceBreaking {
47 unknown_ordinal: u32,
48 },
49}
50
51#[macro_export]
53macro_rules! ErrorUnknown {
54 () => {
55 _
56 };
57}
58
59impl Error {
60 #[inline]
61 pub fn from_primitive(prim: u32) -> Option<Self> {
62 match prim {
63 1 => Some(Self::AlreadyBound),
64 2 => Some(Self::AlreadyConnected),
65 3 => Some(Self::ConnectionReset),
66 4 => Some(Self::ConnectInProgress),
67 5 => Some(Self::NotBound),
68 6 => Some(Self::NotConnected),
69 7 => Some(Self::NotListening),
70 8 => Some(Self::NoConnectionsInQueue),
71 9 => Some(Self::OutOfPorts),
72 _ => None,
73 }
74 }
75
76 #[inline]
77 pub fn from_primitive_allow_unknown(prim: u32) -> Self {
78 match prim {
79 1 => Self::AlreadyBound,
80 2 => Self::AlreadyConnected,
81 3 => Self::ConnectionReset,
82 4 => Self::ConnectInProgress,
83 5 => Self::NotBound,
84 6 => Self::NotConnected,
85 7 => Self::NotListening,
86 8 => Self::NoConnectionsInQueue,
87 9 => Self::OutOfPorts,
88 unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
89 }
90 }
91
92 #[inline]
93 pub fn unknown() -> Self {
94 Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
95 }
96
97 #[inline]
98 pub const fn into_primitive(self) -> u32 {
99 match self {
100 Self::AlreadyBound => 1,
101 Self::AlreadyConnected => 2,
102 Self::ConnectionReset => 3,
103 Self::ConnectInProgress => 4,
104 Self::NotBound => 5,
105 Self::NotConnected => 6,
106 Self::NotListening => 7,
107 Self::NoConnectionsInQueue => 8,
108 Self::OutOfPorts => 9,
109 Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
110 }
111 }
112
113 #[inline]
114 pub fn is_unknown(&self) -> bool {
115 match self {
116 Self::__SourceBreaking { unknown_ordinal: _ } => true,
117 _ => false,
118 }
119 }
120}
121
122#[derive(Clone, Debug, PartialEq)]
123pub struct AcceptorAcceptRequest {
124 pub addr: fidl_fuchsia_hardware_vsock__common::Addr,
125}
126
127impl fidl::Persistable for AcceptorAcceptRequest {}
128
129#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
130#[repr(C)]
131pub struct ConnectorGetCidResponse {
132 pub local_cid: u32,
133}
134
135impl fidl::Persistable for ConnectorGetCidResponse {}
136
137#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
138#[repr(C)]
139pub struct ConnectorConnectResponse {
140 pub local_port: u32,
141}
142
143impl fidl::Persistable for ConnectorConnectResponse {}
144
145#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
146#[repr(C)]
147pub struct ListenerListenRequest {
148 pub backlog: u32,
151}
152
153impl fidl::Persistable for ListenerListenRequest {}
154
155#[derive(Clone, Debug, PartialEq)]
156pub struct ListenerAcceptResponse {
157 pub addr: fidl_fuchsia_hardware_vsock__common::Addr,
158}
159
160impl fidl::Persistable for ListenerAcceptResponse {}
161
162#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
163#[repr(C)]
164pub struct ProviderGetCidResponse {
165 pub local_cid: u32,
166}
167
168impl fidl::Persistable for ProviderGetCidResponse {}
169
170#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
171#[repr(C)]
172pub struct StreamSocketBindRequest {
173 pub addr: VsockAddress,
174}
175
176impl fidl::Persistable for StreamSocketBindRequest {}
177
178#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
179#[repr(C)]
180pub struct StreamSocketListenRequest {
181 pub backlog: i32,
182}
183
184impl fidl::Persistable for StreamSocketListenRequest {}
185
186#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
187#[repr(C)]
188pub struct StreamSocketGetPeerNameResponse {
189 pub addr: VsockAddress,
190}
191
192impl fidl::Persistable for StreamSocketGetPeerNameResponse {}
193
194#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
195#[repr(C)]
196pub struct StreamSocketGetSockNameResponse {
197 pub addr: VsockAddress,
198}
199
200impl fidl::Persistable for StreamSocketGetSockNameResponse {}
201
202#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
204#[repr(C)]
205pub struct VsockAddress {
206 pub cid: u32,
207 pub port: u32,
208}
209
210impl fidl::Persistable for VsockAddress {}
211
212pub mod acceptor_ordinals {
213 pub const ACCEPT: u64 = 0x21fd057ad9c9f443;
214}
215
216pub mod connection_ordinals {
217 pub const SHUTDOWN: u64 = 0x40da7ca487466971;
218}
219
220pub mod connector_ordinals {
221 pub const CONNECT: u64 = 0xdf55c5e6a6a4117;
222 pub const LISTEN: u64 = 0x17c1371908bacf73;
223 pub const BIND: u64 = 0x6e50cd8c895f2e0;
224 pub const GET_CID: u64 = 0x60b3cfa0b40bdd7c;
225}
226
227pub mod listener_ordinals {
228 pub const LISTEN: u64 = 0x53042f6a15d94464;
229 pub const ACCEPT: u64 = 0x4b71e6389d92d322;
230}
231
232pub mod provider_ordinals {
233 pub const STREAM_SOCKET: u64 = 0x638e6822e8c0c333;
234 pub const GET_CID: u64 = 0x7152b198ab4348df;
235}
236
237pub mod stream_socket_ordinals {
238 pub const CLOSE: u64 = 0x5ac5d459ad7f657e;
239 pub const BIND: u64 = 0x72dc3c63cf24329;
240 pub const CONNECT: u64 = 0x50822e8e18b27e75;
241 pub const LISTEN: u64 = 0x4a5b1f2bc958287f;
242 pub const ACCEPT: u64 = 0x10d5fe50cbe19aea;
243 pub const GET_SOCK_NAME: u64 = 0x2011f4a50477ec73;
244 pub const GET_PEER_NAME: u64 = 0x6165feb6a459fb8;
245 pub const GET_ERROR: u64 = 0x18b3da9cea924b38;
246}
247
248mod internal {
249 use super::*;
250 unsafe impl fidl::encoding::TypeMarker for Error {
251 type Owned = Self;
252
253 #[inline(always)]
254 fn inline_align(_context: fidl::encoding::Context) -> usize {
255 std::mem::align_of::<u32>()
256 }
257
258 #[inline(always)]
259 fn inline_size(_context: fidl::encoding::Context) -> usize {
260 std::mem::size_of::<u32>()
261 }
262
263 #[inline(always)]
264 fn encode_is_copy() -> bool {
265 false
266 }
267
268 #[inline(always)]
269 fn decode_is_copy() -> bool {
270 false
271 }
272 }
273
274 impl fidl::encoding::ValueTypeMarker for Error {
275 type Borrowed<'a> = Self;
276 #[inline(always)]
277 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
278 *value
279 }
280 }
281
282 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for Error {
283 #[inline]
284 unsafe fn encode(
285 self,
286 encoder: &mut fidl::encoding::Encoder<'_, D>,
287 offset: usize,
288 _depth: fidl::encoding::Depth,
289 ) -> fidl::Result<()> {
290 encoder.debug_check_bounds::<Self>(offset);
291 encoder.write_num(self.into_primitive(), offset);
292 Ok(())
293 }
294 }
295
296 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Error {
297 #[inline(always)]
298 fn new_empty() -> Self {
299 Self::unknown()
300 }
301
302 #[inline]
303 unsafe fn decode(
304 &mut self,
305 decoder: &mut fidl::encoding::Decoder<'_, D>,
306 offset: usize,
307 _depth: fidl::encoding::Depth,
308 ) -> fidl::Result<()> {
309 decoder.debug_check_bounds::<Self>(offset);
310 let prim = decoder.read_num::<u32>(offset);
311
312 *self = Self::from_primitive_allow_unknown(prim);
313 Ok(())
314 }
315 }
316
317 impl fidl::encoding::ValueTypeMarker for AcceptorAcceptRequest {
318 type Borrowed<'a> = &'a Self;
319 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
320 value
321 }
322 }
323
324 unsafe impl fidl::encoding::TypeMarker for AcceptorAcceptRequest {
325 type Owned = Self;
326
327 #[inline(always)]
328 fn inline_align(_context: fidl::encoding::Context) -> usize {
329 4
330 }
331
332 #[inline(always)]
333 fn inline_size(_context: fidl::encoding::Context) -> usize {
334 12
335 }
336 }
337
338 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<AcceptorAcceptRequest, D>
339 for &AcceptorAcceptRequest
340 {
341 #[inline]
342 unsafe fn encode(
343 self,
344 encoder: &mut fidl::encoding::Encoder<'_, D>,
345 offset: usize,
346 _depth: fidl::encoding::Depth,
347 ) -> fidl::Result<()> {
348 encoder.debug_check_bounds::<AcceptorAcceptRequest>(offset);
349 fidl::encoding::Encode::<AcceptorAcceptRequest, D>::encode(
351 (
352 <fidl_fuchsia_hardware_vsock__common::Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
353 ),
354 encoder, offset, _depth
355 )
356 }
357 }
358 unsafe impl<
359 D: fidl::encoding::ResourceDialect,
360 T0: fidl::encoding::Encode<fidl_fuchsia_hardware_vsock__common::Addr, D>,
361 > fidl::encoding::Encode<AcceptorAcceptRequest, D> for (T0,)
362 {
363 #[inline]
364 unsafe fn encode(
365 self,
366 encoder: &mut fidl::encoding::Encoder<'_, D>,
367 offset: usize,
368 depth: fidl::encoding::Depth,
369 ) -> fidl::Result<()> {
370 encoder.debug_check_bounds::<AcceptorAcceptRequest>(offset);
371 self.0.encode(encoder, offset + 0, depth)?;
375 Ok(())
376 }
377 }
378
379 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for AcceptorAcceptRequest {
380 #[inline(always)]
381 fn new_empty() -> Self {
382 Self { addr: fidl::new_empty!(fidl_fuchsia_hardware_vsock__common::Addr, D) }
383 }
384
385 #[inline]
386 unsafe fn decode(
387 &mut self,
388 decoder: &mut fidl::encoding::Decoder<'_, D>,
389 offset: usize,
390 _depth: fidl::encoding::Depth,
391 ) -> fidl::Result<()> {
392 decoder.debug_check_bounds::<Self>(offset);
393 fidl::decode!(
395 fidl_fuchsia_hardware_vsock__common::Addr,
396 D,
397 &mut self.addr,
398 decoder,
399 offset + 0,
400 _depth
401 )?;
402 Ok(())
403 }
404 }
405
406 impl fidl::encoding::ValueTypeMarker for ConnectorGetCidResponse {
407 type Borrowed<'a> = &'a Self;
408 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
409 value
410 }
411 }
412
413 unsafe impl fidl::encoding::TypeMarker for ConnectorGetCidResponse {
414 type Owned = Self;
415
416 #[inline(always)]
417 fn inline_align(_context: fidl::encoding::Context) -> usize {
418 4
419 }
420
421 #[inline(always)]
422 fn inline_size(_context: fidl::encoding::Context) -> usize {
423 4
424 }
425 #[inline(always)]
426 fn encode_is_copy() -> bool {
427 true
428 }
429
430 #[inline(always)]
431 fn decode_is_copy() -> bool {
432 true
433 }
434 }
435
436 unsafe impl<D: fidl::encoding::ResourceDialect>
437 fidl::encoding::Encode<ConnectorGetCidResponse, D> for &ConnectorGetCidResponse
438 {
439 #[inline]
440 unsafe fn encode(
441 self,
442 encoder: &mut fidl::encoding::Encoder<'_, D>,
443 offset: usize,
444 _depth: fidl::encoding::Depth,
445 ) -> fidl::Result<()> {
446 encoder.debug_check_bounds::<ConnectorGetCidResponse>(offset);
447 unsafe {
448 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
450 (buf_ptr as *mut ConnectorGetCidResponse)
451 .write_unaligned((self as *const ConnectorGetCidResponse).read());
452 }
455 Ok(())
456 }
457 }
458 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
459 fidl::encoding::Encode<ConnectorGetCidResponse, D> for (T0,)
460 {
461 #[inline]
462 unsafe fn encode(
463 self,
464 encoder: &mut fidl::encoding::Encoder<'_, D>,
465 offset: usize,
466 depth: fidl::encoding::Depth,
467 ) -> fidl::Result<()> {
468 encoder.debug_check_bounds::<ConnectorGetCidResponse>(offset);
469 self.0.encode(encoder, offset + 0, depth)?;
473 Ok(())
474 }
475 }
476
477 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
478 for ConnectorGetCidResponse
479 {
480 #[inline(always)]
481 fn new_empty() -> Self {
482 Self { local_cid: fidl::new_empty!(u32, D) }
483 }
484
485 #[inline]
486 unsafe fn decode(
487 &mut self,
488 decoder: &mut fidl::encoding::Decoder<'_, D>,
489 offset: usize,
490 _depth: fidl::encoding::Depth,
491 ) -> fidl::Result<()> {
492 decoder.debug_check_bounds::<Self>(offset);
493 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
494 unsafe {
497 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
498 }
499 Ok(())
500 }
501 }
502
503 impl fidl::encoding::ValueTypeMarker for ConnectorConnectResponse {
504 type Borrowed<'a> = &'a Self;
505 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
506 value
507 }
508 }
509
510 unsafe impl fidl::encoding::TypeMarker for ConnectorConnectResponse {
511 type Owned = Self;
512
513 #[inline(always)]
514 fn inline_align(_context: fidl::encoding::Context) -> usize {
515 4
516 }
517
518 #[inline(always)]
519 fn inline_size(_context: fidl::encoding::Context) -> usize {
520 4
521 }
522 #[inline(always)]
523 fn encode_is_copy() -> bool {
524 true
525 }
526
527 #[inline(always)]
528 fn decode_is_copy() -> bool {
529 true
530 }
531 }
532
533 unsafe impl<D: fidl::encoding::ResourceDialect>
534 fidl::encoding::Encode<ConnectorConnectResponse, D> for &ConnectorConnectResponse
535 {
536 #[inline]
537 unsafe fn encode(
538 self,
539 encoder: &mut fidl::encoding::Encoder<'_, D>,
540 offset: usize,
541 _depth: fidl::encoding::Depth,
542 ) -> fidl::Result<()> {
543 encoder.debug_check_bounds::<ConnectorConnectResponse>(offset);
544 unsafe {
545 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
547 (buf_ptr as *mut ConnectorConnectResponse)
548 .write_unaligned((self as *const ConnectorConnectResponse).read());
549 }
552 Ok(())
553 }
554 }
555 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
556 fidl::encoding::Encode<ConnectorConnectResponse, D> for (T0,)
557 {
558 #[inline]
559 unsafe fn encode(
560 self,
561 encoder: &mut fidl::encoding::Encoder<'_, D>,
562 offset: usize,
563 depth: fidl::encoding::Depth,
564 ) -> fidl::Result<()> {
565 encoder.debug_check_bounds::<ConnectorConnectResponse>(offset);
566 self.0.encode(encoder, offset + 0, depth)?;
570 Ok(())
571 }
572 }
573
574 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
575 for ConnectorConnectResponse
576 {
577 #[inline(always)]
578 fn new_empty() -> Self {
579 Self { local_port: fidl::new_empty!(u32, D) }
580 }
581
582 #[inline]
583 unsafe fn decode(
584 &mut self,
585 decoder: &mut fidl::encoding::Decoder<'_, D>,
586 offset: usize,
587 _depth: fidl::encoding::Depth,
588 ) -> fidl::Result<()> {
589 decoder.debug_check_bounds::<Self>(offset);
590 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
591 unsafe {
594 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
595 }
596 Ok(())
597 }
598 }
599
600 impl fidl::encoding::ValueTypeMarker for ListenerListenRequest {
601 type Borrowed<'a> = &'a Self;
602 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
603 value
604 }
605 }
606
607 unsafe impl fidl::encoding::TypeMarker for ListenerListenRequest {
608 type Owned = Self;
609
610 #[inline(always)]
611 fn inline_align(_context: fidl::encoding::Context) -> usize {
612 4
613 }
614
615 #[inline(always)]
616 fn inline_size(_context: fidl::encoding::Context) -> usize {
617 4
618 }
619 #[inline(always)]
620 fn encode_is_copy() -> bool {
621 true
622 }
623
624 #[inline(always)]
625 fn decode_is_copy() -> bool {
626 true
627 }
628 }
629
630 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ListenerListenRequest, D>
631 for &ListenerListenRequest
632 {
633 #[inline]
634 unsafe fn encode(
635 self,
636 encoder: &mut fidl::encoding::Encoder<'_, D>,
637 offset: usize,
638 _depth: fidl::encoding::Depth,
639 ) -> fidl::Result<()> {
640 encoder.debug_check_bounds::<ListenerListenRequest>(offset);
641 unsafe {
642 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
644 (buf_ptr as *mut ListenerListenRequest)
645 .write_unaligned((self as *const ListenerListenRequest).read());
646 }
649 Ok(())
650 }
651 }
652 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
653 fidl::encoding::Encode<ListenerListenRequest, D> for (T0,)
654 {
655 #[inline]
656 unsafe fn encode(
657 self,
658 encoder: &mut fidl::encoding::Encoder<'_, D>,
659 offset: usize,
660 depth: fidl::encoding::Depth,
661 ) -> fidl::Result<()> {
662 encoder.debug_check_bounds::<ListenerListenRequest>(offset);
663 self.0.encode(encoder, offset + 0, depth)?;
667 Ok(())
668 }
669 }
670
671 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ListenerListenRequest {
672 #[inline(always)]
673 fn new_empty() -> Self {
674 Self { backlog: fidl::new_empty!(u32, D) }
675 }
676
677 #[inline]
678 unsafe fn decode(
679 &mut self,
680 decoder: &mut fidl::encoding::Decoder<'_, D>,
681 offset: usize,
682 _depth: fidl::encoding::Depth,
683 ) -> fidl::Result<()> {
684 decoder.debug_check_bounds::<Self>(offset);
685 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
686 unsafe {
689 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
690 }
691 Ok(())
692 }
693 }
694
695 impl fidl::encoding::ValueTypeMarker for ListenerAcceptResponse {
696 type Borrowed<'a> = &'a Self;
697 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
698 value
699 }
700 }
701
702 unsafe impl fidl::encoding::TypeMarker for ListenerAcceptResponse {
703 type Owned = Self;
704
705 #[inline(always)]
706 fn inline_align(_context: fidl::encoding::Context) -> usize {
707 4
708 }
709
710 #[inline(always)]
711 fn inline_size(_context: fidl::encoding::Context) -> usize {
712 12
713 }
714 }
715
716 unsafe impl<D: fidl::encoding::ResourceDialect>
717 fidl::encoding::Encode<ListenerAcceptResponse, D> for &ListenerAcceptResponse
718 {
719 #[inline]
720 unsafe fn encode(
721 self,
722 encoder: &mut fidl::encoding::Encoder<'_, D>,
723 offset: usize,
724 _depth: fidl::encoding::Depth,
725 ) -> fidl::Result<()> {
726 encoder.debug_check_bounds::<ListenerAcceptResponse>(offset);
727 fidl::encoding::Encode::<ListenerAcceptResponse, D>::encode(
729 (
730 <fidl_fuchsia_hardware_vsock__common::Addr as fidl::encoding::ValueTypeMarker>::borrow(&self.addr),
731 ),
732 encoder, offset, _depth
733 )
734 }
735 }
736 unsafe impl<
737 D: fidl::encoding::ResourceDialect,
738 T0: fidl::encoding::Encode<fidl_fuchsia_hardware_vsock__common::Addr, D>,
739 > fidl::encoding::Encode<ListenerAcceptResponse, D> for (T0,)
740 {
741 #[inline]
742 unsafe fn encode(
743 self,
744 encoder: &mut fidl::encoding::Encoder<'_, D>,
745 offset: usize,
746 depth: fidl::encoding::Depth,
747 ) -> fidl::Result<()> {
748 encoder.debug_check_bounds::<ListenerAcceptResponse>(offset);
749 self.0.encode(encoder, offset + 0, depth)?;
753 Ok(())
754 }
755 }
756
757 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
758 for ListenerAcceptResponse
759 {
760 #[inline(always)]
761 fn new_empty() -> Self {
762 Self { addr: fidl::new_empty!(fidl_fuchsia_hardware_vsock__common::Addr, D) }
763 }
764
765 #[inline]
766 unsafe fn decode(
767 &mut self,
768 decoder: &mut fidl::encoding::Decoder<'_, D>,
769 offset: usize,
770 _depth: fidl::encoding::Depth,
771 ) -> fidl::Result<()> {
772 decoder.debug_check_bounds::<Self>(offset);
773 fidl::decode!(
775 fidl_fuchsia_hardware_vsock__common::Addr,
776 D,
777 &mut self.addr,
778 decoder,
779 offset + 0,
780 _depth
781 )?;
782 Ok(())
783 }
784 }
785
786 impl fidl::encoding::ValueTypeMarker for ProviderGetCidResponse {
787 type Borrowed<'a> = &'a Self;
788 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
789 value
790 }
791 }
792
793 unsafe impl fidl::encoding::TypeMarker for ProviderGetCidResponse {
794 type Owned = Self;
795
796 #[inline(always)]
797 fn inline_align(_context: fidl::encoding::Context) -> usize {
798 4
799 }
800
801 #[inline(always)]
802 fn inline_size(_context: fidl::encoding::Context) -> usize {
803 4
804 }
805 #[inline(always)]
806 fn encode_is_copy() -> bool {
807 true
808 }
809
810 #[inline(always)]
811 fn decode_is_copy() -> bool {
812 true
813 }
814 }
815
816 unsafe impl<D: fidl::encoding::ResourceDialect>
817 fidl::encoding::Encode<ProviderGetCidResponse, D> for &ProviderGetCidResponse
818 {
819 #[inline]
820 unsafe fn encode(
821 self,
822 encoder: &mut fidl::encoding::Encoder<'_, D>,
823 offset: usize,
824 _depth: fidl::encoding::Depth,
825 ) -> fidl::Result<()> {
826 encoder.debug_check_bounds::<ProviderGetCidResponse>(offset);
827 unsafe {
828 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
830 (buf_ptr as *mut ProviderGetCidResponse)
831 .write_unaligned((self as *const ProviderGetCidResponse).read());
832 }
835 Ok(())
836 }
837 }
838 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
839 fidl::encoding::Encode<ProviderGetCidResponse, D> for (T0,)
840 {
841 #[inline]
842 unsafe fn encode(
843 self,
844 encoder: &mut fidl::encoding::Encoder<'_, D>,
845 offset: usize,
846 depth: fidl::encoding::Depth,
847 ) -> fidl::Result<()> {
848 encoder.debug_check_bounds::<ProviderGetCidResponse>(offset);
849 self.0.encode(encoder, offset + 0, depth)?;
853 Ok(())
854 }
855 }
856
857 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
858 for ProviderGetCidResponse
859 {
860 #[inline(always)]
861 fn new_empty() -> Self {
862 Self { local_cid: fidl::new_empty!(u32, D) }
863 }
864
865 #[inline]
866 unsafe fn decode(
867 &mut self,
868 decoder: &mut fidl::encoding::Decoder<'_, D>,
869 offset: usize,
870 _depth: fidl::encoding::Depth,
871 ) -> fidl::Result<()> {
872 decoder.debug_check_bounds::<Self>(offset);
873 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
874 unsafe {
877 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
878 }
879 Ok(())
880 }
881 }
882
883 impl fidl::encoding::ValueTypeMarker for StreamSocketBindRequest {
884 type Borrowed<'a> = &'a Self;
885 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
886 value
887 }
888 }
889
890 unsafe impl fidl::encoding::TypeMarker for StreamSocketBindRequest {
891 type Owned = Self;
892
893 #[inline(always)]
894 fn inline_align(_context: fidl::encoding::Context) -> usize {
895 4
896 }
897
898 #[inline(always)]
899 fn inline_size(_context: fidl::encoding::Context) -> usize {
900 8
901 }
902 #[inline(always)]
903 fn encode_is_copy() -> bool {
904 true
905 }
906
907 #[inline(always)]
908 fn decode_is_copy() -> bool {
909 true
910 }
911 }
912
913 unsafe impl<D: fidl::encoding::ResourceDialect>
914 fidl::encoding::Encode<StreamSocketBindRequest, D> for &StreamSocketBindRequest
915 {
916 #[inline]
917 unsafe fn encode(
918 self,
919 encoder: &mut fidl::encoding::Encoder<'_, D>,
920 offset: usize,
921 _depth: fidl::encoding::Depth,
922 ) -> fidl::Result<()> {
923 encoder.debug_check_bounds::<StreamSocketBindRequest>(offset);
924 unsafe {
925 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
927 (buf_ptr as *mut StreamSocketBindRequest)
928 .write_unaligned((self as *const StreamSocketBindRequest).read());
929 }
932 Ok(())
933 }
934 }
935 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<VsockAddress, D>>
936 fidl::encoding::Encode<StreamSocketBindRequest, D> for (T0,)
937 {
938 #[inline]
939 unsafe fn encode(
940 self,
941 encoder: &mut fidl::encoding::Encoder<'_, D>,
942 offset: usize,
943 depth: fidl::encoding::Depth,
944 ) -> fidl::Result<()> {
945 encoder.debug_check_bounds::<StreamSocketBindRequest>(offset);
946 self.0.encode(encoder, offset + 0, depth)?;
950 Ok(())
951 }
952 }
953
954 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
955 for StreamSocketBindRequest
956 {
957 #[inline(always)]
958 fn new_empty() -> Self {
959 Self { addr: fidl::new_empty!(VsockAddress, D) }
960 }
961
962 #[inline]
963 unsafe fn decode(
964 &mut self,
965 decoder: &mut fidl::encoding::Decoder<'_, D>,
966 offset: usize,
967 _depth: fidl::encoding::Depth,
968 ) -> fidl::Result<()> {
969 decoder.debug_check_bounds::<Self>(offset);
970 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
971 unsafe {
974 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
975 }
976 Ok(())
977 }
978 }
979
980 impl fidl::encoding::ValueTypeMarker for StreamSocketListenRequest {
981 type Borrowed<'a> = &'a Self;
982 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
983 value
984 }
985 }
986
987 unsafe impl fidl::encoding::TypeMarker for StreamSocketListenRequest {
988 type Owned = Self;
989
990 #[inline(always)]
991 fn inline_align(_context: fidl::encoding::Context) -> usize {
992 4
993 }
994
995 #[inline(always)]
996 fn inline_size(_context: fidl::encoding::Context) -> usize {
997 4
998 }
999 #[inline(always)]
1000 fn encode_is_copy() -> bool {
1001 true
1002 }
1003
1004 #[inline(always)]
1005 fn decode_is_copy() -> bool {
1006 true
1007 }
1008 }
1009
1010 unsafe impl<D: fidl::encoding::ResourceDialect>
1011 fidl::encoding::Encode<StreamSocketListenRequest, D> for &StreamSocketListenRequest
1012 {
1013 #[inline]
1014 unsafe fn encode(
1015 self,
1016 encoder: &mut fidl::encoding::Encoder<'_, D>,
1017 offset: usize,
1018 _depth: fidl::encoding::Depth,
1019 ) -> fidl::Result<()> {
1020 encoder.debug_check_bounds::<StreamSocketListenRequest>(offset);
1021 unsafe {
1022 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1024 (buf_ptr as *mut StreamSocketListenRequest)
1025 .write_unaligned((self as *const StreamSocketListenRequest).read());
1026 }
1029 Ok(())
1030 }
1031 }
1032 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
1033 fidl::encoding::Encode<StreamSocketListenRequest, D> for (T0,)
1034 {
1035 #[inline]
1036 unsafe fn encode(
1037 self,
1038 encoder: &mut fidl::encoding::Encoder<'_, D>,
1039 offset: usize,
1040 depth: fidl::encoding::Depth,
1041 ) -> fidl::Result<()> {
1042 encoder.debug_check_bounds::<StreamSocketListenRequest>(offset);
1043 self.0.encode(encoder, offset + 0, depth)?;
1047 Ok(())
1048 }
1049 }
1050
1051 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1052 for StreamSocketListenRequest
1053 {
1054 #[inline(always)]
1055 fn new_empty() -> Self {
1056 Self { backlog: fidl::new_empty!(i32, D) }
1057 }
1058
1059 #[inline]
1060 unsafe fn decode(
1061 &mut self,
1062 decoder: &mut fidl::encoding::Decoder<'_, D>,
1063 offset: usize,
1064 _depth: fidl::encoding::Depth,
1065 ) -> fidl::Result<()> {
1066 decoder.debug_check_bounds::<Self>(offset);
1067 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1068 unsafe {
1071 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1072 }
1073 Ok(())
1074 }
1075 }
1076
1077 impl fidl::encoding::ValueTypeMarker for StreamSocketGetPeerNameResponse {
1078 type Borrowed<'a> = &'a Self;
1079 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1080 value
1081 }
1082 }
1083
1084 unsafe impl fidl::encoding::TypeMarker for StreamSocketGetPeerNameResponse {
1085 type Owned = Self;
1086
1087 #[inline(always)]
1088 fn inline_align(_context: fidl::encoding::Context) -> usize {
1089 4
1090 }
1091
1092 #[inline(always)]
1093 fn inline_size(_context: fidl::encoding::Context) -> usize {
1094 8
1095 }
1096 #[inline(always)]
1097 fn encode_is_copy() -> bool {
1098 true
1099 }
1100
1101 #[inline(always)]
1102 fn decode_is_copy() -> bool {
1103 true
1104 }
1105 }
1106
1107 unsafe impl<D: fidl::encoding::ResourceDialect>
1108 fidl::encoding::Encode<StreamSocketGetPeerNameResponse, D>
1109 for &StreamSocketGetPeerNameResponse
1110 {
1111 #[inline]
1112 unsafe fn encode(
1113 self,
1114 encoder: &mut fidl::encoding::Encoder<'_, D>,
1115 offset: usize,
1116 _depth: fidl::encoding::Depth,
1117 ) -> fidl::Result<()> {
1118 encoder.debug_check_bounds::<StreamSocketGetPeerNameResponse>(offset);
1119 unsafe {
1120 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1122 (buf_ptr as *mut StreamSocketGetPeerNameResponse)
1123 .write_unaligned((self as *const StreamSocketGetPeerNameResponse).read());
1124 }
1127 Ok(())
1128 }
1129 }
1130 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<VsockAddress, D>>
1131 fidl::encoding::Encode<StreamSocketGetPeerNameResponse, D> for (T0,)
1132 {
1133 #[inline]
1134 unsafe fn encode(
1135 self,
1136 encoder: &mut fidl::encoding::Encoder<'_, D>,
1137 offset: usize,
1138 depth: fidl::encoding::Depth,
1139 ) -> fidl::Result<()> {
1140 encoder.debug_check_bounds::<StreamSocketGetPeerNameResponse>(offset);
1141 self.0.encode(encoder, offset + 0, depth)?;
1145 Ok(())
1146 }
1147 }
1148
1149 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1150 for StreamSocketGetPeerNameResponse
1151 {
1152 #[inline(always)]
1153 fn new_empty() -> Self {
1154 Self { addr: fidl::new_empty!(VsockAddress, D) }
1155 }
1156
1157 #[inline]
1158 unsafe fn decode(
1159 &mut self,
1160 decoder: &mut fidl::encoding::Decoder<'_, D>,
1161 offset: usize,
1162 _depth: fidl::encoding::Depth,
1163 ) -> fidl::Result<()> {
1164 decoder.debug_check_bounds::<Self>(offset);
1165 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1166 unsafe {
1169 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1170 }
1171 Ok(())
1172 }
1173 }
1174
1175 impl fidl::encoding::ValueTypeMarker for StreamSocketGetSockNameResponse {
1176 type Borrowed<'a> = &'a Self;
1177 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1178 value
1179 }
1180 }
1181
1182 unsafe impl fidl::encoding::TypeMarker for StreamSocketGetSockNameResponse {
1183 type Owned = Self;
1184
1185 #[inline(always)]
1186 fn inline_align(_context: fidl::encoding::Context) -> usize {
1187 4
1188 }
1189
1190 #[inline(always)]
1191 fn inline_size(_context: fidl::encoding::Context) -> usize {
1192 8
1193 }
1194 #[inline(always)]
1195 fn encode_is_copy() -> bool {
1196 true
1197 }
1198
1199 #[inline(always)]
1200 fn decode_is_copy() -> bool {
1201 true
1202 }
1203 }
1204
1205 unsafe impl<D: fidl::encoding::ResourceDialect>
1206 fidl::encoding::Encode<StreamSocketGetSockNameResponse, D>
1207 for &StreamSocketGetSockNameResponse
1208 {
1209 #[inline]
1210 unsafe fn encode(
1211 self,
1212 encoder: &mut fidl::encoding::Encoder<'_, D>,
1213 offset: usize,
1214 _depth: fidl::encoding::Depth,
1215 ) -> fidl::Result<()> {
1216 encoder.debug_check_bounds::<StreamSocketGetSockNameResponse>(offset);
1217 unsafe {
1218 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1220 (buf_ptr as *mut StreamSocketGetSockNameResponse)
1221 .write_unaligned((self as *const StreamSocketGetSockNameResponse).read());
1222 }
1225 Ok(())
1226 }
1227 }
1228 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<VsockAddress, D>>
1229 fidl::encoding::Encode<StreamSocketGetSockNameResponse, D> for (T0,)
1230 {
1231 #[inline]
1232 unsafe fn encode(
1233 self,
1234 encoder: &mut fidl::encoding::Encoder<'_, D>,
1235 offset: usize,
1236 depth: fidl::encoding::Depth,
1237 ) -> fidl::Result<()> {
1238 encoder.debug_check_bounds::<StreamSocketGetSockNameResponse>(offset);
1239 self.0.encode(encoder, offset + 0, depth)?;
1243 Ok(())
1244 }
1245 }
1246
1247 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1248 for StreamSocketGetSockNameResponse
1249 {
1250 #[inline(always)]
1251 fn new_empty() -> Self {
1252 Self { addr: fidl::new_empty!(VsockAddress, D) }
1253 }
1254
1255 #[inline]
1256 unsafe fn decode(
1257 &mut self,
1258 decoder: &mut fidl::encoding::Decoder<'_, D>,
1259 offset: usize,
1260 _depth: fidl::encoding::Depth,
1261 ) -> fidl::Result<()> {
1262 decoder.debug_check_bounds::<Self>(offset);
1263 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1264 unsafe {
1267 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1268 }
1269 Ok(())
1270 }
1271 }
1272
1273 impl fidl::encoding::ValueTypeMarker for VsockAddress {
1274 type Borrowed<'a> = &'a Self;
1275 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1276 value
1277 }
1278 }
1279
1280 unsafe impl fidl::encoding::TypeMarker for VsockAddress {
1281 type Owned = Self;
1282
1283 #[inline(always)]
1284 fn inline_align(_context: fidl::encoding::Context) -> usize {
1285 4
1286 }
1287
1288 #[inline(always)]
1289 fn inline_size(_context: fidl::encoding::Context) -> usize {
1290 8
1291 }
1292 #[inline(always)]
1293 fn encode_is_copy() -> bool {
1294 true
1295 }
1296
1297 #[inline(always)]
1298 fn decode_is_copy() -> bool {
1299 true
1300 }
1301 }
1302
1303 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<VsockAddress, D>
1304 for &VsockAddress
1305 {
1306 #[inline]
1307 unsafe fn encode(
1308 self,
1309 encoder: &mut fidl::encoding::Encoder<'_, D>,
1310 offset: usize,
1311 _depth: fidl::encoding::Depth,
1312 ) -> fidl::Result<()> {
1313 encoder.debug_check_bounds::<VsockAddress>(offset);
1314 unsafe {
1315 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1317 (buf_ptr as *mut VsockAddress)
1318 .write_unaligned((self as *const VsockAddress).read());
1319 }
1322 Ok(())
1323 }
1324 }
1325 unsafe impl<
1326 D: fidl::encoding::ResourceDialect,
1327 T0: fidl::encoding::Encode<u32, D>,
1328 T1: fidl::encoding::Encode<u32, D>,
1329 > fidl::encoding::Encode<VsockAddress, D> for (T0, T1)
1330 {
1331 #[inline]
1332 unsafe fn encode(
1333 self,
1334 encoder: &mut fidl::encoding::Encoder<'_, D>,
1335 offset: usize,
1336 depth: fidl::encoding::Depth,
1337 ) -> fidl::Result<()> {
1338 encoder.debug_check_bounds::<VsockAddress>(offset);
1339 self.0.encode(encoder, offset + 0, depth)?;
1343 self.1.encode(encoder, offset + 4, depth)?;
1344 Ok(())
1345 }
1346 }
1347
1348 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for VsockAddress {
1349 #[inline(always)]
1350 fn new_empty() -> Self {
1351 Self { cid: fidl::new_empty!(u32, D), port: fidl::new_empty!(u32, D) }
1352 }
1353
1354 #[inline]
1355 unsafe fn decode(
1356 &mut self,
1357 decoder: &mut fidl::encoding::Decoder<'_, D>,
1358 offset: usize,
1359 _depth: fidl::encoding::Depth,
1360 ) -> fidl::Result<()> {
1361 decoder.debug_check_bounds::<Self>(offset);
1362 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1363 unsafe {
1366 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
1367 }
1368 Ok(())
1369 }
1370 }
1371}