Skip to main content

fidl_fuchsia_hardware_usb_function/
fidl_fuchsia_hardware_usb_function.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![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_function_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct EndpointResource {
16    pub direction: fidl_fuchsia_hardware_usb_descriptor::EndpointDirection,
17    pub endpoint: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
18    /// Information about the endpoint (e.g. Bulk, Interrupt).
19    pub ep_info: fidl_fuchsia_hardware_usb_endpoint::EndpointInfo,
20    /// The maximum packet size the endpoint supports.
21    pub max_packet_size: u32,
22}
23
24impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for EndpointResource {}
25
26#[derive(Debug, PartialEq)]
27pub struct UsbFunctionAllocResourcesRequest {
28    pub interface_count: u8,
29    pub endpoints: Vec<EndpointResource>,
30    pub strings: Vec<String>,
31}
32
33impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
34    for UsbFunctionAllocResourcesRequest
35{
36}
37
38#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
39pub struct UsbFunctionConfigureRequest {
40    pub configuration: Vec<u8>,
41    pub iface: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
42}
43
44impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
45    for UsbFunctionConfigureRequest
46{
47}
48
49#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
50pub struct UsbFunctionConnectToEndpointRequest {
51    pub ep_addr: u8,
52    pub ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
53}
54
55impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
56    for UsbFunctionConnectToEndpointRequest
57{
58}
59
60#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
61pub struct UsbFunctionMarker;
62
63impl fidl::endpoints::ProtocolMarker for UsbFunctionMarker {
64    type Proxy = UsbFunctionProxy;
65    type RequestStream = UsbFunctionRequestStream;
66    #[cfg(target_os = "fuchsia")]
67    type SynchronousProxy = UsbFunctionSynchronousProxy;
68
69    const DEBUG_NAME: &'static str = "fuchsia.hardware.usb.function.UsbFunction";
70}
71impl fidl::endpoints::DiscoverableProtocolMarker for UsbFunctionMarker {}
72pub type UsbFunctionConnectToEndpointResult = Result<(), i32>;
73pub type UsbFunctionConfigureResult = Result<(), i32>;
74pub type UsbFunctionDeconfigureResult = Result<(), i32>;
75pub type UsbFunctionAllocResourcesResult = Result<(Vec<u8>, Vec<u8>, Vec<u8>), i32>;
76pub type UsbFunctionEndpointSetStallResult = Result<(), i32>;
77pub type UsbFunctionEndpointClearStallResult = Result<(), i32>;
78pub type UsbFunctionConfigureEndpointResult = Result<(), i32>;
79pub type UsbFunctionDisableEndpointResult = Result<(), i32>;
80
81pub trait UsbFunctionProxyInterface: Send + Sync {
82    type ConnectToEndpointResponseFut: std::future::Future<Output = Result<UsbFunctionConnectToEndpointResult, fidl::Error>>
83        + Send;
84    fn r#connect_to_endpoint(
85        &self,
86        ep_addr: u8,
87        ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
88    ) -> Self::ConnectToEndpointResponseFut;
89    type ConfigureResponseFut: std::future::Future<Output = Result<UsbFunctionConfigureResult, fidl::Error>>
90        + Send;
91    fn r#configure(
92        &self,
93        configuration: &[u8],
94        iface: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
95    ) -> Self::ConfigureResponseFut;
96    type DeconfigureResponseFut: std::future::Future<Output = Result<UsbFunctionDeconfigureResult, fidl::Error>>
97        + Send;
98    fn r#deconfigure(&self) -> Self::DeconfigureResponseFut;
99    type AllocResourcesResponseFut: std::future::Future<Output = Result<UsbFunctionAllocResourcesResult, fidl::Error>>
100        + Send;
101    fn r#alloc_resources(
102        &self,
103        interface_count: u8,
104        endpoints: Vec<EndpointResource>,
105        strings: &[String],
106    ) -> Self::AllocResourcesResponseFut;
107    type EndpointSetStallResponseFut: std::future::Future<Output = Result<UsbFunctionEndpointSetStallResult, fidl::Error>>
108        + Send;
109    fn r#endpoint_set_stall(&self, endpoint_address: u8) -> Self::EndpointSetStallResponseFut;
110    type EndpointClearStallResponseFut: std::future::Future<Output = Result<UsbFunctionEndpointClearStallResult, fidl::Error>>
111        + Send;
112    fn r#endpoint_clear_stall(&self, endpoint_address: u8) -> Self::EndpointClearStallResponseFut;
113    type ConfigureEndpointResponseFut: std::future::Future<Output = Result<UsbFunctionConfigureEndpointResult, fidl::Error>>
114        + Send;
115    fn r#configure_endpoint(
116        &self,
117        endpoint_address: u8,
118        endpoint_configuration: &EndpointConfiguration,
119    ) -> Self::ConfigureEndpointResponseFut;
120    type DisableEndpointResponseFut: std::future::Future<Output = Result<UsbFunctionDisableEndpointResult, fidl::Error>>
121        + Send;
122    fn r#disable_endpoint(&self, endpoint_address: u8) -> Self::DisableEndpointResponseFut;
123}
124#[derive(Debug)]
125#[cfg(target_os = "fuchsia")]
126pub struct UsbFunctionSynchronousProxy {
127    client: fidl::client::sync::Client,
128}
129
130#[cfg(target_os = "fuchsia")]
131impl fidl::endpoints::SynchronousProxy for UsbFunctionSynchronousProxy {
132    type Proxy = UsbFunctionProxy;
133    type Protocol = UsbFunctionMarker;
134
135    fn from_channel(inner: fidl::Channel) -> Self {
136        Self::new(inner)
137    }
138
139    fn into_channel(self) -> fidl::Channel {
140        self.client.into_channel()
141    }
142
143    fn as_channel(&self) -> &fidl::Channel {
144        self.client.as_channel()
145    }
146}
147
148#[cfg(target_os = "fuchsia")]
149impl UsbFunctionSynchronousProxy {
150    pub fn new(channel: fidl::Channel) -> Self {
151        Self { client: fidl::client::sync::Client::new(channel) }
152    }
153
154    pub fn into_channel(self) -> fidl::Channel {
155        self.client.into_channel()
156    }
157
158    /// Waits until an event arrives and returns it. It is safe for other
159    /// threads to make concurrent requests while waiting for an event.
160    pub fn wait_for_event(
161        &self,
162        deadline: zx::MonotonicInstant,
163    ) -> Result<UsbFunctionEvent, fidl::Error> {
164        UsbFunctionEvent::decode(self.client.wait_for_event::<UsbFunctionMarker>(deadline)?)
165    }
166
167    /// Connects to endpoint. Returns
168    ///  * ZX_ERR_NOT_FOUND: if endpoint address does not exist.
169    ///  * ZX_ERR_ALREADY_BOUND: if the endpoint is already bound.
170    pub fn r#connect_to_endpoint(
171        &self,
172        mut ep_addr: u8,
173        mut ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
174        ___deadline: zx::MonotonicInstant,
175    ) -> Result<UsbFunctionConnectToEndpointResult, fidl::Error> {
176        let _response = self.client.send_query::<
177            UsbFunctionConnectToEndpointRequest,
178            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
179            UsbFunctionMarker,
180        >(
181            (ep_addr, ep,),
182            0x11541c67eb1b7f8,
183            fidl::encoding::DynamicFlags::empty(),
184            ___deadline,
185        )?;
186        Ok(_response.map(|x| x))
187    }
188
189    /// Configures the function with the given descriptors.
190    ///
191    /// `configuration` is a vector of USB descriptors to configure the function
192    /// with. The descriptors are concatenated together following the USB
193    /// specification to form the configuration.
194    /// `iface` provides the control-plane callbacks for the function.
195    ///
196    /// The function is *unregistered* from the USB function manager when
197    /// `iface` is closed.
198    ///
199    /// Any resource address and numbers referenced in `configuration` *must* have
200    /// been allocated by a previous call to `AllocResources`.
201    ///
202    /// Returns `ZX_ERR_INVALID_ARGS` if the configuration is invalid.
203    pub fn r#configure(
204        &self,
205        mut configuration: &[u8],
206        mut iface: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
207        ___deadline: zx::MonotonicInstant,
208    ) -> Result<UsbFunctionConfigureResult, fidl::Error> {
209        let _response = self.client.send_query::<
210            UsbFunctionConfigureRequest,
211            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
212            UsbFunctionMarker,
213        >(
214            (configuration, iface,),
215            0x42a444f4abf08b89,
216            fidl::encoding::DynamicFlags::empty(),
217            ___deadline,
218        )?;
219        Ok(_response.map(|x| x))
220    }
221
222    /// Deconfigures the function.
223    ///
224    /// This is the opposite of `Configure`. The server drops its connection to
225    /// the function upon receiving the call, if it's bound.
226    ///
227    /// Returns after the function channel has been unbound from the server.
228    ///
229    /// Trivially succeeds if no function interface is bound.
230    ///
231    /// Returns `ZX_ERR_UNAVAILABLE` if a deconfiguration is already in
232    /// progress.
233    pub fn r#deconfigure(
234        &self,
235        ___deadline: zx::MonotonicInstant,
236    ) -> Result<UsbFunctionDeconfigureResult, fidl::Error> {
237        let _response = self.client.send_query::<
238            fidl::encoding::EmptyPayload,
239            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
240            UsbFunctionMarker,
241        >(
242            (),
243            0x26ee8c8c826367b2,
244            fidl::encoding::DynamicFlags::empty(),
245            ___deadline,
246        )?;
247        Ok(_response.map(|x| x))
248    }
249
250    /// Allocates resources for the function.
251    ///
252    /// This function is used to allocate resources for the function.
253    ///
254    /// `interface_count` informs how many interfaces to create.
255    /// `interface_nums` returns the allocate interface numbers referencing
256    ///  the requested interfaces.
257    ///
258    /// `endpoints` is a vector of endpoints to allocate. The direction and
259    ///  endpoint server end are provided.
260    /// `endpoint_addrs` returns a vector of the same size containing the
261    /// allocated endpoint addresses. On success the endpoint server ends are
262    /// connected to a server. Closed otherwise.
263    ///
264    /// `strings` is a vector of strings to allocate.
265    /// `string_indices` returns a vector of the same size containing the
266    /// allocated string indices.
267    ///
268    /// Returns the interface ids, endpoint ids, and string ids that were
269    /// allocated. On error, no resources are allocated. Returns:
270    ///  * `ZX_ERR_NO_RESOURCES` if any resource namespace numbers are
271    ///  exhausted.
272    ///
273    /// The allocated resource numbers and addresses remain allocated for the
274    /// lifetime of the connection to `UsbFunction`.
275    pub fn r#alloc_resources(
276        &self,
277        mut interface_count: u8,
278        mut endpoints: Vec<EndpointResource>,
279        mut strings: &[String],
280        ___deadline: zx::MonotonicInstant,
281    ) -> Result<UsbFunctionAllocResourcesResult, fidl::Error> {
282        let _response = self.client.send_query::<
283            UsbFunctionAllocResourcesRequest,
284            fidl::encoding::ResultType<UsbFunctionAllocResourcesResponse, i32>,
285            UsbFunctionMarker,
286        >(
287            (interface_count, endpoints.as_mut(), strings,),
288            0x5ab7133ab195daa0,
289            fidl::encoding::DynamicFlags::empty(),
290            ___deadline,
291        )?;
292        Ok(_response.map(|x| (x.interface_nums, x.endpoint_addrs, x.string_indices)))
293    }
294
295    /// Sets stall state in an endpoint.
296    ///
297    /// Returns
298    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
299    ///    inactive.
300    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
301    pub fn r#endpoint_set_stall(
302        &self,
303        mut endpoint_address: u8,
304        ___deadline: zx::MonotonicInstant,
305    ) -> Result<UsbFunctionEndpointSetStallResult, fidl::Error> {
306        let _response = self.client.send_query::<
307            UsbFunctionEndpointSetStallRequest,
308            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
309            UsbFunctionMarker,
310        >(
311            (endpoint_address,),
312            0x1f32c374dac955f1,
313            fidl::encoding::DynamicFlags::empty(),
314            ___deadline,
315        )?;
316        Ok(_response.map(|x| x))
317    }
318
319    /// Clears stall state in an endpoint.
320    ///
321    /// Returns
322    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
323    ///    inactive.
324    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
325    pub fn r#endpoint_clear_stall(
326        &self,
327        mut endpoint_address: u8,
328        ___deadline: zx::MonotonicInstant,
329    ) -> Result<UsbFunctionEndpointClearStallResult, fidl::Error> {
330        let _response = self.client.send_query::<
331            UsbFunctionEndpointClearStallRequest,
332            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
333            UsbFunctionMarker,
334        >(
335            (endpoint_address,),
336            0x221d9488ac58aaba,
337            fidl::encoding::DynamicFlags::empty(),
338            ___deadline,
339        )?;
340        Ok(_response.map(|x| x))
341    }
342
343    /// Configure and enable an endpoint with the given configuration.
344    ///
345    /// See usb20 9.6.6.
346    ///
347    /// Returns
348    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
349    ///    inactive.
350    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
351    /// * `ZX_ERR_INVALID_ARGS`: If the configuration is invalid.
352    pub fn r#configure_endpoint(
353        &self,
354        mut endpoint_address: u8,
355        mut endpoint_configuration: &EndpointConfiguration,
356        ___deadline: zx::MonotonicInstant,
357    ) -> Result<UsbFunctionConfigureEndpointResult, fidl::Error> {
358        let _response = self.client.send_query::<
359            UsbFunctionConfigureEndpointRequest,
360            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
361            UsbFunctionMarker,
362        >(
363            (endpoint_address, endpoint_configuration,),
364            0x314c9dc3c37ebb7c,
365            fidl::encoding::DynamicFlags::empty(),
366            ___deadline,
367        )?;
368        Ok(_response.map(|x| x))
369    }
370
371    /// Disable an endpoint.
372    ///
373    /// Returns
374    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
375    ///    inactive.
376    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
377    pub fn r#disable_endpoint(
378        &self,
379        mut endpoint_address: u8,
380        ___deadline: zx::MonotonicInstant,
381    ) -> Result<UsbFunctionDisableEndpointResult, fidl::Error> {
382        let _response = self.client.send_query::<
383            UsbFunctionDisableEndpointRequest,
384            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
385            UsbFunctionMarker,
386        >(
387            (endpoint_address,),
388            0x112a132561499b6e,
389            fidl::encoding::DynamicFlags::empty(),
390            ___deadline,
391        )?;
392        Ok(_response.map(|x| x))
393    }
394}
395
396#[cfg(target_os = "fuchsia")]
397impl From<UsbFunctionSynchronousProxy> for zx::NullableHandle {
398    fn from(value: UsbFunctionSynchronousProxy) -> Self {
399        value.into_channel().into()
400    }
401}
402
403#[cfg(target_os = "fuchsia")]
404impl From<fidl::Channel> for UsbFunctionSynchronousProxy {
405    fn from(value: fidl::Channel) -> Self {
406        Self::new(value)
407    }
408}
409
410#[cfg(target_os = "fuchsia")]
411impl fidl::endpoints::FromClient for UsbFunctionSynchronousProxy {
412    type Protocol = UsbFunctionMarker;
413
414    fn from_client(value: fidl::endpoints::ClientEnd<UsbFunctionMarker>) -> Self {
415        Self::new(value.into_channel())
416    }
417}
418
419#[derive(Debug, Clone)]
420pub struct UsbFunctionProxy {
421    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
422}
423
424impl fidl::endpoints::Proxy for UsbFunctionProxy {
425    type Protocol = UsbFunctionMarker;
426
427    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
428        Self::new(inner)
429    }
430
431    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
432        self.client.into_channel().map_err(|client| Self { client })
433    }
434
435    fn as_channel(&self) -> &::fidl::AsyncChannel {
436        self.client.as_channel()
437    }
438}
439
440impl UsbFunctionProxy {
441    /// Create a new Proxy for fuchsia.hardware.usb.function/UsbFunction.
442    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
443        let protocol_name = <UsbFunctionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
444        Self { client: fidl::client::Client::new(channel, protocol_name) }
445    }
446
447    /// Get a Stream of events from the remote end of the protocol.
448    ///
449    /// # Panics
450    ///
451    /// Panics if the event stream was already taken.
452    pub fn take_event_stream(&self) -> UsbFunctionEventStream {
453        UsbFunctionEventStream { event_receiver: self.client.take_event_receiver() }
454    }
455
456    /// Connects to endpoint. Returns
457    ///  * ZX_ERR_NOT_FOUND: if endpoint address does not exist.
458    ///  * ZX_ERR_ALREADY_BOUND: if the endpoint is already bound.
459    pub fn r#connect_to_endpoint(
460        &self,
461        mut ep_addr: u8,
462        mut ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
463    ) -> fidl::client::QueryResponseFut<
464        UsbFunctionConnectToEndpointResult,
465        fidl::encoding::DefaultFuchsiaResourceDialect,
466    > {
467        UsbFunctionProxyInterface::r#connect_to_endpoint(self, ep_addr, ep)
468    }
469
470    /// Configures the function with the given descriptors.
471    ///
472    /// `configuration` is a vector of USB descriptors to configure the function
473    /// with. The descriptors are concatenated together following the USB
474    /// specification to form the configuration.
475    /// `iface` provides the control-plane callbacks for the function.
476    ///
477    /// The function is *unregistered* from the USB function manager when
478    /// `iface` is closed.
479    ///
480    /// Any resource address and numbers referenced in `configuration` *must* have
481    /// been allocated by a previous call to `AllocResources`.
482    ///
483    /// Returns `ZX_ERR_INVALID_ARGS` if the configuration is invalid.
484    pub fn r#configure(
485        &self,
486        mut configuration: &[u8],
487        mut iface: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
488    ) -> fidl::client::QueryResponseFut<
489        UsbFunctionConfigureResult,
490        fidl::encoding::DefaultFuchsiaResourceDialect,
491    > {
492        UsbFunctionProxyInterface::r#configure(self, configuration, iface)
493    }
494
495    /// Deconfigures the function.
496    ///
497    /// This is the opposite of `Configure`. The server drops its connection to
498    /// the function upon receiving the call, if it's bound.
499    ///
500    /// Returns after the function channel has been unbound from the server.
501    ///
502    /// Trivially succeeds if no function interface is bound.
503    ///
504    /// Returns `ZX_ERR_UNAVAILABLE` if a deconfiguration is already in
505    /// progress.
506    pub fn r#deconfigure(
507        &self,
508    ) -> fidl::client::QueryResponseFut<
509        UsbFunctionDeconfigureResult,
510        fidl::encoding::DefaultFuchsiaResourceDialect,
511    > {
512        UsbFunctionProxyInterface::r#deconfigure(self)
513    }
514
515    /// Allocates resources for the function.
516    ///
517    /// This function is used to allocate resources for the function.
518    ///
519    /// `interface_count` informs how many interfaces to create.
520    /// `interface_nums` returns the allocate interface numbers referencing
521    ///  the requested interfaces.
522    ///
523    /// `endpoints` is a vector of endpoints to allocate. The direction and
524    ///  endpoint server end are provided.
525    /// `endpoint_addrs` returns a vector of the same size containing the
526    /// allocated endpoint addresses. On success the endpoint server ends are
527    /// connected to a server. Closed otherwise.
528    ///
529    /// `strings` is a vector of strings to allocate.
530    /// `string_indices` returns a vector of the same size containing the
531    /// allocated string indices.
532    ///
533    /// Returns the interface ids, endpoint ids, and string ids that were
534    /// allocated. On error, no resources are allocated. Returns:
535    ///  * `ZX_ERR_NO_RESOURCES` if any resource namespace numbers are
536    ///  exhausted.
537    ///
538    /// The allocated resource numbers and addresses remain allocated for the
539    /// lifetime of the connection to `UsbFunction`.
540    pub fn r#alloc_resources(
541        &self,
542        mut interface_count: u8,
543        mut endpoints: Vec<EndpointResource>,
544        mut strings: &[String],
545    ) -> fidl::client::QueryResponseFut<
546        UsbFunctionAllocResourcesResult,
547        fidl::encoding::DefaultFuchsiaResourceDialect,
548    > {
549        UsbFunctionProxyInterface::r#alloc_resources(self, interface_count, endpoints, strings)
550    }
551
552    /// Sets stall state in an endpoint.
553    ///
554    /// Returns
555    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
556    ///    inactive.
557    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
558    pub fn r#endpoint_set_stall(
559        &self,
560        mut endpoint_address: u8,
561    ) -> fidl::client::QueryResponseFut<
562        UsbFunctionEndpointSetStallResult,
563        fidl::encoding::DefaultFuchsiaResourceDialect,
564    > {
565        UsbFunctionProxyInterface::r#endpoint_set_stall(self, endpoint_address)
566    }
567
568    /// Clears stall state in an endpoint.
569    ///
570    /// Returns
571    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
572    ///    inactive.
573    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
574    pub fn r#endpoint_clear_stall(
575        &self,
576        mut endpoint_address: u8,
577    ) -> fidl::client::QueryResponseFut<
578        UsbFunctionEndpointClearStallResult,
579        fidl::encoding::DefaultFuchsiaResourceDialect,
580    > {
581        UsbFunctionProxyInterface::r#endpoint_clear_stall(self, endpoint_address)
582    }
583
584    /// Configure and enable an endpoint with the given configuration.
585    ///
586    /// See usb20 9.6.6.
587    ///
588    /// Returns
589    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
590    ///    inactive.
591    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
592    /// * `ZX_ERR_INVALID_ARGS`: If the configuration is invalid.
593    pub fn r#configure_endpoint(
594        &self,
595        mut endpoint_address: u8,
596        mut endpoint_configuration: &EndpointConfiguration,
597    ) -> fidl::client::QueryResponseFut<
598        UsbFunctionConfigureEndpointResult,
599        fidl::encoding::DefaultFuchsiaResourceDialect,
600    > {
601        UsbFunctionProxyInterface::r#configure_endpoint(
602            self,
603            endpoint_address,
604            endpoint_configuration,
605        )
606    }
607
608    /// Disable an endpoint.
609    ///
610    /// Returns
611    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
612    ///    inactive.
613    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
614    pub fn r#disable_endpoint(
615        &self,
616        mut endpoint_address: u8,
617    ) -> fidl::client::QueryResponseFut<
618        UsbFunctionDisableEndpointResult,
619        fidl::encoding::DefaultFuchsiaResourceDialect,
620    > {
621        UsbFunctionProxyInterface::r#disable_endpoint(self, endpoint_address)
622    }
623}
624
625impl UsbFunctionProxyInterface for UsbFunctionProxy {
626    type ConnectToEndpointResponseFut = fidl::client::QueryResponseFut<
627        UsbFunctionConnectToEndpointResult,
628        fidl::encoding::DefaultFuchsiaResourceDialect,
629    >;
630    fn r#connect_to_endpoint(
631        &self,
632        mut ep_addr: u8,
633        mut ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
634    ) -> Self::ConnectToEndpointResponseFut {
635        fn _decode(
636            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
637        ) -> Result<UsbFunctionConnectToEndpointResult, fidl::Error> {
638            let _response = fidl::client::decode_transaction_body::<
639                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
640                fidl::encoding::DefaultFuchsiaResourceDialect,
641                0x11541c67eb1b7f8,
642            >(_buf?)?;
643            Ok(_response.map(|x| x))
644        }
645        self.client.send_query_and_decode::<
646            UsbFunctionConnectToEndpointRequest,
647            UsbFunctionConnectToEndpointResult,
648        >(
649            (ep_addr, ep,),
650            0x11541c67eb1b7f8,
651            fidl::encoding::DynamicFlags::empty(),
652            _decode,
653        )
654    }
655
656    type ConfigureResponseFut = fidl::client::QueryResponseFut<
657        UsbFunctionConfigureResult,
658        fidl::encoding::DefaultFuchsiaResourceDialect,
659    >;
660    fn r#configure(
661        &self,
662        mut configuration: &[u8],
663        mut iface: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
664    ) -> Self::ConfigureResponseFut {
665        fn _decode(
666            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
667        ) -> Result<UsbFunctionConfigureResult, fidl::Error> {
668            let _response = fidl::client::decode_transaction_body::<
669                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
670                fidl::encoding::DefaultFuchsiaResourceDialect,
671                0x42a444f4abf08b89,
672            >(_buf?)?;
673            Ok(_response.map(|x| x))
674        }
675        self.client
676            .send_query_and_decode::<UsbFunctionConfigureRequest, UsbFunctionConfigureResult>(
677                (configuration, iface),
678                0x42a444f4abf08b89,
679                fidl::encoding::DynamicFlags::empty(),
680                _decode,
681            )
682    }
683
684    type DeconfigureResponseFut = fidl::client::QueryResponseFut<
685        UsbFunctionDeconfigureResult,
686        fidl::encoding::DefaultFuchsiaResourceDialect,
687    >;
688    fn r#deconfigure(&self) -> Self::DeconfigureResponseFut {
689        fn _decode(
690            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
691        ) -> Result<UsbFunctionDeconfigureResult, fidl::Error> {
692            let _response = fidl::client::decode_transaction_body::<
693                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
694                fidl::encoding::DefaultFuchsiaResourceDialect,
695                0x26ee8c8c826367b2,
696            >(_buf?)?;
697            Ok(_response.map(|x| x))
698        }
699        self.client
700            .send_query_and_decode::<fidl::encoding::EmptyPayload, UsbFunctionDeconfigureResult>(
701                (),
702                0x26ee8c8c826367b2,
703                fidl::encoding::DynamicFlags::empty(),
704                _decode,
705            )
706    }
707
708    type AllocResourcesResponseFut = fidl::client::QueryResponseFut<
709        UsbFunctionAllocResourcesResult,
710        fidl::encoding::DefaultFuchsiaResourceDialect,
711    >;
712    fn r#alloc_resources(
713        &self,
714        mut interface_count: u8,
715        mut endpoints: Vec<EndpointResource>,
716        mut strings: &[String],
717    ) -> Self::AllocResourcesResponseFut {
718        fn _decode(
719            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
720        ) -> Result<UsbFunctionAllocResourcesResult, fidl::Error> {
721            let _response = fidl::client::decode_transaction_body::<
722                fidl::encoding::ResultType<UsbFunctionAllocResourcesResponse, i32>,
723                fidl::encoding::DefaultFuchsiaResourceDialect,
724                0x5ab7133ab195daa0,
725            >(_buf?)?;
726            Ok(_response.map(|x| (x.interface_nums, x.endpoint_addrs, x.string_indices)))
727        }
728        self.client.send_query_and_decode::<
729            UsbFunctionAllocResourcesRequest,
730            UsbFunctionAllocResourcesResult,
731        >(
732            (interface_count, endpoints.as_mut(), strings,),
733            0x5ab7133ab195daa0,
734            fidl::encoding::DynamicFlags::empty(),
735            _decode,
736        )
737    }
738
739    type EndpointSetStallResponseFut = fidl::client::QueryResponseFut<
740        UsbFunctionEndpointSetStallResult,
741        fidl::encoding::DefaultFuchsiaResourceDialect,
742    >;
743    fn r#endpoint_set_stall(&self, mut endpoint_address: u8) -> Self::EndpointSetStallResponseFut {
744        fn _decode(
745            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
746        ) -> Result<UsbFunctionEndpointSetStallResult, fidl::Error> {
747            let _response = fidl::client::decode_transaction_body::<
748                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
749                fidl::encoding::DefaultFuchsiaResourceDialect,
750                0x1f32c374dac955f1,
751            >(_buf?)?;
752            Ok(_response.map(|x| x))
753        }
754        self.client.send_query_and_decode::<
755            UsbFunctionEndpointSetStallRequest,
756            UsbFunctionEndpointSetStallResult,
757        >(
758            (endpoint_address,),
759            0x1f32c374dac955f1,
760            fidl::encoding::DynamicFlags::empty(),
761            _decode,
762        )
763    }
764
765    type EndpointClearStallResponseFut = fidl::client::QueryResponseFut<
766        UsbFunctionEndpointClearStallResult,
767        fidl::encoding::DefaultFuchsiaResourceDialect,
768    >;
769    fn r#endpoint_clear_stall(
770        &self,
771        mut endpoint_address: u8,
772    ) -> Self::EndpointClearStallResponseFut {
773        fn _decode(
774            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
775        ) -> Result<UsbFunctionEndpointClearStallResult, fidl::Error> {
776            let _response = fidl::client::decode_transaction_body::<
777                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
778                fidl::encoding::DefaultFuchsiaResourceDialect,
779                0x221d9488ac58aaba,
780            >(_buf?)?;
781            Ok(_response.map(|x| x))
782        }
783        self.client.send_query_and_decode::<
784            UsbFunctionEndpointClearStallRequest,
785            UsbFunctionEndpointClearStallResult,
786        >(
787            (endpoint_address,),
788            0x221d9488ac58aaba,
789            fidl::encoding::DynamicFlags::empty(),
790            _decode,
791        )
792    }
793
794    type ConfigureEndpointResponseFut = fidl::client::QueryResponseFut<
795        UsbFunctionConfigureEndpointResult,
796        fidl::encoding::DefaultFuchsiaResourceDialect,
797    >;
798    fn r#configure_endpoint(
799        &self,
800        mut endpoint_address: u8,
801        mut endpoint_configuration: &EndpointConfiguration,
802    ) -> Self::ConfigureEndpointResponseFut {
803        fn _decode(
804            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
805        ) -> Result<UsbFunctionConfigureEndpointResult, fidl::Error> {
806            let _response = fidl::client::decode_transaction_body::<
807                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
808                fidl::encoding::DefaultFuchsiaResourceDialect,
809                0x314c9dc3c37ebb7c,
810            >(_buf?)?;
811            Ok(_response.map(|x| x))
812        }
813        self.client.send_query_and_decode::<
814            UsbFunctionConfigureEndpointRequest,
815            UsbFunctionConfigureEndpointResult,
816        >(
817            (endpoint_address, endpoint_configuration,),
818            0x314c9dc3c37ebb7c,
819            fidl::encoding::DynamicFlags::empty(),
820            _decode,
821        )
822    }
823
824    type DisableEndpointResponseFut = fidl::client::QueryResponseFut<
825        UsbFunctionDisableEndpointResult,
826        fidl::encoding::DefaultFuchsiaResourceDialect,
827    >;
828    fn r#disable_endpoint(&self, mut endpoint_address: u8) -> Self::DisableEndpointResponseFut {
829        fn _decode(
830            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
831        ) -> Result<UsbFunctionDisableEndpointResult, fidl::Error> {
832            let _response = fidl::client::decode_transaction_body::<
833                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
834                fidl::encoding::DefaultFuchsiaResourceDialect,
835                0x112a132561499b6e,
836            >(_buf?)?;
837            Ok(_response.map(|x| x))
838        }
839        self.client.send_query_and_decode::<
840            UsbFunctionDisableEndpointRequest,
841            UsbFunctionDisableEndpointResult,
842        >(
843            (endpoint_address,),
844            0x112a132561499b6e,
845            fidl::encoding::DynamicFlags::empty(),
846            _decode,
847        )
848    }
849}
850
851pub struct UsbFunctionEventStream {
852    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
853}
854
855impl std::marker::Unpin for UsbFunctionEventStream {}
856
857impl futures::stream::FusedStream for UsbFunctionEventStream {
858    fn is_terminated(&self) -> bool {
859        self.event_receiver.is_terminated()
860    }
861}
862
863impl futures::Stream for UsbFunctionEventStream {
864    type Item = Result<UsbFunctionEvent, fidl::Error>;
865
866    fn poll_next(
867        mut self: std::pin::Pin<&mut Self>,
868        cx: &mut std::task::Context<'_>,
869    ) -> std::task::Poll<Option<Self::Item>> {
870        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
871            &mut self.event_receiver,
872            cx
873        )?) {
874            Some(buf) => std::task::Poll::Ready(Some(UsbFunctionEvent::decode(buf))),
875            None => std::task::Poll::Ready(None),
876        }
877    }
878}
879
880#[derive(Debug)]
881pub enum UsbFunctionEvent {}
882
883impl UsbFunctionEvent {
884    /// Decodes a message buffer as a [`UsbFunctionEvent`].
885    fn decode(
886        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
887    ) -> Result<UsbFunctionEvent, fidl::Error> {
888        let (bytes, _handles) = buf.split_mut();
889        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
890        debug_assert_eq!(tx_header.tx_id, 0);
891        match tx_header.ordinal {
892            _ => Err(fidl::Error::UnknownOrdinal {
893                ordinal: tx_header.ordinal,
894                protocol_name: <UsbFunctionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
895            }),
896        }
897    }
898}
899
900/// A Stream of incoming requests for fuchsia.hardware.usb.function/UsbFunction.
901pub struct UsbFunctionRequestStream {
902    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
903    is_terminated: bool,
904}
905
906impl std::marker::Unpin for UsbFunctionRequestStream {}
907
908impl futures::stream::FusedStream for UsbFunctionRequestStream {
909    fn is_terminated(&self) -> bool {
910        self.is_terminated
911    }
912}
913
914impl fidl::endpoints::RequestStream for UsbFunctionRequestStream {
915    type Protocol = UsbFunctionMarker;
916    type ControlHandle = UsbFunctionControlHandle;
917
918    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
919        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
920    }
921
922    fn control_handle(&self) -> Self::ControlHandle {
923        UsbFunctionControlHandle { inner: self.inner.clone() }
924    }
925
926    fn into_inner(
927        self,
928    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
929    {
930        (self.inner, self.is_terminated)
931    }
932
933    fn from_inner(
934        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
935        is_terminated: bool,
936    ) -> Self {
937        Self { inner, is_terminated }
938    }
939}
940
941impl futures::Stream for UsbFunctionRequestStream {
942    type Item = Result<UsbFunctionRequest, fidl::Error>;
943
944    fn poll_next(
945        mut self: std::pin::Pin<&mut Self>,
946        cx: &mut std::task::Context<'_>,
947    ) -> std::task::Poll<Option<Self::Item>> {
948        let this = &mut *self;
949        if this.inner.check_shutdown(cx) {
950            this.is_terminated = true;
951            return std::task::Poll::Ready(None);
952        }
953        if this.is_terminated {
954            panic!("polled UsbFunctionRequestStream after completion");
955        }
956        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
957            |bytes, handles| {
958                match this.inner.channel().read_etc(cx, bytes, handles) {
959                    std::task::Poll::Ready(Ok(())) => {}
960                    std::task::Poll::Pending => return std::task::Poll::Pending,
961                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
962                        this.is_terminated = true;
963                        return std::task::Poll::Ready(None);
964                    }
965                    std::task::Poll::Ready(Err(e)) => {
966                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
967                            e.into(),
968                        ))));
969                    }
970                }
971
972                // A message has been received from the channel
973                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
974
975                std::task::Poll::Ready(Some(match header.ordinal {
976                    0x11541c67eb1b7f8 => {
977                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
978                        let mut req = fidl::new_empty!(
979                            UsbFunctionConnectToEndpointRequest,
980                            fidl::encoding::DefaultFuchsiaResourceDialect
981                        );
982                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionConnectToEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
983                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
984                        Ok(UsbFunctionRequest::ConnectToEndpoint {
985                            ep_addr: req.ep_addr,
986                            ep: req.ep,
987
988                            responder: UsbFunctionConnectToEndpointResponder {
989                                control_handle: std::mem::ManuallyDrop::new(control_handle),
990                                tx_id: header.tx_id,
991                            },
992                        })
993                    }
994                    0x42a444f4abf08b89 => {
995                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
996                        let mut req = fidl::new_empty!(
997                            UsbFunctionConfigureRequest,
998                            fidl::encoding::DefaultFuchsiaResourceDialect
999                        );
1000                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionConfigureRequest>(&header, _body_bytes, handles, &mut req)?;
1001                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
1002                        Ok(UsbFunctionRequest::Configure {
1003                            configuration: req.configuration,
1004                            iface: req.iface,
1005
1006                            responder: UsbFunctionConfigureResponder {
1007                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1008                                tx_id: header.tx_id,
1009                            },
1010                        })
1011                    }
1012                    0x26ee8c8c826367b2 => {
1013                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1014                        let mut req = fidl::new_empty!(
1015                            fidl::encoding::EmptyPayload,
1016                            fidl::encoding::DefaultFuchsiaResourceDialect
1017                        );
1018                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1019                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
1020                        Ok(UsbFunctionRequest::Deconfigure {
1021                            responder: UsbFunctionDeconfigureResponder {
1022                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1023                                tx_id: header.tx_id,
1024                            },
1025                        })
1026                    }
1027                    0x5ab7133ab195daa0 => {
1028                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1029                        let mut req = fidl::new_empty!(
1030                            UsbFunctionAllocResourcesRequest,
1031                            fidl::encoding::DefaultFuchsiaResourceDialect
1032                        );
1033                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionAllocResourcesRequest>(&header, _body_bytes, handles, &mut req)?;
1034                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
1035                        Ok(UsbFunctionRequest::AllocResources {
1036                            interface_count: req.interface_count,
1037                            endpoints: req.endpoints,
1038                            strings: req.strings,
1039
1040                            responder: UsbFunctionAllocResourcesResponder {
1041                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1042                                tx_id: header.tx_id,
1043                            },
1044                        })
1045                    }
1046                    0x1f32c374dac955f1 => {
1047                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1048                        let mut req = fidl::new_empty!(
1049                            UsbFunctionEndpointSetStallRequest,
1050                            fidl::encoding::DefaultFuchsiaResourceDialect
1051                        );
1052                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionEndpointSetStallRequest>(&header, _body_bytes, handles, &mut req)?;
1053                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
1054                        Ok(UsbFunctionRequest::EndpointSetStall {
1055                            endpoint_address: req.endpoint_address,
1056
1057                            responder: UsbFunctionEndpointSetStallResponder {
1058                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1059                                tx_id: header.tx_id,
1060                            },
1061                        })
1062                    }
1063                    0x221d9488ac58aaba => {
1064                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1065                        let mut req = fidl::new_empty!(
1066                            UsbFunctionEndpointClearStallRequest,
1067                            fidl::encoding::DefaultFuchsiaResourceDialect
1068                        );
1069                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionEndpointClearStallRequest>(&header, _body_bytes, handles, &mut req)?;
1070                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
1071                        Ok(UsbFunctionRequest::EndpointClearStall {
1072                            endpoint_address: req.endpoint_address,
1073
1074                            responder: UsbFunctionEndpointClearStallResponder {
1075                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1076                                tx_id: header.tx_id,
1077                            },
1078                        })
1079                    }
1080                    0x314c9dc3c37ebb7c => {
1081                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1082                        let mut req = fidl::new_empty!(
1083                            UsbFunctionConfigureEndpointRequest,
1084                            fidl::encoding::DefaultFuchsiaResourceDialect
1085                        );
1086                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionConfigureEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
1087                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
1088                        Ok(UsbFunctionRequest::ConfigureEndpoint {
1089                            endpoint_address: req.endpoint_address,
1090                            endpoint_configuration: req.endpoint_configuration,
1091
1092                            responder: UsbFunctionConfigureEndpointResponder {
1093                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1094                                tx_id: header.tx_id,
1095                            },
1096                        })
1097                    }
1098                    0x112a132561499b6e => {
1099                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1100                        let mut req = fidl::new_empty!(
1101                            UsbFunctionDisableEndpointRequest,
1102                            fidl::encoding::DefaultFuchsiaResourceDialect
1103                        );
1104                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionDisableEndpointRequest>(&header, _body_bytes, handles, &mut req)?;
1105                        let control_handle = UsbFunctionControlHandle { inner: this.inner.clone() };
1106                        Ok(UsbFunctionRequest::DisableEndpoint {
1107                            endpoint_address: req.endpoint_address,
1108
1109                            responder: UsbFunctionDisableEndpointResponder {
1110                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1111                                tx_id: header.tx_id,
1112                            },
1113                        })
1114                    }
1115                    _ => Err(fidl::Error::UnknownOrdinal {
1116                        ordinal: header.ordinal,
1117                        protocol_name:
1118                            <UsbFunctionMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1119                    }),
1120                }))
1121            },
1122        )
1123    }
1124}
1125
1126#[derive(Debug)]
1127pub enum UsbFunctionRequest {
1128    /// Connects to endpoint. Returns
1129    ///  * ZX_ERR_NOT_FOUND: if endpoint address does not exist.
1130    ///  * ZX_ERR_ALREADY_BOUND: if the endpoint is already bound.
1131    ConnectToEndpoint {
1132        ep_addr: u8,
1133        ep: fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
1134        responder: UsbFunctionConnectToEndpointResponder,
1135    },
1136    /// Configures the function with the given descriptors.
1137    ///
1138    /// `configuration` is a vector of USB descriptors to configure the function
1139    /// with. The descriptors are concatenated together following the USB
1140    /// specification to form the configuration.
1141    /// `iface` provides the control-plane callbacks for the function.
1142    ///
1143    /// The function is *unregistered* from the USB function manager when
1144    /// `iface` is closed.
1145    ///
1146    /// Any resource address and numbers referenced in `configuration` *must* have
1147    /// been allocated by a previous call to `AllocResources`.
1148    ///
1149    /// Returns `ZX_ERR_INVALID_ARGS` if the configuration is invalid.
1150    Configure {
1151        configuration: Vec<u8>,
1152        iface: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
1153        responder: UsbFunctionConfigureResponder,
1154    },
1155    /// Deconfigures the function.
1156    ///
1157    /// This is the opposite of `Configure`. The server drops its connection to
1158    /// the function upon receiving the call, if it's bound.
1159    ///
1160    /// Returns after the function channel has been unbound from the server.
1161    ///
1162    /// Trivially succeeds if no function interface is bound.
1163    ///
1164    /// Returns `ZX_ERR_UNAVAILABLE` if a deconfiguration is already in
1165    /// progress.
1166    Deconfigure { responder: UsbFunctionDeconfigureResponder },
1167    /// Allocates resources for the function.
1168    ///
1169    /// This function is used to allocate resources for the function.
1170    ///
1171    /// `interface_count` informs how many interfaces to create.
1172    /// `interface_nums` returns the allocate interface numbers referencing
1173    ///  the requested interfaces.
1174    ///
1175    /// `endpoints` is a vector of endpoints to allocate. The direction and
1176    ///  endpoint server end are provided.
1177    /// `endpoint_addrs` returns a vector of the same size containing the
1178    /// allocated endpoint addresses. On success the endpoint server ends are
1179    /// connected to a server. Closed otherwise.
1180    ///
1181    /// `strings` is a vector of strings to allocate.
1182    /// `string_indices` returns a vector of the same size containing the
1183    /// allocated string indices.
1184    ///
1185    /// Returns the interface ids, endpoint ids, and string ids that were
1186    /// allocated. On error, no resources are allocated. Returns:
1187    ///  * `ZX_ERR_NO_RESOURCES` if any resource namespace numbers are
1188    ///  exhausted.
1189    ///
1190    /// The allocated resource numbers and addresses remain allocated for the
1191    /// lifetime of the connection to `UsbFunction`.
1192    AllocResources {
1193        interface_count: u8,
1194        endpoints: Vec<EndpointResource>,
1195        strings: Vec<String>,
1196        responder: UsbFunctionAllocResourcesResponder,
1197    },
1198    /// Sets stall state in an endpoint.
1199    ///
1200    /// Returns
1201    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
1202    ///    inactive.
1203    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
1204    EndpointSetStall { endpoint_address: u8, responder: UsbFunctionEndpointSetStallResponder },
1205    /// Clears stall state in an endpoint.
1206    ///
1207    /// Returns
1208    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
1209    ///    inactive.
1210    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
1211    EndpointClearStall { endpoint_address: u8, responder: UsbFunctionEndpointClearStallResponder },
1212    /// Configure and enable an endpoint with the given configuration.
1213    ///
1214    /// See usb20 9.6.6.
1215    ///
1216    /// Returns
1217    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
1218    ///    inactive.
1219    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
1220    /// * `ZX_ERR_INVALID_ARGS`: If the configuration is invalid.
1221    ConfigureEndpoint {
1222        endpoint_address: u8,
1223        endpoint_configuration: EndpointConfiguration,
1224        responder: UsbFunctionConfigureEndpointResponder,
1225    },
1226    /// Disable an endpoint.
1227    ///
1228    /// Returns
1229    /// * `ZX_ERR_IO_NOT_PRESENT`: If device is not running, disconnected, or
1230    ///    inactive.
1231    /// * `ZX_ERR_NOT_FOUND`: If endpoint address does not exist.
1232    DisableEndpoint { endpoint_address: u8, responder: UsbFunctionDisableEndpointResponder },
1233}
1234
1235impl UsbFunctionRequest {
1236    #[allow(irrefutable_let_patterns)]
1237    pub fn into_connect_to_endpoint(
1238        self,
1239    ) -> Option<(
1240        u8,
1241        fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
1242        UsbFunctionConnectToEndpointResponder,
1243    )> {
1244        if let UsbFunctionRequest::ConnectToEndpoint { ep_addr, ep, responder } = self {
1245            Some((ep_addr, ep, responder))
1246        } else {
1247            None
1248        }
1249    }
1250
1251    #[allow(irrefutable_let_patterns)]
1252    pub fn into_configure(
1253        self,
1254    ) -> Option<(
1255        Vec<u8>,
1256        fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
1257        UsbFunctionConfigureResponder,
1258    )> {
1259        if let UsbFunctionRequest::Configure { configuration, iface, responder } = self {
1260            Some((configuration, iface, responder))
1261        } else {
1262            None
1263        }
1264    }
1265
1266    #[allow(irrefutable_let_patterns)]
1267    pub fn into_deconfigure(self) -> Option<(UsbFunctionDeconfigureResponder)> {
1268        if let UsbFunctionRequest::Deconfigure { responder } = self {
1269            Some((responder))
1270        } else {
1271            None
1272        }
1273    }
1274
1275    #[allow(irrefutable_let_patterns)]
1276    pub fn into_alloc_resources(
1277        self,
1278    ) -> Option<(u8, Vec<EndpointResource>, Vec<String>, UsbFunctionAllocResourcesResponder)> {
1279        if let UsbFunctionRequest::AllocResources {
1280            interface_count,
1281            endpoints,
1282            strings,
1283            responder,
1284        } = self
1285        {
1286            Some((interface_count, endpoints, strings, responder))
1287        } else {
1288            None
1289        }
1290    }
1291
1292    #[allow(irrefutable_let_patterns)]
1293    pub fn into_endpoint_set_stall(self) -> Option<(u8, UsbFunctionEndpointSetStallResponder)> {
1294        if let UsbFunctionRequest::EndpointSetStall { endpoint_address, responder } = self {
1295            Some((endpoint_address, responder))
1296        } else {
1297            None
1298        }
1299    }
1300
1301    #[allow(irrefutable_let_patterns)]
1302    pub fn into_endpoint_clear_stall(self) -> Option<(u8, UsbFunctionEndpointClearStallResponder)> {
1303        if let UsbFunctionRequest::EndpointClearStall { endpoint_address, responder } = self {
1304            Some((endpoint_address, responder))
1305        } else {
1306            None
1307        }
1308    }
1309
1310    #[allow(irrefutable_let_patterns)]
1311    pub fn into_configure_endpoint(
1312        self,
1313    ) -> Option<(u8, EndpointConfiguration, UsbFunctionConfigureEndpointResponder)> {
1314        if let UsbFunctionRequest::ConfigureEndpoint {
1315            endpoint_address,
1316            endpoint_configuration,
1317            responder,
1318        } = self
1319        {
1320            Some((endpoint_address, endpoint_configuration, responder))
1321        } else {
1322            None
1323        }
1324    }
1325
1326    #[allow(irrefutable_let_patterns)]
1327    pub fn into_disable_endpoint(self) -> Option<(u8, UsbFunctionDisableEndpointResponder)> {
1328        if let UsbFunctionRequest::DisableEndpoint { endpoint_address, responder } = self {
1329            Some((endpoint_address, responder))
1330        } else {
1331            None
1332        }
1333    }
1334
1335    /// Name of the method defined in FIDL
1336    pub fn method_name(&self) -> &'static str {
1337        match *self {
1338            UsbFunctionRequest::ConnectToEndpoint { .. } => "connect_to_endpoint",
1339            UsbFunctionRequest::Configure { .. } => "configure",
1340            UsbFunctionRequest::Deconfigure { .. } => "deconfigure",
1341            UsbFunctionRequest::AllocResources { .. } => "alloc_resources",
1342            UsbFunctionRequest::EndpointSetStall { .. } => "endpoint_set_stall",
1343            UsbFunctionRequest::EndpointClearStall { .. } => "endpoint_clear_stall",
1344            UsbFunctionRequest::ConfigureEndpoint { .. } => "configure_endpoint",
1345            UsbFunctionRequest::DisableEndpoint { .. } => "disable_endpoint",
1346        }
1347    }
1348}
1349
1350#[derive(Debug, Clone)]
1351pub struct UsbFunctionControlHandle {
1352    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1353}
1354
1355impl fidl::endpoints::ControlHandle for UsbFunctionControlHandle {
1356    fn shutdown(&self) {
1357        self.inner.shutdown()
1358    }
1359
1360    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1361        self.inner.shutdown_with_epitaph(status)
1362    }
1363
1364    fn is_closed(&self) -> bool {
1365        self.inner.channel().is_closed()
1366    }
1367    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1368        self.inner.channel().on_closed()
1369    }
1370
1371    #[cfg(target_os = "fuchsia")]
1372    fn signal_peer(
1373        &self,
1374        clear_mask: zx::Signals,
1375        set_mask: zx::Signals,
1376    ) -> Result<(), zx_status::Status> {
1377        use fidl::Peered;
1378        self.inner.channel().signal_peer(clear_mask, set_mask)
1379    }
1380}
1381
1382impl UsbFunctionControlHandle {}
1383
1384#[must_use = "FIDL methods require a response to be sent"]
1385#[derive(Debug)]
1386pub struct UsbFunctionConnectToEndpointResponder {
1387    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1388    tx_id: u32,
1389}
1390
1391/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1392/// if the responder is dropped without sending a response, so that the client
1393/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1394impl std::ops::Drop for UsbFunctionConnectToEndpointResponder {
1395    fn drop(&mut self) {
1396        self.control_handle.shutdown();
1397        // Safety: drops once, never accessed again
1398        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1399    }
1400}
1401
1402impl fidl::endpoints::Responder for UsbFunctionConnectToEndpointResponder {
1403    type ControlHandle = UsbFunctionControlHandle;
1404
1405    fn control_handle(&self) -> &UsbFunctionControlHandle {
1406        &self.control_handle
1407    }
1408
1409    fn drop_without_shutdown(mut self) {
1410        // Safety: drops once, never accessed again due to mem::forget
1411        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1412        // Prevent Drop from running (which would shut down the channel)
1413        std::mem::forget(self);
1414    }
1415}
1416
1417impl UsbFunctionConnectToEndpointResponder {
1418    /// Sends a response to the FIDL transaction.
1419    ///
1420    /// Sets the channel to shutdown if an error occurs.
1421    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1422        let _result = self.send_raw(result);
1423        if _result.is_err() {
1424            self.control_handle.shutdown();
1425        }
1426        self.drop_without_shutdown();
1427        _result
1428    }
1429
1430    /// Similar to "send" but does not shutdown the channel if an error occurs.
1431    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1432        let _result = self.send_raw(result);
1433        self.drop_without_shutdown();
1434        _result
1435    }
1436
1437    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1438        self.control_handle
1439            .inner
1440            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1441                result,
1442                self.tx_id,
1443                0x11541c67eb1b7f8,
1444                fidl::encoding::DynamicFlags::empty(),
1445            )
1446    }
1447}
1448
1449#[must_use = "FIDL methods require a response to be sent"]
1450#[derive(Debug)]
1451pub struct UsbFunctionConfigureResponder {
1452    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1453    tx_id: u32,
1454}
1455
1456/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1457/// if the responder is dropped without sending a response, so that the client
1458/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1459impl std::ops::Drop for UsbFunctionConfigureResponder {
1460    fn drop(&mut self) {
1461        self.control_handle.shutdown();
1462        // Safety: drops once, never accessed again
1463        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1464    }
1465}
1466
1467impl fidl::endpoints::Responder for UsbFunctionConfigureResponder {
1468    type ControlHandle = UsbFunctionControlHandle;
1469
1470    fn control_handle(&self) -> &UsbFunctionControlHandle {
1471        &self.control_handle
1472    }
1473
1474    fn drop_without_shutdown(mut self) {
1475        // Safety: drops once, never accessed again due to mem::forget
1476        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1477        // Prevent Drop from running (which would shut down the channel)
1478        std::mem::forget(self);
1479    }
1480}
1481
1482impl UsbFunctionConfigureResponder {
1483    /// Sends a response to the FIDL transaction.
1484    ///
1485    /// Sets the channel to shutdown if an error occurs.
1486    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1487        let _result = self.send_raw(result);
1488        if _result.is_err() {
1489            self.control_handle.shutdown();
1490        }
1491        self.drop_without_shutdown();
1492        _result
1493    }
1494
1495    /// Similar to "send" but does not shutdown the channel if an error occurs.
1496    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1497        let _result = self.send_raw(result);
1498        self.drop_without_shutdown();
1499        _result
1500    }
1501
1502    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1503        self.control_handle
1504            .inner
1505            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1506                result,
1507                self.tx_id,
1508                0x42a444f4abf08b89,
1509                fidl::encoding::DynamicFlags::empty(),
1510            )
1511    }
1512}
1513
1514#[must_use = "FIDL methods require a response to be sent"]
1515#[derive(Debug)]
1516pub struct UsbFunctionDeconfigureResponder {
1517    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1518    tx_id: u32,
1519}
1520
1521/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1522/// if the responder is dropped without sending a response, so that the client
1523/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1524impl std::ops::Drop for UsbFunctionDeconfigureResponder {
1525    fn drop(&mut self) {
1526        self.control_handle.shutdown();
1527        // Safety: drops once, never accessed again
1528        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1529    }
1530}
1531
1532impl fidl::endpoints::Responder for UsbFunctionDeconfigureResponder {
1533    type ControlHandle = UsbFunctionControlHandle;
1534
1535    fn control_handle(&self) -> &UsbFunctionControlHandle {
1536        &self.control_handle
1537    }
1538
1539    fn drop_without_shutdown(mut self) {
1540        // Safety: drops once, never accessed again due to mem::forget
1541        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1542        // Prevent Drop from running (which would shut down the channel)
1543        std::mem::forget(self);
1544    }
1545}
1546
1547impl UsbFunctionDeconfigureResponder {
1548    /// Sends a response to the FIDL transaction.
1549    ///
1550    /// Sets the channel to shutdown if an error occurs.
1551    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1552        let _result = self.send_raw(result);
1553        if _result.is_err() {
1554            self.control_handle.shutdown();
1555        }
1556        self.drop_without_shutdown();
1557        _result
1558    }
1559
1560    /// Similar to "send" but does not shutdown the channel if an error occurs.
1561    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1562        let _result = self.send_raw(result);
1563        self.drop_without_shutdown();
1564        _result
1565    }
1566
1567    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1568        self.control_handle
1569            .inner
1570            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1571                result,
1572                self.tx_id,
1573                0x26ee8c8c826367b2,
1574                fidl::encoding::DynamicFlags::empty(),
1575            )
1576    }
1577}
1578
1579#[must_use = "FIDL methods require a response to be sent"]
1580#[derive(Debug)]
1581pub struct UsbFunctionAllocResourcesResponder {
1582    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1583    tx_id: u32,
1584}
1585
1586/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1587/// if the responder is dropped without sending a response, so that the client
1588/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1589impl std::ops::Drop for UsbFunctionAllocResourcesResponder {
1590    fn drop(&mut self) {
1591        self.control_handle.shutdown();
1592        // Safety: drops once, never accessed again
1593        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1594    }
1595}
1596
1597impl fidl::endpoints::Responder for UsbFunctionAllocResourcesResponder {
1598    type ControlHandle = UsbFunctionControlHandle;
1599
1600    fn control_handle(&self) -> &UsbFunctionControlHandle {
1601        &self.control_handle
1602    }
1603
1604    fn drop_without_shutdown(mut self) {
1605        // Safety: drops once, never accessed again due to mem::forget
1606        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1607        // Prevent Drop from running (which would shut down the channel)
1608        std::mem::forget(self);
1609    }
1610}
1611
1612impl UsbFunctionAllocResourcesResponder {
1613    /// Sends a response to the FIDL transaction.
1614    ///
1615    /// Sets the channel to shutdown if an error occurs.
1616    pub fn send(self, mut result: Result<(&[u8], &[u8], &[u8]), i32>) -> Result<(), fidl::Error> {
1617        let _result = self.send_raw(result);
1618        if _result.is_err() {
1619            self.control_handle.shutdown();
1620        }
1621        self.drop_without_shutdown();
1622        _result
1623    }
1624
1625    /// Similar to "send" but does not shutdown the channel if an error occurs.
1626    pub fn send_no_shutdown_on_err(
1627        self,
1628        mut result: Result<(&[u8], &[u8], &[u8]), i32>,
1629    ) -> Result<(), fidl::Error> {
1630        let _result = self.send_raw(result);
1631        self.drop_without_shutdown();
1632        _result
1633    }
1634
1635    fn send_raw(&self, mut result: Result<(&[u8], &[u8], &[u8]), i32>) -> Result<(), fidl::Error> {
1636        self.control_handle
1637            .inner
1638            .send::<fidl::encoding::ResultType<UsbFunctionAllocResourcesResponse, i32>>(
1639                result,
1640                self.tx_id,
1641                0x5ab7133ab195daa0,
1642                fidl::encoding::DynamicFlags::empty(),
1643            )
1644    }
1645}
1646
1647#[must_use = "FIDL methods require a response to be sent"]
1648#[derive(Debug)]
1649pub struct UsbFunctionEndpointSetStallResponder {
1650    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1651    tx_id: u32,
1652}
1653
1654/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1655/// if the responder is dropped without sending a response, so that the client
1656/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1657impl std::ops::Drop for UsbFunctionEndpointSetStallResponder {
1658    fn drop(&mut self) {
1659        self.control_handle.shutdown();
1660        // Safety: drops once, never accessed again
1661        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1662    }
1663}
1664
1665impl fidl::endpoints::Responder for UsbFunctionEndpointSetStallResponder {
1666    type ControlHandle = UsbFunctionControlHandle;
1667
1668    fn control_handle(&self) -> &UsbFunctionControlHandle {
1669        &self.control_handle
1670    }
1671
1672    fn drop_without_shutdown(mut self) {
1673        // Safety: drops once, never accessed again due to mem::forget
1674        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1675        // Prevent Drop from running (which would shut down the channel)
1676        std::mem::forget(self);
1677    }
1678}
1679
1680impl UsbFunctionEndpointSetStallResponder {
1681    /// Sends a response to the FIDL transaction.
1682    ///
1683    /// Sets the channel to shutdown if an error occurs.
1684    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1685        let _result = self.send_raw(result);
1686        if _result.is_err() {
1687            self.control_handle.shutdown();
1688        }
1689        self.drop_without_shutdown();
1690        _result
1691    }
1692
1693    /// Similar to "send" but does not shutdown the channel if an error occurs.
1694    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1695        let _result = self.send_raw(result);
1696        self.drop_without_shutdown();
1697        _result
1698    }
1699
1700    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1701        self.control_handle
1702            .inner
1703            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1704                result,
1705                self.tx_id,
1706                0x1f32c374dac955f1,
1707                fidl::encoding::DynamicFlags::empty(),
1708            )
1709    }
1710}
1711
1712#[must_use = "FIDL methods require a response to be sent"]
1713#[derive(Debug)]
1714pub struct UsbFunctionEndpointClearStallResponder {
1715    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1716    tx_id: u32,
1717}
1718
1719/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1720/// if the responder is dropped without sending a response, so that the client
1721/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1722impl std::ops::Drop for UsbFunctionEndpointClearStallResponder {
1723    fn drop(&mut self) {
1724        self.control_handle.shutdown();
1725        // Safety: drops once, never accessed again
1726        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1727    }
1728}
1729
1730impl fidl::endpoints::Responder for UsbFunctionEndpointClearStallResponder {
1731    type ControlHandle = UsbFunctionControlHandle;
1732
1733    fn control_handle(&self) -> &UsbFunctionControlHandle {
1734        &self.control_handle
1735    }
1736
1737    fn drop_without_shutdown(mut self) {
1738        // Safety: drops once, never accessed again due to mem::forget
1739        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1740        // Prevent Drop from running (which would shut down the channel)
1741        std::mem::forget(self);
1742    }
1743}
1744
1745impl UsbFunctionEndpointClearStallResponder {
1746    /// Sends a response to the FIDL transaction.
1747    ///
1748    /// Sets the channel to shutdown if an error occurs.
1749    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1750        let _result = self.send_raw(result);
1751        if _result.is_err() {
1752            self.control_handle.shutdown();
1753        }
1754        self.drop_without_shutdown();
1755        _result
1756    }
1757
1758    /// Similar to "send" but does not shutdown the channel if an error occurs.
1759    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1760        let _result = self.send_raw(result);
1761        self.drop_without_shutdown();
1762        _result
1763    }
1764
1765    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1766        self.control_handle
1767            .inner
1768            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1769                result,
1770                self.tx_id,
1771                0x221d9488ac58aaba,
1772                fidl::encoding::DynamicFlags::empty(),
1773            )
1774    }
1775}
1776
1777#[must_use = "FIDL methods require a response to be sent"]
1778#[derive(Debug)]
1779pub struct UsbFunctionConfigureEndpointResponder {
1780    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1781    tx_id: u32,
1782}
1783
1784/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1785/// if the responder is dropped without sending a response, so that the client
1786/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1787impl std::ops::Drop for UsbFunctionConfigureEndpointResponder {
1788    fn drop(&mut self) {
1789        self.control_handle.shutdown();
1790        // Safety: drops once, never accessed again
1791        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1792    }
1793}
1794
1795impl fidl::endpoints::Responder for UsbFunctionConfigureEndpointResponder {
1796    type ControlHandle = UsbFunctionControlHandle;
1797
1798    fn control_handle(&self) -> &UsbFunctionControlHandle {
1799        &self.control_handle
1800    }
1801
1802    fn drop_without_shutdown(mut self) {
1803        // Safety: drops once, never accessed again due to mem::forget
1804        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1805        // Prevent Drop from running (which would shut down the channel)
1806        std::mem::forget(self);
1807    }
1808}
1809
1810impl UsbFunctionConfigureEndpointResponder {
1811    /// Sends a response to the FIDL transaction.
1812    ///
1813    /// Sets the channel to shutdown if an error occurs.
1814    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1815        let _result = self.send_raw(result);
1816        if _result.is_err() {
1817            self.control_handle.shutdown();
1818        }
1819        self.drop_without_shutdown();
1820        _result
1821    }
1822
1823    /// Similar to "send" but does not shutdown the channel if an error occurs.
1824    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1825        let _result = self.send_raw(result);
1826        self.drop_without_shutdown();
1827        _result
1828    }
1829
1830    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1831        self.control_handle
1832            .inner
1833            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1834                result,
1835                self.tx_id,
1836                0x314c9dc3c37ebb7c,
1837                fidl::encoding::DynamicFlags::empty(),
1838            )
1839    }
1840}
1841
1842#[must_use = "FIDL methods require a response to be sent"]
1843#[derive(Debug)]
1844pub struct UsbFunctionDisableEndpointResponder {
1845    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1846    tx_id: u32,
1847}
1848
1849/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1850/// if the responder is dropped without sending a response, so that the client
1851/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1852impl std::ops::Drop for UsbFunctionDisableEndpointResponder {
1853    fn drop(&mut self) {
1854        self.control_handle.shutdown();
1855        // Safety: drops once, never accessed again
1856        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1857    }
1858}
1859
1860impl fidl::endpoints::Responder for UsbFunctionDisableEndpointResponder {
1861    type ControlHandle = UsbFunctionControlHandle;
1862
1863    fn control_handle(&self) -> &UsbFunctionControlHandle {
1864        &self.control_handle
1865    }
1866
1867    fn drop_without_shutdown(mut self) {
1868        // Safety: drops once, never accessed again due to mem::forget
1869        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1870        // Prevent Drop from running (which would shut down the channel)
1871        std::mem::forget(self);
1872    }
1873}
1874
1875impl UsbFunctionDisableEndpointResponder {
1876    /// Sends a response to the FIDL transaction.
1877    ///
1878    /// Sets the channel to shutdown if an error occurs.
1879    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1880        let _result = self.send_raw(result);
1881        if _result.is_err() {
1882            self.control_handle.shutdown();
1883        }
1884        self.drop_without_shutdown();
1885        _result
1886    }
1887
1888    /// Similar to "send" but does not shutdown the channel if an error occurs.
1889    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1890        let _result = self.send_raw(result);
1891        self.drop_without_shutdown();
1892        _result
1893    }
1894
1895    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1896        self.control_handle
1897            .inner
1898            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1899                result,
1900                self.tx_id,
1901                0x112a132561499b6e,
1902                fidl::encoding::DynamicFlags::empty(),
1903            )
1904    }
1905}
1906
1907#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1908pub struct UsbFunctionInterfaceMarker;
1909
1910impl fidl::endpoints::ProtocolMarker for UsbFunctionInterfaceMarker {
1911    type Proxy = UsbFunctionInterfaceProxy;
1912    type RequestStream = UsbFunctionInterfaceRequestStream;
1913    #[cfg(target_os = "fuchsia")]
1914    type SynchronousProxy = UsbFunctionInterfaceSynchronousProxy;
1915
1916    const DEBUG_NAME: &'static str = "(anonymous) UsbFunctionInterface";
1917}
1918pub type UsbFunctionInterfaceControlResult = Result<Vec<u8>, i32>;
1919pub type UsbFunctionInterfaceSetConfiguredResult = Result<(), i32>;
1920pub type UsbFunctionInterfaceSetInterfaceResult = Result<(), i32>;
1921
1922pub trait UsbFunctionInterfaceProxyInterface: Send + Sync {
1923    type ControlResponseFut: std::future::Future<Output = Result<UsbFunctionInterfaceControlResult, fidl::Error>>
1924        + Send;
1925    fn r#control(
1926        &self,
1927        setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
1928        write: &[u8],
1929    ) -> Self::ControlResponseFut;
1930    type SetConfiguredResponseFut: std::future::Future<Output = Result<UsbFunctionInterfaceSetConfiguredResult, fidl::Error>>
1931        + Send;
1932    fn r#set_configured(
1933        &self,
1934        configured: bool,
1935        speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
1936    ) -> Self::SetConfiguredResponseFut;
1937    type SetInterfaceResponseFut: std::future::Future<Output = Result<UsbFunctionInterfaceSetInterfaceResult, fidl::Error>>
1938        + Send;
1939    fn r#set_interface(&self, interface: u8, alt_setting: u8) -> Self::SetInterfaceResponseFut;
1940}
1941#[derive(Debug)]
1942#[cfg(target_os = "fuchsia")]
1943pub struct UsbFunctionInterfaceSynchronousProxy {
1944    client: fidl::client::sync::Client,
1945}
1946
1947#[cfg(target_os = "fuchsia")]
1948impl fidl::endpoints::SynchronousProxy for UsbFunctionInterfaceSynchronousProxy {
1949    type Proxy = UsbFunctionInterfaceProxy;
1950    type Protocol = UsbFunctionInterfaceMarker;
1951
1952    fn from_channel(inner: fidl::Channel) -> Self {
1953        Self::new(inner)
1954    }
1955
1956    fn into_channel(self) -> fidl::Channel {
1957        self.client.into_channel()
1958    }
1959
1960    fn as_channel(&self) -> &fidl::Channel {
1961        self.client.as_channel()
1962    }
1963}
1964
1965#[cfg(target_os = "fuchsia")]
1966impl UsbFunctionInterfaceSynchronousProxy {
1967    pub fn new(channel: fidl::Channel) -> Self {
1968        Self { client: fidl::client::sync::Client::new(channel) }
1969    }
1970
1971    pub fn into_channel(self) -> fidl::Channel {
1972        self.client.into_channel()
1973    }
1974
1975    /// Waits until an event arrives and returns it. It is safe for other
1976    /// threads to make concurrent requests while waiting for an event.
1977    pub fn wait_for_event(
1978        &self,
1979        deadline: zx::MonotonicInstant,
1980    ) -> Result<UsbFunctionInterfaceEvent, fidl::Error> {
1981        UsbFunctionInterfaceEvent::decode(
1982            self.client.wait_for_event::<UsbFunctionInterfaceMarker>(deadline)?,
1983        )
1984    }
1985
1986    /// Callback for handling ep0 control requests.
1987    ///
1988    /// `setup` is the control request to handle.
1989    /// `write` is the data to write to the endpoint.
1990    /// `read` is the data to read from the endpoint.
1991    pub fn r#control(
1992        &self,
1993        mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
1994        mut write: &[u8],
1995        ___deadline: zx::MonotonicInstant,
1996    ) -> Result<UsbFunctionInterfaceControlResult, fidl::Error> {
1997        let _response = self.client.send_query::<
1998            UsbFunctionInterfaceControlRequest,
1999            fidl::encoding::FlexibleResultType<UsbFunctionInterfaceControlResponse, i32>,
2000            UsbFunctionInterfaceMarker,
2001        >(
2002            (setup, write,),
2003            0x3cce27231c012cff,
2004            fidl::encoding::DynamicFlags::FLEXIBLE,
2005            ___deadline,
2006        )?
2007        .into_result::<UsbFunctionInterfaceMarker>("control")?;
2008        Ok(_response.map(|x| x.read))
2009    }
2010
2011    /// Inform the function driver when the USB device configured state changes.
2012    ///
2013    /// Called with `configured == true` in response to a `SET_CONFIGURATION`
2014    /// control request that selects a configuration that contains this
2015    /// function. In this case, the function driver should use
2016    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure its endpoints.
2017    ///
2018    /// Called with `configured == false` when configuration is disabled or USB
2019    /// is disconnected. The function driver should then use
2020    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to disable its endpoints.
2021    pub fn r#set_configured(
2022        &self,
2023        mut configured: bool,
2024        mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2025        ___deadline: zx::MonotonicInstant,
2026    ) -> Result<UsbFunctionInterfaceSetConfiguredResult, fidl::Error> {
2027        let _response = self.client.send_query::<
2028            UsbFunctionInterfaceSetConfiguredRequest,
2029            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2030            UsbFunctionInterfaceMarker,
2031        >(
2032            (configured, speed,),
2033            0x5c26cc1f53f57a72,
2034            fidl::encoding::DynamicFlags::FLEXIBLE,
2035            ___deadline,
2036        )?
2037        .into_result::<UsbFunctionInterfaceMarker>("set_configured")?;
2038        Ok(_response.map(|x| x))
2039    }
2040
2041    /// Called to set an alternate setting for an interface due to a
2042    /// `SET_INTERFACE` control request.
2043    ///
2044    /// The function driver should use
2045    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure or disable the
2046    /// interface's endpoints as appropriate.
2047    pub fn r#set_interface(
2048        &self,
2049        mut interface: u8,
2050        mut alt_setting: u8,
2051        ___deadline: zx::MonotonicInstant,
2052    ) -> Result<UsbFunctionInterfaceSetInterfaceResult, fidl::Error> {
2053        let _response = self.client.send_query::<
2054            UsbFunctionInterfaceSetInterfaceRequest,
2055            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2056            UsbFunctionInterfaceMarker,
2057        >(
2058            (interface, alt_setting,),
2059            0x42ebdcefc1543f32,
2060            fidl::encoding::DynamicFlags::FLEXIBLE,
2061            ___deadline,
2062        )?
2063        .into_result::<UsbFunctionInterfaceMarker>("set_interface")?;
2064        Ok(_response.map(|x| x))
2065    }
2066}
2067
2068#[cfg(target_os = "fuchsia")]
2069impl From<UsbFunctionInterfaceSynchronousProxy> for zx::NullableHandle {
2070    fn from(value: UsbFunctionInterfaceSynchronousProxy) -> Self {
2071        value.into_channel().into()
2072    }
2073}
2074
2075#[cfg(target_os = "fuchsia")]
2076impl From<fidl::Channel> for UsbFunctionInterfaceSynchronousProxy {
2077    fn from(value: fidl::Channel) -> Self {
2078        Self::new(value)
2079    }
2080}
2081
2082#[cfg(target_os = "fuchsia")]
2083impl fidl::endpoints::FromClient for UsbFunctionInterfaceSynchronousProxy {
2084    type Protocol = UsbFunctionInterfaceMarker;
2085
2086    fn from_client(value: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>) -> Self {
2087        Self::new(value.into_channel())
2088    }
2089}
2090
2091#[derive(Debug, Clone)]
2092pub struct UsbFunctionInterfaceProxy {
2093    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2094}
2095
2096impl fidl::endpoints::Proxy for UsbFunctionInterfaceProxy {
2097    type Protocol = UsbFunctionInterfaceMarker;
2098
2099    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2100        Self::new(inner)
2101    }
2102
2103    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2104        self.client.into_channel().map_err(|client| Self { client })
2105    }
2106
2107    fn as_channel(&self) -> &::fidl::AsyncChannel {
2108        self.client.as_channel()
2109    }
2110}
2111
2112impl UsbFunctionInterfaceProxy {
2113    /// Create a new Proxy for fuchsia.hardware.usb.function/UsbFunctionInterface.
2114    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2115        let protocol_name =
2116            <UsbFunctionInterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2117        Self { client: fidl::client::Client::new(channel, protocol_name) }
2118    }
2119
2120    /// Get a Stream of events from the remote end of the protocol.
2121    ///
2122    /// # Panics
2123    ///
2124    /// Panics if the event stream was already taken.
2125    pub fn take_event_stream(&self) -> UsbFunctionInterfaceEventStream {
2126        UsbFunctionInterfaceEventStream { event_receiver: self.client.take_event_receiver() }
2127    }
2128
2129    /// Callback for handling ep0 control requests.
2130    ///
2131    /// `setup` is the control request to handle.
2132    /// `write` is the data to write to the endpoint.
2133    /// `read` is the data to read from the endpoint.
2134    pub fn r#control(
2135        &self,
2136        mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2137        mut write: &[u8],
2138    ) -> fidl::client::QueryResponseFut<
2139        UsbFunctionInterfaceControlResult,
2140        fidl::encoding::DefaultFuchsiaResourceDialect,
2141    > {
2142        UsbFunctionInterfaceProxyInterface::r#control(self, setup, write)
2143    }
2144
2145    /// Inform the function driver when the USB device configured state changes.
2146    ///
2147    /// Called with `configured == true` in response to a `SET_CONFIGURATION`
2148    /// control request that selects a configuration that contains this
2149    /// function. In this case, the function driver should use
2150    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure its endpoints.
2151    ///
2152    /// Called with `configured == false` when configuration is disabled or USB
2153    /// is disconnected. The function driver should then use
2154    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to disable its endpoints.
2155    pub fn r#set_configured(
2156        &self,
2157        mut configured: bool,
2158        mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2159    ) -> fidl::client::QueryResponseFut<
2160        UsbFunctionInterfaceSetConfiguredResult,
2161        fidl::encoding::DefaultFuchsiaResourceDialect,
2162    > {
2163        UsbFunctionInterfaceProxyInterface::r#set_configured(self, configured, speed)
2164    }
2165
2166    /// Called to set an alternate setting for an interface due to a
2167    /// `SET_INTERFACE` control request.
2168    ///
2169    /// The function driver should use
2170    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure or disable the
2171    /// interface's endpoints as appropriate.
2172    pub fn r#set_interface(
2173        &self,
2174        mut interface: u8,
2175        mut alt_setting: u8,
2176    ) -> fidl::client::QueryResponseFut<
2177        UsbFunctionInterfaceSetInterfaceResult,
2178        fidl::encoding::DefaultFuchsiaResourceDialect,
2179    > {
2180        UsbFunctionInterfaceProxyInterface::r#set_interface(self, interface, alt_setting)
2181    }
2182}
2183
2184impl UsbFunctionInterfaceProxyInterface for UsbFunctionInterfaceProxy {
2185    type ControlResponseFut = fidl::client::QueryResponseFut<
2186        UsbFunctionInterfaceControlResult,
2187        fidl::encoding::DefaultFuchsiaResourceDialect,
2188    >;
2189    fn r#control(
2190        &self,
2191        mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2192        mut write: &[u8],
2193    ) -> Self::ControlResponseFut {
2194        fn _decode(
2195            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2196        ) -> Result<UsbFunctionInterfaceControlResult, fidl::Error> {
2197            let _response = fidl::client::decode_transaction_body::<
2198                fidl::encoding::FlexibleResultType<UsbFunctionInterfaceControlResponse, i32>,
2199                fidl::encoding::DefaultFuchsiaResourceDialect,
2200                0x3cce27231c012cff,
2201            >(_buf?)?
2202            .into_result::<UsbFunctionInterfaceMarker>("control")?;
2203            Ok(_response.map(|x| x.read))
2204        }
2205        self.client.send_query_and_decode::<
2206            UsbFunctionInterfaceControlRequest,
2207            UsbFunctionInterfaceControlResult,
2208        >(
2209            (setup, write,),
2210            0x3cce27231c012cff,
2211            fidl::encoding::DynamicFlags::FLEXIBLE,
2212            _decode,
2213        )
2214    }
2215
2216    type SetConfiguredResponseFut = fidl::client::QueryResponseFut<
2217        UsbFunctionInterfaceSetConfiguredResult,
2218        fidl::encoding::DefaultFuchsiaResourceDialect,
2219    >;
2220    fn r#set_configured(
2221        &self,
2222        mut configured: bool,
2223        mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2224    ) -> Self::SetConfiguredResponseFut {
2225        fn _decode(
2226            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2227        ) -> Result<UsbFunctionInterfaceSetConfiguredResult, fidl::Error> {
2228            let _response = fidl::client::decode_transaction_body::<
2229                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2230                fidl::encoding::DefaultFuchsiaResourceDialect,
2231                0x5c26cc1f53f57a72,
2232            >(_buf?)?
2233            .into_result::<UsbFunctionInterfaceMarker>("set_configured")?;
2234            Ok(_response.map(|x| x))
2235        }
2236        self.client.send_query_and_decode::<
2237            UsbFunctionInterfaceSetConfiguredRequest,
2238            UsbFunctionInterfaceSetConfiguredResult,
2239        >(
2240            (configured, speed,),
2241            0x5c26cc1f53f57a72,
2242            fidl::encoding::DynamicFlags::FLEXIBLE,
2243            _decode,
2244        )
2245    }
2246
2247    type SetInterfaceResponseFut = fidl::client::QueryResponseFut<
2248        UsbFunctionInterfaceSetInterfaceResult,
2249        fidl::encoding::DefaultFuchsiaResourceDialect,
2250    >;
2251    fn r#set_interface(
2252        &self,
2253        mut interface: u8,
2254        mut alt_setting: u8,
2255    ) -> Self::SetInterfaceResponseFut {
2256        fn _decode(
2257            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2258        ) -> Result<UsbFunctionInterfaceSetInterfaceResult, fidl::Error> {
2259            let _response = fidl::client::decode_transaction_body::<
2260                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2261                fidl::encoding::DefaultFuchsiaResourceDialect,
2262                0x42ebdcefc1543f32,
2263            >(_buf?)?
2264            .into_result::<UsbFunctionInterfaceMarker>("set_interface")?;
2265            Ok(_response.map(|x| x))
2266        }
2267        self.client.send_query_and_decode::<
2268            UsbFunctionInterfaceSetInterfaceRequest,
2269            UsbFunctionInterfaceSetInterfaceResult,
2270        >(
2271            (interface, alt_setting,),
2272            0x42ebdcefc1543f32,
2273            fidl::encoding::DynamicFlags::FLEXIBLE,
2274            _decode,
2275        )
2276    }
2277}
2278
2279pub struct UsbFunctionInterfaceEventStream {
2280    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2281}
2282
2283impl std::marker::Unpin for UsbFunctionInterfaceEventStream {}
2284
2285impl futures::stream::FusedStream for UsbFunctionInterfaceEventStream {
2286    fn is_terminated(&self) -> bool {
2287        self.event_receiver.is_terminated()
2288    }
2289}
2290
2291impl futures::Stream for UsbFunctionInterfaceEventStream {
2292    type Item = Result<UsbFunctionInterfaceEvent, fidl::Error>;
2293
2294    fn poll_next(
2295        mut self: std::pin::Pin<&mut Self>,
2296        cx: &mut std::task::Context<'_>,
2297    ) -> std::task::Poll<Option<Self::Item>> {
2298        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2299            &mut self.event_receiver,
2300            cx
2301        )?) {
2302            Some(buf) => std::task::Poll::Ready(Some(UsbFunctionInterfaceEvent::decode(buf))),
2303            None => std::task::Poll::Ready(None),
2304        }
2305    }
2306}
2307
2308#[derive(Debug)]
2309pub enum UsbFunctionInterfaceEvent {
2310    #[non_exhaustive]
2311    _UnknownEvent {
2312        /// Ordinal of the event that was sent.
2313        ordinal: u64,
2314    },
2315}
2316
2317impl UsbFunctionInterfaceEvent {
2318    /// Decodes a message buffer as a [`UsbFunctionInterfaceEvent`].
2319    fn decode(
2320        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2321    ) -> Result<UsbFunctionInterfaceEvent, fidl::Error> {
2322        let (bytes, _handles) = buf.split_mut();
2323        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2324        debug_assert_eq!(tx_header.tx_id, 0);
2325        match tx_header.ordinal {
2326            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2327                Ok(UsbFunctionInterfaceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2328            }
2329            _ => Err(fidl::Error::UnknownOrdinal {
2330                ordinal: tx_header.ordinal,
2331                protocol_name:
2332                    <UsbFunctionInterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2333            }),
2334        }
2335    }
2336}
2337
2338/// A Stream of incoming requests for fuchsia.hardware.usb.function/UsbFunctionInterface.
2339pub struct UsbFunctionInterfaceRequestStream {
2340    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2341    is_terminated: bool,
2342}
2343
2344impl std::marker::Unpin for UsbFunctionInterfaceRequestStream {}
2345
2346impl futures::stream::FusedStream for UsbFunctionInterfaceRequestStream {
2347    fn is_terminated(&self) -> bool {
2348        self.is_terminated
2349    }
2350}
2351
2352impl fidl::endpoints::RequestStream for UsbFunctionInterfaceRequestStream {
2353    type Protocol = UsbFunctionInterfaceMarker;
2354    type ControlHandle = UsbFunctionInterfaceControlHandle;
2355
2356    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2357        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2358    }
2359
2360    fn control_handle(&self) -> Self::ControlHandle {
2361        UsbFunctionInterfaceControlHandle { inner: self.inner.clone() }
2362    }
2363
2364    fn into_inner(
2365        self,
2366    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2367    {
2368        (self.inner, self.is_terminated)
2369    }
2370
2371    fn from_inner(
2372        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2373        is_terminated: bool,
2374    ) -> Self {
2375        Self { inner, is_terminated }
2376    }
2377}
2378
2379impl futures::Stream for UsbFunctionInterfaceRequestStream {
2380    type Item = Result<UsbFunctionInterfaceRequest, fidl::Error>;
2381
2382    fn poll_next(
2383        mut self: std::pin::Pin<&mut Self>,
2384        cx: &mut std::task::Context<'_>,
2385    ) -> std::task::Poll<Option<Self::Item>> {
2386        let this = &mut *self;
2387        if this.inner.check_shutdown(cx) {
2388            this.is_terminated = true;
2389            return std::task::Poll::Ready(None);
2390        }
2391        if this.is_terminated {
2392            panic!("polled UsbFunctionInterfaceRequestStream after completion");
2393        }
2394        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2395            |bytes, handles| {
2396                match this.inner.channel().read_etc(cx, bytes, handles) {
2397                    std::task::Poll::Ready(Ok(())) => {}
2398                    std::task::Poll::Pending => return std::task::Poll::Pending,
2399                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2400                        this.is_terminated = true;
2401                        return std::task::Poll::Ready(None);
2402                    }
2403                    std::task::Poll::Ready(Err(e)) => {
2404                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2405                            e.into(),
2406                        ))));
2407                    }
2408                }
2409
2410                // A message has been received from the channel
2411                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2412
2413                std::task::Poll::Ready(Some(match header.ordinal {
2414                0x3cce27231c012cff => {
2415                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2416                    let mut req = fidl::new_empty!(UsbFunctionInterfaceControlRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2417                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionInterfaceControlRequest>(&header, _body_bytes, handles, &mut req)?;
2418                    let control_handle = UsbFunctionInterfaceControlHandle {
2419                        inner: this.inner.clone(),
2420                    };
2421                    Ok(UsbFunctionInterfaceRequest::Control {setup: req.setup,
2422write: req.write,
2423
2424                        responder: UsbFunctionInterfaceControlResponder {
2425                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2426                            tx_id: header.tx_id,
2427                        },
2428                    })
2429                }
2430                0x5c26cc1f53f57a72 => {
2431                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2432                    let mut req = fidl::new_empty!(UsbFunctionInterfaceSetConfiguredRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2433                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionInterfaceSetConfiguredRequest>(&header, _body_bytes, handles, &mut req)?;
2434                    let control_handle = UsbFunctionInterfaceControlHandle {
2435                        inner: this.inner.clone(),
2436                    };
2437                    Ok(UsbFunctionInterfaceRequest::SetConfigured {configured: req.configured,
2438speed: req.speed,
2439
2440                        responder: UsbFunctionInterfaceSetConfiguredResponder {
2441                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2442                            tx_id: header.tx_id,
2443                        },
2444                    })
2445                }
2446                0x42ebdcefc1543f32 => {
2447                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2448                    let mut req = fidl::new_empty!(UsbFunctionInterfaceSetInterfaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2449                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionInterfaceSetInterfaceRequest>(&header, _body_bytes, handles, &mut req)?;
2450                    let control_handle = UsbFunctionInterfaceControlHandle {
2451                        inner: this.inner.clone(),
2452                    };
2453                    Ok(UsbFunctionInterfaceRequest::SetInterface {interface: req.interface,
2454alt_setting: req.alt_setting,
2455
2456                        responder: UsbFunctionInterfaceSetInterfaceResponder {
2457                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2458                            tx_id: header.tx_id,
2459                        },
2460                    })
2461                }
2462                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2463                    Ok(UsbFunctionInterfaceRequest::_UnknownMethod {
2464                        ordinal: header.ordinal,
2465                        control_handle: UsbFunctionInterfaceControlHandle { inner: this.inner.clone() },
2466                        method_type: fidl::MethodType::OneWay,
2467                    })
2468                }
2469                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2470                    this.inner.send_framework_err(
2471                        fidl::encoding::FrameworkErr::UnknownMethod,
2472                        header.tx_id,
2473                        header.ordinal,
2474                        header.dynamic_flags(),
2475                        (bytes, handles),
2476                    )?;
2477                    Ok(UsbFunctionInterfaceRequest::_UnknownMethod {
2478                        ordinal: header.ordinal,
2479                        control_handle: UsbFunctionInterfaceControlHandle { inner: this.inner.clone() },
2480                        method_type: fidl::MethodType::TwoWay,
2481                    })
2482                }
2483                _ => Err(fidl::Error::UnknownOrdinal {
2484                    ordinal: header.ordinal,
2485                    protocol_name: <UsbFunctionInterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2486                }),
2487            }))
2488            },
2489        )
2490    }
2491}
2492
2493/// Protocol offered to [`UsbFunction`] instances to handle host-initiated
2494/// requests.
2495#[derive(Debug)]
2496pub enum UsbFunctionInterfaceRequest {
2497    /// Callback for handling ep0 control requests.
2498    ///
2499    /// `setup` is the control request to handle.
2500    /// `write` is the data to write to the endpoint.
2501    /// `read` is the data to read from the endpoint.
2502    Control {
2503        setup: fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2504        write: Vec<u8>,
2505        responder: UsbFunctionInterfaceControlResponder,
2506    },
2507    /// Inform the function driver when the USB device configured state changes.
2508    ///
2509    /// Called with `configured == true` in response to a `SET_CONFIGURATION`
2510    /// control request that selects a configuration that contains this
2511    /// function. In this case, the function driver should use
2512    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure its endpoints.
2513    ///
2514    /// Called with `configured == false` when configuration is disabled or USB
2515    /// is disconnected. The function driver should then use
2516    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to disable its endpoints.
2517    SetConfigured {
2518        configured: bool,
2519        speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2520        responder: UsbFunctionInterfaceSetConfiguredResponder,
2521    },
2522    /// Called to set an alternate setting for an interface due to a
2523    /// `SET_INTERFACE` control request.
2524    ///
2525    /// The function driver should use
2526    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure or disable the
2527    /// interface's endpoints as appropriate.
2528    SetInterface {
2529        interface: u8,
2530        alt_setting: u8,
2531        responder: UsbFunctionInterfaceSetInterfaceResponder,
2532    },
2533    /// An interaction was received which does not match any known method.
2534    #[non_exhaustive]
2535    _UnknownMethod {
2536        /// Ordinal of the method that was called.
2537        ordinal: u64,
2538        control_handle: UsbFunctionInterfaceControlHandle,
2539        method_type: fidl::MethodType,
2540    },
2541}
2542
2543impl UsbFunctionInterfaceRequest {
2544    #[allow(irrefutable_let_patterns)]
2545    pub fn into_control(
2546        self,
2547    ) -> Option<(
2548        fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2549        Vec<u8>,
2550        UsbFunctionInterfaceControlResponder,
2551    )> {
2552        if let UsbFunctionInterfaceRequest::Control { setup, write, responder } = self {
2553            Some((setup, write, responder))
2554        } else {
2555            None
2556        }
2557    }
2558
2559    #[allow(irrefutable_let_patterns)]
2560    pub fn into_set_configured(
2561        self,
2562    ) -> Option<(
2563        bool,
2564        fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2565        UsbFunctionInterfaceSetConfiguredResponder,
2566    )> {
2567        if let UsbFunctionInterfaceRequest::SetConfigured { configured, speed, responder } = self {
2568            Some((configured, speed, responder))
2569        } else {
2570            None
2571        }
2572    }
2573
2574    #[allow(irrefutable_let_patterns)]
2575    pub fn into_set_interface(self) -> Option<(u8, u8, UsbFunctionInterfaceSetInterfaceResponder)> {
2576        if let UsbFunctionInterfaceRequest::SetInterface { interface, alt_setting, responder } =
2577            self
2578        {
2579            Some((interface, alt_setting, responder))
2580        } else {
2581            None
2582        }
2583    }
2584
2585    /// Name of the method defined in FIDL
2586    pub fn method_name(&self) -> &'static str {
2587        match *self {
2588            UsbFunctionInterfaceRequest::Control { .. } => "control",
2589            UsbFunctionInterfaceRequest::SetConfigured { .. } => "set_configured",
2590            UsbFunctionInterfaceRequest::SetInterface { .. } => "set_interface",
2591            UsbFunctionInterfaceRequest::_UnknownMethod {
2592                method_type: fidl::MethodType::OneWay,
2593                ..
2594            } => "unknown one-way method",
2595            UsbFunctionInterfaceRequest::_UnknownMethod {
2596                method_type: fidl::MethodType::TwoWay,
2597                ..
2598            } => "unknown two-way method",
2599        }
2600    }
2601}
2602
2603#[derive(Debug, Clone)]
2604pub struct UsbFunctionInterfaceControlHandle {
2605    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2606}
2607
2608impl fidl::endpoints::ControlHandle for UsbFunctionInterfaceControlHandle {
2609    fn shutdown(&self) {
2610        self.inner.shutdown()
2611    }
2612
2613    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
2614        self.inner.shutdown_with_epitaph(status)
2615    }
2616
2617    fn is_closed(&self) -> bool {
2618        self.inner.channel().is_closed()
2619    }
2620    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2621        self.inner.channel().on_closed()
2622    }
2623
2624    #[cfg(target_os = "fuchsia")]
2625    fn signal_peer(
2626        &self,
2627        clear_mask: zx::Signals,
2628        set_mask: zx::Signals,
2629    ) -> Result<(), zx_status::Status> {
2630        use fidl::Peered;
2631        self.inner.channel().signal_peer(clear_mask, set_mask)
2632    }
2633}
2634
2635impl UsbFunctionInterfaceControlHandle {}
2636
2637#[must_use = "FIDL methods require a response to be sent"]
2638#[derive(Debug)]
2639pub struct UsbFunctionInterfaceControlResponder {
2640    control_handle: std::mem::ManuallyDrop<UsbFunctionInterfaceControlHandle>,
2641    tx_id: u32,
2642}
2643
2644/// Set the the channel to be shutdown (see [`UsbFunctionInterfaceControlHandle::shutdown`])
2645/// if the responder is dropped without sending a response, so that the client
2646/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2647impl std::ops::Drop for UsbFunctionInterfaceControlResponder {
2648    fn drop(&mut self) {
2649        self.control_handle.shutdown();
2650        // Safety: drops once, never accessed again
2651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2652    }
2653}
2654
2655impl fidl::endpoints::Responder for UsbFunctionInterfaceControlResponder {
2656    type ControlHandle = UsbFunctionInterfaceControlHandle;
2657
2658    fn control_handle(&self) -> &UsbFunctionInterfaceControlHandle {
2659        &self.control_handle
2660    }
2661
2662    fn drop_without_shutdown(mut self) {
2663        // Safety: drops once, never accessed again due to mem::forget
2664        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2665        // Prevent Drop from running (which would shut down the channel)
2666        std::mem::forget(self);
2667    }
2668}
2669
2670impl UsbFunctionInterfaceControlResponder {
2671    /// Sends a response to the FIDL transaction.
2672    ///
2673    /// Sets the channel to shutdown if an error occurs.
2674    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2675        let _result = self.send_raw(result);
2676        if _result.is_err() {
2677            self.control_handle.shutdown();
2678        }
2679        self.drop_without_shutdown();
2680        _result
2681    }
2682
2683    /// Similar to "send" but does not shutdown the channel if an error occurs.
2684    pub fn send_no_shutdown_on_err(
2685        self,
2686        mut result: Result<&[u8], i32>,
2687    ) -> Result<(), fidl::Error> {
2688        let _result = self.send_raw(result);
2689        self.drop_without_shutdown();
2690        _result
2691    }
2692
2693    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2694        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2695            UsbFunctionInterfaceControlResponse,
2696            i32,
2697        >>(
2698            fidl::encoding::FlexibleResult::new(result.map(|read| (read,))),
2699            self.tx_id,
2700            0x3cce27231c012cff,
2701            fidl::encoding::DynamicFlags::FLEXIBLE,
2702        )
2703    }
2704}
2705
2706#[must_use = "FIDL methods require a response to be sent"]
2707#[derive(Debug)]
2708pub struct UsbFunctionInterfaceSetConfiguredResponder {
2709    control_handle: std::mem::ManuallyDrop<UsbFunctionInterfaceControlHandle>,
2710    tx_id: u32,
2711}
2712
2713/// Set the the channel to be shutdown (see [`UsbFunctionInterfaceControlHandle::shutdown`])
2714/// if the responder is dropped without sending a response, so that the client
2715/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2716impl std::ops::Drop for UsbFunctionInterfaceSetConfiguredResponder {
2717    fn drop(&mut self) {
2718        self.control_handle.shutdown();
2719        // Safety: drops once, never accessed again
2720        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2721    }
2722}
2723
2724impl fidl::endpoints::Responder for UsbFunctionInterfaceSetConfiguredResponder {
2725    type ControlHandle = UsbFunctionInterfaceControlHandle;
2726
2727    fn control_handle(&self) -> &UsbFunctionInterfaceControlHandle {
2728        &self.control_handle
2729    }
2730
2731    fn drop_without_shutdown(mut self) {
2732        // Safety: drops once, never accessed again due to mem::forget
2733        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2734        // Prevent Drop from running (which would shut down the channel)
2735        std::mem::forget(self);
2736    }
2737}
2738
2739impl UsbFunctionInterfaceSetConfiguredResponder {
2740    /// Sends a response to the FIDL transaction.
2741    ///
2742    /// Sets the channel to shutdown if an error occurs.
2743    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2744        let _result = self.send_raw(result);
2745        if _result.is_err() {
2746            self.control_handle.shutdown();
2747        }
2748        self.drop_without_shutdown();
2749        _result
2750    }
2751
2752    /// Similar to "send" but does not shutdown the channel if an error occurs.
2753    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2754        let _result = self.send_raw(result);
2755        self.drop_without_shutdown();
2756        _result
2757    }
2758
2759    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2760        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2761            fidl::encoding::EmptyStruct,
2762            i32,
2763        >>(
2764            fidl::encoding::FlexibleResult::new(result),
2765            self.tx_id,
2766            0x5c26cc1f53f57a72,
2767            fidl::encoding::DynamicFlags::FLEXIBLE,
2768        )
2769    }
2770}
2771
2772#[must_use = "FIDL methods require a response to be sent"]
2773#[derive(Debug)]
2774pub struct UsbFunctionInterfaceSetInterfaceResponder {
2775    control_handle: std::mem::ManuallyDrop<UsbFunctionInterfaceControlHandle>,
2776    tx_id: u32,
2777}
2778
2779/// Set the the channel to be shutdown (see [`UsbFunctionInterfaceControlHandle::shutdown`])
2780/// if the responder is dropped without sending a response, so that the client
2781/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2782impl std::ops::Drop for UsbFunctionInterfaceSetInterfaceResponder {
2783    fn drop(&mut self) {
2784        self.control_handle.shutdown();
2785        // Safety: drops once, never accessed again
2786        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2787    }
2788}
2789
2790impl fidl::endpoints::Responder for UsbFunctionInterfaceSetInterfaceResponder {
2791    type ControlHandle = UsbFunctionInterfaceControlHandle;
2792
2793    fn control_handle(&self) -> &UsbFunctionInterfaceControlHandle {
2794        &self.control_handle
2795    }
2796
2797    fn drop_without_shutdown(mut self) {
2798        // Safety: drops once, never accessed again due to mem::forget
2799        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2800        // Prevent Drop from running (which would shut down the channel)
2801        std::mem::forget(self);
2802    }
2803}
2804
2805impl UsbFunctionInterfaceSetInterfaceResponder {
2806    /// Sends a response to the FIDL transaction.
2807    ///
2808    /// Sets the channel to shutdown if an error occurs.
2809    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2810        let _result = self.send_raw(result);
2811        if _result.is_err() {
2812            self.control_handle.shutdown();
2813        }
2814        self.drop_without_shutdown();
2815        _result
2816    }
2817
2818    /// Similar to "send" but does not shutdown the channel if an error occurs.
2819    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2820        let _result = self.send_raw(result);
2821        self.drop_without_shutdown();
2822        _result
2823    }
2824
2825    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2826        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2827            fidl::encoding::EmptyStruct,
2828            i32,
2829        >>(
2830            fidl::encoding::FlexibleResult::new(result),
2831            self.tx_id,
2832            0x42ebdcefc1543f32,
2833            fidl::encoding::DynamicFlags::FLEXIBLE,
2834        )
2835    }
2836}
2837
2838#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2839pub struct UsbFunctionServiceMarker;
2840
2841#[cfg(target_os = "fuchsia")]
2842impl fidl::endpoints::ServiceMarker for UsbFunctionServiceMarker {
2843    type Proxy = UsbFunctionServiceProxy;
2844    type Request = UsbFunctionServiceRequest;
2845    const SERVICE_NAME: &'static str = "fuchsia.hardware.usb.function.UsbFunctionService";
2846}
2847
2848/// A request for one of the member protocols of UsbFunctionService.
2849///
2850#[cfg(target_os = "fuchsia")]
2851pub enum UsbFunctionServiceRequest {
2852    Device(UsbFunctionRequestStream),
2853}
2854
2855#[cfg(target_os = "fuchsia")]
2856impl fidl::endpoints::ServiceRequest for UsbFunctionServiceRequest {
2857    type Service = UsbFunctionServiceMarker;
2858
2859    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2860        match name {
2861            "device" => Self::Device(
2862                <UsbFunctionRequestStream as fidl::endpoints::RequestStream>::from_channel(
2863                    _channel,
2864                ),
2865            ),
2866            _ => panic!("no such member protocol name for service UsbFunctionService"),
2867        }
2868    }
2869
2870    fn member_names() -> &'static [&'static str] {
2871        &["device"]
2872    }
2873}
2874#[cfg(target_os = "fuchsia")]
2875pub struct UsbFunctionServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2876
2877#[cfg(target_os = "fuchsia")]
2878impl fidl::endpoints::ServiceProxy for UsbFunctionServiceProxy {
2879    type Service = UsbFunctionServiceMarker;
2880
2881    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2882        Self(opener)
2883    }
2884}
2885
2886#[cfg(target_os = "fuchsia")]
2887impl UsbFunctionServiceProxy {
2888    pub fn connect_to_device(&self) -> Result<UsbFunctionProxy, fidl::Error> {
2889        let (proxy, server_end) = fidl::endpoints::create_proxy::<UsbFunctionMarker>();
2890        self.connect_channel_to_device(server_end)?;
2891        Ok(proxy)
2892    }
2893
2894    /// Like `connect_to_device`, but returns a sync proxy.
2895    /// See [`Self::connect_to_device`] for more details.
2896    pub fn connect_to_device_sync(&self) -> Result<UsbFunctionSynchronousProxy, fidl::Error> {
2897        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<UsbFunctionMarker>();
2898        self.connect_channel_to_device(server_end)?;
2899        Ok(proxy)
2900    }
2901
2902    /// Like `connect_to_device`, but accepts a server end.
2903    /// See [`Self::connect_to_device`] for more details.
2904    pub fn connect_channel_to_device(
2905        &self,
2906        server_end: fidl::endpoints::ServerEnd<UsbFunctionMarker>,
2907    ) -> Result<(), fidl::Error> {
2908        self.0.open_member("device", server_end.into_channel())
2909    }
2910
2911    pub fn instance_name(&self) -> &str {
2912        self.0.instance_name()
2913    }
2914}
2915
2916mod internal {
2917    use super::*;
2918
2919    impl fidl::encoding::ResourceTypeMarker for EndpointResource {
2920        type Borrowed<'a> = &'a mut Self;
2921        fn take_or_borrow<'a>(
2922            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2923        ) -> Self::Borrowed<'a> {
2924            value
2925        }
2926    }
2927
2928    unsafe impl fidl::encoding::TypeMarker for EndpointResource {
2929        type Owned = Self;
2930
2931        #[inline(always)]
2932        fn inline_align(_context: fidl::encoding::Context) -> usize {
2933            8
2934        }
2935
2936        #[inline(always)]
2937        fn inline_size(_context: fidl::encoding::Context) -> usize {
2938            32
2939        }
2940    }
2941
2942    unsafe impl
2943        fidl::encoding::Encode<EndpointResource, fidl::encoding::DefaultFuchsiaResourceDialect>
2944        for &mut EndpointResource
2945    {
2946        #[inline]
2947        unsafe fn encode(
2948            self,
2949            encoder: &mut fidl::encoding::Encoder<
2950                '_,
2951                fidl::encoding::DefaultFuchsiaResourceDialect,
2952            >,
2953            offset: usize,
2954            _depth: fidl::encoding::Depth,
2955        ) -> fidl::Result<()> {
2956            encoder.debug_check_bounds::<EndpointResource>(offset);
2957            // Delegate to tuple encoding.
2958            fidl::encoding::Encode::<EndpointResource, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2959                (
2960                    <fidl_fuchsia_hardware_usb_descriptor::EndpointDirection as fidl::encoding::ValueTypeMarker>::borrow(&self.direction),
2961                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
2962                    <fidl_fuchsia_hardware_usb_endpoint::EndpointInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.ep_info),
2963                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_packet_size),
2964                ),
2965                encoder, offset, _depth
2966            )
2967        }
2968    }
2969    unsafe impl<
2970        T0: fidl::encoding::Encode<
2971                fidl_fuchsia_hardware_usb_descriptor::EndpointDirection,
2972                fidl::encoding::DefaultFuchsiaResourceDialect,
2973            >,
2974        T1: fidl::encoding::Encode<
2975                fidl::encoding::Endpoint<
2976                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
2977                >,
2978                fidl::encoding::DefaultFuchsiaResourceDialect,
2979            >,
2980        T2: fidl::encoding::Encode<
2981                fidl_fuchsia_hardware_usb_endpoint::EndpointInfo,
2982                fidl::encoding::DefaultFuchsiaResourceDialect,
2983            >,
2984        T3: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2985    > fidl::encoding::Encode<EndpointResource, fidl::encoding::DefaultFuchsiaResourceDialect>
2986        for (T0, T1, T2, T3)
2987    {
2988        #[inline]
2989        unsafe fn encode(
2990            self,
2991            encoder: &mut fidl::encoding::Encoder<
2992                '_,
2993                fidl::encoding::DefaultFuchsiaResourceDialect,
2994            >,
2995            offset: usize,
2996            depth: fidl::encoding::Depth,
2997        ) -> fidl::Result<()> {
2998            encoder.debug_check_bounds::<EndpointResource>(offset);
2999            // Zero out padding regions. There's no need to apply masks
3000            // because the unmasked parts will be overwritten by fields.
3001            unsafe {
3002                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3003                (ptr as *mut u64).write_unaligned(0);
3004            }
3005            unsafe {
3006                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
3007                (ptr as *mut u64).write_unaligned(0);
3008            }
3009            // Write the fields.
3010            self.0.encode(encoder, offset + 0, depth)?;
3011            self.1.encode(encoder, offset + 4, depth)?;
3012            self.2.encode(encoder, offset + 8, depth)?;
3013            self.3.encode(encoder, offset + 24, depth)?;
3014            Ok(())
3015        }
3016    }
3017
3018    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3019        for EndpointResource
3020    {
3021        #[inline(always)]
3022        fn new_empty() -> Self {
3023            Self {
3024                direction: fidl::new_empty!(
3025                    fidl_fuchsia_hardware_usb_descriptor::EndpointDirection,
3026                    fidl::encoding::DefaultFuchsiaResourceDialect
3027                ),
3028                endpoint: fidl::new_empty!(
3029                    fidl::encoding::Endpoint<
3030                        fidl::endpoints::ServerEnd<
3031                            fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
3032                        >,
3033                    >,
3034                    fidl::encoding::DefaultFuchsiaResourceDialect
3035                ),
3036                ep_info: fidl::new_empty!(
3037                    fidl_fuchsia_hardware_usb_endpoint::EndpointInfo,
3038                    fidl::encoding::DefaultFuchsiaResourceDialect
3039                ),
3040                max_packet_size: fidl::new_empty!(
3041                    u32,
3042                    fidl::encoding::DefaultFuchsiaResourceDialect
3043                ),
3044            }
3045        }
3046
3047        #[inline]
3048        unsafe fn decode(
3049            &mut self,
3050            decoder: &mut fidl::encoding::Decoder<
3051                '_,
3052                fidl::encoding::DefaultFuchsiaResourceDialect,
3053            >,
3054            offset: usize,
3055            _depth: fidl::encoding::Depth,
3056        ) -> fidl::Result<()> {
3057            decoder.debug_check_bounds::<Self>(offset);
3058            // Verify that padding bytes are zero.
3059            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3060            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3061            let mask = 0xffffff00u64;
3062            let maskedval = padval & mask;
3063            if maskedval != 0 {
3064                return Err(fidl::Error::NonZeroPadding {
3065                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3066                });
3067            }
3068            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
3069            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3070            let mask = 0xffffffff00000000u64;
3071            let maskedval = padval & mask;
3072            if maskedval != 0 {
3073                return Err(fidl::Error::NonZeroPadding {
3074                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
3075                });
3076            }
3077            fidl::decode!(
3078                fidl_fuchsia_hardware_usb_descriptor::EndpointDirection,
3079                fidl::encoding::DefaultFuchsiaResourceDialect,
3080                &mut self.direction,
3081                decoder,
3082                offset + 0,
3083                _depth
3084            )?;
3085            fidl::decode!(
3086                fidl::encoding::Endpoint<
3087                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
3088                >,
3089                fidl::encoding::DefaultFuchsiaResourceDialect,
3090                &mut self.endpoint,
3091                decoder,
3092                offset + 4,
3093                _depth
3094            )?;
3095            fidl::decode!(
3096                fidl_fuchsia_hardware_usb_endpoint::EndpointInfo,
3097                fidl::encoding::DefaultFuchsiaResourceDialect,
3098                &mut self.ep_info,
3099                decoder,
3100                offset + 8,
3101                _depth
3102            )?;
3103            fidl::decode!(
3104                u32,
3105                fidl::encoding::DefaultFuchsiaResourceDialect,
3106                &mut self.max_packet_size,
3107                decoder,
3108                offset + 24,
3109                _depth
3110            )?;
3111            Ok(())
3112        }
3113    }
3114
3115    impl fidl::encoding::ResourceTypeMarker for UsbFunctionAllocResourcesRequest {
3116        type Borrowed<'a> = &'a mut Self;
3117        fn take_or_borrow<'a>(
3118            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3119        ) -> Self::Borrowed<'a> {
3120            value
3121        }
3122    }
3123
3124    unsafe impl fidl::encoding::TypeMarker for UsbFunctionAllocResourcesRequest {
3125        type Owned = Self;
3126
3127        #[inline(always)]
3128        fn inline_align(_context: fidl::encoding::Context) -> usize {
3129            8
3130        }
3131
3132        #[inline(always)]
3133        fn inline_size(_context: fidl::encoding::Context) -> usize {
3134            40
3135        }
3136    }
3137
3138    unsafe impl
3139        fidl::encoding::Encode<
3140            UsbFunctionAllocResourcesRequest,
3141            fidl::encoding::DefaultFuchsiaResourceDialect,
3142        > for &mut UsbFunctionAllocResourcesRequest
3143    {
3144        #[inline]
3145        unsafe fn encode(
3146            self,
3147            encoder: &mut fidl::encoding::Encoder<
3148                '_,
3149                fidl::encoding::DefaultFuchsiaResourceDialect,
3150            >,
3151            offset: usize,
3152            _depth: fidl::encoding::Depth,
3153        ) -> fidl::Result<()> {
3154            encoder.debug_check_bounds::<UsbFunctionAllocResourcesRequest>(offset);
3155            // Delegate to tuple encoding.
3156            fidl::encoding::Encode::<UsbFunctionAllocResourcesRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3157                (
3158                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_count),
3159                    <fidl::encoding::Vector<EndpointResource, 255> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoints),
3160                    <fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255> as fidl::encoding::ValueTypeMarker>::borrow(&self.strings),
3161                ),
3162                encoder, offset, _depth
3163            )
3164        }
3165    }
3166    unsafe impl<
3167        T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
3168        T1: fidl::encoding::Encode<
3169                fidl::encoding::Vector<EndpointResource, 255>,
3170                fidl::encoding::DefaultFuchsiaResourceDialect,
3171            >,
3172        T2: fidl::encoding::Encode<
3173                fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255>,
3174                fidl::encoding::DefaultFuchsiaResourceDialect,
3175            >,
3176    >
3177        fidl::encoding::Encode<
3178            UsbFunctionAllocResourcesRequest,
3179            fidl::encoding::DefaultFuchsiaResourceDialect,
3180        > for (T0, T1, T2)
3181    {
3182        #[inline]
3183        unsafe fn encode(
3184            self,
3185            encoder: &mut fidl::encoding::Encoder<
3186                '_,
3187                fidl::encoding::DefaultFuchsiaResourceDialect,
3188            >,
3189            offset: usize,
3190            depth: fidl::encoding::Depth,
3191        ) -> fidl::Result<()> {
3192            encoder.debug_check_bounds::<UsbFunctionAllocResourcesRequest>(offset);
3193            // Zero out padding regions. There's no need to apply masks
3194            // because the unmasked parts will be overwritten by fields.
3195            unsafe {
3196                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3197                (ptr as *mut u64).write_unaligned(0);
3198            }
3199            // Write the fields.
3200            self.0.encode(encoder, offset + 0, depth)?;
3201            self.1.encode(encoder, offset + 8, depth)?;
3202            self.2.encode(encoder, offset + 24, depth)?;
3203            Ok(())
3204        }
3205    }
3206
3207    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3208        for UsbFunctionAllocResourcesRequest
3209    {
3210        #[inline(always)]
3211        fn new_empty() -> Self {
3212            Self {
3213                interface_count: fidl::new_empty!(
3214                    u8,
3215                    fidl::encoding::DefaultFuchsiaResourceDialect
3216                ),
3217                endpoints: fidl::new_empty!(fidl::encoding::Vector<EndpointResource, 255>, fidl::encoding::DefaultFuchsiaResourceDialect),
3218                strings: fidl::new_empty!(
3219                    fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255>,
3220                    fidl::encoding::DefaultFuchsiaResourceDialect
3221                ),
3222            }
3223        }
3224
3225        #[inline]
3226        unsafe fn decode(
3227            &mut self,
3228            decoder: &mut fidl::encoding::Decoder<
3229                '_,
3230                fidl::encoding::DefaultFuchsiaResourceDialect,
3231            >,
3232            offset: usize,
3233            _depth: fidl::encoding::Depth,
3234        ) -> fidl::Result<()> {
3235            decoder.debug_check_bounds::<Self>(offset);
3236            // Verify that padding bytes are zero.
3237            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3238            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3239            let mask = 0xffffffffffffff00u64;
3240            let maskedval = padval & mask;
3241            if maskedval != 0 {
3242                return Err(fidl::Error::NonZeroPadding {
3243                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3244                });
3245            }
3246            fidl::decode!(
3247                u8,
3248                fidl::encoding::DefaultFuchsiaResourceDialect,
3249                &mut self.interface_count,
3250                decoder,
3251                offset + 0,
3252                _depth
3253            )?;
3254            fidl::decode!(fidl::encoding::Vector<EndpointResource, 255>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.endpoints, decoder, offset + 8, _depth)?;
3255            fidl::decode!(
3256                fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255>,
3257                fidl::encoding::DefaultFuchsiaResourceDialect,
3258                &mut self.strings,
3259                decoder,
3260                offset + 24,
3261                _depth
3262            )?;
3263            Ok(())
3264        }
3265    }
3266
3267    impl fidl::encoding::ResourceTypeMarker for UsbFunctionConfigureRequest {
3268        type Borrowed<'a> = &'a mut Self;
3269        fn take_or_borrow<'a>(
3270            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3271        ) -> Self::Borrowed<'a> {
3272            value
3273        }
3274    }
3275
3276    unsafe impl fidl::encoding::TypeMarker for UsbFunctionConfigureRequest {
3277        type Owned = Self;
3278
3279        #[inline(always)]
3280        fn inline_align(_context: fidl::encoding::Context) -> usize {
3281            8
3282        }
3283
3284        #[inline(always)]
3285        fn inline_size(_context: fidl::encoding::Context) -> usize {
3286            24
3287        }
3288    }
3289
3290    unsafe impl
3291        fidl::encoding::Encode<
3292            UsbFunctionConfigureRequest,
3293            fidl::encoding::DefaultFuchsiaResourceDialect,
3294        > for &mut UsbFunctionConfigureRequest
3295    {
3296        #[inline]
3297        unsafe fn encode(
3298            self,
3299            encoder: &mut fidl::encoding::Encoder<
3300                '_,
3301                fidl::encoding::DefaultFuchsiaResourceDialect,
3302            >,
3303            offset: usize,
3304            _depth: fidl::encoding::Depth,
3305        ) -> fidl::Result<()> {
3306            encoder.debug_check_bounds::<UsbFunctionConfigureRequest>(offset);
3307            // Delegate to tuple encoding.
3308            fidl::encoding::Encode::<UsbFunctionConfigureRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3309                (
3310                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
3311                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iface),
3312                ),
3313                encoder, offset, _depth
3314            )
3315        }
3316    }
3317    unsafe impl<
3318        T0: fidl::encoding::Encode<
3319                fidl::encoding::UnboundedVector<u8>,
3320                fidl::encoding::DefaultFuchsiaResourceDialect,
3321            >,
3322        T1: fidl::encoding::Encode<
3323                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>>,
3324                fidl::encoding::DefaultFuchsiaResourceDialect,
3325            >,
3326    >
3327        fidl::encoding::Encode<
3328            UsbFunctionConfigureRequest,
3329            fidl::encoding::DefaultFuchsiaResourceDialect,
3330        > for (T0, T1)
3331    {
3332        #[inline]
3333        unsafe fn encode(
3334            self,
3335            encoder: &mut fidl::encoding::Encoder<
3336                '_,
3337                fidl::encoding::DefaultFuchsiaResourceDialect,
3338            >,
3339            offset: usize,
3340            depth: fidl::encoding::Depth,
3341        ) -> fidl::Result<()> {
3342            encoder.debug_check_bounds::<UsbFunctionConfigureRequest>(offset);
3343            // Zero out padding regions. There's no need to apply masks
3344            // because the unmasked parts will be overwritten by fields.
3345            unsafe {
3346                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3347                (ptr as *mut u64).write_unaligned(0);
3348            }
3349            // Write the fields.
3350            self.0.encode(encoder, offset + 0, depth)?;
3351            self.1.encode(encoder, offset + 16, depth)?;
3352            Ok(())
3353        }
3354    }
3355
3356    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3357        for UsbFunctionConfigureRequest
3358    {
3359        #[inline(always)]
3360        fn new_empty() -> Self {
3361            Self {
3362                configuration: fidl::new_empty!(
3363                    fidl::encoding::UnboundedVector<u8>,
3364                    fidl::encoding::DefaultFuchsiaResourceDialect
3365                ),
3366                iface: fidl::new_empty!(
3367                    fidl::encoding::Endpoint<
3368                        fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
3369                    >,
3370                    fidl::encoding::DefaultFuchsiaResourceDialect
3371                ),
3372            }
3373        }
3374
3375        #[inline]
3376        unsafe fn decode(
3377            &mut self,
3378            decoder: &mut fidl::encoding::Decoder<
3379                '_,
3380                fidl::encoding::DefaultFuchsiaResourceDialect,
3381            >,
3382            offset: usize,
3383            _depth: fidl::encoding::Depth,
3384        ) -> fidl::Result<()> {
3385            decoder.debug_check_bounds::<Self>(offset);
3386            // Verify that padding bytes are zero.
3387            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3388            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3389            let mask = 0xffffffff00000000u64;
3390            let maskedval = padval & mask;
3391            if maskedval != 0 {
3392                return Err(fidl::Error::NonZeroPadding {
3393                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3394                });
3395            }
3396            fidl::decode!(
3397                fidl::encoding::UnboundedVector<u8>,
3398                fidl::encoding::DefaultFuchsiaResourceDialect,
3399                &mut self.configuration,
3400                decoder,
3401                offset + 0,
3402                _depth
3403            )?;
3404            fidl::decode!(
3405                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>>,
3406                fidl::encoding::DefaultFuchsiaResourceDialect,
3407                &mut self.iface,
3408                decoder,
3409                offset + 16,
3410                _depth
3411            )?;
3412            Ok(())
3413        }
3414    }
3415
3416    impl fidl::encoding::ResourceTypeMarker for UsbFunctionConnectToEndpointRequest {
3417        type Borrowed<'a> = &'a mut Self;
3418        fn take_or_borrow<'a>(
3419            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3420        ) -> Self::Borrowed<'a> {
3421            value
3422        }
3423    }
3424
3425    unsafe impl fidl::encoding::TypeMarker for UsbFunctionConnectToEndpointRequest {
3426        type Owned = Self;
3427
3428        #[inline(always)]
3429        fn inline_align(_context: fidl::encoding::Context) -> usize {
3430            4
3431        }
3432
3433        #[inline(always)]
3434        fn inline_size(_context: fidl::encoding::Context) -> usize {
3435            8
3436        }
3437    }
3438
3439    unsafe impl
3440        fidl::encoding::Encode<
3441            UsbFunctionConnectToEndpointRequest,
3442            fidl::encoding::DefaultFuchsiaResourceDialect,
3443        > for &mut UsbFunctionConnectToEndpointRequest
3444    {
3445        #[inline]
3446        unsafe fn encode(
3447            self,
3448            encoder: &mut fidl::encoding::Encoder<
3449                '_,
3450                fidl::encoding::DefaultFuchsiaResourceDialect,
3451            >,
3452            offset: usize,
3453            _depth: fidl::encoding::Depth,
3454        ) -> fidl::Result<()> {
3455            encoder.debug_check_bounds::<UsbFunctionConnectToEndpointRequest>(offset);
3456            // Delegate to tuple encoding.
3457            fidl::encoding::Encode::<
3458                UsbFunctionConnectToEndpointRequest,
3459                fidl::encoding::DefaultFuchsiaResourceDialect,
3460            >::encode(
3461                (
3462                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.ep_addr),
3463                    <fidl::encoding::Endpoint<
3464                        fidl::endpoints::ServerEnd<
3465                            fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
3466                        >,
3467                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3468                        &mut self.ep
3469                    ),
3470                ),
3471                encoder,
3472                offset,
3473                _depth,
3474            )
3475        }
3476    }
3477    unsafe impl<
3478        T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
3479        T1: fidl::encoding::Encode<
3480                fidl::encoding::Endpoint<
3481                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
3482                >,
3483                fidl::encoding::DefaultFuchsiaResourceDialect,
3484            >,
3485    >
3486        fidl::encoding::Encode<
3487            UsbFunctionConnectToEndpointRequest,
3488            fidl::encoding::DefaultFuchsiaResourceDialect,
3489        > for (T0, T1)
3490    {
3491        #[inline]
3492        unsafe fn encode(
3493            self,
3494            encoder: &mut fidl::encoding::Encoder<
3495                '_,
3496                fidl::encoding::DefaultFuchsiaResourceDialect,
3497            >,
3498            offset: usize,
3499            depth: fidl::encoding::Depth,
3500        ) -> fidl::Result<()> {
3501            encoder.debug_check_bounds::<UsbFunctionConnectToEndpointRequest>(offset);
3502            // Zero out padding regions. There's no need to apply masks
3503            // because the unmasked parts will be overwritten by fields.
3504            unsafe {
3505                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3506                (ptr as *mut u32).write_unaligned(0);
3507            }
3508            // Write the fields.
3509            self.0.encode(encoder, offset + 0, depth)?;
3510            self.1.encode(encoder, offset + 4, depth)?;
3511            Ok(())
3512        }
3513    }
3514
3515    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3516        for UsbFunctionConnectToEndpointRequest
3517    {
3518        #[inline(always)]
3519        fn new_empty() -> Self {
3520            Self {
3521                ep_addr: fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect),
3522                ep: fidl::new_empty!(
3523                    fidl::encoding::Endpoint<
3524                        fidl::endpoints::ServerEnd<
3525                            fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
3526                        >,
3527                    >,
3528                    fidl::encoding::DefaultFuchsiaResourceDialect
3529                ),
3530            }
3531        }
3532
3533        #[inline]
3534        unsafe fn decode(
3535            &mut self,
3536            decoder: &mut fidl::encoding::Decoder<
3537                '_,
3538                fidl::encoding::DefaultFuchsiaResourceDialect,
3539            >,
3540            offset: usize,
3541            _depth: fidl::encoding::Depth,
3542        ) -> fidl::Result<()> {
3543            decoder.debug_check_bounds::<Self>(offset);
3544            // Verify that padding bytes are zero.
3545            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3546            let padval = unsafe { (ptr as *const u32).read_unaligned() };
3547            let mask = 0xffffff00u32;
3548            let maskedval = padval & mask;
3549            if maskedval != 0 {
3550                return Err(fidl::Error::NonZeroPadding {
3551                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3552                });
3553            }
3554            fidl::decode!(
3555                u8,
3556                fidl::encoding::DefaultFuchsiaResourceDialect,
3557                &mut self.ep_addr,
3558                decoder,
3559                offset + 0,
3560                _depth
3561            )?;
3562            fidl::decode!(
3563                fidl::encoding::Endpoint<
3564                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
3565                >,
3566                fidl::encoding::DefaultFuchsiaResourceDialect,
3567                &mut self.ep,
3568                decoder,
3569                offset + 4,
3570                _depth
3571            )?;
3572            Ok(())
3573        }
3574    }
3575}