1#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_hardware_sockettunnel_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Default, PartialEq)]
15pub struct DeviceRegisterSocketRequest {
16 pub server_socket: Option<fidl::Socket>,
17 pub socket_label: Option<String>,
18 #[doc(hidden)]
19 pub __source_breaking: fidl::marker::SourceBreaking,
20}
21
22impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
23 for DeviceRegisterSocketRequest
24{
25}
26
27#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
28pub struct DeviceMarker;
29
30impl fidl::endpoints::ProtocolMarker for DeviceMarker {
31 type Proxy = DeviceProxy;
32 type RequestStream = DeviceRequestStream;
33 #[cfg(target_os = "fuchsia")]
34 type SynchronousProxy = DeviceSynchronousProxy;
35
36 const DEBUG_NAME: &'static str = "fuchsia.hardware.sockettunnel.Device";
37}
38impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
39pub type DeviceRegisterSocketResult = Result<(), i32>;
40
41pub trait DeviceProxyInterface: Send + Sync {
42 type RegisterSocketResponseFut: std::future::Future<Output = Result<DeviceRegisterSocketResult, fidl::Error>>
43 + Send;
44 fn r#register_socket(
45 &self,
46 payload: DeviceRegisterSocketRequest,
47 ) -> Self::RegisterSocketResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct DeviceSynchronousProxy {
52 client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
57 type Proxy = DeviceProxy;
58 type Protocol = DeviceMarker;
59
60 fn from_channel(inner: fidl::Channel) -> Self {
61 Self::new(inner)
62 }
63
64 fn into_channel(self) -> fidl::Channel {
65 self.client.into_channel()
66 }
67
68 fn as_channel(&self) -> &fidl::Channel {
69 self.client.as_channel()
70 }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl DeviceSynchronousProxy {
75 pub fn new(channel: fidl::Channel) -> Self {
76 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
77 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
78 }
79
80 pub fn into_channel(self) -> fidl::Channel {
81 self.client.into_channel()
82 }
83
84 pub fn wait_for_event(
87 &self,
88 deadline: zx::MonotonicInstant,
89 ) -> Result<DeviceEvent, fidl::Error> {
90 DeviceEvent::decode(self.client.wait_for_event(deadline)?)
91 }
92
93 pub fn r#register_socket(
94 &self,
95 mut payload: DeviceRegisterSocketRequest,
96 ___deadline: zx::MonotonicInstant,
97 ) -> Result<DeviceRegisterSocketResult, fidl::Error> {
98 let _response = self.client.send_query::<
99 DeviceRegisterSocketRequest,
100 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
101 >(
102 &mut payload,
103 0x4b2c4d82dae82c6d,
104 fidl::encoding::DynamicFlags::FLEXIBLE,
105 ___deadline,
106 )?
107 .into_result::<DeviceMarker>("register_socket")?;
108 Ok(_response.map(|x| x))
109 }
110}
111
112#[cfg(target_os = "fuchsia")]
113impl From<DeviceSynchronousProxy> for zx::Handle {
114 fn from(value: DeviceSynchronousProxy) -> Self {
115 value.into_channel().into()
116 }
117}
118
119#[cfg(target_os = "fuchsia")]
120impl From<fidl::Channel> for DeviceSynchronousProxy {
121 fn from(value: fidl::Channel) -> Self {
122 Self::new(value)
123 }
124}
125
126#[derive(Debug, Clone)]
127pub struct DeviceProxy {
128 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
129}
130
131impl fidl::endpoints::Proxy for DeviceProxy {
132 type Protocol = DeviceMarker;
133
134 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
135 Self::new(inner)
136 }
137
138 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
139 self.client.into_channel().map_err(|client| Self { client })
140 }
141
142 fn as_channel(&self) -> &::fidl::AsyncChannel {
143 self.client.as_channel()
144 }
145}
146
147impl DeviceProxy {
148 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
150 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
151 Self { client: fidl::client::Client::new(channel, protocol_name) }
152 }
153
154 pub fn take_event_stream(&self) -> DeviceEventStream {
160 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
161 }
162
163 pub fn r#register_socket(
164 &self,
165 mut payload: DeviceRegisterSocketRequest,
166 ) -> fidl::client::QueryResponseFut<
167 DeviceRegisterSocketResult,
168 fidl::encoding::DefaultFuchsiaResourceDialect,
169 > {
170 DeviceProxyInterface::r#register_socket(self, payload)
171 }
172}
173
174impl DeviceProxyInterface for DeviceProxy {
175 type RegisterSocketResponseFut = fidl::client::QueryResponseFut<
176 DeviceRegisterSocketResult,
177 fidl::encoding::DefaultFuchsiaResourceDialect,
178 >;
179 fn r#register_socket(
180 &self,
181 mut payload: DeviceRegisterSocketRequest,
182 ) -> Self::RegisterSocketResponseFut {
183 fn _decode(
184 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
185 ) -> Result<DeviceRegisterSocketResult, fidl::Error> {
186 let _response = fidl::client::decode_transaction_body::<
187 fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
188 fidl::encoding::DefaultFuchsiaResourceDialect,
189 0x4b2c4d82dae82c6d,
190 >(_buf?)?
191 .into_result::<DeviceMarker>("register_socket")?;
192 Ok(_response.map(|x| x))
193 }
194 self.client
195 .send_query_and_decode::<DeviceRegisterSocketRequest, DeviceRegisterSocketResult>(
196 &mut payload,
197 0x4b2c4d82dae82c6d,
198 fidl::encoding::DynamicFlags::FLEXIBLE,
199 _decode,
200 )
201 }
202}
203
204pub struct DeviceEventStream {
205 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
206}
207
208impl std::marker::Unpin for DeviceEventStream {}
209
210impl futures::stream::FusedStream for DeviceEventStream {
211 fn is_terminated(&self) -> bool {
212 self.event_receiver.is_terminated()
213 }
214}
215
216impl futures::Stream for DeviceEventStream {
217 type Item = Result<DeviceEvent, fidl::Error>;
218
219 fn poll_next(
220 mut self: std::pin::Pin<&mut Self>,
221 cx: &mut std::task::Context<'_>,
222 ) -> std::task::Poll<Option<Self::Item>> {
223 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
224 &mut self.event_receiver,
225 cx
226 )?) {
227 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
228 None => std::task::Poll::Ready(None),
229 }
230 }
231}
232
233#[derive(Debug)]
234pub enum DeviceEvent {
235 #[non_exhaustive]
236 _UnknownEvent {
237 ordinal: u64,
239 },
240}
241
242impl DeviceEvent {
243 fn decode(
245 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
246 ) -> Result<DeviceEvent, fidl::Error> {
247 let (bytes, _handles) = buf.split_mut();
248 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
249 debug_assert_eq!(tx_header.tx_id, 0);
250 match tx_header.ordinal {
251 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
252 Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
253 }
254 _ => Err(fidl::Error::UnknownOrdinal {
255 ordinal: tx_header.ordinal,
256 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
257 }),
258 }
259 }
260}
261
262pub struct DeviceRequestStream {
264 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
265 is_terminated: bool,
266}
267
268impl std::marker::Unpin for DeviceRequestStream {}
269
270impl futures::stream::FusedStream for DeviceRequestStream {
271 fn is_terminated(&self) -> bool {
272 self.is_terminated
273 }
274}
275
276impl fidl::endpoints::RequestStream for DeviceRequestStream {
277 type Protocol = DeviceMarker;
278 type ControlHandle = DeviceControlHandle;
279
280 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
281 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
282 }
283
284 fn control_handle(&self) -> Self::ControlHandle {
285 DeviceControlHandle { inner: self.inner.clone() }
286 }
287
288 fn into_inner(
289 self,
290 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
291 {
292 (self.inner, self.is_terminated)
293 }
294
295 fn from_inner(
296 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
297 is_terminated: bool,
298 ) -> Self {
299 Self { inner, is_terminated }
300 }
301}
302
303impl futures::Stream for DeviceRequestStream {
304 type Item = Result<DeviceRequest, fidl::Error>;
305
306 fn poll_next(
307 mut self: std::pin::Pin<&mut Self>,
308 cx: &mut std::task::Context<'_>,
309 ) -> std::task::Poll<Option<Self::Item>> {
310 let this = &mut *self;
311 if this.inner.check_shutdown(cx) {
312 this.is_terminated = true;
313 return std::task::Poll::Ready(None);
314 }
315 if this.is_terminated {
316 panic!("polled DeviceRequestStream after completion");
317 }
318 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
319 |bytes, handles| {
320 match this.inner.channel().read_etc(cx, bytes, handles) {
321 std::task::Poll::Ready(Ok(())) => {}
322 std::task::Poll::Pending => return std::task::Poll::Pending,
323 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
324 this.is_terminated = true;
325 return std::task::Poll::Ready(None);
326 }
327 std::task::Poll::Ready(Err(e)) => {
328 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
329 e.into(),
330 ))))
331 }
332 }
333
334 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
336
337 std::task::Poll::Ready(Some(match header.ordinal {
338 0x4b2c4d82dae82c6d => {
339 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
340 let mut req = fidl::new_empty!(
341 DeviceRegisterSocketRequest,
342 fidl::encoding::DefaultFuchsiaResourceDialect
343 );
344 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceRegisterSocketRequest>(&header, _body_bytes, handles, &mut req)?;
345 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
346 Ok(DeviceRequest::RegisterSocket {
347 payload: req,
348 responder: DeviceRegisterSocketResponder {
349 control_handle: std::mem::ManuallyDrop::new(control_handle),
350 tx_id: header.tx_id,
351 },
352 })
353 }
354 _ if header.tx_id == 0
355 && header
356 .dynamic_flags()
357 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
358 {
359 Ok(DeviceRequest::_UnknownMethod {
360 ordinal: header.ordinal,
361 control_handle: DeviceControlHandle { inner: this.inner.clone() },
362 method_type: fidl::MethodType::OneWay,
363 })
364 }
365 _ if header
366 .dynamic_flags()
367 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
368 {
369 this.inner.send_framework_err(
370 fidl::encoding::FrameworkErr::UnknownMethod,
371 header.tx_id,
372 header.ordinal,
373 header.dynamic_flags(),
374 (bytes, handles),
375 )?;
376 Ok(DeviceRequest::_UnknownMethod {
377 ordinal: header.ordinal,
378 control_handle: DeviceControlHandle { inner: this.inner.clone() },
379 method_type: fidl::MethodType::TwoWay,
380 })
381 }
382 _ => Err(fidl::Error::UnknownOrdinal {
383 ordinal: header.ordinal,
384 protocol_name:
385 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
386 }),
387 }))
388 },
389 )
390 }
391}
392
393#[derive(Debug)]
396pub enum DeviceRequest {
397 RegisterSocket {
398 payload: DeviceRegisterSocketRequest,
399 responder: DeviceRegisterSocketResponder,
400 },
401 #[non_exhaustive]
403 _UnknownMethod {
404 ordinal: u64,
406 control_handle: DeviceControlHandle,
407 method_type: fidl::MethodType,
408 },
409}
410
411impl DeviceRequest {
412 #[allow(irrefutable_let_patterns)]
413 pub fn into_register_socket(
414 self,
415 ) -> Option<(DeviceRegisterSocketRequest, DeviceRegisterSocketResponder)> {
416 if let DeviceRequest::RegisterSocket { payload, responder } = self {
417 Some((payload, responder))
418 } else {
419 None
420 }
421 }
422
423 pub fn method_name(&self) -> &'static str {
425 match *self {
426 DeviceRequest::RegisterSocket { .. } => "register_socket",
427 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
428 "unknown one-way method"
429 }
430 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
431 "unknown two-way method"
432 }
433 }
434 }
435}
436
437#[derive(Debug, Clone)]
438pub struct DeviceControlHandle {
439 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
440}
441
442impl fidl::endpoints::ControlHandle for DeviceControlHandle {
443 fn shutdown(&self) {
444 self.inner.shutdown()
445 }
446 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
447 self.inner.shutdown_with_epitaph(status)
448 }
449
450 fn is_closed(&self) -> bool {
451 self.inner.channel().is_closed()
452 }
453 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
454 self.inner.channel().on_closed()
455 }
456
457 #[cfg(target_os = "fuchsia")]
458 fn signal_peer(
459 &self,
460 clear_mask: zx::Signals,
461 set_mask: zx::Signals,
462 ) -> Result<(), zx_status::Status> {
463 use fidl::Peered;
464 self.inner.channel().signal_peer(clear_mask, set_mask)
465 }
466}
467
468impl DeviceControlHandle {}
469
470#[must_use = "FIDL methods require a response to be sent"]
471#[derive(Debug)]
472pub struct DeviceRegisterSocketResponder {
473 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
474 tx_id: u32,
475}
476
477impl std::ops::Drop for DeviceRegisterSocketResponder {
481 fn drop(&mut self) {
482 self.control_handle.shutdown();
483 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
485 }
486}
487
488impl fidl::endpoints::Responder for DeviceRegisterSocketResponder {
489 type ControlHandle = DeviceControlHandle;
490
491 fn control_handle(&self) -> &DeviceControlHandle {
492 &self.control_handle
493 }
494
495 fn drop_without_shutdown(mut self) {
496 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
498 std::mem::forget(self);
500 }
501}
502
503impl DeviceRegisterSocketResponder {
504 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
508 let _result = self.send_raw(result);
509 if _result.is_err() {
510 self.control_handle.shutdown();
511 }
512 self.drop_without_shutdown();
513 _result
514 }
515
516 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
518 let _result = self.send_raw(result);
519 self.drop_without_shutdown();
520 _result
521 }
522
523 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
524 self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
525 fidl::encoding::EmptyStruct,
526 i32,
527 >>(
528 fidl::encoding::FlexibleResult::new(result),
529 self.tx_id,
530 0x4b2c4d82dae82c6d,
531 fidl::encoding::DynamicFlags::FLEXIBLE,
532 )
533 }
534}
535
536#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
537pub struct ServiceMarker;
538
539#[cfg(target_os = "fuchsia")]
540impl fidl::endpoints::ServiceMarker for ServiceMarker {
541 type Proxy = ServiceProxy;
542 type Request = ServiceRequest;
543 const SERVICE_NAME: &'static str = "fuchsia.hardware.sockettunnel.Service";
544}
545
546#[cfg(target_os = "fuchsia")]
549pub enum ServiceRequest {
550 SocketTunnel(DeviceRequestStream),
551}
552
553#[cfg(target_os = "fuchsia")]
554impl fidl::endpoints::ServiceRequest for ServiceRequest {
555 type Service = ServiceMarker;
556
557 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
558 match name {
559 "socket_tunnel" => Self::SocketTunnel(
560 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
561 ),
562 _ => panic!("no such member protocol name for service Service"),
563 }
564 }
565
566 fn member_names() -> &'static [&'static str] {
567 &["socket_tunnel"]
568 }
569}
570#[cfg(target_os = "fuchsia")]
571pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
572
573#[cfg(target_os = "fuchsia")]
574impl fidl::endpoints::ServiceProxy for ServiceProxy {
575 type Service = ServiceMarker;
576
577 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
578 Self(opener)
579 }
580}
581
582#[cfg(target_os = "fuchsia")]
583impl ServiceProxy {
584 pub fn connect_to_socket_tunnel(&self) -> Result<DeviceProxy, fidl::Error> {
585 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
586 self.connect_channel_to_socket_tunnel(server_end)?;
587 Ok(proxy)
588 }
589
590 pub fn connect_to_socket_tunnel_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
593 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
594 self.connect_channel_to_socket_tunnel(server_end)?;
595 Ok(proxy)
596 }
597
598 pub fn connect_channel_to_socket_tunnel(
601 &self,
602 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
603 ) -> Result<(), fidl::Error> {
604 self.0.open_member("socket_tunnel", server_end.into_channel())
605 }
606
607 pub fn instance_name(&self) -> &str {
608 self.0.instance_name()
609 }
610}
611
612mod internal {
613 use super::*;
614
615 impl DeviceRegisterSocketRequest {
616 #[inline(always)]
617 fn max_ordinal_present(&self) -> u64 {
618 if let Some(_) = self.socket_label {
619 return 2;
620 }
621 if let Some(_) = self.server_socket {
622 return 1;
623 }
624 0
625 }
626 }
627
628 impl fidl::encoding::ResourceTypeMarker for DeviceRegisterSocketRequest {
629 type Borrowed<'a> = &'a mut Self;
630 fn take_or_borrow<'a>(
631 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
632 ) -> Self::Borrowed<'a> {
633 value
634 }
635 }
636
637 unsafe impl fidl::encoding::TypeMarker for DeviceRegisterSocketRequest {
638 type Owned = Self;
639
640 #[inline(always)]
641 fn inline_align(_context: fidl::encoding::Context) -> usize {
642 8
643 }
644
645 #[inline(always)]
646 fn inline_size(_context: fidl::encoding::Context) -> usize {
647 16
648 }
649 }
650
651 unsafe impl
652 fidl::encoding::Encode<
653 DeviceRegisterSocketRequest,
654 fidl::encoding::DefaultFuchsiaResourceDialect,
655 > for &mut DeviceRegisterSocketRequest
656 {
657 unsafe fn encode(
658 self,
659 encoder: &mut fidl::encoding::Encoder<
660 '_,
661 fidl::encoding::DefaultFuchsiaResourceDialect,
662 >,
663 offset: usize,
664 mut depth: fidl::encoding::Depth,
665 ) -> fidl::Result<()> {
666 encoder.debug_check_bounds::<DeviceRegisterSocketRequest>(offset);
667 let max_ordinal: u64 = self.max_ordinal_present();
669 encoder.write_num(max_ordinal, offset);
670 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
671 if max_ordinal == 0 {
673 return Ok(());
674 }
675 depth.increment()?;
676 let envelope_size = 8;
677 let bytes_len = max_ordinal as usize * envelope_size;
678 #[allow(unused_variables)]
679 let offset = encoder.out_of_line_offset(bytes_len);
680 let mut _prev_end_offset: usize = 0;
681 if 1 > max_ordinal {
682 return Ok(());
683 }
684
685 let cur_offset: usize = (1 - 1) * envelope_size;
688
689 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
691
692 fidl::encoding::encode_in_envelope_optional::<
697 fidl::encoding::HandleType<
698 fidl::Socket,
699 { fidl::ObjectType::SOCKET.into_raw() },
700 2147483648,
701 >,
702 fidl::encoding::DefaultFuchsiaResourceDialect,
703 >(
704 self.server_socket.as_mut().map(
705 <fidl::encoding::HandleType<
706 fidl::Socket,
707 { fidl::ObjectType::SOCKET.into_raw() },
708 2147483648,
709 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
710 ),
711 encoder,
712 offset + cur_offset,
713 depth,
714 )?;
715
716 _prev_end_offset = cur_offset + envelope_size;
717 if 2 > max_ordinal {
718 return Ok(());
719 }
720
721 let cur_offset: usize = (2 - 1) * envelope_size;
724
725 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
727
728 fidl::encoding::encode_in_envelope_optional::<
733 fidl::encoding::UnboundedString,
734 fidl::encoding::DefaultFuchsiaResourceDialect,
735 >(
736 self.socket_label.as_ref().map(
737 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow,
738 ),
739 encoder,
740 offset + cur_offset,
741 depth,
742 )?;
743
744 _prev_end_offset = cur_offset + envelope_size;
745
746 Ok(())
747 }
748 }
749
750 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
751 for DeviceRegisterSocketRequest
752 {
753 #[inline(always)]
754 fn new_empty() -> Self {
755 Self::default()
756 }
757
758 unsafe fn decode(
759 &mut self,
760 decoder: &mut fidl::encoding::Decoder<
761 '_,
762 fidl::encoding::DefaultFuchsiaResourceDialect,
763 >,
764 offset: usize,
765 mut depth: fidl::encoding::Depth,
766 ) -> fidl::Result<()> {
767 decoder.debug_check_bounds::<Self>(offset);
768 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
769 None => return Err(fidl::Error::NotNullable),
770 Some(len) => len,
771 };
772 if len == 0 {
774 return Ok(());
775 };
776 depth.increment()?;
777 let envelope_size = 8;
778 let bytes_len = len * envelope_size;
779 let offset = decoder.out_of_line_offset(bytes_len)?;
780 let mut _next_ordinal_to_read = 0;
782 let mut next_offset = offset;
783 let end_offset = offset + bytes_len;
784 _next_ordinal_to_read += 1;
785 if next_offset >= end_offset {
786 return Ok(());
787 }
788
789 while _next_ordinal_to_read < 1 {
791 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
792 _next_ordinal_to_read += 1;
793 next_offset += envelope_size;
794 }
795
796 let next_out_of_line = decoder.next_out_of_line();
797 let handles_before = decoder.remaining_handles();
798 if let Some((inlined, num_bytes, num_handles)) =
799 fidl::encoding::decode_envelope_header(decoder, next_offset)?
800 {
801 let member_inline_size = <fidl::encoding::HandleType<
802 fidl::Socket,
803 { fidl::ObjectType::SOCKET.into_raw() },
804 2147483648,
805 > as fidl::encoding::TypeMarker>::inline_size(
806 decoder.context
807 );
808 if inlined != (member_inline_size <= 4) {
809 return Err(fidl::Error::InvalidInlineBitInEnvelope);
810 }
811 let inner_offset;
812 let mut inner_depth = depth.clone();
813 if inlined {
814 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
815 inner_offset = next_offset;
816 } else {
817 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
818 inner_depth.increment()?;
819 }
820 let val_ref =
821 self.server_socket.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
822 fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
823 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
824 {
825 return Err(fidl::Error::InvalidNumBytesInEnvelope);
826 }
827 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
828 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
829 }
830 }
831
832 next_offset += envelope_size;
833 _next_ordinal_to_read += 1;
834 if next_offset >= end_offset {
835 return Ok(());
836 }
837
838 while _next_ordinal_to_read < 2 {
840 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
841 _next_ordinal_to_read += 1;
842 next_offset += envelope_size;
843 }
844
845 let next_out_of_line = decoder.next_out_of_line();
846 let handles_before = decoder.remaining_handles();
847 if let Some((inlined, num_bytes, num_handles)) =
848 fidl::encoding::decode_envelope_header(decoder, next_offset)?
849 {
850 let member_inline_size =
851 <fidl::encoding::UnboundedString as fidl::encoding::TypeMarker>::inline_size(
852 decoder.context,
853 );
854 if inlined != (member_inline_size <= 4) {
855 return Err(fidl::Error::InvalidInlineBitInEnvelope);
856 }
857 let inner_offset;
858 let mut inner_depth = depth.clone();
859 if inlined {
860 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
861 inner_offset = next_offset;
862 } else {
863 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
864 inner_depth.increment()?;
865 }
866 let val_ref = self.socket_label.get_or_insert_with(|| {
867 fidl::new_empty!(
868 fidl::encoding::UnboundedString,
869 fidl::encoding::DefaultFuchsiaResourceDialect
870 )
871 });
872 fidl::decode!(
873 fidl::encoding::UnboundedString,
874 fidl::encoding::DefaultFuchsiaResourceDialect,
875 val_ref,
876 decoder,
877 inner_offset,
878 inner_depth
879 )?;
880 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
881 {
882 return Err(fidl::Error::InvalidNumBytesInEnvelope);
883 }
884 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
885 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
886 }
887 }
888
889 next_offset += envelope_size;
890
891 while next_offset < end_offset {
893 _next_ordinal_to_read += 1;
894 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
895 next_offset += envelope_size;
896 }
897
898 Ok(())
899 }
900 }
901}