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_usb_endpoint_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct EndpointOnCompletionRequest {
16 pub completion: Vec<Completion>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20 for EndpointOnCompletionRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct EndpointQueueRequestsRequest {
26 pub req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30 for EndpointQueueRequestsRequest
31{
32}
33
34#[derive(Debug, PartialEq)]
35pub struct EndpointRegisterVmosRequest {
36 pub vmo_ids: Vec<VmoInfo>,
37}
38
39impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
40 for EndpointRegisterVmosRequest
41{
42}
43
44#[derive(Debug, PartialEq)]
45pub struct EndpointRegisterVmosResponse {
46 pub vmos: Vec<VmoHandle>,
47}
48
49impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
50 for EndpointRegisterVmosResponse
51{
52}
53
54#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
55pub struct EndpointUnregisterVmosResponse {
56 pub failed_vmo_ids: Vec<u64>,
57 pub errors: Vec<i32>,
58}
59
60impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
61 for EndpointUnregisterVmosResponse
62{
63}
64
65#[derive(Debug, Default, PartialEq)]
67pub struct Completion {
68 pub request: Option<fidl_fuchsia_hardware_usb_request::Request>,
70 pub status: Option<i32>,
92 pub transfer_size: Option<u64>,
94 pub wake_lease: Option<fidl::EventPair>,
96 #[doc(hidden)]
97 pub __source_breaking: fidl::marker::SourceBreaking,
98}
99
100impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Completion {}
101
102#[derive(Debug, Default, PartialEq)]
105pub struct VmoHandle {
106 pub id: Option<u64>,
108 pub vmo: Option<fidl::Vmo>,
110 #[doc(hidden)]
111 pub __source_breaking: fidl::marker::SourceBreaking,
112}
113
114impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for VmoHandle {}
115
116#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
117pub struct EndpointMarker;
118
119impl fidl::endpoints::ProtocolMarker for EndpointMarker {
120 type Proxy = EndpointProxy;
121 type RequestStream = EndpointRequestStream;
122 #[cfg(target_os = "fuchsia")]
123 type SynchronousProxy = EndpointSynchronousProxy;
124
125 const DEBUG_NAME: &'static str = "fuchsia.hardware.usb.endpoint.Endpoint";
126}
127impl fidl::endpoints::DiscoverableProtocolMarker for EndpointMarker {}
128pub type EndpointGetInfoResult = Result<EndpointInfo, i32>;
129pub type EndpointCancelAllResult = Result<(), i32>;
130
131pub trait EndpointProxyInterface: Send + Sync {
132 type GetInfoResponseFut: std::future::Future<Output = Result<EndpointGetInfoResult, fidl::Error>>
133 + Send;
134 fn r#get_info(&self) -> Self::GetInfoResponseFut;
135 type RegisterVmosResponseFut: std::future::Future<Output = Result<Vec<VmoHandle>, fidl::Error>>
136 + Send;
137 fn r#register_vmos(&self, vmo_ids: &[VmoInfo]) -> Self::RegisterVmosResponseFut;
138 type UnregisterVmosResponseFut: std::future::Future<Output = Result<(Vec<u64>, Vec<i32>), fidl::Error>>
139 + Send;
140 fn r#unregister_vmos(&self, vmo_ids: &[u64]) -> Self::UnregisterVmosResponseFut;
141 fn r#queue_requests(
142 &self,
143 req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
144 ) -> Result<(), fidl::Error>;
145 type CancelAllResponseFut: std::future::Future<Output = Result<EndpointCancelAllResult, fidl::Error>>
146 + Send;
147 fn r#cancel_all(&self) -> Self::CancelAllResponseFut;
148}
149#[derive(Debug)]
150#[cfg(target_os = "fuchsia")]
151pub struct EndpointSynchronousProxy {
152 client: fidl::client::sync::Client,
153}
154
155#[cfg(target_os = "fuchsia")]
156impl fidl::endpoints::SynchronousProxy for EndpointSynchronousProxy {
157 type Proxy = EndpointProxy;
158 type Protocol = EndpointMarker;
159
160 fn from_channel(inner: fidl::Channel) -> Self {
161 Self::new(inner)
162 }
163
164 fn into_channel(self) -> fidl::Channel {
165 self.client.into_channel()
166 }
167
168 fn as_channel(&self) -> &fidl::Channel {
169 self.client.as_channel()
170 }
171}
172
173#[cfg(target_os = "fuchsia")]
174impl EndpointSynchronousProxy {
175 pub fn new(channel: fidl::Channel) -> Self {
176 Self { client: fidl::client::sync::Client::new(channel) }
177 }
178
179 pub fn into_channel(self) -> fidl::Channel {
180 self.client.into_channel()
181 }
182
183 pub fn wait_for_event(
186 &self,
187 deadline: zx::MonotonicInstant,
188 ) -> Result<EndpointEvent, fidl::Error> {
189 EndpointEvent::decode(self.client.wait_for_event::<EndpointMarker>(deadline)?)
190 }
191
192 pub fn r#get_info(
194 &self,
195 ___deadline: zx::MonotonicInstant,
196 ) -> Result<EndpointGetInfoResult, fidl::Error> {
197 let _response = self.client.send_query::<
198 fidl::encoding::EmptyPayload,
199 fidl::encoding::ResultType<EndpointGetInfoResponse, i32>,
200 EndpointMarker,
201 >(
202 (),
203 0x1fba84f171a95023,
204 fidl::encoding::DynamicFlags::empty(),
205 ___deadline,
206 )?;
207 Ok(_response.map(|x| x.info))
208 }
209
210 pub fn r#register_vmos(
214 &self,
215 mut vmo_ids: &[VmoInfo],
216 ___deadline: zx::MonotonicInstant,
217 ) -> Result<Vec<VmoHandle>, fidl::Error> {
218 let _response = self.client.send_query::<
219 EndpointRegisterVmosRequest,
220 EndpointRegisterVmosResponse,
221 EndpointMarker,
222 >(
223 (vmo_ids,),
224 0x1dea601921185c7b,
225 fidl::encoding::DynamicFlags::empty(),
226 ___deadline,
227 )?;
228 Ok(_response.vmos)
229 }
230
231 pub fn r#unregister_vmos(
235 &self,
236 mut vmo_ids: &[u64],
237 ___deadline: zx::MonotonicInstant,
238 ) -> Result<(Vec<u64>, Vec<i32>), fidl::Error> {
239 let _response = self.client.send_query::<
240 EndpointUnregisterVmosRequest,
241 EndpointUnregisterVmosResponse,
242 EndpointMarker,
243 >(
244 (vmo_ids,),
245 0x34719ede1c99c10,
246 fidl::encoding::DynamicFlags::empty(),
247 ___deadline,
248 )?;
249 Ok((_response.failed_vmo_ids, _response.errors))
250 }
251
252 pub fn r#queue_requests(
285 &self,
286 mut req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
287 ) -> Result<(), fidl::Error> {
288 self.client.send::<EndpointQueueRequestsRequest>(
289 (req.as_mut(),),
290 0x431e4170793e38a6,
291 fidl::encoding::DynamicFlags::empty(),
292 )
293 }
294
295 pub fn r#cancel_all(
299 &self,
300 ___deadline: zx::MonotonicInstant,
301 ) -> Result<EndpointCancelAllResult, fidl::Error> {
302 let _response = self.client.send_query::<
303 fidl::encoding::EmptyPayload,
304 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
305 EndpointMarker,
306 >(
307 (),
308 0x233854c776cda1cc,
309 fidl::encoding::DynamicFlags::empty(),
310 ___deadline,
311 )?;
312 Ok(_response.map(|x| x))
313 }
314}
315
316#[cfg(target_os = "fuchsia")]
317impl From<EndpointSynchronousProxy> for zx::NullableHandle {
318 fn from(value: EndpointSynchronousProxy) -> Self {
319 value.into_channel().into()
320 }
321}
322
323#[cfg(target_os = "fuchsia")]
324impl From<fidl::Channel> for EndpointSynchronousProxy {
325 fn from(value: fidl::Channel) -> Self {
326 Self::new(value)
327 }
328}
329
330#[cfg(target_os = "fuchsia")]
331impl fidl::endpoints::FromClient for EndpointSynchronousProxy {
332 type Protocol = EndpointMarker;
333
334 fn from_client(value: fidl::endpoints::ClientEnd<EndpointMarker>) -> Self {
335 Self::new(value.into_channel())
336 }
337}
338
339#[derive(Debug, Clone)]
340pub struct EndpointProxy {
341 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
342}
343
344impl fidl::endpoints::Proxy for EndpointProxy {
345 type Protocol = EndpointMarker;
346
347 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
348 Self::new(inner)
349 }
350
351 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
352 self.client.into_channel().map_err(|client| Self { client })
353 }
354
355 fn as_channel(&self) -> &::fidl::AsyncChannel {
356 self.client.as_channel()
357 }
358}
359
360impl EndpointProxy {
361 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
363 let protocol_name = <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
364 Self { client: fidl::client::Client::new(channel, protocol_name) }
365 }
366
367 pub fn take_event_stream(&self) -> EndpointEventStream {
373 EndpointEventStream { event_receiver: self.client.take_event_receiver() }
374 }
375
376 pub fn r#get_info(
378 &self,
379 ) -> fidl::client::QueryResponseFut<
380 EndpointGetInfoResult,
381 fidl::encoding::DefaultFuchsiaResourceDialect,
382 > {
383 EndpointProxyInterface::r#get_info(self)
384 }
385
386 pub fn r#register_vmos(
390 &self,
391 mut vmo_ids: &[VmoInfo],
392 ) -> fidl::client::QueryResponseFut<Vec<VmoHandle>, fidl::encoding::DefaultFuchsiaResourceDialect>
393 {
394 EndpointProxyInterface::r#register_vmos(self, vmo_ids)
395 }
396
397 pub fn r#unregister_vmos(
401 &self,
402 mut vmo_ids: &[u64],
403 ) -> fidl::client::QueryResponseFut<
404 (Vec<u64>, Vec<i32>),
405 fidl::encoding::DefaultFuchsiaResourceDialect,
406 > {
407 EndpointProxyInterface::r#unregister_vmos(self, vmo_ids)
408 }
409
410 pub fn r#queue_requests(
443 &self,
444 mut req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
445 ) -> Result<(), fidl::Error> {
446 EndpointProxyInterface::r#queue_requests(self, req)
447 }
448
449 pub fn r#cancel_all(
453 &self,
454 ) -> fidl::client::QueryResponseFut<
455 EndpointCancelAllResult,
456 fidl::encoding::DefaultFuchsiaResourceDialect,
457 > {
458 EndpointProxyInterface::r#cancel_all(self)
459 }
460}
461
462impl EndpointProxyInterface for EndpointProxy {
463 type GetInfoResponseFut = fidl::client::QueryResponseFut<
464 EndpointGetInfoResult,
465 fidl::encoding::DefaultFuchsiaResourceDialect,
466 >;
467 fn r#get_info(&self) -> Self::GetInfoResponseFut {
468 fn _decode(
469 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
470 ) -> Result<EndpointGetInfoResult, fidl::Error> {
471 let _response = fidl::client::decode_transaction_body::<
472 fidl::encoding::ResultType<EndpointGetInfoResponse, i32>,
473 fidl::encoding::DefaultFuchsiaResourceDialect,
474 0x1fba84f171a95023,
475 >(_buf?)?;
476 Ok(_response.map(|x| x.info))
477 }
478 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, EndpointGetInfoResult>(
479 (),
480 0x1fba84f171a95023,
481 fidl::encoding::DynamicFlags::empty(),
482 _decode,
483 )
484 }
485
486 type RegisterVmosResponseFut = fidl::client::QueryResponseFut<
487 Vec<VmoHandle>,
488 fidl::encoding::DefaultFuchsiaResourceDialect,
489 >;
490 fn r#register_vmos(&self, mut vmo_ids: &[VmoInfo]) -> Self::RegisterVmosResponseFut {
491 fn _decode(
492 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
493 ) -> Result<Vec<VmoHandle>, fidl::Error> {
494 let _response = fidl::client::decode_transaction_body::<
495 EndpointRegisterVmosResponse,
496 fidl::encoding::DefaultFuchsiaResourceDialect,
497 0x1dea601921185c7b,
498 >(_buf?)?;
499 Ok(_response.vmos)
500 }
501 self.client.send_query_and_decode::<EndpointRegisterVmosRequest, Vec<VmoHandle>>(
502 (vmo_ids,),
503 0x1dea601921185c7b,
504 fidl::encoding::DynamicFlags::empty(),
505 _decode,
506 )
507 }
508
509 type UnregisterVmosResponseFut = fidl::client::QueryResponseFut<
510 (Vec<u64>, Vec<i32>),
511 fidl::encoding::DefaultFuchsiaResourceDialect,
512 >;
513 fn r#unregister_vmos(&self, mut vmo_ids: &[u64]) -> Self::UnregisterVmosResponseFut {
514 fn _decode(
515 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
516 ) -> Result<(Vec<u64>, Vec<i32>), fidl::Error> {
517 let _response = fidl::client::decode_transaction_body::<
518 EndpointUnregisterVmosResponse,
519 fidl::encoding::DefaultFuchsiaResourceDialect,
520 0x34719ede1c99c10,
521 >(_buf?)?;
522 Ok((_response.failed_vmo_ids, _response.errors))
523 }
524 self.client.send_query_and_decode::<EndpointUnregisterVmosRequest, (Vec<u64>, Vec<i32>)>(
525 (vmo_ids,),
526 0x34719ede1c99c10,
527 fidl::encoding::DynamicFlags::empty(),
528 _decode,
529 )
530 }
531
532 fn r#queue_requests(
533 &self,
534 mut req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
535 ) -> Result<(), fidl::Error> {
536 self.client.send::<EndpointQueueRequestsRequest>(
537 (req.as_mut(),),
538 0x431e4170793e38a6,
539 fidl::encoding::DynamicFlags::empty(),
540 )
541 }
542
543 type CancelAllResponseFut = fidl::client::QueryResponseFut<
544 EndpointCancelAllResult,
545 fidl::encoding::DefaultFuchsiaResourceDialect,
546 >;
547 fn r#cancel_all(&self) -> Self::CancelAllResponseFut {
548 fn _decode(
549 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
550 ) -> Result<EndpointCancelAllResult, fidl::Error> {
551 let _response = fidl::client::decode_transaction_body::<
552 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
553 fidl::encoding::DefaultFuchsiaResourceDialect,
554 0x233854c776cda1cc,
555 >(_buf?)?;
556 Ok(_response.map(|x| x))
557 }
558 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, EndpointCancelAllResult>(
559 (),
560 0x233854c776cda1cc,
561 fidl::encoding::DynamicFlags::empty(),
562 _decode,
563 )
564 }
565}
566
567pub struct EndpointEventStream {
568 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
569}
570
571impl std::marker::Unpin for EndpointEventStream {}
572
573impl futures::stream::FusedStream for EndpointEventStream {
574 fn is_terminated(&self) -> bool {
575 self.event_receiver.is_terminated()
576 }
577}
578
579impl futures::Stream for EndpointEventStream {
580 type Item = Result<EndpointEvent, fidl::Error>;
581
582 fn poll_next(
583 mut self: std::pin::Pin<&mut Self>,
584 cx: &mut std::task::Context<'_>,
585 ) -> std::task::Poll<Option<Self::Item>> {
586 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
587 &mut self.event_receiver,
588 cx
589 )?) {
590 Some(buf) => std::task::Poll::Ready(Some(EndpointEvent::decode(buf))),
591 None => std::task::Poll::Ready(None),
592 }
593 }
594}
595
596#[derive(Debug)]
597pub enum EndpointEvent {
598 OnCompletion { completion: Vec<Completion> },
599}
600
601impl EndpointEvent {
602 #[allow(irrefutable_let_patterns)]
603 pub fn into_on_completion(self) -> Option<Vec<Completion>> {
604 if let EndpointEvent::OnCompletion { completion } = self {
605 Some((completion))
606 } else {
607 None
608 }
609 }
610
611 fn decode(
613 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
614 ) -> Result<EndpointEvent, fidl::Error> {
615 let (bytes, _handles) = buf.split_mut();
616 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
617 debug_assert_eq!(tx_header.tx_id, 0);
618 match tx_header.ordinal {
619 0x2d6471306c049771 => {
620 let mut out = fidl::new_empty!(
621 EndpointOnCompletionRequest,
622 fidl::encoding::DefaultFuchsiaResourceDialect
623 );
624 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointOnCompletionRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
625 Ok((EndpointEvent::OnCompletion { completion: out.completion }))
626 }
627 _ => Err(fidl::Error::UnknownOrdinal {
628 ordinal: tx_header.ordinal,
629 protocol_name: <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
630 }),
631 }
632 }
633}
634
635pub struct EndpointRequestStream {
637 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
638 is_terminated: bool,
639}
640
641impl std::marker::Unpin for EndpointRequestStream {}
642
643impl futures::stream::FusedStream for EndpointRequestStream {
644 fn is_terminated(&self) -> bool {
645 self.is_terminated
646 }
647}
648
649impl fidl::endpoints::RequestStream for EndpointRequestStream {
650 type Protocol = EndpointMarker;
651 type ControlHandle = EndpointControlHandle;
652
653 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
654 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
655 }
656
657 fn control_handle(&self) -> Self::ControlHandle {
658 EndpointControlHandle { inner: self.inner.clone() }
659 }
660
661 fn into_inner(
662 self,
663 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
664 {
665 (self.inner, self.is_terminated)
666 }
667
668 fn from_inner(
669 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
670 is_terminated: bool,
671 ) -> Self {
672 Self { inner, is_terminated }
673 }
674}
675
676impl futures::Stream for EndpointRequestStream {
677 type Item = Result<EndpointRequest, fidl::Error>;
678
679 fn poll_next(
680 mut self: std::pin::Pin<&mut Self>,
681 cx: &mut std::task::Context<'_>,
682 ) -> std::task::Poll<Option<Self::Item>> {
683 let this = &mut *self;
684 if this.inner.check_shutdown(cx) {
685 this.is_terminated = true;
686 return std::task::Poll::Ready(None);
687 }
688 if this.is_terminated {
689 panic!("polled EndpointRequestStream after completion");
690 }
691 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
692 |bytes, handles| {
693 match this.inner.channel().read_etc(cx, bytes, handles) {
694 std::task::Poll::Ready(Ok(())) => {}
695 std::task::Poll::Pending => return std::task::Poll::Pending,
696 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
697 this.is_terminated = true;
698 return std::task::Poll::Ready(None);
699 }
700 std::task::Poll::Ready(Err(e)) => {
701 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
702 e.into(),
703 ))));
704 }
705 }
706
707 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
709
710 std::task::Poll::Ready(Some(match header.ordinal {
711 0x1fba84f171a95023 => {
712 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
713 let mut req = fidl::new_empty!(
714 fidl::encoding::EmptyPayload,
715 fidl::encoding::DefaultFuchsiaResourceDialect
716 );
717 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
718 let control_handle = EndpointControlHandle { inner: this.inner.clone() };
719 Ok(EndpointRequest::GetInfo {
720 responder: EndpointGetInfoResponder {
721 control_handle: std::mem::ManuallyDrop::new(control_handle),
722 tx_id: header.tx_id,
723 },
724 })
725 }
726 0x1dea601921185c7b => {
727 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
728 let mut req = fidl::new_empty!(
729 EndpointRegisterVmosRequest,
730 fidl::encoding::DefaultFuchsiaResourceDialect
731 );
732 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointRegisterVmosRequest>(&header, _body_bytes, handles, &mut req)?;
733 let control_handle = EndpointControlHandle { inner: this.inner.clone() };
734 Ok(EndpointRequest::RegisterVmos {
735 vmo_ids: req.vmo_ids,
736
737 responder: EndpointRegisterVmosResponder {
738 control_handle: std::mem::ManuallyDrop::new(control_handle),
739 tx_id: header.tx_id,
740 },
741 })
742 }
743 0x34719ede1c99c10 => {
744 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
745 let mut req = fidl::new_empty!(
746 EndpointUnregisterVmosRequest,
747 fidl::encoding::DefaultFuchsiaResourceDialect
748 );
749 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointUnregisterVmosRequest>(&header, _body_bytes, handles, &mut req)?;
750 let control_handle = EndpointControlHandle { inner: this.inner.clone() };
751 Ok(EndpointRequest::UnregisterVmos {
752 vmo_ids: req.vmo_ids,
753
754 responder: EndpointUnregisterVmosResponder {
755 control_handle: std::mem::ManuallyDrop::new(control_handle),
756 tx_id: header.tx_id,
757 },
758 })
759 }
760 0x431e4170793e38a6 => {
761 header.validate_request_tx_id(fidl::MethodType::OneWay)?;
762 let mut req = fidl::new_empty!(
763 EndpointQueueRequestsRequest,
764 fidl::encoding::DefaultFuchsiaResourceDialect
765 );
766 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<EndpointQueueRequestsRequest>(&header, _body_bytes, handles, &mut req)?;
767 let control_handle = EndpointControlHandle { inner: this.inner.clone() };
768 Ok(EndpointRequest::QueueRequests { req: req.req, control_handle })
769 }
770 0x233854c776cda1cc => {
771 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
772 let mut req = fidl::new_empty!(
773 fidl::encoding::EmptyPayload,
774 fidl::encoding::DefaultFuchsiaResourceDialect
775 );
776 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
777 let control_handle = EndpointControlHandle { inner: this.inner.clone() };
778 Ok(EndpointRequest::CancelAll {
779 responder: EndpointCancelAllResponder {
780 control_handle: std::mem::ManuallyDrop::new(control_handle),
781 tx_id: header.tx_id,
782 },
783 })
784 }
785 _ => Err(fidl::Error::UnknownOrdinal {
786 ordinal: header.ordinal,
787 protocol_name:
788 <EndpointMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
789 }),
790 }))
791 },
792 )
793 }
794}
795
796#[derive(Debug)]
801pub enum EndpointRequest {
802 GetInfo { responder: EndpointGetInfoResponder },
804 RegisterVmos { vmo_ids: Vec<VmoInfo>, responder: EndpointRegisterVmosResponder },
808 UnregisterVmos { vmo_ids: Vec<u64>, responder: EndpointUnregisterVmosResponder },
812 QueueRequests {
845 req: Vec<fidl_fuchsia_hardware_usb_request::Request>,
846 control_handle: EndpointControlHandle,
847 },
848 CancelAll { responder: EndpointCancelAllResponder },
852}
853
854impl EndpointRequest {
855 #[allow(irrefutable_let_patterns)]
856 pub fn into_get_info(self) -> Option<(EndpointGetInfoResponder)> {
857 if let EndpointRequest::GetInfo { responder } = self { Some((responder)) } else { None }
858 }
859
860 #[allow(irrefutable_let_patterns)]
861 pub fn into_register_vmos(self) -> Option<(Vec<VmoInfo>, EndpointRegisterVmosResponder)> {
862 if let EndpointRequest::RegisterVmos { vmo_ids, responder } = self {
863 Some((vmo_ids, responder))
864 } else {
865 None
866 }
867 }
868
869 #[allow(irrefutable_let_patterns)]
870 pub fn into_unregister_vmos(self) -> Option<(Vec<u64>, EndpointUnregisterVmosResponder)> {
871 if let EndpointRequest::UnregisterVmos { vmo_ids, responder } = self {
872 Some((vmo_ids, responder))
873 } else {
874 None
875 }
876 }
877
878 #[allow(irrefutable_let_patterns)]
879 pub fn into_queue_requests(
880 self,
881 ) -> Option<(Vec<fidl_fuchsia_hardware_usb_request::Request>, EndpointControlHandle)> {
882 if let EndpointRequest::QueueRequests { req, control_handle } = self {
883 Some((req, control_handle))
884 } else {
885 None
886 }
887 }
888
889 #[allow(irrefutable_let_patterns)]
890 pub fn into_cancel_all(self) -> Option<(EndpointCancelAllResponder)> {
891 if let EndpointRequest::CancelAll { responder } = self { Some((responder)) } else { None }
892 }
893
894 pub fn method_name(&self) -> &'static str {
896 match *self {
897 EndpointRequest::GetInfo { .. } => "get_info",
898 EndpointRequest::RegisterVmos { .. } => "register_vmos",
899 EndpointRequest::UnregisterVmos { .. } => "unregister_vmos",
900 EndpointRequest::QueueRequests { .. } => "queue_requests",
901 EndpointRequest::CancelAll { .. } => "cancel_all",
902 }
903 }
904}
905
906#[derive(Debug, Clone)]
907pub struct EndpointControlHandle {
908 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
909}
910
911impl EndpointControlHandle {
912 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
913 self.inner.shutdown_with_epitaph(status.into())
914 }
915}
916
917impl fidl::endpoints::ControlHandle for EndpointControlHandle {
918 fn shutdown(&self) {
919 self.inner.shutdown()
920 }
921
922 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
923 self.inner.shutdown_with_epitaph(status)
924 }
925
926 fn is_closed(&self) -> bool {
927 self.inner.channel().is_closed()
928 }
929 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
930 self.inner.channel().on_closed()
931 }
932
933 #[cfg(target_os = "fuchsia")]
934 fn signal_peer(
935 &self,
936 clear_mask: zx::Signals,
937 set_mask: zx::Signals,
938 ) -> Result<(), zx_status::Status> {
939 use fidl::Peered;
940 self.inner.channel().signal_peer(clear_mask, set_mask)
941 }
942}
943
944impl EndpointControlHandle {
945 pub fn send_on_completion(&self, mut completion: Vec<Completion>) -> Result<(), fidl::Error> {
946 self.inner.send::<EndpointOnCompletionRequest>(
947 (completion.as_mut(),),
948 0,
949 0x2d6471306c049771,
950 fidl::encoding::DynamicFlags::empty(),
951 )
952 }
953}
954
955#[must_use = "FIDL methods require a response to be sent"]
956#[derive(Debug)]
957pub struct EndpointGetInfoResponder {
958 control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
959 tx_id: u32,
960}
961
962impl std::ops::Drop for EndpointGetInfoResponder {
966 fn drop(&mut self) {
967 self.control_handle.shutdown();
968 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
970 }
971}
972
973impl fidl::endpoints::Responder for EndpointGetInfoResponder {
974 type ControlHandle = EndpointControlHandle;
975
976 fn control_handle(&self) -> &EndpointControlHandle {
977 &self.control_handle
978 }
979
980 fn drop_without_shutdown(mut self) {
981 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
983 std::mem::forget(self);
985 }
986}
987
988impl EndpointGetInfoResponder {
989 pub fn send(self, mut result: Result<&EndpointInfo, i32>) -> Result<(), fidl::Error> {
993 let _result = self.send_raw(result);
994 if _result.is_err() {
995 self.control_handle.shutdown();
996 }
997 self.drop_without_shutdown();
998 _result
999 }
1000
1001 pub fn send_no_shutdown_on_err(
1003 self,
1004 mut result: Result<&EndpointInfo, i32>,
1005 ) -> Result<(), fidl::Error> {
1006 let _result = self.send_raw(result);
1007 self.drop_without_shutdown();
1008 _result
1009 }
1010
1011 fn send_raw(&self, mut result: Result<&EndpointInfo, i32>) -> Result<(), fidl::Error> {
1012 self.control_handle.inner.send::<fidl::encoding::ResultType<EndpointGetInfoResponse, i32>>(
1013 result.map(|info| (info,)),
1014 self.tx_id,
1015 0x1fba84f171a95023,
1016 fidl::encoding::DynamicFlags::empty(),
1017 )
1018 }
1019}
1020
1021#[must_use = "FIDL methods require a response to be sent"]
1022#[derive(Debug)]
1023pub struct EndpointRegisterVmosResponder {
1024 control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1025 tx_id: u32,
1026}
1027
1028impl std::ops::Drop for EndpointRegisterVmosResponder {
1032 fn drop(&mut self) {
1033 self.control_handle.shutdown();
1034 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1036 }
1037}
1038
1039impl fidl::endpoints::Responder for EndpointRegisterVmosResponder {
1040 type ControlHandle = EndpointControlHandle;
1041
1042 fn control_handle(&self) -> &EndpointControlHandle {
1043 &self.control_handle
1044 }
1045
1046 fn drop_without_shutdown(mut self) {
1047 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1049 std::mem::forget(self);
1051 }
1052}
1053
1054impl EndpointRegisterVmosResponder {
1055 pub fn send(self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1059 let _result = self.send_raw(vmos);
1060 if _result.is_err() {
1061 self.control_handle.shutdown();
1062 }
1063 self.drop_without_shutdown();
1064 _result
1065 }
1066
1067 pub fn send_no_shutdown_on_err(self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1069 let _result = self.send_raw(vmos);
1070 self.drop_without_shutdown();
1071 _result
1072 }
1073
1074 fn send_raw(&self, mut vmos: Vec<VmoHandle>) -> Result<(), fidl::Error> {
1075 self.control_handle.inner.send::<EndpointRegisterVmosResponse>(
1076 (vmos.as_mut(),),
1077 self.tx_id,
1078 0x1dea601921185c7b,
1079 fidl::encoding::DynamicFlags::empty(),
1080 )
1081 }
1082}
1083
1084#[must_use = "FIDL methods require a response to be sent"]
1085#[derive(Debug)]
1086pub struct EndpointUnregisterVmosResponder {
1087 control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1088 tx_id: u32,
1089}
1090
1091impl std::ops::Drop for EndpointUnregisterVmosResponder {
1095 fn drop(&mut self) {
1096 self.control_handle.shutdown();
1097 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1099 }
1100}
1101
1102impl fidl::endpoints::Responder for EndpointUnregisterVmosResponder {
1103 type ControlHandle = EndpointControlHandle;
1104
1105 fn control_handle(&self) -> &EndpointControlHandle {
1106 &self.control_handle
1107 }
1108
1109 fn drop_without_shutdown(mut self) {
1110 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1112 std::mem::forget(self);
1114 }
1115}
1116
1117impl EndpointUnregisterVmosResponder {
1118 pub fn send(self, mut failed_vmo_ids: &[u64], mut errors: &[i32]) -> Result<(), fidl::Error> {
1122 let _result = self.send_raw(failed_vmo_ids, errors);
1123 if _result.is_err() {
1124 self.control_handle.shutdown();
1125 }
1126 self.drop_without_shutdown();
1127 _result
1128 }
1129
1130 pub fn send_no_shutdown_on_err(
1132 self,
1133 mut failed_vmo_ids: &[u64],
1134 mut errors: &[i32],
1135 ) -> Result<(), fidl::Error> {
1136 let _result = self.send_raw(failed_vmo_ids, errors);
1137 self.drop_without_shutdown();
1138 _result
1139 }
1140
1141 fn send_raw(&self, mut failed_vmo_ids: &[u64], mut errors: &[i32]) -> Result<(), fidl::Error> {
1142 self.control_handle.inner.send::<EndpointUnregisterVmosResponse>(
1143 (failed_vmo_ids, errors),
1144 self.tx_id,
1145 0x34719ede1c99c10,
1146 fidl::encoding::DynamicFlags::empty(),
1147 )
1148 }
1149}
1150
1151#[must_use = "FIDL methods require a response to be sent"]
1152#[derive(Debug)]
1153pub struct EndpointCancelAllResponder {
1154 control_handle: std::mem::ManuallyDrop<EndpointControlHandle>,
1155 tx_id: u32,
1156}
1157
1158impl std::ops::Drop for EndpointCancelAllResponder {
1162 fn drop(&mut self) {
1163 self.control_handle.shutdown();
1164 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1166 }
1167}
1168
1169impl fidl::endpoints::Responder for EndpointCancelAllResponder {
1170 type ControlHandle = EndpointControlHandle;
1171
1172 fn control_handle(&self) -> &EndpointControlHandle {
1173 &self.control_handle
1174 }
1175
1176 fn drop_without_shutdown(mut self) {
1177 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1179 std::mem::forget(self);
1181 }
1182}
1183
1184impl EndpointCancelAllResponder {
1185 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1189 let _result = self.send_raw(result);
1190 if _result.is_err() {
1191 self.control_handle.shutdown();
1192 }
1193 self.drop_without_shutdown();
1194 _result
1195 }
1196
1197 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1199 let _result = self.send_raw(result);
1200 self.drop_without_shutdown();
1201 _result
1202 }
1203
1204 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1205 self.control_handle
1206 .inner
1207 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1208 result,
1209 self.tx_id,
1210 0x233854c776cda1cc,
1211 fidl::encoding::DynamicFlags::empty(),
1212 )
1213 }
1214}
1215
1216mod internal {
1217 use super::*;
1218
1219 impl fidl::encoding::ResourceTypeMarker for EndpointOnCompletionRequest {
1220 type Borrowed<'a> = &'a mut Self;
1221 fn take_or_borrow<'a>(
1222 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1223 ) -> Self::Borrowed<'a> {
1224 value
1225 }
1226 }
1227
1228 unsafe impl fidl::encoding::TypeMarker for EndpointOnCompletionRequest {
1229 type Owned = Self;
1230
1231 #[inline(always)]
1232 fn inline_align(_context: fidl::encoding::Context) -> usize {
1233 8
1234 }
1235
1236 #[inline(always)]
1237 fn inline_size(_context: fidl::encoding::Context) -> usize {
1238 16
1239 }
1240 }
1241
1242 unsafe impl
1243 fidl::encoding::Encode<
1244 EndpointOnCompletionRequest,
1245 fidl::encoding::DefaultFuchsiaResourceDialect,
1246 > for &mut EndpointOnCompletionRequest
1247 {
1248 #[inline]
1249 unsafe fn encode(
1250 self,
1251 encoder: &mut fidl::encoding::Encoder<
1252 '_,
1253 fidl::encoding::DefaultFuchsiaResourceDialect,
1254 >,
1255 offset: usize,
1256 _depth: fidl::encoding::Depth,
1257 ) -> fidl::Result<()> {
1258 encoder.debug_check_bounds::<EndpointOnCompletionRequest>(offset);
1259 fidl::encoding::Encode::<EndpointOnCompletionRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1261 (
1262 <fidl::encoding::Vector<Completion, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.completion),
1263 ),
1264 encoder, offset, _depth
1265 )
1266 }
1267 }
1268 unsafe impl<
1269 T0: fidl::encoding::Encode<
1270 fidl::encoding::Vector<Completion, 64>,
1271 fidl::encoding::DefaultFuchsiaResourceDialect,
1272 >,
1273 >
1274 fidl::encoding::Encode<
1275 EndpointOnCompletionRequest,
1276 fidl::encoding::DefaultFuchsiaResourceDialect,
1277 > for (T0,)
1278 {
1279 #[inline]
1280 unsafe fn encode(
1281 self,
1282 encoder: &mut fidl::encoding::Encoder<
1283 '_,
1284 fidl::encoding::DefaultFuchsiaResourceDialect,
1285 >,
1286 offset: usize,
1287 depth: fidl::encoding::Depth,
1288 ) -> fidl::Result<()> {
1289 encoder.debug_check_bounds::<EndpointOnCompletionRequest>(offset);
1290 self.0.encode(encoder, offset + 0, depth)?;
1294 Ok(())
1295 }
1296 }
1297
1298 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1299 for EndpointOnCompletionRequest
1300 {
1301 #[inline(always)]
1302 fn new_empty() -> Self {
1303 Self {
1304 completion: fidl::new_empty!(fidl::encoding::Vector<Completion, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
1305 }
1306 }
1307
1308 #[inline]
1309 unsafe fn decode(
1310 &mut self,
1311 decoder: &mut fidl::encoding::Decoder<
1312 '_,
1313 fidl::encoding::DefaultFuchsiaResourceDialect,
1314 >,
1315 offset: usize,
1316 _depth: fidl::encoding::Depth,
1317 ) -> fidl::Result<()> {
1318 decoder.debug_check_bounds::<Self>(offset);
1319 fidl::decode!(fidl::encoding::Vector<Completion, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.completion, decoder, offset + 0, _depth)?;
1321 Ok(())
1322 }
1323 }
1324
1325 impl fidl::encoding::ResourceTypeMarker for EndpointQueueRequestsRequest {
1326 type Borrowed<'a> = &'a mut Self;
1327 fn take_or_borrow<'a>(
1328 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1329 ) -> Self::Borrowed<'a> {
1330 value
1331 }
1332 }
1333
1334 unsafe impl fidl::encoding::TypeMarker for EndpointQueueRequestsRequest {
1335 type Owned = Self;
1336
1337 #[inline(always)]
1338 fn inline_align(_context: fidl::encoding::Context) -> usize {
1339 8
1340 }
1341
1342 #[inline(always)]
1343 fn inline_size(_context: fidl::encoding::Context) -> usize {
1344 16
1345 }
1346 }
1347
1348 unsafe impl
1349 fidl::encoding::Encode<
1350 EndpointQueueRequestsRequest,
1351 fidl::encoding::DefaultFuchsiaResourceDialect,
1352 > for &mut EndpointQueueRequestsRequest
1353 {
1354 #[inline]
1355 unsafe fn encode(
1356 self,
1357 encoder: &mut fidl::encoding::Encoder<
1358 '_,
1359 fidl::encoding::DefaultFuchsiaResourceDialect,
1360 >,
1361 offset: usize,
1362 _depth: fidl::encoding::Depth,
1363 ) -> fidl::Result<()> {
1364 encoder.debug_check_bounds::<EndpointQueueRequestsRequest>(offset);
1365 fidl::encoding::Encode::<EndpointQueueRequestsRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1367 (
1368 <fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.req),
1369 ),
1370 encoder, offset, _depth
1371 )
1372 }
1373 }
1374 unsafe impl<
1375 T0: fidl::encoding::Encode<
1376 fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 64>,
1377 fidl::encoding::DefaultFuchsiaResourceDialect,
1378 >,
1379 >
1380 fidl::encoding::Encode<
1381 EndpointQueueRequestsRequest,
1382 fidl::encoding::DefaultFuchsiaResourceDialect,
1383 > for (T0,)
1384 {
1385 #[inline]
1386 unsafe fn encode(
1387 self,
1388 encoder: &mut fidl::encoding::Encoder<
1389 '_,
1390 fidl::encoding::DefaultFuchsiaResourceDialect,
1391 >,
1392 offset: usize,
1393 depth: fidl::encoding::Depth,
1394 ) -> fidl::Result<()> {
1395 encoder.debug_check_bounds::<EndpointQueueRequestsRequest>(offset);
1396 self.0.encode(encoder, offset + 0, depth)?;
1400 Ok(())
1401 }
1402 }
1403
1404 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1405 for EndpointQueueRequestsRequest
1406 {
1407 #[inline(always)]
1408 fn new_empty() -> Self {
1409 Self {
1410 req: fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
1411 }
1412 }
1413
1414 #[inline]
1415 unsafe fn decode(
1416 &mut self,
1417 decoder: &mut fidl::encoding::Decoder<
1418 '_,
1419 fidl::encoding::DefaultFuchsiaResourceDialect,
1420 >,
1421 offset: usize,
1422 _depth: fidl::encoding::Depth,
1423 ) -> fidl::Result<()> {
1424 decoder.debug_check_bounds::<Self>(offset);
1425 fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_hardware_usb_request::Request, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.req, decoder, offset + 0, _depth)?;
1427 Ok(())
1428 }
1429 }
1430
1431 impl fidl::encoding::ResourceTypeMarker for EndpointRegisterVmosRequest {
1432 type Borrowed<'a> = &'a mut Self;
1433 fn take_or_borrow<'a>(
1434 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1435 ) -> Self::Borrowed<'a> {
1436 value
1437 }
1438 }
1439
1440 unsafe impl fidl::encoding::TypeMarker for EndpointRegisterVmosRequest {
1441 type Owned = Self;
1442
1443 #[inline(always)]
1444 fn inline_align(_context: fidl::encoding::Context) -> usize {
1445 8
1446 }
1447
1448 #[inline(always)]
1449 fn inline_size(_context: fidl::encoding::Context) -> usize {
1450 16
1451 }
1452 }
1453
1454 unsafe impl
1455 fidl::encoding::Encode<
1456 EndpointRegisterVmosRequest,
1457 fidl::encoding::DefaultFuchsiaResourceDialect,
1458 > for &mut EndpointRegisterVmosRequest
1459 {
1460 #[inline]
1461 unsafe fn encode(
1462 self,
1463 encoder: &mut fidl::encoding::Encoder<
1464 '_,
1465 fidl::encoding::DefaultFuchsiaResourceDialect,
1466 >,
1467 offset: usize,
1468 _depth: fidl::encoding::Depth,
1469 ) -> fidl::Result<()> {
1470 encoder.debug_check_bounds::<EndpointRegisterVmosRequest>(offset);
1471 fidl::encoding::Encode::<
1473 EndpointRegisterVmosRequest,
1474 fidl::encoding::DefaultFuchsiaResourceDialect,
1475 >::encode(
1476 (<fidl::encoding::Vector<VmoInfo, 64> as fidl::encoding::ValueTypeMarker>::borrow(
1477 &self.vmo_ids,
1478 ),),
1479 encoder,
1480 offset,
1481 _depth,
1482 )
1483 }
1484 }
1485 unsafe impl<
1486 T0: fidl::encoding::Encode<
1487 fidl::encoding::Vector<VmoInfo, 64>,
1488 fidl::encoding::DefaultFuchsiaResourceDialect,
1489 >,
1490 >
1491 fidl::encoding::Encode<
1492 EndpointRegisterVmosRequest,
1493 fidl::encoding::DefaultFuchsiaResourceDialect,
1494 > for (T0,)
1495 {
1496 #[inline]
1497 unsafe fn encode(
1498 self,
1499 encoder: &mut fidl::encoding::Encoder<
1500 '_,
1501 fidl::encoding::DefaultFuchsiaResourceDialect,
1502 >,
1503 offset: usize,
1504 depth: fidl::encoding::Depth,
1505 ) -> fidl::Result<()> {
1506 encoder.debug_check_bounds::<EndpointRegisterVmosRequest>(offset);
1507 self.0.encode(encoder, offset + 0, depth)?;
1511 Ok(())
1512 }
1513 }
1514
1515 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1516 for EndpointRegisterVmosRequest
1517 {
1518 #[inline(always)]
1519 fn new_empty() -> Self {
1520 Self {
1521 vmo_ids: fidl::new_empty!(fidl::encoding::Vector<VmoInfo, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
1522 }
1523 }
1524
1525 #[inline]
1526 unsafe fn decode(
1527 &mut self,
1528 decoder: &mut fidl::encoding::Decoder<
1529 '_,
1530 fidl::encoding::DefaultFuchsiaResourceDialect,
1531 >,
1532 offset: usize,
1533 _depth: fidl::encoding::Depth,
1534 ) -> fidl::Result<()> {
1535 decoder.debug_check_bounds::<Self>(offset);
1536 fidl::decode!(fidl::encoding::Vector<VmoInfo, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmo_ids, decoder, offset + 0, _depth)?;
1538 Ok(())
1539 }
1540 }
1541
1542 impl fidl::encoding::ResourceTypeMarker for EndpointRegisterVmosResponse {
1543 type Borrowed<'a> = &'a mut Self;
1544 fn take_or_borrow<'a>(
1545 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1546 ) -> Self::Borrowed<'a> {
1547 value
1548 }
1549 }
1550
1551 unsafe impl fidl::encoding::TypeMarker for EndpointRegisterVmosResponse {
1552 type Owned = Self;
1553
1554 #[inline(always)]
1555 fn inline_align(_context: fidl::encoding::Context) -> usize {
1556 8
1557 }
1558
1559 #[inline(always)]
1560 fn inline_size(_context: fidl::encoding::Context) -> usize {
1561 16
1562 }
1563 }
1564
1565 unsafe impl
1566 fidl::encoding::Encode<
1567 EndpointRegisterVmosResponse,
1568 fidl::encoding::DefaultFuchsiaResourceDialect,
1569 > for &mut EndpointRegisterVmosResponse
1570 {
1571 #[inline]
1572 unsafe fn encode(
1573 self,
1574 encoder: &mut fidl::encoding::Encoder<
1575 '_,
1576 fidl::encoding::DefaultFuchsiaResourceDialect,
1577 >,
1578 offset: usize,
1579 _depth: fidl::encoding::Depth,
1580 ) -> fidl::Result<()> {
1581 encoder.debug_check_bounds::<EndpointRegisterVmosResponse>(offset);
1582 fidl::encoding::Encode::<EndpointRegisterVmosResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1584 (
1585 <fidl::encoding::Vector<VmoHandle, 64> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.vmos),
1586 ),
1587 encoder, offset, _depth
1588 )
1589 }
1590 }
1591 unsafe impl<
1592 T0: fidl::encoding::Encode<
1593 fidl::encoding::Vector<VmoHandle, 64>,
1594 fidl::encoding::DefaultFuchsiaResourceDialect,
1595 >,
1596 >
1597 fidl::encoding::Encode<
1598 EndpointRegisterVmosResponse,
1599 fidl::encoding::DefaultFuchsiaResourceDialect,
1600 > for (T0,)
1601 {
1602 #[inline]
1603 unsafe fn encode(
1604 self,
1605 encoder: &mut fidl::encoding::Encoder<
1606 '_,
1607 fidl::encoding::DefaultFuchsiaResourceDialect,
1608 >,
1609 offset: usize,
1610 depth: fidl::encoding::Depth,
1611 ) -> fidl::Result<()> {
1612 encoder.debug_check_bounds::<EndpointRegisterVmosResponse>(offset);
1613 self.0.encode(encoder, offset + 0, depth)?;
1617 Ok(())
1618 }
1619 }
1620
1621 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1622 for EndpointRegisterVmosResponse
1623 {
1624 #[inline(always)]
1625 fn new_empty() -> Self {
1626 Self {
1627 vmos: fidl::new_empty!(fidl::encoding::Vector<VmoHandle, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
1628 }
1629 }
1630
1631 #[inline]
1632 unsafe fn decode(
1633 &mut self,
1634 decoder: &mut fidl::encoding::Decoder<
1635 '_,
1636 fidl::encoding::DefaultFuchsiaResourceDialect,
1637 >,
1638 offset: usize,
1639 _depth: fidl::encoding::Depth,
1640 ) -> fidl::Result<()> {
1641 decoder.debug_check_bounds::<Self>(offset);
1642 fidl::decode!(fidl::encoding::Vector<VmoHandle, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.vmos, decoder, offset + 0, _depth)?;
1644 Ok(())
1645 }
1646 }
1647
1648 impl fidl::encoding::ResourceTypeMarker for EndpointUnregisterVmosResponse {
1649 type Borrowed<'a> = &'a mut Self;
1650 fn take_or_borrow<'a>(
1651 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1652 ) -> Self::Borrowed<'a> {
1653 value
1654 }
1655 }
1656
1657 unsafe impl fidl::encoding::TypeMarker for EndpointUnregisterVmosResponse {
1658 type Owned = Self;
1659
1660 #[inline(always)]
1661 fn inline_align(_context: fidl::encoding::Context) -> usize {
1662 8
1663 }
1664
1665 #[inline(always)]
1666 fn inline_size(_context: fidl::encoding::Context) -> usize {
1667 32
1668 }
1669 }
1670
1671 unsafe impl
1672 fidl::encoding::Encode<
1673 EndpointUnregisterVmosResponse,
1674 fidl::encoding::DefaultFuchsiaResourceDialect,
1675 > for &mut EndpointUnregisterVmosResponse
1676 {
1677 #[inline]
1678 unsafe fn encode(
1679 self,
1680 encoder: &mut fidl::encoding::Encoder<
1681 '_,
1682 fidl::encoding::DefaultFuchsiaResourceDialect,
1683 >,
1684 offset: usize,
1685 _depth: fidl::encoding::Depth,
1686 ) -> fidl::Result<()> {
1687 encoder.debug_check_bounds::<EndpointUnregisterVmosResponse>(offset);
1688 fidl::encoding::Encode::<
1690 EndpointUnregisterVmosResponse,
1691 fidl::encoding::DefaultFuchsiaResourceDialect,
1692 >::encode(
1693 (
1694 <fidl::encoding::Vector<u64, 64> as fidl::encoding::ValueTypeMarker>::borrow(
1695 &self.failed_vmo_ids,
1696 ),
1697 <fidl::encoding::Vector<i32, 64> as fidl::encoding::ValueTypeMarker>::borrow(
1698 &self.errors,
1699 ),
1700 ),
1701 encoder,
1702 offset,
1703 _depth,
1704 )
1705 }
1706 }
1707 unsafe impl<
1708 T0: fidl::encoding::Encode<
1709 fidl::encoding::Vector<u64, 64>,
1710 fidl::encoding::DefaultFuchsiaResourceDialect,
1711 >,
1712 T1: fidl::encoding::Encode<
1713 fidl::encoding::Vector<i32, 64>,
1714 fidl::encoding::DefaultFuchsiaResourceDialect,
1715 >,
1716 >
1717 fidl::encoding::Encode<
1718 EndpointUnregisterVmosResponse,
1719 fidl::encoding::DefaultFuchsiaResourceDialect,
1720 > for (T0, T1)
1721 {
1722 #[inline]
1723 unsafe fn encode(
1724 self,
1725 encoder: &mut fidl::encoding::Encoder<
1726 '_,
1727 fidl::encoding::DefaultFuchsiaResourceDialect,
1728 >,
1729 offset: usize,
1730 depth: fidl::encoding::Depth,
1731 ) -> fidl::Result<()> {
1732 encoder.debug_check_bounds::<EndpointUnregisterVmosResponse>(offset);
1733 self.0.encode(encoder, offset + 0, depth)?;
1737 self.1.encode(encoder, offset + 16, depth)?;
1738 Ok(())
1739 }
1740 }
1741
1742 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1743 for EndpointUnregisterVmosResponse
1744 {
1745 #[inline(always)]
1746 fn new_empty() -> Self {
1747 Self {
1748 failed_vmo_ids: fidl::new_empty!(fidl::encoding::Vector<u64, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
1749 errors: fidl::new_empty!(fidl::encoding::Vector<i32, 64>, fidl::encoding::DefaultFuchsiaResourceDialect),
1750 }
1751 }
1752
1753 #[inline]
1754 unsafe fn decode(
1755 &mut self,
1756 decoder: &mut fidl::encoding::Decoder<
1757 '_,
1758 fidl::encoding::DefaultFuchsiaResourceDialect,
1759 >,
1760 offset: usize,
1761 _depth: fidl::encoding::Depth,
1762 ) -> fidl::Result<()> {
1763 decoder.debug_check_bounds::<Self>(offset);
1764 fidl::decode!(fidl::encoding::Vector<u64, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.failed_vmo_ids, decoder, offset + 0, _depth)?;
1766 fidl::decode!(fidl::encoding::Vector<i32, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.errors, decoder, offset + 16, _depth)?;
1767 Ok(())
1768 }
1769 }
1770
1771 impl Completion {
1772 #[inline(always)]
1773 fn max_ordinal_present(&self) -> u64 {
1774 if let Some(_) = self.wake_lease {
1775 return 4;
1776 }
1777 if let Some(_) = self.transfer_size {
1778 return 3;
1779 }
1780 if let Some(_) = self.status {
1781 return 2;
1782 }
1783 if let Some(_) = self.request {
1784 return 1;
1785 }
1786 0
1787 }
1788 }
1789
1790 impl fidl::encoding::ResourceTypeMarker for Completion {
1791 type Borrowed<'a> = &'a mut Self;
1792 fn take_or_borrow<'a>(
1793 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1794 ) -> Self::Borrowed<'a> {
1795 value
1796 }
1797 }
1798
1799 unsafe impl fidl::encoding::TypeMarker for Completion {
1800 type Owned = Self;
1801
1802 #[inline(always)]
1803 fn inline_align(_context: fidl::encoding::Context) -> usize {
1804 8
1805 }
1806
1807 #[inline(always)]
1808 fn inline_size(_context: fidl::encoding::Context) -> usize {
1809 16
1810 }
1811 }
1812
1813 unsafe impl fidl::encoding::Encode<Completion, fidl::encoding::DefaultFuchsiaResourceDialect>
1814 for &mut Completion
1815 {
1816 unsafe fn encode(
1817 self,
1818 encoder: &mut fidl::encoding::Encoder<
1819 '_,
1820 fidl::encoding::DefaultFuchsiaResourceDialect,
1821 >,
1822 offset: usize,
1823 mut depth: fidl::encoding::Depth,
1824 ) -> fidl::Result<()> {
1825 encoder.debug_check_bounds::<Completion>(offset);
1826 let max_ordinal: u64 = self.max_ordinal_present();
1828 encoder.write_num(max_ordinal, offset);
1829 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
1830 if max_ordinal == 0 {
1832 return Ok(());
1833 }
1834 depth.increment()?;
1835 let envelope_size = 8;
1836 let bytes_len = max_ordinal as usize * envelope_size;
1837 #[allow(unused_variables)]
1838 let offset = encoder.out_of_line_offset(bytes_len);
1839 let mut _prev_end_offset: usize = 0;
1840 if 1 > max_ordinal {
1841 return Ok(());
1842 }
1843
1844 let cur_offset: usize = (1 - 1) * envelope_size;
1847
1848 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1850
1851 fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_hardware_usb_request::Request, fidl::encoding::DefaultFuchsiaResourceDialect>(
1856 self.request.as_mut().map(<fidl_fuchsia_hardware_usb_request::Request as fidl::encoding::ResourceTypeMarker>::take_or_borrow),
1857 encoder, offset + cur_offset, depth
1858 )?;
1859
1860 _prev_end_offset = cur_offset + envelope_size;
1861 if 2 > max_ordinal {
1862 return Ok(());
1863 }
1864
1865 let cur_offset: usize = (2 - 1) * envelope_size;
1868
1869 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1871
1872 fidl::encoding::encode_in_envelope_optional::<
1877 i32,
1878 fidl::encoding::DefaultFuchsiaResourceDialect,
1879 >(
1880 self.status.as_ref().map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
1881 encoder,
1882 offset + cur_offset,
1883 depth,
1884 )?;
1885
1886 _prev_end_offset = cur_offset + envelope_size;
1887 if 3 > max_ordinal {
1888 return Ok(());
1889 }
1890
1891 let cur_offset: usize = (3 - 1) * envelope_size;
1894
1895 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1897
1898 fidl::encoding::encode_in_envelope_optional::<
1903 u64,
1904 fidl::encoding::DefaultFuchsiaResourceDialect,
1905 >(
1906 self.transfer_size.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
1907 encoder,
1908 offset + cur_offset,
1909 depth,
1910 )?;
1911
1912 _prev_end_offset = cur_offset + envelope_size;
1913 if 4 > max_ordinal {
1914 return Ok(());
1915 }
1916
1917 let cur_offset: usize = (4 - 1) * envelope_size;
1920
1921 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
1923
1924 fidl::encoding::encode_in_envelope_optional::<
1929 fidl::encoding::HandleType<
1930 fidl::EventPair,
1931 { fidl::ObjectType::EVENTPAIR.into_raw() },
1932 2147483648,
1933 >,
1934 fidl::encoding::DefaultFuchsiaResourceDialect,
1935 >(
1936 self.wake_lease.as_mut().map(
1937 <fidl::encoding::HandleType<
1938 fidl::EventPair,
1939 { fidl::ObjectType::EVENTPAIR.into_raw() },
1940 2147483648,
1941 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
1942 ),
1943 encoder,
1944 offset + cur_offset,
1945 depth,
1946 )?;
1947
1948 _prev_end_offset = cur_offset + envelope_size;
1949
1950 Ok(())
1951 }
1952 }
1953
1954 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Completion {
1955 #[inline(always)]
1956 fn new_empty() -> Self {
1957 Self::default()
1958 }
1959
1960 unsafe fn decode(
1961 &mut self,
1962 decoder: &mut fidl::encoding::Decoder<
1963 '_,
1964 fidl::encoding::DefaultFuchsiaResourceDialect,
1965 >,
1966 offset: usize,
1967 mut depth: fidl::encoding::Depth,
1968 ) -> fidl::Result<()> {
1969 decoder.debug_check_bounds::<Self>(offset);
1970 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
1971 None => return Err(fidl::Error::NotNullable),
1972 Some(len) => len,
1973 };
1974 if len == 0 {
1976 return Ok(());
1977 };
1978 depth.increment()?;
1979 let envelope_size = 8;
1980 let bytes_len = len * envelope_size;
1981 let offset = decoder.out_of_line_offset(bytes_len)?;
1982 let mut _next_ordinal_to_read = 0;
1984 let mut next_offset = offset;
1985 let end_offset = offset + bytes_len;
1986 _next_ordinal_to_read += 1;
1987 if next_offset >= end_offset {
1988 return Ok(());
1989 }
1990
1991 while _next_ordinal_to_read < 1 {
1993 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
1994 _next_ordinal_to_read += 1;
1995 next_offset += envelope_size;
1996 }
1997
1998 let next_out_of_line = decoder.next_out_of_line();
1999 let handles_before = decoder.remaining_handles();
2000 if let Some((inlined, num_bytes, num_handles)) =
2001 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2002 {
2003 let member_inline_size = <fidl_fuchsia_hardware_usb_request::Request as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2004 if inlined != (member_inline_size <= 4) {
2005 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2006 }
2007 let inner_offset;
2008 let mut inner_depth = depth.clone();
2009 if inlined {
2010 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2011 inner_offset = next_offset;
2012 } else {
2013 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2014 inner_depth.increment()?;
2015 }
2016 let val_ref = self.request.get_or_insert_with(|| {
2017 fidl::new_empty!(
2018 fidl_fuchsia_hardware_usb_request::Request,
2019 fidl::encoding::DefaultFuchsiaResourceDialect
2020 )
2021 });
2022 fidl::decode!(
2023 fidl_fuchsia_hardware_usb_request::Request,
2024 fidl::encoding::DefaultFuchsiaResourceDialect,
2025 val_ref,
2026 decoder,
2027 inner_offset,
2028 inner_depth
2029 )?;
2030 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2031 {
2032 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2033 }
2034 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2035 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2036 }
2037 }
2038
2039 next_offset += envelope_size;
2040 _next_ordinal_to_read += 1;
2041 if next_offset >= end_offset {
2042 return Ok(());
2043 }
2044
2045 while _next_ordinal_to_read < 2 {
2047 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2048 _next_ordinal_to_read += 1;
2049 next_offset += envelope_size;
2050 }
2051
2052 let next_out_of_line = decoder.next_out_of_line();
2053 let handles_before = decoder.remaining_handles();
2054 if let Some((inlined, num_bytes, num_handles)) =
2055 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2056 {
2057 let member_inline_size =
2058 <i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2059 if inlined != (member_inline_size <= 4) {
2060 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2061 }
2062 let inner_offset;
2063 let mut inner_depth = depth.clone();
2064 if inlined {
2065 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2066 inner_offset = next_offset;
2067 } else {
2068 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2069 inner_depth.increment()?;
2070 }
2071 let val_ref = self.status.get_or_insert_with(|| {
2072 fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect)
2073 });
2074 fidl::decode!(
2075 i32,
2076 fidl::encoding::DefaultFuchsiaResourceDialect,
2077 val_ref,
2078 decoder,
2079 inner_offset,
2080 inner_depth
2081 )?;
2082 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2083 {
2084 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2085 }
2086 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2087 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2088 }
2089 }
2090
2091 next_offset += envelope_size;
2092 _next_ordinal_to_read += 1;
2093 if next_offset >= end_offset {
2094 return Ok(());
2095 }
2096
2097 while _next_ordinal_to_read < 3 {
2099 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2100 _next_ordinal_to_read += 1;
2101 next_offset += envelope_size;
2102 }
2103
2104 let next_out_of_line = decoder.next_out_of_line();
2105 let handles_before = decoder.remaining_handles();
2106 if let Some((inlined, num_bytes, num_handles)) =
2107 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2108 {
2109 let member_inline_size =
2110 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2111 if inlined != (member_inline_size <= 4) {
2112 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2113 }
2114 let inner_offset;
2115 let mut inner_depth = depth.clone();
2116 if inlined {
2117 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2118 inner_offset = next_offset;
2119 } else {
2120 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2121 inner_depth.increment()?;
2122 }
2123 let val_ref = self.transfer_size.get_or_insert_with(|| {
2124 fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2125 });
2126 fidl::decode!(
2127 u64,
2128 fidl::encoding::DefaultFuchsiaResourceDialect,
2129 val_ref,
2130 decoder,
2131 inner_offset,
2132 inner_depth
2133 )?;
2134 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2135 {
2136 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2137 }
2138 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2139 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2140 }
2141 }
2142
2143 next_offset += envelope_size;
2144 _next_ordinal_to_read += 1;
2145 if next_offset >= end_offset {
2146 return Ok(());
2147 }
2148
2149 while _next_ordinal_to_read < 4 {
2151 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2152 _next_ordinal_to_read += 1;
2153 next_offset += envelope_size;
2154 }
2155
2156 let next_out_of_line = decoder.next_out_of_line();
2157 let handles_before = decoder.remaining_handles();
2158 if let Some((inlined, num_bytes, num_handles)) =
2159 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2160 {
2161 let member_inline_size = <fidl::encoding::HandleType<
2162 fidl::EventPair,
2163 { fidl::ObjectType::EVENTPAIR.into_raw() },
2164 2147483648,
2165 > as fidl::encoding::TypeMarker>::inline_size(
2166 decoder.context
2167 );
2168 if inlined != (member_inline_size <= 4) {
2169 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2170 }
2171 let inner_offset;
2172 let mut inner_depth = depth.clone();
2173 if inlined {
2174 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2175 inner_offset = next_offset;
2176 } else {
2177 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2178 inner_depth.increment()?;
2179 }
2180 let val_ref =
2181 self.wake_lease.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2182 fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2183 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2184 {
2185 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2186 }
2187 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2188 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2189 }
2190 }
2191
2192 next_offset += envelope_size;
2193
2194 while next_offset < end_offset {
2196 _next_ordinal_to_read += 1;
2197 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2198 next_offset += envelope_size;
2199 }
2200
2201 Ok(())
2202 }
2203 }
2204
2205 impl VmoHandle {
2206 #[inline(always)]
2207 fn max_ordinal_present(&self) -> u64 {
2208 if let Some(_) = self.vmo {
2209 return 2;
2210 }
2211 if let Some(_) = self.id {
2212 return 1;
2213 }
2214 0
2215 }
2216 }
2217
2218 impl fidl::encoding::ResourceTypeMarker for VmoHandle {
2219 type Borrowed<'a> = &'a mut Self;
2220 fn take_or_borrow<'a>(
2221 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2222 ) -> Self::Borrowed<'a> {
2223 value
2224 }
2225 }
2226
2227 unsafe impl fidl::encoding::TypeMarker for VmoHandle {
2228 type Owned = Self;
2229
2230 #[inline(always)]
2231 fn inline_align(_context: fidl::encoding::Context) -> usize {
2232 8
2233 }
2234
2235 #[inline(always)]
2236 fn inline_size(_context: fidl::encoding::Context) -> usize {
2237 16
2238 }
2239 }
2240
2241 unsafe impl fidl::encoding::Encode<VmoHandle, fidl::encoding::DefaultFuchsiaResourceDialect>
2242 for &mut VmoHandle
2243 {
2244 unsafe fn encode(
2245 self,
2246 encoder: &mut fidl::encoding::Encoder<
2247 '_,
2248 fidl::encoding::DefaultFuchsiaResourceDialect,
2249 >,
2250 offset: usize,
2251 mut depth: fidl::encoding::Depth,
2252 ) -> fidl::Result<()> {
2253 encoder.debug_check_bounds::<VmoHandle>(offset);
2254 let max_ordinal: u64 = self.max_ordinal_present();
2256 encoder.write_num(max_ordinal, offset);
2257 encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
2258 if max_ordinal == 0 {
2260 return Ok(());
2261 }
2262 depth.increment()?;
2263 let envelope_size = 8;
2264 let bytes_len = max_ordinal as usize * envelope_size;
2265 #[allow(unused_variables)]
2266 let offset = encoder.out_of_line_offset(bytes_len);
2267 let mut _prev_end_offset: usize = 0;
2268 if 1 > max_ordinal {
2269 return Ok(());
2270 }
2271
2272 let cur_offset: usize = (1 - 1) * envelope_size;
2275
2276 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2278
2279 fidl::encoding::encode_in_envelope_optional::<
2284 u64,
2285 fidl::encoding::DefaultFuchsiaResourceDialect,
2286 >(
2287 self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
2288 encoder,
2289 offset + cur_offset,
2290 depth,
2291 )?;
2292
2293 _prev_end_offset = cur_offset + envelope_size;
2294 if 2 > max_ordinal {
2295 return Ok(());
2296 }
2297
2298 let cur_offset: usize = (2 - 1) * envelope_size;
2301
2302 encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
2304
2305 fidl::encoding::encode_in_envelope_optional::<
2310 fidl::encoding::HandleType<
2311 fidl::Vmo,
2312 { fidl::ObjectType::VMO.into_raw() },
2313 2147483648,
2314 >,
2315 fidl::encoding::DefaultFuchsiaResourceDialect,
2316 >(
2317 self.vmo.as_mut().map(
2318 <fidl::encoding::HandleType<
2319 fidl::Vmo,
2320 { fidl::ObjectType::VMO.into_raw() },
2321 2147483648,
2322 > as fidl::encoding::ResourceTypeMarker>::take_or_borrow,
2323 ),
2324 encoder,
2325 offset + cur_offset,
2326 depth,
2327 )?;
2328
2329 _prev_end_offset = cur_offset + envelope_size;
2330
2331 Ok(())
2332 }
2333 }
2334
2335 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for VmoHandle {
2336 #[inline(always)]
2337 fn new_empty() -> Self {
2338 Self::default()
2339 }
2340
2341 unsafe fn decode(
2342 &mut self,
2343 decoder: &mut fidl::encoding::Decoder<
2344 '_,
2345 fidl::encoding::DefaultFuchsiaResourceDialect,
2346 >,
2347 offset: usize,
2348 mut depth: fidl::encoding::Depth,
2349 ) -> fidl::Result<()> {
2350 decoder.debug_check_bounds::<Self>(offset);
2351 let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
2352 None => return Err(fidl::Error::NotNullable),
2353 Some(len) => len,
2354 };
2355 if len == 0 {
2357 return Ok(());
2358 };
2359 depth.increment()?;
2360 let envelope_size = 8;
2361 let bytes_len = len * envelope_size;
2362 let offset = decoder.out_of_line_offset(bytes_len)?;
2363 let mut _next_ordinal_to_read = 0;
2365 let mut next_offset = offset;
2366 let end_offset = offset + bytes_len;
2367 _next_ordinal_to_read += 1;
2368 if next_offset >= end_offset {
2369 return Ok(());
2370 }
2371
2372 while _next_ordinal_to_read < 1 {
2374 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2375 _next_ordinal_to_read += 1;
2376 next_offset += envelope_size;
2377 }
2378
2379 let next_out_of_line = decoder.next_out_of_line();
2380 let handles_before = decoder.remaining_handles();
2381 if let Some((inlined, num_bytes, num_handles)) =
2382 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2383 {
2384 let member_inline_size =
2385 <u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
2386 if inlined != (member_inline_size <= 4) {
2387 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2388 }
2389 let inner_offset;
2390 let mut inner_depth = depth.clone();
2391 if inlined {
2392 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2393 inner_offset = next_offset;
2394 } else {
2395 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2396 inner_depth.increment()?;
2397 }
2398 let val_ref = self.id.get_or_insert_with(|| {
2399 fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect)
2400 });
2401 fidl::decode!(
2402 u64,
2403 fidl::encoding::DefaultFuchsiaResourceDialect,
2404 val_ref,
2405 decoder,
2406 inner_offset,
2407 inner_depth
2408 )?;
2409 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2410 {
2411 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2412 }
2413 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2414 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2415 }
2416 }
2417
2418 next_offset += envelope_size;
2419 _next_ordinal_to_read += 1;
2420 if next_offset >= end_offset {
2421 return Ok(());
2422 }
2423
2424 while _next_ordinal_to_read < 2 {
2426 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2427 _next_ordinal_to_read += 1;
2428 next_offset += envelope_size;
2429 }
2430
2431 let next_out_of_line = decoder.next_out_of_line();
2432 let handles_before = decoder.remaining_handles();
2433 if let Some((inlined, num_bytes, num_handles)) =
2434 fidl::encoding::decode_envelope_header(decoder, next_offset)?
2435 {
2436 let member_inline_size = <fidl::encoding::HandleType<
2437 fidl::Vmo,
2438 { fidl::ObjectType::VMO.into_raw() },
2439 2147483648,
2440 > as fidl::encoding::TypeMarker>::inline_size(
2441 decoder.context
2442 );
2443 if inlined != (member_inline_size <= 4) {
2444 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2445 }
2446 let inner_offset;
2447 let mut inner_depth = depth.clone();
2448 if inlined {
2449 decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
2450 inner_offset = next_offset;
2451 } else {
2452 inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2453 inner_depth.increment()?;
2454 }
2455 let val_ref =
2456 self.vmo.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect));
2457 fidl::decode!(fidl::encoding::HandleType<fidl::Vmo, { fidl::ObjectType::VMO.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
2458 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
2459 {
2460 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2461 }
2462 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2463 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2464 }
2465 }
2466
2467 next_offset += envelope_size;
2468
2469 while next_offset < end_offset {
2471 _next_ordinal_to_read += 1;
2472 fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
2473 next_offset += envelope_size;
2474 }
2475
2476 Ok(())
2477 }
2478 }
2479}