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 UsbFunctionControlHandle {
1356    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
1357        self.inner.shutdown_with_epitaph(status.into())
1358    }
1359}
1360
1361impl fidl::endpoints::ControlHandle for UsbFunctionControlHandle {
1362    fn shutdown(&self) {
1363        self.inner.shutdown()
1364    }
1365
1366    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
1367        self.inner.shutdown_with_epitaph(status)
1368    }
1369
1370    fn is_closed(&self) -> bool {
1371        self.inner.channel().is_closed()
1372    }
1373    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1374        self.inner.channel().on_closed()
1375    }
1376
1377    #[cfg(target_os = "fuchsia")]
1378    fn signal_peer(
1379        &self,
1380        clear_mask: zx::Signals,
1381        set_mask: zx::Signals,
1382    ) -> Result<(), zx_status::Status> {
1383        use fidl::Peered;
1384        self.inner.channel().signal_peer(clear_mask, set_mask)
1385    }
1386}
1387
1388impl UsbFunctionControlHandle {}
1389
1390#[must_use = "FIDL methods require a response to be sent"]
1391#[derive(Debug)]
1392pub struct UsbFunctionConnectToEndpointResponder {
1393    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1394    tx_id: u32,
1395}
1396
1397/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1398/// if the responder is dropped without sending a response, so that the client
1399/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1400impl std::ops::Drop for UsbFunctionConnectToEndpointResponder {
1401    fn drop(&mut self) {
1402        self.control_handle.shutdown();
1403        // Safety: drops once, never accessed again
1404        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1405    }
1406}
1407
1408impl fidl::endpoints::Responder for UsbFunctionConnectToEndpointResponder {
1409    type ControlHandle = UsbFunctionControlHandle;
1410
1411    fn control_handle(&self) -> &UsbFunctionControlHandle {
1412        &self.control_handle
1413    }
1414
1415    fn drop_without_shutdown(mut self) {
1416        // Safety: drops once, never accessed again due to mem::forget
1417        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1418        // Prevent Drop from running (which would shut down the channel)
1419        std::mem::forget(self);
1420    }
1421}
1422
1423impl UsbFunctionConnectToEndpointResponder {
1424    /// Sends a response to the FIDL transaction.
1425    ///
1426    /// Sets the channel to shutdown if an error occurs.
1427    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1428        let _result = self.send_raw(result);
1429        if _result.is_err() {
1430            self.control_handle.shutdown();
1431        }
1432        self.drop_without_shutdown();
1433        _result
1434    }
1435
1436    /// Similar to "send" but does not shutdown the channel if an error occurs.
1437    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1438        let _result = self.send_raw(result);
1439        self.drop_without_shutdown();
1440        _result
1441    }
1442
1443    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1444        self.control_handle
1445            .inner
1446            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1447                result,
1448                self.tx_id,
1449                0x11541c67eb1b7f8,
1450                fidl::encoding::DynamicFlags::empty(),
1451            )
1452    }
1453}
1454
1455#[must_use = "FIDL methods require a response to be sent"]
1456#[derive(Debug)]
1457pub struct UsbFunctionConfigureResponder {
1458    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1459    tx_id: u32,
1460}
1461
1462/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1463/// if the responder is dropped without sending a response, so that the client
1464/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1465impl std::ops::Drop for UsbFunctionConfigureResponder {
1466    fn drop(&mut self) {
1467        self.control_handle.shutdown();
1468        // Safety: drops once, never accessed again
1469        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1470    }
1471}
1472
1473impl fidl::endpoints::Responder for UsbFunctionConfigureResponder {
1474    type ControlHandle = UsbFunctionControlHandle;
1475
1476    fn control_handle(&self) -> &UsbFunctionControlHandle {
1477        &self.control_handle
1478    }
1479
1480    fn drop_without_shutdown(mut self) {
1481        // Safety: drops once, never accessed again due to mem::forget
1482        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1483        // Prevent Drop from running (which would shut down the channel)
1484        std::mem::forget(self);
1485    }
1486}
1487
1488impl UsbFunctionConfigureResponder {
1489    /// Sends a response to the FIDL transaction.
1490    ///
1491    /// Sets the channel to shutdown if an error occurs.
1492    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1493        let _result = self.send_raw(result);
1494        if _result.is_err() {
1495            self.control_handle.shutdown();
1496        }
1497        self.drop_without_shutdown();
1498        _result
1499    }
1500
1501    /// Similar to "send" but does not shutdown the channel if an error occurs.
1502    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1503        let _result = self.send_raw(result);
1504        self.drop_without_shutdown();
1505        _result
1506    }
1507
1508    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1509        self.control_handle
1510            .inner
1511            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1512                result,
1513                self.tx_id,
1514                0x42a444f4abf08b89,
1515                fidl::encoding::DynamicFlags::empty(),
1516            )
1517    }
1518}
1519
1520#[must_use = "FIDL methods require a response to be sent"]
1521#[derive(Debug)]
1522pub struct UsbFunctionDeconfigureResponder {
1523    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1524    tx_id: u32,
1525}
1526
1527/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1528/// if the responder is dropped without sending a response, so that the client
1529/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1530impl std::ops::Drop for UsbFunctionDeconfigureResponder {
1531    fn drop(&mut self) {
1532        self.control_handle.shutdown();
1533        // Safety: drops once, never accessed again
1534        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1535    }
1536}
1537
1538impl fidl::endpoints::Responder for UsbFunctionDeconfigureResponder {
1539    type ControlHandle = UsbFunctionControlHandle;
1540
1541    fn control_handle(&self) -> &UsbFunctionControlHandle {
1542        &self.control_handle
1543    }
1544
1545    fn drop_without_shutdown(mut self) {
1546        // Safety: drops once, never accessed again due to mem::forget
1547        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1548        // Prevent Drop from running (which would shut down the channel)
1549        std::mem::forget(self);
1550    }
1551}
1552
1553impl UsbFunctionDeconfigureResponder {
1554    /// Sends a response to the FIDL transaction.
1555    ///
1556    /// Sets the channel to shutdown if an error occurs.
1557    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1558        let _result = self.send_raw(result);
1559        if _result.is_err() {
1560            self.control_handle.shutdown();
1561        }
1562        self.drop_without_shutdown();
1563        _result
1564    }
1565
1566    /// Similar to "send" but does not shutdown the channel if an error occurs.
1567    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1568        let _result = self.send_raw(result);
1569        self.drop_without_shutdown();
1570        _result
1571    }
1572
1573    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1574        self.control_handle
1575            .inner
1576            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1577                result,
1578                self.tx_id,
1579                0x26ee8c8c826367b2,
1580                fidl::encoding::DynamicFlags::empty(),
1581            )
1582    }
1583}
1584
1585#[must_use = "FIDL methods require a response to be sent"]
1586#[derive(Debug)]
1587pub struct UsbFunctionAllocResourcesResponder {
1588    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1589    tx_id: u32,
1590}
1591
1592/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1593/// if the responder is dropped without sending a response, so that the client
1594/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1595impl std::ops::Drop for UsbFunctionAllocResourcesResponder {
1596    fn drop(&mut self) {
1597        self.control_handle.shutdown();
1598        // Safety: drops once, never accessed again
1599        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1600    }
1601}
1602
1603impl fidl::endpoints::Responder for UsbFunctionAllocResourcesResponder {
1604    type ControlHandle = UsbFunctionControlHandle;
1605
1606    fn control_handle(&self) -> &UsbFunctionControlHandle {
1607        &self.control_handle
1608    }
1609
1610    fn drop_without_shutdown(mut self) {
1611        // Safety: drops once, never accessed again due to mem::forget
1612        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1613        // Prevent Drop from running (which would shut down the channel)
1614        std::mem::forget(self);
1615    }
1616}
1617
1618impl UsbFunctionAllocResourcesResponder {
1619    /// Sends a response to the FIDL transaction.
1620    ///
1621    /// Sets the channel to shutdown if an error occurs.
1622    pub fn send(self, mut result: Result<(&[u8], &[u8], &[u8]), i32>) -> Result<(), fidl::Error> {
1623        let _result = self.send_raw(result);
1624        if _result.is_err() {
1625            self.control_handle.shutdown();
1626        }
1627        self.drop_without_shutdown();
1628        _result
1629    }
1630
1631    /// Similar to "send" but does not shutdown the channel if an error occurs.
1632    pub fn send_no_shutdown_on_err(
1633        self,
1634        mut result: Result<(&[u8], &[u8], &[u8]), i32>,
1635    ) -> Result<(), fidl::Error> {
1636        let _result = self.send_raw(result);
1637        self.drop_without_shutdown();
1638        _result
1639    }
1640
1641    fn send_raw(&self, mut result: Result<(&[u8], &[u8], &[u8]), i32>) -> Result<(), fidl::Error> {
1642        self.control_handle
1643            .inner
1644            .send::<fidl::encoding::ResultType<UsbFunctionAllocResourcesResponse, i32>>(
1645                result,
1646                self.tx_id,
1647                0x5ab7133ab195daa0,
1648                fidl::encoding::DynamicFlags::empty(),
1649            )
1650    }
1651}
1652
1653#[must_use = "FIDL methods require a response to be sent"]
1654#[derive(Debug)]
1655pub struct UsbFunctionEndpointSetStallResponder {
1656    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1657    tx_id: u32,
1658}
1659
1660/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1661/// if the responder is dropped without sending a response, so that the client
1662/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1663impl std::ops::Drop for UsbFunctionEndpointSetStallResponder {
1664    fn drop(&mut self) {
1665        self.control_handle.shutdown();
1666        // Safety: drops once, never accessed again
1667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1668    }
1669}
1670
1671impl fidl::endpoints::Responder for UsbFunctionEndpointSetStallResponder {
1672    type ControlHandle = UsbFunctionControlHandle;
1673
1674    fn control_handle(&self) -> &UsbFunctionControlHandle {
1675        &self.control_handle
1676    }
1677
1678    fn drop_without_shutdown(mut self) {
1679        // Safety: drops once, never accessed again due to mem::forget
1680        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1681        // Prevent Drop from running (which would shut down the channel)
1682        std::mem::forget(self);
1683    }
1684}
1685
1686impl UsbFunctionEndpointSetStallResponder {
1687    /// Sends a response to the FIDL transaction.
1688    ///
1689    /// Sets the channel to shutdown if an error occurs.
1690    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1691        let _result = self.send_raw(result);
1692        if _result.is_err() {
1693            self.control_handle.shutdown();
1694        }
1695        self.drop_without_shutdown();
1696        _result
1697    }
1698
1699    /// Similar to "send" but does not shutdown the channel if an error occurs.
1700    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1701        let _result = self.send_raw(result);
1702        self.drop_without_shutdown();
1703        _result
1704    }
1705
1706    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1707        self.control_handle
1708            .inner
1709            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1710                result,
1711                self.tx_id,
1712                0x1f32c374dac955f1,
1713                fidl::encoding::DynamicFlags::empty(),
1714            )
1715    }
1716}
1717
1718#[must_use = "FIDL methods require a response to be sent"]
1719#[derive(Debug)]
1720pub struct UsbFunctionEndpointClearStallResponder {
1721    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1722    tx_id: u32,
1723}
1724
1725/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1726/// if the responder is dropped without sending a response, so that the client
1727/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1728impl std::ops::Drop for UsbFunctionEndpointClearStallResponder {
1729    fn drop(&mut self) {
1730        self.control_handle.shutdown();
1731        // Safety: drops once, never accessed again
1732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1733    }
1734}
1735
1736impl fidl::endpoints::Responder for UsbFunctionEndpointClearStallResponder {
1737    type ControlHandle = UsbFunctionControlHandle;
1738
1739    fn control_handle(&self) -> &UsbFunctionControlHandle {
1740        &self.control_handle
1741    }
1742
1743    fn drop_without_shutdown(mut self) {
1744        // Safety: drops once, never accessed again due to mem::forget
1745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1746        // Prevent Drop from running (which would shut down the channel)
1747        std::mem::forget(self);
1748    }
1749}
1750
1751impl UsbFunctionEndpointClearStallResponder {
1752    /// Sends a response to the FIDL transaction.
1753    ///
1754    /// Sets the channel to shutdown if an error occurs.
1755    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1756        let _result = self.send_raw(result);
1757        if _result.is_err() {
1758            self.control_handle.shutdown();
1759        }
1760        self.drop_without_shutdown();
1761        _result
1762    }
1763
1764    /// Similar to "send" but does not shutdown the channel if an error occurs.
1765    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1766        let _result = self.send_raw(result);
1767        self.drop_without_shutdown();
1768        _result
1769    }
1770
1771    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1772        self.control_handle
1773            .inner
1774            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1775                result,
1776                self.tx_id,
1777                0x221d9488ac58aaba,
1778                fidl::encoding::DynamicFlags::empty(),
1779            )
1780    }
1781}
1782
1783#[must_use = "FIDL methods require a response to be sent"]
1784#[derive(Debug)]
1785pub struct UsbFunctionConfigureEndpointResponder {
1786    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1787    tx_id: u32,
1788}
1789
1790/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1791/// if the responder is dropped without sending a response, so that the client
1792/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1793impl std::ops::Drop for UsbFunctionConfigureEndpointResponder {
1794    fn drop(&mut self) {
1795        self.control_handle.shutdown();
1796        // Safety: drops once, never accessed again
1797        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1798    }
1799}
1800
1801impl fidl::endpoints::Responder for UsbFunctionConfigureEndpointResponder {
1802    type ControlHandle = UsbFunctionControlHandle;
1803
1804    fn control_handle(&self) -> &UsbFunctionControlHandle {
1805        &self.control_handle
1806    }
1807
1808    fn drop_without_shutdown(mut self) {
1809        // Safety: drops once, never accessed again due to mem::forget
1810        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1811        // Prevent Drop from running (which would shut down the channel)
1812        std::mem::forget(self);
1813    }
1814}
1815
1816impl UsbFunctionConfigureEndpointResponder {
1817    /// Sends a response to the FIDL transaction.
1818    ///
1819    /// Sets the channel to shutdown if an error occurs.
1820    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1821        let _result = self.send_raw(result);
1822        if _result.is_err() {
1823            self.control_handle.shutdown();
1824        }
1825        self.drop_without_shutdown();
1826        _result
1827    }
1828
1829    /// Similar to "send" but does not shutdown the channel if an error occurs.
1830    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1831        let _result = self.send_raw(result);
1832        self.drop_without_shutdown();
1833        _result
1834    }
1835
1836    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1837        self.control_handle
1838            .inner
1839            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1840                result,
1841                self.tx_id,
1842                0x314c9dc3c37ebb7c,
1843                fidl::encoding::DynamicFlags::empty(),
1844            )
1845    }
1846}
1847
1848#[must_use = "FIDL methods require a response to be sent"]
1849#[derive(Debug)]
1850pub struct UsbFunctionDisableEndpointResponder {
1851    control_handle: std::mem::ManuallyDrop<UsbFunctionControlHandle>,
1852    tx_id: u32,
1853}
1854
1855/// Set the the channel to be shutdown (see [`UsbFunctionControlHandle::shutdown`])
1856/// if the responder is dropped without sending a response, so that the client
1857/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1858impl std::ops::Drop for UsbFunctionDisableEndpointResponder {
1859    fn drop(&mut self) {
1860        self.control_handle.shutdown();
1861        // Safety: drops once, never accessed again
1862        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1863    }
1864}
1865
1866impl fidl::endpoints::Responder for UsbFunctionDisableEndpointResponder {
1867    type ControlHandle = UsbFunctionControlHandle;
1868
1869    fn control_handle(&self) -> &UsbFunctionControlHandle {
1870        &self.control_handle
1871    }
1872
1873    fn drop_without_shutdown(mut self) {
1874        // Safety: drops once, never accessed again due to mem::forget
1875        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1876        // Prevent Drop from running (which would shut down the channel)
1877        std::mem::forget(self);
1878    }
1879}
1880
1881impl UsbFunctionDisableEndpointResponder {
1882    /// Sends a response to the FIDL transaction.
1883    ///
1884    /// Sets the channel to shutdown if an error occurs.
1885    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1886        let _result = self.send_raw(result);
1887        if _result.is_err() {
1888            self.control_handle.shutdown();
1889        }
1890        self.drop_without_shutdown();
1891        _result
1892    }
1893
1894    /// Similar to "send" but does not shutdown the channel if an error occurs.
1895    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1896        let _result = self.send_raw(result);
1897        self.drop_without_shutdown();
1898        _result
1899    }
1900
1901    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1902        self.control_handle
1903            .inner
1904            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1905                result,
1906                self.tx_id,
1907                0x112a132561499b6e,
1908                fidl::encoding::DynamicFlags::empty(),
1909            )
1910    }
1911}
1912
1913#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1914pub struct UsbFunctionInterfaceMarker;
1915
1916impl fidl::endpoints::ProtocolMarker for UsbFunctionInterfaceMarker {
1917    type Proxy = UsbFunctionInterfaceProxy;
1918    type RequestStream = UsbFunctionInterfaceRequestStream;
1919    #[cfg(target_os = "fuchsia")]
1920    type SynchronousProxy = UsbFunctionInterfaceSynchronousProxy;
1921
1922    const DEBUG_NAME: &'static str = "(anonymous) UsbFunctionInterface";
1923}
1924pub type UsbFunctionInterfaceControlResult = Result<Vec<u8>, i32>;
1925pub type UsbFunctionInterfaceSetConfiguredResult = Result<(), i32>;
1926pub type UsbFunctionInterfaceSetInterfaceResult = Result<(), i32>;
1927
1928pub trait UsbFunctionInterfaceProxyInterface: Send + Sync {
1929    type ControlResponseFut: std::future::Future<Output = Result<UsbFunctionInterfaceControlResult, fidl::Error>>
1930        + Send;
1931    fn r#control(
1932        &self,
1933        setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
1934        write: &[u8],
1935    ) -> Self::ControlResponseFut;
1936    type SetConfiguredResponseFut: std::future::Future<Output = Result<UsbFunctionInterfaceSetConfiguredResult, fidl::Error>>
1937        + Send;
1938    fn r#set_configured(
1939        &self,
1940        configured: bool,
1941        speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
1942    ) -> Self::SetConfiguredResponseFut;
1943    type SetInterfaceResponseFut: std::future::Future<Output = Result<UsbFunctionInterfaceSetInterfaceResult, fidl::Error>>
1944        + Send;
1945    fn r#set_interface(&self, interface: u8, alt_setting: u8) -> Self::SetInterfaceResponseFut;
1946}
1947#[derive(Debug)]
1948#[cfg(target_os = "fuchsia")]
1949pub struct UsbFunctionInterfaceSynchronousProxy {
1950    client: fidl::client::sync::Client,
1951}
1952
1953#[cfg(target_os = "fuchsia")]
1954impl fidl::endpoints::SynchronousProxy for UsbFunctionInterfaceSynchronousProxy {
1955    type Proxy = UsbFunctionInterfaceProxy;
1956    type Protocol = UsbFunctionInterfaceMarker;
1957
1958    fn from_channel(inner: fidl::Channel) -> Self {
1959        Self::new(inner)
1960    }
1961
1962    fn into_channel(self) -> fidl::Channel {
1963        self.client.into_channel()
1964    }
1965
1966    fn as_channel(&self) -> &fidl::Channel {
1967        self.client.as_channel()
1968    }
1969}
1970
1971#[cfg(target_os = "fuchsia")]
1972impl UsbFunctionInterfaceSynchronousProxy {
1973    pub fn new(channel: fidl::Channel) -> Self {
1974        Self { client: fidl::client::sync::Client::new(channel) }
1975    }
1976
1977    pub fn into_channel(self) -> fidl::Channel {
1978        self.client.into_channel()
1979    }
1980
1981    /// Waits until an event arrives and returns it. It is safe for other
1982    /// threads to make concurrent requests while waiting for an event.
1983    pub fn wait_for_event(
1984        &self,
1985        deadline: zx::MonotonicInstant,
1986    ) -> Result<UsbFunctionInterfaceEvent, fidl::Error> {
1987        UsbFunctionInterfaceEvent::decode(
1988            self.client.wait_for_event::<UsbFunctionInterfaceMarker>(deadline)?,
1989        )
1990    }
1991
1992    /// Callback for handling ep0 control requests.
1993    ///
1994    /// `setup` is the control request to handle.
1995    /// `write` is the data to write to the endpoint.
1996    /// `read` is the data to read from the endpoint.
1997    pub fn r#control(
1998        &self,
1999        mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2000        mut write: &[u8],
2001        ___deadline: zx::MonotonicInstant,
2002    ) -> Result<UsbFunctionInterfaceControlResult, fidl::Error> {
2003        let _response = self.client.send_query::<
2004            UsbFunctionInterfaceControlRequest,
2005            fidl::encoding::FlexibleResultType<UsbFunctionInterfaceControlResponse, i32>,
2006            UsbFunctionInterfaceMarker,
2007        >(
2008            (setup, write,),
2009            0x3cce27231c012cff,
2010            fidl::encoding::DynamicFlags::FLEXIBLE,
2011            ___deadline,
2012        )?
2013        .into_result::<UsbFunctionInterfaceMarker>("control")?;
2014        Ok(_response.map(|x| x.read))
2015    }
2016
2017    /// Inform the function driver when the USB device configured state changes.
2018    ///
2019    /// Called with `configured == true` in response to a `SET_CONFIGURATION`
2020    /// control request that selects a configuration that contains this
2021    /// function. In this case, the function driver should use
2022    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure its endpoints.
2023    ///
2024    /// Called with `configured == false` when configuration is disabled or USB
2025    /// is disconnected. The function driver should then use
2026    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to disable its endpoints.
2027    pub fn r#set_configured(
2028        &self,
2029        mut configured: bool,
2030        mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2031        ___deadline: zx::MonotonicInstant,
2032    ) -> Result<UsbFunctionInterfaceSetConfiguredResult, fidl::Error> {
2033        let _response = self.client.send_query::<
2034            UsbFunctionInterfaceSetConfiguredRequest,
2035            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2036            UsbFunctionInterfaceMarker,
2037        >(
2038            (configured, speed,),
2039            0x5c26cc1f53f57a72,
2040            fidl::encoding::DynamicFlags::FLEXIBLE,
2041            ___deadline,
2042        )?
2043        .into_result::<UsbFunctionInterfaceMarker>("set_configured")?;
2044        Ok(_response.map(|x| x))
2045    }
2046
2047    /// Called to set an alternate setting for an interface due to a
2048    /// `SET_INTERFACE` control request.
2049    ///
2050    /// The function driver should use
2051    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure or disable the
2052    /// interface's endpoints as appropriate.
2053    pub fn r#set_interface(
2054        &self,
2055        mut interface: u8,
2056        mut alt_setting: u8,
2057        ___deadline: zx::MonotonicInstant,
2058    ) -> Result<UsbFunctionInterfaceSetInterfaceResult, fidl::Error> {
2059        let _response = self.client.send_query::<
2060            UsbFunctionInterfaceSetInterfaceRequest,
2061            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2062            UsbFunctionInterfaceMarker,
2063        >(
2064            (interface, alt_setting,),
2065            0x42ebdcefc1543f32,
2066            fidl::encoding::DynamicFlags::FLEXIBLE,
2067            ___deadline,
2068        )?
2069        .into_result::<UsbFunctionInterfaceMarker>("set_interface")?;
2070        Ok(_response.map(|x| x))
2071    }
2072}
2073
2074#[cfg(target_os = "fuchsia")]
2075impl From<UsbFunctionInterfaceSynchronousProxy> for zx::NullableHandle {
2076    fn from(value: UsbFunctionInterfaceSynchronousProxy) -> Self {
2077        value.into_channel().into()
2078    }
2079}
2080
2081#[cfg(target_os = "fuchsia")]
2082impl From<fidl::Channel> for UsbFunctionInterfaceSynchronousProxy {
2083    fn from(value: fidl::Channel) -> Self {
2084        Self::new(value)
2085    }
2086}
2087
2088#[cfg(target_os = "fuchsia")]
2089impl fidl::endpoints::FromClient for UsbFunctionInterfaceSynchronousProxy {
2090    type Protocol = UsbFunctionInterfaceMarker;
2091
2092    fn from_client(value: fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>) -> Self {
2093        Self::new(value.into_channel())
2094    }
2095}
2096
2097#[derive(Debug, Clone)]
2098pub struct UsbFunctionInterfaceProxy {
2099    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
2100}
2101
2102impl fidl::endpoints::Proxy for UsbFunctionInterfaceProxy {
2103    type Protocol = UsbFunctionInterfaceMarker;
2104
2105    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
2106        Self::new(inner)
2107    }
2108
2109    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
2110        self.client.into_channel().map_err(|client| Self { client })
2111    }
2112
2113    fn as_channel(&self) -> &::fidl::AsyncChannel {
2114        self.client.as_channel()
2115    }
2116}
2117
2118impl UsbFunctionInterfaceProxy {
2119    /// Create a new Proxy for fuchsia.hardware.usb.function/UsbFunctionInterface.
2120    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
2121        let protocol_name =
2122            <UsbFunctionInterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
2123        Self { client: fidl::client::Client::new(channel, protocol_name) }
2124    }
2125
2126    /// Get a Stream of events from the remote end of the protocol.
2127    ///
2128    /// # Panics
2129    ///
2130    /// Panics if the event stream was already taken.
2131    pub fn take_event_stream(&self) -> UsbFunctionInterfaceEventStream {
2132        UsbFunctionInterfaceEventStream { event_receiver: self.client.take_event_receiver() }
2133    }
2134
2135    /// Callback for handling ep0 control requests.
2136    ///
2137    /// `setup` is the control request to handle.
2138    /// `write` is the data to write to the endpoint.
2139    /// `read` is the data to read from the endpoint.
2140    pub fn r#control(
2141        &self,
2142        mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2143        mut write: &[u8],
2144    ) -> fidl::client::QueryResponseFut<
2145        UsbFunctionInterfaceControlResult,
2146        fidl::encoding::DefaultFuchsiaResourceDialect,
2147    > {
2148        UsbFunctionInterfaceProxyInterface::r#control(self, setup, write)
2149    }
2150
2151    /// Inform the function driver when the USB device configured state changes.
2152    ///
2153    /// Called with `configured == true` in response to a `SET_CONFIGURATION`
2154    /// control request that selects a configuration that contains this
2155    /// function. In this case, the function driver should use
2156    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure its endpoints.
2157    ///
2158    /// Called with `configured == false` when configuration is disabled or USB
2159    /// is disconnected. The function driver should then use
2160    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to disable its endpoints.
2161    pub fn r#set_configured(
2162        &self,
2163        mut configured: bool,
2164        mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2165    ) -> fidl::client::QueryResponseFut<
2166        UsbFunctionInterfaceSetConfiguredResult,
2167        fidl::encoding::DefaultFuchsiaResourceDialect,
2168    > {
2169        UsbFunctionInterfaceProxyInterface::r#set_configured(self, configured, speed)
2170    }
2171
2172    /// Called to set an alternate setting for an interface due to a
2173    /// `SET_INTERFACE` control request.
2174    ///
2175    /// The function driver should use
2176    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure or disable the
2177    /// interface's endpoints as appropriate.
2178    pub fn r#set_interface(
2179        &self,
2180        mut interface: u8,
2181        mut alt_setting: u8,
2182    ) -> fidl::client::QueryResponseFut<
2183        UsbFunctionInterfaceSetInterfaceResult,
2184        fidl::encoding::DefaultFuchsiaResourceDialect,
2185    > {
2186        UsbFunctionInterfaceProxyInterface::r#set_interface(self, interface, alt_setting)
2187    }
2188}
2189
2190impl UsbFunctionInterfaceProxyInterface for UsbFunctionInterfaceProxy {
2191    type ControlResponseFut = fidl::client::QueryResponseFut<
2192        UsbFunctionInterfaceControlResult,
2193        fidl::encoding::DefaultFuchsiaResourceDialect,
2194    >;
2195    fn r#control(
2196        &self,
2197        mut setup: &fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2198        mut write: &[u8],
2199    ) -> Self::ControlResponseFut {
2200        fn _decode(
2201            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2202        ) -> Result<UsbFunctionInterfaceControlResult, fidl::Error> {
2203            let _response = fidl::client::decode_transaction_body::<
2204                fidl::encoding::FlexibleResultType<UsbFunctionInterfaceControlResponse, i32>,
2205                fidl::encoding::DefaultFuchsiaResourceDialect,
2206                0x3cce27231c012cff,
2207            >(_buf?)?
2208            .into_result::<UsbFunctionInterfaceMarker>("control")?;
2209            Ok(_response.map(|x| x.read))
2210        }
2211        self.client.send_query_and_decode::<
2212            UsbFunctionInterfaceControlRequest,
2213            UsbFunctionInterfaceControlResult,
2214        >(
2215            (setup, write,),
2216            0x3cce27231c012cff,
2217            fidl::encoding::DynamicFlags::FLEXIBLE,
2218            _decode,
2219        )
2220    }
2221
2222    type SetConfiguredResponseFut = fidl::client::QueryResponseFut<
2223        UsbFunctionInterfaceSetConfiguredResult,
2224        fidl::encoding::DefaultFuchsiaResourceDialect,
2225    >;
2226    fn r#set_configured(
2227        &self,
2228        mut configured: bool,
2229        mut speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2230    ) -> Self::SetConfiguredResponseFut {
2231        fn _decode(
2232            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2233        ) -> Result<UsbFunctionInterfaceSetConfiguredResult, fidl::Error> {
2234            let _response = fidl::client::decode_transaction_body::<
2235                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2236                fidl::encoding::DefaultFuchsiaResourceDialect,
2237                0x5c26cc1f53f57a72,
2238            >(_buf?)?
2239            .into_result::<UsbFunctionInterfaceMarker>("set_configured")?;
2240            Ok(_response.map(|x| x))
2241        }
2242        self.client.send_query_and_decode::<
2243            UsbFunctionInterfaceSetConfiguredRequest,
2244            UsbFunctionInterfaceSetConfiguredResult,
2245        >(
2246            (configured, speed,),
2247            0x5c26cc1f53f57a72,
2248            fidl::encoding::DynamicFlags::FLEXIBLE,
2249            _decode,
2250        )
2251    }
2252
2253    type SetInterfaceResponseFut = fidl::client::QueryResponseFut<
2254        UsbFunctionInterfaceSetInterfaceResult,
2255        fidl::encoding::DefaultFuchsiaResourceDialect,
2256    >;
2257    fn r#set_interface(
2258        &self,
2259        mut interface: u8,
2260        mut alt_setting: u8,
2261    ) -> Self::SetInterfaceResponseFut {
2262        fn _decode(
2263            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
2264        ) -> Result<UsbFunctionInterfaceSetInterfaceResult, fidl::Error> {
2265            let _response = fidl::client::decode_transaction_body::<
2266                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, i32>,
2267                fidl::encoding::DefaultFuchsiaResourceDialect,
2268                0x42ebdcefc1543f32,
2269            >(_buf?)?
2270            .into_result::<UsbFunctionInterfaceMarker>("set_interface")?;
2271            Ok(_response.map(|x| x))
2272        }
2273        self.client.send_query_and_decode::<
2274            UsbFunctionInterfaceSetInterfaceRequest,
2275            UsbFunctionInterfaceSetInterfaceResult,
2276        >(
2277            (interface, alt_setting,),
2278            0x42ebdcefc1543f32,
2279            fidl::encoding::DynamicFlags::FLEXIBLE,
2280            _decode,
2281        )
2282    }
2283}
2284
2285pub struct UsbFunctionInterfaceEventStream {
2286    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
2287}
2288
2289impl std::marker::Unpin for UsbFunctionInterfaceEventStream {}
2290
2291impl futures::stream::FusedStream for UsbFunctionInterfaceEventStream {
2292    fn is_terminated(&self) -> bool {
2293        self.event_receiver.is_terminated()
2294    }
2295}
2296
2297impl futures::Stream for UsbFunctionInterfaceEventStream {
2298    type Item = Result<UsbFunctionInterfaceEvent, fidl::Error>;
2299
2300    fn poll_next(
2301        mut self: std::pin::Pin<&mut Self>,
2302        cx: &mut std::task::Context<'_>,
2303    ) -> std::task::Poll<Option<Self::Item>> {
2304        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
2305            &mut self.event_receiver,
2306            cx
2307        )?) {
2308            Some(buf) => std::task::Poll::Ready(Some(UsbFunctionInterfaceEvent::decode(buf))),
2309            None => std::task::Poll::Ready(None),
2310        }
2311    }
2312}
2313
2314#[derive(Debug)]
2315pub enum UsbFunctionInterfaceEvent {
2316    #[non_exhaustive]
2317    _UnknownEvent {
2318        /// Ordinal of the event that was sent.
2319        ordinal: u64,
2320    },
2321}
2322
2323impl UsbFunctionInterfaceEvent {
2324    /// Decodes a message buffer as a [`UsbFunctionInterfaceEvent`].
2325    fn decode(
2326        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
2327    ) -> Result<UsbFunctionInterfaceEvent, fidl::Error> {
2328        let (bytes, _handles) = buf.split_mut();
2329        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2330        debug_assert_eq!(tx_header.tx_id, 0);
2331        match tx_header.ordinal {
2332            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2333                Ok(UsbFunctionInterfaceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
2334            }
2335            _ => Err(fidl::Error::UnknownOrdinal {
2336                ordinal: tx_header.ordinal,
2337                protocol_name:
2338                    <UsbFunctionInterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2339            }),
2340        }
2341    }
2342}
2343
2344/// A Stream of incoming requests for fuchsia.hardware.usb.function/UsbFunctionInterface.
2345pub struct UsbFunctionInterfaceRequestStream {
2346    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2347    is_terminated: bool,
2348}
2349
2350impl std::marker::Unpin for UsbFunctionInterfaceRequestStream {}
2351
2352impl futures::stream::FusedStream for UsbFunctionInterfaceRequestStream {
2353    fn is_terminated(&self) -> bool {
2354        self.is_terminated
2355    }
2356}
2357
2358impl fidl::endpoints::RequestStream for UsbFunctionInterfaceRequestStream {
2359    type Protocol = UsbFunctionInterfaceMarker;
2360    type ControlHandle = UsbFunctionInterfaceControlHandle;
2361
2362    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
2363        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
2364    }
2365
2366    fn control_handle(&self) -> Self::ControlHandle {
2367        UsbFunctionInterfaceControlHandle { inner: self.inner.clone() }
2368    }
2369
2370    fn into_inner(
2371        self,
2372    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
2373    {
2374        (self.inner, self.is_terminated)
2375    }
2376
2377    fn from_inner(
2378        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2379        is_terminated: bool,
2380    ) -> Self {
2381        Self { inner, is_terminated }
2382    }
2383}
2384
2385impl futures::Stream for UsbFunctionInterfaceRequestStream {
2386    type Item = Result<UsbFunctionInterfaceRequest, fidl::Error>;
2387
2388    fn poll_next(
2389        mut self: std::pin::Pin<&mut Self>,
2390        cx: &mut std::task::Context<'_>,
2391    ) -> std::task::Poll<Option<Self::Item>> {
2392        let this = &mut *self;
2393        if this.inner.check_shutdown(cx) {
2394            this.is_terminated = true;
2395            return std::task::Poll::Ready(None);
2396        }
2397        if this.is_terminated {
2398            panic!("polled UsbFunctionInterfaceRequestStream after completion");
2399        }
2400        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
2401            |bytes, handles| {
2402                match this.inner.channel().read_etc(cx, bytes, handles) {
2403                    std::task::Poll::Ready(Ok(())) => {}
2404                    std::task::Poll::Pending => return std::task::Poll::Pending,
2405                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
2406                        this.is_terminated = true;
2407                        return std::task::Poll::Ready(None);
2408                    }
2409                    std::task::Poll::Ready(Err(e)) => {
2410                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
2411                            e.into(),
2412                        ))));
2413                    }
2414                }
2415
2416                // A message has been received from the channel
2417                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
2418
2419                std::task::Poll::Ready(Some(match header.ordinal {
2420                0x3cce27231c012cff => {
2421                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2422                    let mut req = fidl::new_empty!(UsbFunctionInterfaceControlRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2423                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionInterfaceControlRequest>(&header, _body_bytes, handles, &mut req)?;
2424                    let control_handle = UsbFunctionInterfaceControlHandle {
2425                        inner: this.inner.clone(),
2426                    };
2427                    Ok(UsbFunctionInterfaceRequest::Control {setup: req.setup,
2428write: req.write,
2429
2430                        responder: UsbFunctionInterfaceControlResponder {
2431                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2432                            tx_id: header.tx_id,
2433                        },
2434                    })
2435                }
2436                0x5c26cc1f53f57a72 => {
2437                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2438                    let mut req = fidl::new_empty!(UsbFunctionInterfaceSetConfiguredRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2439                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionInterfaceSetConfiguredRequest>(&header, _body_bytes, handles, &mut req)?;
2440                    let control_handle = UsbFunctionInterfaceControlHandle {
2441                        inner: this.inner.clone(),
2442                    };
2443                    Ok(UsbFunctionInterfaceRequest::SetConfigured {configured: req.configured,
2444speed: req.speed,
2445
2446                        responder: UsbFunctionInterfaceSetConfiguredResponder {
2447                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2448                            tx_id: header.tx_id,
2449                        },
2450                    })
2451                }
2452                0x42ebdcefc1543f32 => {
2453                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
2454                    let mut req = fidl::new_empty!(UsbFunctionInterfaceSetInterfaceRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
2455                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<UsbFunctionInterfaceSetInterfaceRequest>(&header, _body_bytes, handles, &mut req)?;
2456                    let control_handle = UsbFunctionInterfaceControlHandle {
2457                        inner: this.inner.clone(),
2458                    };
2459                    Ok(UsbFunctionInterfaceRequest::SetInterface {interface: req.interface,
2460alt_setting: req.alt_setting,
2461
2462                        responder: UsbFunctionInterfaceSetInterfaceResponder {
2463                            control_handle: std::mem::ManuallyDrop::new(control_handle),
2464                            tx_id: header.tx_id,
2465                        },
2466                    })
2467                }
2468                _ if header.tx_id == 0 && header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2469                    Ok(UsbFunctionInterfaceRequest::_UnknownMethod {
2470                        ordinal: header.ordinal,
2471                        control_handle: UsbFunctionInterfaceControlHandle { inner: this.inner.clone() },
2472                        method_type: fidl::MethodType::OneWay,
2473                    })
2474                }
2475                _ if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
2476                    this.inner.send_framework_err(
2477                        fidl::encoding::FrameworkErr::UnknownMethod,
2478                        header.tx_id,
2479                        header.ordinal,
2480                        header.dynamic_flags(),
2481                        (bytes, handles),
2482                    )?;
2483                    Ok(UsbFunctionInterfaceRequest::_UnknownMethod {
2484                        ordinal: header.ordinal,
2485                        control_handle: UsbFunctionInterfaceControlHandle { inner: this.inner.clone() },
2486                        method_type: fidl::MethodType::TwoWay,
2487                    })
2488                }
2489                _ => Err(fidl::Error::UnknownOrdinal {
2490                    ordinal: header.ordinal,
2491                    protocol_name: <UsbFunctionInterfaceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
2492                }),
2493            }))
2494            },
2495        )
2496    }
2497}
2498
2499/// Protocol offered to [`UsbFunction`] instances to handle host-initiated
2500/// requests.
2501#[derive(Debug)]
2502pub enum UsbFunctionInterfaceRequest {
2503    /// Callback for handling ep0 control requests.
2504    ///
2505    /// `setup` is the control request to handle.
2506    /// `write` is the data to write to the endpoint.
2507    /// `read` is the data to read from the endpoint.
2508    Control {
2509        setup: fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2510        write: Vec<u8>,
2511        responder: UsbFunctionInterfaceControlResponder,
2512    },
2513    /// Inform the function driver when the USB device configured state changes.
2514    ///
2515    /// Called with `configured == true` in response to a `SET_CONFIGURATION`
2516    /// control request that selects a configuration that contains this
2517    /// function. In this case, the function driver should use
2518    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure its endpoints.
2519    ///
2520    /// Called with `configured == false` when configuration is disabled or USB
2521    /// is disconnected. The function driver should then use
2522    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to disable its endpoints.
2523    SetConfigured {
2524        configured: bool,
2525        speed: fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2526        responder: UsbFunctionInterfaceSetConfiguredResponder,
2527    },
2528    /// Called to set an alternate setting for an interface due to a
2529    /// `SET_INTERFACE` control request.
2530    ///
2531    /// The function driver should use
2532    /// [`fuchsia.hardware.usb.endpoint/Endpoint`] to configure or disable the
2533    /// interface's endpoints as appropriate.
2534    SetInterface {
2535        interface: u8,
2536        alt_setting: u8,
2537        responder: UsbFunctionInterfaceSetInterfaceResponder,
2538    },
2539    /// An interaction was received which does not match any known method.
2540    #[non_exhaustive]
2541    _UnknownMethod {
2542        /// Ordinal of the method that was called.
2543        ordinal: u64,
2544        control_handle: UsbFunctionInterfaceControlHandle,
2545        method_type: fidl::MethodType,
2546    },
2547}
2548
2549impl UsbFunctionInterfaceRequest {
2550    #[allow(irrefutable_let_patterns)]
2551    pub fn into_control(
2552        self,
2553    ) -> Option<(
2554        fidl_fuchsia_hardware_usb_descriptor::UsbSetup,
2555        Vec<u8>,
2556        UsbFunctionInterfaceControlResponder,
2557    )> {
2558        if let UsbFunctionInterfaceRequest::Control { setup, write, responder } = self {
2559            Some((setup, write, responder))
2560        } else {
2561            None
2562        }
2563    }
2564
2565    #[allow(irrefutable_let_patterns)]
2566    pub fn into_set_configured(
2567        self,
2568    ) -> Option<(
2569        bool,
2570        fidl_fuchsia_hardware_usb_descriptor::UsbSpeed,
2571        UsbFunctionInterfaceSetConfiguredResponder,
2572    )> {
2573        if let UsbFunctionInterfaceRequest::SetConfigured { configured, speed, responder } = self {
2574            Some((configured, speed, responder))
2575        } else {
2576            None
2577        }
2578    }
2579
2580    #[allow(irrefutable_let_patterns)]
2581    pub fn into_set_interface(self) -> Option<(u8, u8, UsbFunctionInterfaceSetInterfaceResponder)> {
2582        if let UsbFunctionInterfaceRequest::SetInterface { interface, alt_setting, responder } =
2583            self
2584        {
2585            Some((interface, alt_setting, responder))
2586        } else {
2587            None
2588        }
2589    }
2590
2591    /// Name of the method defined in FIDL
2592    pub fn method_name(&self) -> &'static str {
2593        match *self {
2594            UsbFunctionInterfaceRequest::Control { .. } => "control",
2595            UsbFunctionInterfaceRequest::SetConfigured { .. } => "set_configured",
2596            UsbFunctionInterfaceRequest::SetInterface { .. } => "set_interface",
2597            UsbFunctionInterfaceRequest::_UnknownMethod {
2598                method_type: fidl::MethodType::OneWay,
2599                ..
2600            } => "unknown one-way method",
2601            UsbFunctionInterfaceRequest::_UnknownMethod {
2602                method_type: fidl::MethodType::TwoWay,
2603                ..
2604            } => "unknown two-way method",
2605        }
2606    }
2607}
2608
2609#[derive(Debug, Clone)]
2610pub struct UsbFunctionInterfaceControlHandle {
2611    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
2612}
2613
2614impl UsbFunctionInterfaceControlHandle {
2615    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
2616        self.inner.shutdown_with_epitaph(status.into())
2617    }
2618}
2619
2620impl fidl::endpoints::ControlHandle for UsbFunctionInterfaceControlHandle {
2621    fn shutdown(&self) {
2622        self.inner.shutdown()
2623    }
2624
2625    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
2626        self.inner.shutdown_with_epitaph(status)
2627    }
2628
2629    fn is_closed(&self) -> bool {
2630        self.inner.channel().is_closed()
2631    }
2632    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
2633        self.inner.channel().on_closed()
2634    }
2635
2636    #[cfg(target_os = "fuchsia")]
2637    fn signal_peer(
2638        &self,
2639        clear_mask: zx::Signals,
2640        set_mask: zx::Signals,
2641    ) -> Result<(), zx_status::Status> {
2642        use fidl::Peered;
2643        self.inner.channel().signal_peer(clear_mask, set_mask)
2644    }
2645}
2646
2647impl UsbFunctionInterfaceControlHandle {}
2648
2649#[must_use = "FIDL methods require a response to be sent"]
2650#[derive(Debug)]
2651pub struct UsbFunctionInterfaceControlResponder {
2652    control_handle: std::mem::ManuallyDrop<UsbFunctionInterfaceControlHandle>,
2653    tx_id: u32,
2654}
2655
2656/// Set the the channel to be shutdown (see [`UsbFunctionInterfaceControlHandle::shutdown`])
2657/// if the responder is dropped without sending a response, so that the client
2658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2659impl std::ops::Drop for UsbFunctionInterfaceControlResponder {
2660    fn drop(&mut self) {
2661        self.control_handle.shutdown();
2662        // Safety: drops once, never accessed again
2663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2664    }
2665}
2666
2667impl fidl::endpoints::Responder for UsbFunctionInterfaceControlResponder {
2668    type ControlHandle = UsbFunctionInterfaceControlHandle;
2669
2670    fn control_handle(&self) -> &UsbFunctionInterfaceControlHandle {
2671        &self.control_handle
2672    }
2673
2674    fn drop_without_shutdown(mut self) {
2675        // Safety: drops once, never accessed again due to mem::forget
2676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2677        // Prevent Drop from running (which would shut down the channel)
2678        std::mem::forget(self);
2679    }
2680}
2681
2682impl UsbFunctionInterfaceControlResponder {
2683    /// Sends a response to the FIDL transaction.
2684    ///
2685    /// Sets the channel to shutdown if an error occurs.
2686    pub fn send(self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2687        let _result = self.send_raw(result);
2688        if _result.is_err() {
2689            self.control_handle.shutdown();
2690        }
2691        self.drop_without_shutdown();
2692        _result
2693    }
2694
2695    /// Similar to "send" but does not shutdown the channel if an error occurs.
2696    pub fn send_no_shutdown_on_err(
2697        self,
2698        mut result: Result<&[u8], i32>,
2699    ) -> Result<(), fidl::Error> {
2700        let _result = self.send_raw(result);
2701        self.drop_without_shutdown();
2702        _result
2703    }
2704
2705    fn send_raw(&self, mut result: Result<&[u8], i32>) -> Result<(), fidl::Error> {
2706        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2707            UsbFunctionInterfaceControlResponse,
2708            i32,
2709        >>(
2710            fidl::encoding::FlexibleResult::new(result.map(|read| (read,))),
2711            self.tx_id,
2712            0x3cce27231c012cff,
2713            fidl::encoding::DynamicFlags::FLEXIBLE,
2714        )
2715    }
2716}
2717
2718#[must_use = "FIDL methods require a response to be sent"]
2719#[derive(Debug)]
2720pub struct UsbFunctionInterfaceSetConfiguredResponder {
2721    control_handle: std::mem::ManuallyDrop<UsbFunctionInterfaceControlHandle>,
2722    tx_id: u32,
2723}
2724
2725/// Set the the channel to be shutdown (see [`UsbFunctionInterfaceControlHandle::shutdown`])
2726/// if the responder is dropped without sending a response, so that the client
2727/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2728impl std::ops::Drop for UsbFunctionInterfaceSetConfiguredResponder {
2729    fn drop(&mut self) {
2730        self.control_handle.shutdown();
2731        // Safety: drops once, never accessed again
2732        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2733    }
2734}
2735
2736impl fidl::endpoints::Responder for UsbFunctionInterfaceSetConfiguredResponder {
2737    type ControlHandle = UsbFunctionInterfaceControlHandle;
2738
2739    fn control_handle(&self) -> &UsbFunctionInterfaceControlHandle {
2740        &self.control_handle
2741    }
2742
2743    fn drop_without_shutdown(mut self) {
2744        // Safety: drops once, never accessed again due to mem::forget
2745        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2746        // Prevent Drop from running (which would shut down the channel)
2747        std::mem::forget(self);
2748    }
2749}
2750
2751impl UsbFunctionInterfaceSetConfiguredResponder {
2752    /// Sends a response to the FIDL transaction.
2753    ///
2754    /// Sets the channel to shutdown if an error occurs.
2755    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2756        let _result = self.send_raw(result);
2757        if _result.is_err() {
2758            self.control_handle.shutdown();
2759        }
2760        self.drop_without_shutdown();
2761        _result
2762    }
2763
2764    /// Similar to "send" but does not shutdown the channel if an error occurs.
2765    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2766        let _result = self.send_raw(result);
2767        self.drop_without_shutdown();
2768        _result
2769    }
2770
2771    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2772        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2773            fidl::encoding::EmptyStruct,
2774            i32,
2775        >>(
2776            fidl::encoding::FlexibleResult::new(result),
2777            self.tx_id,
2778            0x5c26cc1f53f57a72,
2779            fidl::encoding::DynamicFlags::FLEXIBLE,
2780        )
2781    }
2782}
2783
2784#[must_use = "FIDL methods require a response to be sent"]
2785#[derive(Debug)]
2786pub struct UsbFunctionInterfaceSetInterfaceResponder {
2787    control_handle: std::mem::ManuallyDrop<UsbFunctionInterfaceControlHandle>,
2788    tx_id: u32,
2789}
2790
2791/// Set the the channel to be shutdown (see [`UsbFunctionInterfaceControlHandle::shutdown`])
2792/// if the responder is dropped without sending a response, so that the client
2793/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
2794impl std::ops::Drop for UsbFunctionInterfaceSetInterfaceResponder {
2795    fn drop(&mut self) {
2796        self.control_handle.shutdown();
2797        // Safety: drops once, never accessed again
2798        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2799    }
2800}
2801
2802impl fidl::endpoints::Responder for UsbFunctionInterfaceSetInterfaceResponder {
2803    type ControlHandle = UsbFunctionInterfaceControlHandle;
2804
2805    fn control_handle(&self) -> &UsbFunctionInterfaceControlHandle {
2806        &self.control_handle
2807    }
2808
2809    fn drop_without_shutdown(mut self) {
2810        // Safety: drops once, never accessed again due to mem::forget
2811        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
2812        // Prevent Drop from running (which would shut down the channel)
2813        std::mem::forget(self);
2814    }
2815}
2816
2817impl UsbFunctionInterfaceSetInterfaceResponder {
2818    /// Sends a response to the FIDL transaction.
2819    ///
2820    /// Sets the channel to shutdown if an error occurs.
2821    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2822        let _result = self.send_raw(result);
2823        if _result.is_err() {
2824            self.control_handle.shutdown();
2825        }
2826        self.drop_without_shutdown();
2827        _result
2828    }
2829
2830    /// Similar to "send" but does not shutdown the channel if an error occurs.
2831    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2832        let _result = self.send_raw(result);
2833        self.drop_without_shutdown();
2834        _result
2835    }
2836
2837    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
2838        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
2839            fidl::encoding::EmptyStruct,
2840            i32,
2841        >>(
2842            fidl::encoding::FlexibleResult::new(result),
2843            self.tx_id,
2844            0x42ebdcefc1543f32,
2845            fidl::encoding::DynamicFlags::FLEXIBLE,
2846        )
2847    }
2848}
2849
2850#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
2851pub struct UsbFunctionServiceMarker;
2852
2853#[cfg(target_os = "fuchsia")]
2854impl fidl::endpoints::ServiceMarker for UsbFunctionServiceMarker {
2855    type Proxy = UsbFunctionServiceProxy;
2856    type Request = UsbFunctionServiceRequest;
2857    const SERVICE_NAME: &'static str = "fuchsia.hardware.usb.function.UsbFunctionService";
2858}
2859
2860/// A request for one of the member protocols of UsbFunctionService.
2861///
2862#[cfg(target_os = "fuchsia")]
2863pub enum UsbFunctionServiceRequest {
2864    Device(UsbFunctionRequestStream),
2865}
2866
2867#[cfg(target_os = "fuchsia")]
2868impl fidl::endpoints::ServiceRequest for UsbFunctionServiceRequest {
2869    type Service = UsbFunctionServiceMarker;
2870
2871    fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
2872        match name {
2873            "device" => Self::Device(
2874                <UsbFunctionRequestStream as fidl::endpoints::RequestStream>::from_channel(
2875                    _channel,
2876                ),
2877            ),
2878            _ => panic!("no such member protocol name for service UsbFunctionService"),
2879        }
2880    }
2881
2882    fn member_names() -> &'static [&'static str] {
2883        &["device"]
2884    }
2885}
2886#[cfg(target_os = "fuchsia")]
2887pub struct UsbFunctionServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
2888
2889#[cfg(target_os = "fuchsia")]
2890impl fidl::endpoints::ServiceProxy for UsbFunctionServiceProxy {
2891    type Service = UsbFunctionServiceMarker;
2892
2893    fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
2894        Self(opener)
2895    }
2896}
2897
2898#[cfg(target_os = "fuchsia")]
2899impl UsbFunctionServiceProxy {
2900    pub fn connect_to_device(&self) -> Result<UsbFunctionProxy, fidl::Error> {
2901        let (proxy, server_end) = fidl::endpoints::create_proxy::<UsbFunctionMarker>();
2902        self.connect_channel_to_device(server_end)?;
2903        Ok(proxy)
2904    }
2905
2906    /// Like `connect_to_device`, but returns a sync proxy.
2907    /// See [`Self::connect_to_device`] for more details.
2908    pub fn connect_to_device_sync(&self) -> Result<UsbFunctionSynchronousProxy, fidl::Error> {
2909        let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<UsbFunctionMarker>();
2910        self.connect_channel_to_device(server_end)?;
2911        Ok(proxy)
2912    }
2913
2914    /// Like `connect_to_device`, but accepts a server end.
2915    /// See [`Self::connect_to_device`] for more details.
2916    pub fn connect_channel_to_device(
2917        &self,
2918        server_end: fidl::endpoints::ServerEnd<UsbFunctionMarker>,
2919    ) -> Result<(), fidl::Error> {
2920        self.0.open_member("device", server_end.into_channel())
2921    }
2922
2923    pub fn instance_name(&self) -> &str {
2924        self.0.instance_name()
2925    }
2926}
2927
2928mod internal {
2929    use super::*;
2930
2931    impl fidl::encoding::ResourceTypeMarker for EndpointResource {
2932        type Borrowed<'a> = &'a mut Self;
2933        fn take_or_borrow<'a>(
2934            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2935        ) -> Self::Borrowed<'a> {
2936            value
2937        }
2938    }
2939
2940    unsafe impl fidl::encoding::TypeMarker for EndpointResource {
2941        type Owned = Self;
2942
2943        #[inline(always)]
2944        fn inline_align(_context: fidl::encoding::Context) -> usize {
2945            8
2946        }
2947
2948        #[inline(always)]
2949        fn inline_size(_context: fidl::encoding::Context) -> usize {
2950            32
2951        }
2952    }
2953
2954    unsafe impl
2955        fidl::encoding::Encode<EndpointResource, fidl::encoding::DefaultFuchsiaResourceDialect>
2956        for &mut EndpointResource
2957    {
2958        #[inline]
2959        unsafe fn encode(
2960            self,
2961            encoder: &mut fidl::encoding::Encoder<
2962                '_,
2963                fidl::encoding::DefaultFuchsiaResourceDialect,
2964            >,
2965            offset: usize,
2966            _depth: fidl::encoding::Depth,
2967        ) -> fidl::Result<()> {
2968            encoder.debug_check_bounds::<EndpointResource>(offset);
2969            // Delegate to tuple encoding.
2970            fidl::encoding::Encode::<EndpointResource, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2971                (
2972                    <fidl_fuchsia_hardware_usb_descriptor::EndpointDirection as fidl::encoding::ValueTypeMarker>::borrow(&self.direction),
2973                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoint),
2974                    <fidl_fuchsia_hardware_usb_endpoint::EndpointInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.ep_info),
2975                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.max_packet_size),
2976                ),
2977                encoder, offset, _depth
2978            )
2979        }
2980    }
2981    unsafe impl<
2982        T0: fidl::encoding::Encode<
2983                fidl_fuchsia_hardware_usb_descriptor::EndpointDirection,
2984                fidl::encoding::DefaultFuchsiaResourceDialect,
2985            >,
2986        T1: fidl::encoding::Encode<
2987                fidl::encoding::Endpoint<
2988                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
2989                >,
2990                fidl::encoding::DefaultFuchsiaResourceDialect,
2991            >,
2992        T2: fidl::encoding::Encode<
2993                fidl_fuchsia_hardware_usb_endpoint::EndpointInfo,
2994                fidl::encoding::DefaultFuchsiaResourceDialect,
2995            >,
2996        T3: fidl::encoding::Encode<u32, fidl::encoding::DefaultFuchsiaResourceDialect>,
2997    > fidl::encoding::Encode<EndpointResource, fidl::encoding::DefaultFuchsiaResourceDialect>
2998        for (T0, T1, T2, T3)
2999    {
3000        #[inline]
3001        unsafe fn encode(
3002            self,
3003            encoder: &mut fidl::encoding::Encoder<
3004                '_,
3005                fidl::encoding::DefaultFuchsiaResourceDialect,
3006            >,
3007            offset: usize,
3008            depth: fidl::encoding::Depth,
3009        ) -> fidl::Result<()> {
3010            encoder.debug_check_bounds::<EndpointResource>(offset);
3011            // Zero out padding regions. There's no need to apply masks
3012            // because the unmasked parts will be overwritten by fields.
3013            unsafe {
3014                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3015                (ptr as *mut u64).write_unaligned(0);
3016            }
3017            unsafe {
3018                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(24);
3019                (ptr as *mut u64).write_unaligned(0);
3020            }
3021            // Write the fields.
3022            self.0.encode(encoder, offset + 0, depth)?;
3023            self.1.encode(encoder, offset + 4, depth)?;
3024            self.2.encode(encoder, offset + 8, depth)?;
3025            self.3.encode(encoder, offset + 24, depth)?;
3026            Ok(())
3027        }
3028    }
3029
3030    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3031        for EndpointResource
3032    {
3033        #[inline(always)]
3034        fn new_empty() -> Self {
3035            Self {
3036                direction: fidl::new_empty!(
3037                    fidl_fuchsia_hardware_usb_descriptor::EndpointDirection,
3038                    fidl::encoding::DefaultFuchsiaResourceDialect
3039                ),
3040                endpoint: fidl::new_empty!(
3041                    fidl::encoding::Endpoint<
3042                        fidl::endpoints::ServerEnd<
3043                            fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
3044                        >,
3045                    >,
3046                    fidl::encoding::DefaultFuchsiaResourceDialect
3047                ),
3048                ep_info: fidl::new_empty!(
3049                    fidl_fuchsia_hardware_usb_endpoint::EndpointInfo,
3050                    fidl::encoding::DefaultFuchsiaResourceDialect
3051                ),
3052                max_packet_size: fidl::new_empty!(
3053                    u32,
3054                    fidl::encoding::DefaultFuchsiaResourceDialect
3055                ),
3056            }
3057        }
3058
3059        #[inline]
3060        unsafe fn decode(
3061            &mut self,
3062            decoder: &mut fidl::encoding::Decoder<
3063                '_,
3064                fidl::encoding::DefaultFuchsiaResourceDialect,
3065            >,
3066            offset: usize,
3067            _depth: fidl::encoding::Depth,
3068        ) -> fidl::Result<()> {
3069            decoder.debug_check_bounds::<Self>(offset);
3070            // Verify that padding bytes are zero.
3071            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3072            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3073            let mask = 0xffffff00u64;
3074            let maskedval = padval & mask;
3075            if maskedval != 0 {
3076                return Err(fidl::Error::NonZeroPadding {
3077                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3078                });
3079            }
3080            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(24) };
3081            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3082            let mask = 0xffffffff00000000u64;
3083            let maskedval = padval & mask;
3084            if maskedval != 0 {
3085                return Err(fidl::Error::NonZeroPadding {
3086                    padding_start: offset + 24 + ((mask as u64).trailing_zeros() / 8) as usize,
3087                });
3088            }
3089            fidl::decode!(
3090                fidl_fuchsia_hardware_usb_descriptor::EndpointDirection,
3091                fidl::encoding::DefaultFuchsiaResourceDialect,
3092                &mut self.direction,
3093                decoder,
3094                offset + 0,
3095                _depth
3096            )?;
3097            fidl::decode!(
3098                fidl::encoding::Endpoint<
3099                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
3100                >,
3101                fidl::encoding::DefaultFuchsiaResourceDialect,
3102                &mut self.endpoint,
3103                decoder,
3104                offset + 4,
3105                _depth
3106            )?;
3107            fidl::decode!(
3108                fidl_fuchsia_hardware_usb_endpoint::EndpointInfo,
3109                fidl::encoding::DefaultFuchsiaResourceDialect,
3110                &mut self.ep_info,
3111                decoder,
3112                offset + 8,
3113                _depth
3114            )?;
3115            fidl::decode!(
3116                u32,
3117                fidl::encoding::DefaultFuchsiaResourceDialect,
3118                &mut self.max_packet_size,
3119                decoder,
3120                offset + 24,
3121                _depth
3122            )?;
3123            Ok(())
3124        }
3125    }
3126
3127    impl fidl::encoding::ResourceTypeMarker for UsbFunctionAllocResourcesRequest {
3128        type Borrowed<'a> = &'a mut Self;
3129        fn take_or_borrow<'a>(
3130            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3131        ) -> Self::Borrowed<'a> {
3132            value
3133        }
3134    }
3135
3136    unsafe impl fidl::encoding::TypeMarker for UsbFunctionAllocResourcesRequest {
3137        type Owned = Self;
3138
3139        #[inline(always)]
3140        fn inline_align(_context: fidl::encoding::Context) -> usize {
3141            8
3142        }
3143
3144        #[inline(always)]
3145        fn inline_size(_context: fidl::encoding::Context) -> usize {
3146            40
3147        }
3148    }
3149
3150    unsafe impl
3151        fidl::encoding::Encode<
3152            UsbFunctionAllocResourcesRequest,
3153            fidl::encoding::DefaultFuchsiaResourceDialect,
3154        > for &mut UsbFunctionAllocResourcesRequest
3155    {
3156        #[inline]
3157        unsafe fn encode(
3158            self,
3159            encoder: &mut fidl::encoding::Encoder<
3160                '_,
3161                fidl::encoding::DefaultFuchsiaResourceDialect,
3162            >,
3163            offset: usize,
3164            _depth: fidl::encoding::Depth,
3165        ) -> fidl::Result<()> {
3166            encoder.debug_check_bounds::<UsbFunctionAllocResourcesRequest>(offset);
3167            // Delegate to tuple encoding.
3168            fidl::encoding::Encode::<UsbFunctionAllocResourcesRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3169                (
3170                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.interface_count),
3171                    <fidl::encoding::Vector<EndpointResource, 255> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.endpoints),
3172                    <fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255> as fidl::encoding::ValueTypeMarker>::borrow(&self.strings),
3173                ),
3174                encoder, offset, _depth
3175            )
3176        }
3177    }
3178    unsafe impl<
3179        T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
3180        T1: fidl::encoding::Encode<
3181                fidl::encoding::Vector<EndpointResource, 255>,
3182                fidl::encoding::DefaultFuchsiaResourceDialect,
3183            >,
3184        T2: fidl::encoding::Encode<
3185                fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255>,
3186                fidl::encoding::DefaultFuchsiaResourceDialect,
3187            >,
3188    >
3189        fidl::encoding::Encode<
3190            UsbFunctionAllocResourcesRequest,
3191            fidl::encoding::DefaultFuchsiaResourceDialect,
3192        > for (T0, T1, T2)
3193    {
3194        #[inline]
3195        unsafe fn encode(
3196            self,
3197            encoder: &mut fidl::encoding::Encoder<
3198                '_,
3199                fidl::encoding::DefaultFuchsiaResourceDialect,
3200            >,
3201            offset: usize,
3202            depth: fidl::encoding::Depth,
3203        ) -> fidl::Result<()> {
3204            encoder.debug_check_bounds::<UsbFunctionAllocResourcesRequest>(offset);
3205            // Zero out padding regions. There's no need to apply masks
3206            // because the unmasked parts will be overwritten by fields.
3207            unsafe {
3208                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3209                (ptr as *mut u64).write_unaligned(0);
3210            }
3211            // Write the fields.
3212            self.0.encode(encoder, offset + 0, depth)?;
3213            self.1.encode(encoder, offset + 8, depth)?;
3214            self.2.encode(encoder, offset + 24, depth)?;
3215            Ok(())
3216        }
3217    }
3218
3219    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3220        for UsbFunctionAllocResourcesRequest
3221    {
3222        #[inline(always)]
3223        fn new_empty() -> Self {
3224            Self {
3225                interface_count: fidl::new_empty!(
3226                    u8,
3227                    fidl::encoding::DefaultFuchsiaResourceDialect
3228                ),
3229                endpoints: fidl::new_empty!(fidl::encoding::Vector<EndpointResource, 255>, fidl::encoding::DefaultFuchsiaResourceDialect),
3230                strings: fidl::new_empty!(
3231                    fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255>,
3232                    fidl::encoding::DefaultFuchsiaResourceDialect
3233                ),
3234            }
3235        }
3236
3237        #[inline]
3238        unsafe fn decode(
3239            &mut self,
3240            decoder: &mut fidl::encoding::Decoder<
3241                '_,
3242                fidl::encoding::DefaultFuchsiaResourceDialect,
3243            >,
3244            offset: usize,
3245            _depth: fidl::encoding::Depth,
3246        ) -> fidl::Result<()> {
3247            decoder.debug_check_bounds::<Self>(offset);
3248            // Verify that padding bytes are zero.
3249            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3250            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3251            let mask = 0xffffffffffffff00u64;
3252            let maskedval = padval & mask;
3253            if maskedval != 0 {
3254                return Err(fidl::Error::NonZeroPadding {
3255                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3256                });
3257            }
3258            fidl::decode!(
3259                u8,
3260                fidl::encoding::DefaultFuchsiaResourceDialect,
3261                &mut self.interface_count,
3262                decoder,
3263                offset + 0,
3264                _depth
3265            )?;
3266            fidl::decode!(fidl::encoding::Vector<EndpointResource, 255>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.endpoints, decoder, offset + 8, _depth)?;
3267            fidl::decode!(
3268                fidl::encoding::Vector<fidl::encoding::BoundedString<126>, 255>,
3269                fidl::encoding::DefaultFuchsiaResourceDialect,
3270                &mut self.strings,
3271                decoder,
3272                offset + 24,
3273                _depth
3274            )?;
3275            Ok(())
3276        }
3277    }
3278
3279    impl fidl::encoding::ResourceTypeMarker for UsbFunctionConfigureRequest {
3280        type Borrowed<'a> = &'a mut Self;
3281        fn take_or_borrow<'a>(
3282            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3283        ) -> Self::Borrowed<'a> {
3284            value
3285        }
3286    }
3287
3288    unsafe impl fidl::encoding::TypeMarker for UsbFunctionConfigureRequest {
3289        type Owned = Self;
3290
3291        #[inline(always)]
3292        fn inline_align(_context: fidl::encoding::Context) -> usize {
3293            8
3294        }
3295
3296        #[inline(always)]
3297        fn inline_size(_context: fidl::encoding::Context) -> usize {
3298            24
3299        }
3300    }
3301
3302    unsafe impl
3303        fidl::encoding::Encode<
3304            UsbFunctionConfigureRequest,
3305            fidl::encoding::DefaultFuchsiaResourceDialect,
3306        > for &mut UsbFunctionConfigureRequest
3307    {
3308        #[inline]
3309        unsafe fn encode(
3310            self,
3311            encoder: &mut fidl::encoding::Encoder<
3312                '_,
3313                fidl::encoding::DefaultFuchsiaResourceDialect,
3314            >,
3315            offset: usize,
3316            _depth: fidl::encoding::Depth,
3317        ) -> fidl::Result<()> {
3318            encoder.debug_check_bounds::<UsbFunctionConfigureRequest>(offset);
3319            // Delegate to tuple encoding.
3320            fidl::encoding::Encode::<UsbFunctionConfigureRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
3321                (
3322                    <fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow(&self.configuration),
3323                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.iface),
3324                ),
3325                encoder, offset, _depth
3326            )
3327        }
3328    }
3329    unsafe impl<
3330        T0: fidl::encoding::Encode<
3331                fidl::encoding::UnboundedVector<u8>,
3332                fidl::encoding::DefaultFuchsiaResourceDialect,
3333            >,
3334        T1: fidl::encoding::Encode<
3335                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>>,
3336                fidl::encoding::DefaultFuchsiaResourceDialect,
3337            >,
3338    >
3339        fidl::encoding::Encode<
3340            UsbFunctionConfigureRequest,
3341            fidl::encoding::DefaultFuchsiaResourceDialect,
3342        > for (T0, T1)
3343    {
3344        #[inline]
3345        unsafe fn encode(
3346            self,
3347            encoder: &mut fidl::encoding::Encoder<
3348                '_,
3349                fidl::encoding::DefaultFuchsiaResourceDialect,
3350            >,
3351            offset: usize,
3352            depth: fidl::encoding::Depth,
3353        ) -> fidl::Result<()> {
3354            encoder.debug_check_bounds::<UsbFunctionConfigureRequest>(offset);
3355            // Zero out padding regions. There's no need to apply masks
3356            // because the unmasked parts will be overwritten by fields.
3357            unsafe {
3358                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
3359                (ptr as *mut u64).write_unaligned(0);
3360            }
3361            // Write the fields.
3362            self.0.encode(encoder, offset + 0, depth)?;
3363            self.1.encode(encoder, offset + 16, depth)?;
3364            Ok(())
3365        }
3366    }
3367
3368    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3369        for UsbFunctionConfigureRequest
3370    {
3371        #[inline(always)]
3372        fn new_empty() -> Self {
3373            Self {
3374                configuration: fidl::new_empty!(
3375                    fidl::encoding::UnboundedVector<u8>,
3376                    fidl::encoding::DefaultFuchsiaResourceDialect
3377                ),
3378                iface: fidl::new_empty!(
3379                    fidl::encoding::Endpoint<
3380                        fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>,
3381                    >,
3382                    fidl::encoding::DefaultFuchsiaResourceDialect
3383                ),
3384            }
3385        }
3386
3387        #[inline]
3388        unsafe fn decode(
3389            &mut self,
3390            decoder: &mut fidl::encoding::Decoder<
3391                '_,
3392                fidl::encoding::DefaultFuchsiaResourceDialect,
3393            >,
3394            offset: usize,
3395            _depth: fidl::encoding::Depth,
3396        ) -> fidl::Result<()> {
3397            decoder.debug_check_bounds::<Self>(offset);
3398            // Verify that padding bytes are zero.
3399            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
3400            let padval = unsafe { (ptr as *const u64).read_unaligned() };
3401            let mask = 0xffffffff00000000u64;
3402            let maskedval = padval & mask;
3403            if maskedval != 0 {
3404                return Err(fidl::Error::NonZeroPadding {
3405                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
3406                });
3407            }
3408            fidl::decode!(
3409                fidl::encoding::UnboundedVector<u8>,
3410                fidl::encoding::DefaultFuchsiaResourceDialect,
3411                &mut self.configuration,
3412                decoder,
3413                offset + 0,
3414                _depth
3415            )?;
3416            fidl::decode!(
3417                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<UsbFunctionInterfaceMarker>>,
3418                fidl::encoding::DefaultFuchsiaResourceDialect,
3419                &mut self.iface,
3420                decoder,
3421                offset + 16,
3422                _depth
3423            )?;
3424            Ok(())
3425        }
3426    }
3427
3428    impl fidl::encoding::ResourceTypeMarker for UsbFunctionConnectToEndpointRequest {
3429        type Borrowed<'a> = &'a mut Self;
3430        fn take_or_borrow<'a>(
3431            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
3432        ) -> Self::Borrowed<'a> {
3433            value
3434        }
3435    }
3436
3437    unsafe impl fidl::encoding::TypeMarker for UsbFunctionConnectToEndpointRequest {
3438        type Owned = Self;
3439
3440        #[inline(always)]
3441        fn inline_align(_context: fidl::encoding::Context) -> usize {
3442            4
3443        }
3444
3445        #[inline(always)]
3446        fn inline_size(_context: fidl::encoding::Context) -> usize {
3447            8
3448        }
3449    }
3450
3451    unsafe impl
3452        fidl::encoding::Encode<
3453            UsbFunctionConnectToEndpointRequest,
3454            fidl::encoding::DefaultFuchsiaResourceDialect,
3455        > for &mut UsbFunctionConnectToEndpointRequest
3456    {
3457        #[inline]
3458        unsafe fn encode(
3459            self,
3460            encoder: &mut fidl::encoding::Encoder<
3461                '_,
3462                fidl::encoding::DefaultFuchsiaResourceDialect,
3463            >,
3464            offset: usize,
3465            _depth: fidl::encoding::Depth,
3466        ) -> fidl::Result<()> {
3467            encoder.debug_check_bounds::<UsbFunctionConnectToEndpointRequest>(offset);
3468            // Delegate to tuple encoding.
3469            fidl::encoding::Encode::<
3470                UsbFunctionConnectToEndpointRequest,
3471                fidl::encoding::DefaultFuchsiaResourceDialect,
3472            >::encode(
3473                (
3474                    <u8 as fidl::encoding::ValueTypeMarker>::borrow(&self.ep_addr),
3475                    <fidl::encoding::Endpoint<
3476                        fidl::endpoints::ServerEnd<
3477                            fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
3478                        >,
3479                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
3480                        &mut self.ep
3481                    ),
3482                ),
3483                encoder,
3484                offset,
3485                _depth,
3486            )
3487        }
3488    }
3489    unsafe impl<
3490        T0: fidl::encoding::Encode<u8, fidl::encoding::DefaultFuchsiaResourceDialect>,
3491        T1: fidl::encoding::Encode<
3492                fidl::encoding::Endpoint<
3493                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
3494                >,
3495                fidl::encoding::DefaultFuchsiaResourceDialect,
3496            >,
3497    >
3498        fidl::encoding::Encode<
3499            UsbFunctionConnectToEndpointRequest,
3500            fidl::encoding::DefaultFuchsiaResourceDialect,
3501        > for (T0, T1)
3502    {
3503        #[inline]
3504        unsafe fn encode(
3505            self,
3506            encoder: &mut fidl::encoding::Encoder<
3507                '_,
3508                fidl::encoding::DefaultFuchsiaResourceDialect,
3509            >,
3510            offset: usize,
3511            depth: fidl::encoding::Depth,
3512        ) -> fidl::Result<()> {
3513            encoder.debug_check_bounds::<UsbFunctionConnectToEndpointRequest>(offset);
3514            // Zero out padding regions. There's no need to apply masks
3515            // because the unmasked parts will be overwritten by fields.
3516            unsafe {
3517                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
3518                (ptr as *mut u32).write_unaligned(0);
3519            }
3520            // Write the fields.
3521            self.0.encode(encoder, offset + 0, depth)?;
3522            self.1.encode(encoder, offset + 4, depth)?;
3523            Ok(())
3524        }
3525    }
3526
3527    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
3528        for UsbFunctionConnectToEndpointRequest
3529    {
3530        #[inline(always)]
3531        fn new_empty() -> Self {
3532            Self {
3533                ep_addr: fidl::new_empty!(u8, fidl::encoding::DefaultFuchsiaResourceDialect),
3534                ep: fidl::new_empty!(
3535                    fidl::encoding::Endpoint<
3536                        fidl::endpoints::ServerEnd<
3537                            fidl_fuchsia_hardware_usb_endpoint::EndpointMarker,
3538                        >,
3539                    >,
3540                    fidl::encoding::DefaultFuchsiaResourceDialect
3541                ),
3542            }
3543        }
3544
3545        #[inline]
3546        unsafe fn decode(
3547            &mut self,
3548            decoder: &mut fidl::encoding::Decoder<
3549                '_,
3550                fidl::encoding::DefaultFuchsiaResourceDialect,
3551            >,
3552            offset: usize,
3553            _depth: fidl::encoding::Depth,
3554        ) -> fidl::Result<()> {
3555            decoder.debug_check_bounds::<Self>(offset);
3556            // Verify that padding bytes are zero.
3557            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
3558            let padval = unsafe { (ptr as *const u32).read_unaligned() };
3559            let mask = 0xffffff00u32;
3560            let maskedval = padval & mask;
3561            if maskedval != 0 {
3562                return Err(fidl::Error::NonZeroPadding {
3563                    padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
3564                });
3565            }
3566            fidl::decode!(
3567                u8,
3568                fidl::encoding::DefaultFuchsiaResourceDialect,
3569                &mut self.ep_addr,
3570                decoder,
3571                offset + 0,
3572                _depth
3573            )?;
3574            fidl::decode!(
3575                fidl::encoding::Endpoint<
3576                    fidl::endpoints::ServerEnd<fidl_fuchsia_hardware_usb_endpoint::EndpointMarker>,
3577                >,
3578                fidl::encoding::DefaultFuchsiaResourceDialect,
3579                &mut self.ep,
3580                decoder,
3581                offset + 4,
3582                _depth
3583            )?;
3584            Ok(())
3585        }
3586    }
3587}