fidl_fuchsia_factory_lowpan/
fidl_fuchsia_factory_lowpan.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_factory_lowpan__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct FactoryDeviceSetupOtCliRequest {
16    pub server_socket: fidl::Socket,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for FactoryDeviceSetupOtCliRequest
21{
22}
23
24#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
25pub struct FactoryDriverGetFactoryDeviceRequest {
26    pub device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
27}
28
29impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
30    for FactoryDriverGetFactoryDeviceRequest
31{
32}
33
34#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct FactoryLookupLookupRequest {
36    pub name: String,
37    pub device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
38}
39
40impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
41    for FactoryLookupLookupRequest
42{
43}
44
45#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
46pub struct FactoryRegisterRegisterRequest {
47    pub name: String,
48    pub driver: fidl::endpoints::ClientEnd<FactoryDriverMarker>,
49}
50
51impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
52    for FactoryRegisterRegisterRequest
53{
54}
55
56#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
57pub struct FactoryDeviceMarker;
58
59impl fidl::endpoints::ProtocolMarker for FactoryDeviceMarker {
60    type Proxy = FactoryDeviceProxy;
61    type RequestStream = FactoryDeviceRequestStream;
62    #[cfg(target_os = "fuchsia")]
63    type SynchronousProxy = FactoryDeviceSynchronousProxy;
64
65    const DEBUG_NAME: &'static str = "(anonymous) FactoryDevice";
66}
67
68pub trait FactoryDeviceProxyInterface: Send + Sync {
69    type SendMfgCommandResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
70    fn r#send_mfg_command(&self, command: &str) -> Self::SendMfgCommandResponseFut;
71    type SetupOtCliResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
72    fn r#setup_ot_cli(&self, server_socket: fidl::Socket) -> Self::SetupOtCliResponseFut;
73}
74#[derive(Debug)]
75#[cfg(target_os = "fuchsia")]
76pub struct FactoryDeviceSynchronousProxy {
77    client: fidl::client::sync::Client,
78}
79
80#[cfg(target_os = "fuchsia")]
81impl fidl::endpoints::SynchronousProxy for FactoryDeviceSynchronousProxy {
82    type Proxy = FactoryDeviceProxy;
83    type Protocol = FactoryDeviceMarker;
84
85    fn from_channel(inner: fidl::Channel) -> Self {
86        Self::new(inner)
87    }
88
89    fn into_channel(self) -> fidl::Channel {
90        self.client.into_channel()
91    }
92
93    fn as_channel(&self) -> &fidl::Channel {
94        self.client.as_channel()
95    }
96}
97
98#[cfg(target_os = "fuchsia")]
99impl FactoryDeviceSynchronousProxy {
100    pub fn new(channel: fidl::Channel) -> Self {
101        let protocol_name = <FactoryDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
102        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
103    }
104
105    pub fn into_channel(self) -> fidl::Channel {
106        self.client.into_channel()
107    }
108
109    /// Waits until an event arrives and returns it. It is safe for other
110    /// threads to make concurrent requests while waiting for an event.
111    pub fn wait_for_event(
112        &self,
113        deadline: zx::MonotonicInstant,
114    ) -> Result<FactoryDeviceEvent, fidl::Error> {
115        FactoryDeviceEvent::decode(self.client.wait_for_event(deadline)?)
116    }
117
118    /// Send a proprietary manufacturing command to the device and return the response.
119    ///
120    /// This method is intended to be used to facilitate device testing on the assembly line and is
121    /// typically only used during device manufacturing.
122    ///
123    /// Commands are given as strings (command + arguments) and the response is also a string. The
124    /// usage and format of the commands is dependent on the firmware on the LoWPAN device.
125    ///
126    /// When finished sending manufacturing commands, call `fuchsia.lowpan.test.DeviceTest.reset()`
127    /// to return the device to normal behavior.
128    pub fn r#send_mfg_command(
129        &self,
130        mut command: &str,
131        ___deadline: zx::MonotonicInstant,
132    ) -> Result<String, fidl::Error> {
133        let _response = self
134            .client
135            .send_query::<FactoryDeviceSendMfgCommandRequest, FactoryDeviceSendMfgCommandResponse>(
136                (command,),
137                0x61ea2fba8c9fb7,
138                fidl::encoding::DynamicFlags::empty(),
139                ___deadline,
140            )?;
141        Ok(_response.response)
142    }
143
144    /// Send proprietary manufacturing commands to the device and return the response.
145    ///
146    /// This method is intended to send the exact same set of commands as SendMfgCommand(), but
147    /// instead of sending one command at a time, this method opens an opens an interactive shell
148    /// operated over `server_socket`.
149    pub fn r#setup_ot_cli(
150        &self,
151        mut server_socket: fidl::Socket,
152        ___deadline: zx::MonotonicInstant,
153    ) -> Result<(), fidl::Error> {
154        let _response = self
155            .client
156            .send_query::<FactoryDeviceSetupOtCliRequest, fidl::encoding::EmptyPayload>(
157                (server_socket,),
158                0x6a2b94d0a72e1663,
159                fidl::encoding::DynamicFlags::empty(),
160                ___deadline,
161            )?;
162        Ok(_response)
163    }
164}
165
166#[cfg(target_os = "fuchsia")]
167impl From<FactoryDeviceSynchronousProxy> for zx::NullableHandle {
168    fn from(value: FactoryDeviceSynchronousProxy) -> Self {
169        value.into_channel().into()
170    }
171}
172
173#[cfg(target_os = "fuchsia")]
174impl From<fidl::Channel> for FactoryDeviceSynchronousProxy {
175    fn from(value: fidl::Channel) -> Self {
176        Self::new(value)
177    }
178}
179
180#[cfg(target_os = "fuchsia")]
181impl fidl::endpoints::FromClient for FactoryDeviceSynchronousProxy {
182    type Protocol = FactoryDeviceMarker;
183
184    fn from_client(value: fidl::endpoints::ClientEnd<FactoryDeviceMarker>) -> Self {
185        Self::new(value.into_channel())
186    }
187}
188
189#[derive(Debug, Clone)]
190pub struct FactoryDeviceProxy {
191    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
192}
193
194impl fidl::endpoints::Proxy for FactoryDeviceProxy {
195    type Protocol = FactoryDeviceMarker;
196
197    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
198        Self::new(inner)
199    }
200
201    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
202        self.client.into_channel().map_err(|client| Self { client })
203    }
204
205    fn as_channel(&self) -> &::fidl::AsyncChannel {
206        self.client.as_channel()
207    }
208}
209
210impl FactoryDeviceProxy {
211    /// Create a new Proxy for fuchsia.factory.lowpan/FactoryDevice.
212    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
213        let protocol_name = <FactoryDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
214        Self { client: fidl::client::Client::new(channel, protocol_name) }
215    }
216
217    /// Get a Stream of events from the remote end of the protocol.
218    ///
219    /// # Panics
220    ///
221    /// Panics if the event stream was already taken.
222    pub fn take_event_stream(&self) -> FactoryDeviceEventStream {
223        FactoryDeviceEventStream { event_receiver: self.client.take_event_receiver() }
224    }
225
226    /// Send a proprietary manufacturing command to the device and return the response.
227    ///
228    /// This method is intended to be used to facilitate device testing on the assembly line and is
229    /// typically only used during device manufacturing.
230    ///
231    /// Commands are given as strings (command + arguments) and the response is also a string. The
232    /// usage and format of the commands is dependent on the firmware on the LoWPAN device.
233    ///
234    /// When finished sending manufacturing commands, call `fuchsia.lowpan.test.DeviceTest.reset()`
235    /// to return the device to normal behavior.
236    pub fn r#send_mfg_command(
237        &self,
238        mut command: &str,
239    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
240        FactoryDeviceProxyInterface::r#send_mfg_command(self, command)
241    }
242
243    /// Send proprietary manufacturing commands to the device and return the response.
244    ///
245    /// This method is intended to send the exact same set of commands as SendMfgCommand(), but
246    /// instead of sending one command at a time, this method opens an opens an interactive shell
247    /// operated over `server_socket`.
248    pub fn r#setup_ot_cli(
249        &self,
250        mut server_socket: fidl::Socket,
251    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
252        FactoryDeviceProxyInterface::r#setup_ot_cli(self, server_socket)
253    }
254}
255
256impl FactoryDeviceProxyInterface for FactoryDeviceProxy {
257    type SendMfgCommandResponseFut =
258        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
259    fn r#send_mfg_command(&self, mut command: &str) -> Self::SendMfgCommandResponseFut {
260        fn _decode(
261            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
262        ) -> Result<String, fidl::Error> {
263            let _response = fidl::client::decode_transaction_body::<
264                FactoryDeviceSendMfgCommandResponse,
265                fidl::encoding::DefaultFuchsiaResourceDialect,
266                0x61ea2fba8c9fb7,
267            >(_buf?)?;
268            Ok(_response.response)
269        }
270        self.client.send_query_and_decode::<FactoryDeviceSendMfgCommandRequest, String>(
271            (command,),
272            0x61ea2fba8c9fb7,
273            fidl::encoding::DynamicFlags::empty(),
274            _decode,
275        )
276    }
277
278    type SetupOtCliResponseFut =
279        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
280    fn r#setup_ot_cli(&self, mut server_socket: fidl::Socket) -> Self::SetupOtCliResponseFut {
281        fn _decode(
282            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
283        ) -> Result<(), fidl::Error> {
284            let _response = fidl::client::decode_transaction_body::<
285                fidl::encoding::EmptyPayload,
286                fidl::encoding::DefaultFuchsiaResourceDialect,
287                0x6a2b94d0a72e1663,
288            >(_buf?)?;
289            Ok(_response)
290        }
291        self.client.send_query_and_decode::<FactoryDeviceSetupOtCliRequest, ()>(
292            (server_socket,),
293            0x6a2b94d0a72e1663,
294            fidl::encoding::DynamicFlags::empty(),
295            _decode,
296        )
297    }
298}
299
300pub struct FactoryDeviceEventStream {
301    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
302}
303
304impl std::marker::Unpin for FactoryDeviceEventStream {}
305
306impl futures::stream::FusedStream for FactoryDeviceEventStream {
307    fn is_terminated(&self) -> bool {
308        self.event_receiver.is_terminated()
309    }
310}
311
312impl futures::Stream for FactoryDeviceEventStream {
313    type Item = Result<FactoryDeviceEvent, fidl::Error>;
314
315    fn poll_next(
316        mut self: std::pin::Pin<&mut Self>,
317        cx: &mut std::task::Context<'_>,
318    ) -> std::task::Poll<Option<Self::Item>> {
319        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
320            &mut self.event_receiver,
321            cx
322        )?) {
323            Some(buf) => std::task::Poll::Ready(Some(FactoryDeviceEvent::decode(buf))),
324            None => std::task::Poll::Ready(None),
325        }
326    }
327}
328
329#[derive(Debug)]
330pub enum FactoryDeviceEvent {}
331
332impl FactoryDeviceEvent {
333    /// Decodes a message buffer as a [`FactoryDeviceEvent`].
334    fn decode(
335        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
336    ) -> Result<FactoryDeviceEvent, fidl::Error> {
337        let (bytes, _handles) = buf.split_mut();
338        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
339        debug_assert_eq!(tx_header.tx_id, 0);
340        match tx_header.ordinal {
341            _ => Err(fidl::Error::UnknownOrdinal {
342                ordinal: tx_header.ordinal,
343                protocol_name: <FactoryDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
344            }),
345        }
346    }
347}
348
349/// A Stream of incoming requests for fuchsia.factory.lowpan/FactoryDevice.
350pub struct FactoryDeviceRequestStream {
351    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
352    is_terminated: bool,
353}
354
355impl std::marker::Unpin for FactoryDeviceRequestStream {}
356
357impl futures::stream::FusedStream for FactoryDeviceRequestStream {
358    fn is_terminated(&self) -> bool {
359        self.is_terminated
360    }
361}
362
363impl fidl::endpoints::RequestStream for FactoryDeviceRequestStream {
364    type Protocol = FactoryDeviceMarker;
365    type ControlHandle = FactoryDeviceControlHandle;
366
367    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
368        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
369    }
370
371    fn control_handle(&self) -> Self::ControlHandle {
372        FactoryDeviceControlHandle { inner: self.inner.clone() }
373    }
374
375    fn into_inner(
376        self,
377    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
378    {
379        (self.inner, self.is_terminated)
380    }
381
382    fn from_inner(
383        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
384        is_terminated: bool,
385    ) -> Self {
386        Self { inner, is_terminated }
387    }
388}
389
390impl futures::Stream for FactoryDeviceRequestStream {
391    type Item = Result<FactoryDeviceRequest, fidl::Error>;
392
393    fn poll_next(
394        mut self: std::pin::Pin<&mut Self>,
395        cx: &mut std::task::Context<'_>,
396    ) -> std::task::Poll<Option<Self::Item>> {
397        let this = &mut *self;
398        if this.inner.check_shutdown(cx) {
399            this.is_terminated = true;
400            return std::task::Poll::Ready(None);
401        }
402        if this.is_terminated {
403            panic!("polled FactoryDeviceRequestStream after completion");
404        }
405        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
406            |bytes, handles| {
407                match this.inner.channel().read_etc(cx, bytes, handles) {
408                    std::task::Poll::Ready(Ok(())) => {}
409                    std::task::Poll::Pending => return std::task::Poll::Pending,
410                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
411                        this.is_terminated = true;
412                        return std::task::Poll::Ready(None);
413                    }
414                    std::task::Poll::Ready(Err(e)) => {
415                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
416                            e.into(),
417                        ))));
418                    }
419                }
420
421                // A message has been received from the channel
422                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
423
424                std::task::Poll::Ready(Some(match header.ordinal {
425                    0x61ea2fba8c9fb7 => {
426                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
427                        let mut req = fidl::new_empty!(
428                            FactoryDeviceSendMfgCommandRequest,
429                            fidl::encoding::DefaultFuchsiaResourceDialect
430                        );
431                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryDeviceSendMfgCommandRequest>(&header, _body_bytes, handles, &mut req)?;
432                        let control_handle =
433                            FactoryDeviceControlHandle { inner: this.inner.clone() };
434                        Ok(FactoryDeviceRequest::SendMfgCommand {
435                            command: req.command,
436
437                            responder: FactoryDeviceSendMfgCommandResponder {
438                                control_handle: std::mem::ManuallyDrop::new(control_handle),
439                                tx_id: header.tx_id,
440                            },
441                        })
442                    }
443                    0x6a2b94d0a72e1663 => {
444                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
445                        let mut req = fidl::new_empty!(
446                            FactoryDeviceSetupOtCliRequest,
447                            fidl::encoding::DefaultFuchsiaResourceDialect
448                        );
449                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryDeviceSetupOtCliRequest>(&header, _body_bytes, handles, &mut req)?;
450                        let control_handle =
451                            FactoryDeviceControlHandle { inner: this.inner.clone() };
452                        Ok(FactoryDeviceRequest::SetupOtCli {
453                            server_socket: req.server_socket,
454
455                            responder: FactoryDeviceSetupOtCliResponder {
456                                control_handle: std::mem::ManuallyDrop::new(control_handle),
457                                tx_id: header.tx_id,
458                            },
459                        })
460                    }
461                    _ => Err(fidl::Error::UnknownOrdinal {
462                        ordinal: header.ordinal,
463                        protocol_name:
464                            <FactoryDeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
465                    }),
466                }))
467            },
468        )
469    }
470}
471
472/// Protocol for sending factory commands to a LoWPAN device.
473///
474/// Not to be confused with `FactoryDriver`.
475///
476/// This protocol is implemented by LoWPAN drivers and used by client tools that need to issue
477/// factory commands. It is obtained from calling `FactoryLookup.Lookup()`.
478#[derive(Debug)]
479pub enum FactoryDeviceRequest {
480    /// Send a proprietary manufacturing command to the device and return the response.
481    ///
482    /// This method is intended to be used to facilitate device testing on the assembly line and is
483    /// typically only used during device manufacturing.
484    ///
485    /// Commands are given as strings (command + arguments) and the response is also a string. The
486    /// usage and format of the commands is dependent on the firmware on the LoWPAN device.
487    ///
488    /// When finished sending manufacturing commands, call `fuchsia.lowpan.test.DeviceTest.reset()`
489    /// to return the device to normal behavior.
490    SendMfgCommand { command: String, responder: FactoryDeviceSendMfgCommandResponder },
491    /// Send proprietary manufacturing commands to the device and return the response.
492    ///
493    /// This method is intended to send the exact same set of commands as SendMfgCommand(), but
494    /// instead of sending one command at a time, this method opens an opens an interactive shell
495    /// operated over `server_socket`.
496    SetupOtCli { server_socket: fidl::Socket, responder: FactoryDeviceSetupOtCliResponder },
497}
498
499impl FactoryDeviceRequest {
500    #[allow(irrefutable_let_patterns)]
501    pub fn into_send_mfg_command(self) -> Option<(String, FactoryDeviceSendMfgCommandResponder)> {
502        if let FactoryDeviceRequest::SendMfgCommand { command, responder } = self {
503            Some((command, responder))
504        } else {
505            None
506        }
507    }
508
509    #[allow(irrefutable_let_patterns)]
510    pub fn into_setup_ot_cli(self) -> Option<(fidl::Socket, FactoryDeviceSetupOtCliResponder)> {
511        if let FactoryDeviceRequest::SetupOtCli { server_socket, responder } = self {
512            Some((server_socket, responder))
513        } else {
514            None
515        }
516    }
517
518    /// Name of the method defined in FIDL
519    pub fn method_name(&self) -> &'static str {
520        match *self {
521            FactoryDeviceRequest::SendMfgCommand { .. } => "send_mfg_command",
522            FactoryDeviceRequest::SetupOtCli { .. } => "setup_ot_cli",
523        }
524    }
525}
526
527#[derive(Debug, Clone)]
528pub struct FactoryDeviceControlHandle {
529    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
530}
531
532impl fidl::endpoints::ControlHandle for FactoryDeviceControlHandle {
533    fn shutdown(&self) {
534        self.inner.shutdown()
535    }
536
537    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
538        self.inner.shutdown_with_epitaph(status)
539    }
540
541    fn is_closed(&self) -> bool {
542        self.inner.channel().is_closed()
543    }
544    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
545        self.inner.channel().on_closed()
546    }
547
548    #[cfg(target_os = "fuchsia")]
549    fn signal_peer(
550        &self,
551        clear_mask: zx::Signals,
552        set_mask: zx::Signals,
553    ) -> Result<(), zx_status::Status> {
554        use fidl::Peered;
555        self.inner.channel().signal_peer(clear_mask, set_mask)
556    }
557}
558
559impl FactoryDeviceControlHandle {}
560
561#[must_use = "FIDL methods require a response to be sent"]
562#[derive(Debug)]
563pub struct FactoryDeviceSendMfgCommandResponder {
564    control_handle: std::mem::ManuallyDrop<FactoryDeviceControlHandle>,
565    tx_id: u32,
566}
567
568/// Set the the channel to be shutdown (see [`FactoryDeviceControlHandle::shutdown`])
569/// if the responder is dropped without sending a response, so that the client
570/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
571impl std::ops::Drop for FactoryDeviceSendMfgCommandResponder {
572    fn drop(&mut self) {
573        self.control_handle.shutdown();
574        // Safety: drops once, never accessed again
575        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
576    }
577}
578
579impl fidl::endpoints::Responder for FactoryDeviceSendMfgCommandResponder {
580    type ControlHandle = FactoryDeviceControlHandle;
581
582    fn control_handle(&self) -> &FactoryDeviceControlHandle {
583        &self.control_handle
584    }
585
586    fn drop_without_shutdown(mut self) {
587        // Safety: drops once, never accessed again due to mem::forget
588        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
589        // Prevent Drop from running (which would shut down the channel)
590        std::mem::forget(self);
591    }
592}
593
594impl FactoryDeviceSendMfgCommandResponder {
595    /// Sends a response to the FIDL transaction.
596    ///
597    /// Sets the channel to shutdown if an error occurs.
598    pub fn send(self, mut response: &str) -> Result<(), fidl::Error> {
599        let _result = self.send_raw(response);
600        if _result.is_err() {
601            self.control_handle.shutdown();
602        }
603        self.drop_without_shutdown();
604        _result
605    }
606
607    /// Similar to "send" but does not shutdown the channel if an error occurs.
608    pub fn send_no_shutdown_on_err(self, mut response: &str) -> Result<(), fidl::Error> {
609        let _result = self.send_raw(response);
610        self.drop_without_shutdown();
611        _result
612    }
613
614    fn send_raw(&self, mut response: &str) -> Result<(), fidl::Error> {
615        self.control_handle.inner.send::<FactoryDeviceSendMfgCommandResponse>(
616            (response,),
617            self.tx_id,
618            0x61ea2fba8c9fb7,
619            fidl::encoding::DynamicFlags::empty(),
620        )
621    }
622}
623
624#[must_use = "FIDL methods require a response to be sent"]
625#[derive(Debug)]
626pub struct FactoryDeviceSetupOtCliResponder {
627    control_handle: std::mem::ManuallyDrop<FactoryDeviceControlHandle>,
628    tx_id: u32,
629}
630
631/// Set the the channel to be shutdown (see [`FactoryDeviceControlHandle::shutdown`])
632/// if the responder is dropped without sending a response, so that the client
633/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
634impl std::ops::Drop for FactoryDeviceSetupOtCliResponder {
635    fn drop(&mut self) {
636        self.control_handle.shutdown();
637        // Safety: drops once, never accessed again
638        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
639    }
640}
641
642impl fidl::endpoints::Responder for FactoryDeviceSetupOtCliResponder {
643    type ControlHandle = FactoryDeviceControlHandle;
644
645    fn control_handle(&self) -> &FactoryDeviceControlHandle {
646        &self.control_handle
647    }
648
649    fn drop_without_shutdown(mut self) {
650        // Safety: drops once, never accessed again due to mem::forget
651        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
652        // Prevent Drop from running (which would shut down the channel)
653        std::mem::forget(self);
654    }
655}
656
657impl FactoryDeviceSetupOtCliResponder {
658    /// Sends a response to the FIDL transaction.
659    ///
660    /// Sets the channel to shutdown if an error occurs.
661    pub fn send(self) -> Result<(), fidl::Error> {
662        let _result = self.send_raw();
663        if _result.is_err() {
664            self.control_handle.shutdown();
665        }
666        self.drop_without_shutdown();
667        _result
668    }
669
670    /// Similar to "send" but does not shutdown the channel if an error occurs.
671    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
672        let _result = self.send_raw();
673        self.drop_without_shutdown();
674        _result
675    }
676
677    fn send_raw(&self) -> Result<(), fidl::Error> {
678        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
679            (),
680            self.tx_id,
681            0x6a2b94d0a72e1663,
682            fidl::encoding::DynamicFlags::empty(),
683        )
684    }
685}
686
687#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
688pub struct FactoryDriverMarker;
689
690impl fidl::endpoints::ProtocolMarker for FactoryDriverMarker {
691    type Proxy = FactoryDriverProxy;
692    type RequestStream = FactoryDriverRequestStream;
693    #[cfg(target_os = "fuchsia")]
694    type SynchronousProxy = FactoryDriverSynchronousProxy;
695
696    const DEBUG_NAME: &'static str = "(anonymous) FactoryDriver";
697}
698
699pub trait FactoryDriverProxyInterface: Send + Sync {
700    fn r#get_factory_device(
701        &self,
702        device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
703    ) -> Result<(), fidl::Error>;
704}
705#[derive(Debug)]
706#[cfg(target_os = "fuchsia")]
707pub struct FactoryDriverSynchronousProxy {
708    client: fidl::client::sync::Client,
709}
710
711#[cfg(target_os = "fuchsia")]
712impl fidl::endpoints::SynchronousProxy for FactoryDriverSynchronousProxy {
713    type Proxy = FactoryDriverProxy;
714    type Protocol = FactoryDriverMarker;
715
716    fn from_channel(inner: fidl::Channel) -> Self {
717        Self::new(inner)
718    }
719
720    fn into_channel(self) -> fidl::Channel {
721        self.client.into_channel()
722    }
723
724    fn as_channel(&self) -> &fidl::Channel {
725        self.client.as_channel()
726    }
727}
728
729#[cfg(target_os = "fuchsia")]
730impl FactoryDriverSynchronousProxy {
731    pub fn new(channel: fidl::Channel) -> Self {
732        let protocol_name = <FactoryDriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
733        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
734    }
735
736    pub fn into_channel(self) -> fidl::Channel {
737        self.client.into_channel()
738    }
739
740    /// Waits until an event arrives and returns it. It is safe for other
741    /// threads to make concurrent requests while waiting for an event.
742    pub fn wait_for_event(
743        &self,
744        deadline: zx::MonotonicInstant,
745    ) -> Result<FactoryDriverEvent, fidl::Error> {
746        FactoryDriverEvent::decode(self.client.wait_for_event(deadline)?)
747    }
748
749    /// Used to obtain a `FactoryDevice` protocol instance.
750    pub fn r#get_factory_device(
751        &self,
752        mut device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
753    ) -> Result<(), fidl::Error> {
754        self.client.send::<FactoryDriverGetFactoryDeviceRequest>(
755            (device_factory,),
756            0x7b3a42b6d35a7e1d,
757            fidl::encoding::DynamicFlags::empty(),
758        )
759    }
760}
761
762#[cfg(target_os = "fuchsia")]
763impl From<FactoryDriverSynchronousProxy> for zx::NullableHandle {
764    fn from(value: FactoryDriverSynchronousProxy) -> Self {
765        value.into_channel().into()
766    }
767}
768
769#[cfg(target_os = "fuchsia")]
770impl From<fidl::Channel> for FactoryDriverSynchronousProxy {
771    fn from(value: fidl::Channel) -> Self {
772        Self::new(value)
773    }
774}
775
776#[cfg(target_os = "fuchsia")]
777impl fidl::endpoints::FromClient for FactoryDriverSynchronousProxy {
778    type Protocol = FactoryDriverMarker;
779
780    fn from_client(value: fidl::endpoints::ClientEnd<FactoryDriverMarker>) -> Self {
781        Self::new(value.into_channel())
782    }
783}
784
785#[derive(Debug, Clone)]
786pub struct FactoryDriverProxy {
787    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
788}
789
790impl fidl::endpoints::Proxy for FactoryDriverProxy {
791    type Protocol = FactoryDriverMarker;
792
793    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
794        Self::new(inner)
795    }
796
797    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
798        self.client.into_channel().map_err(|client| Self { client })
799    }
800
801    fn as_channel(&self) -> &::fidl::AsyncChannel {
802        self.client.as_channel()
803    }
804}
805
806impl FactoryDriverProxy {
807    /// Create a new Proxy for fuchsia.factory.lowpan/FactoryDriver.
808    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
809        let protocol_name = <FactoryDriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
810        Self { client: fidl::client::Client::new(channel, protocol_name) }
811    }
812
813    /// Get a Stream of events from the remote end of the protocol.
814    ///
815    /// # Panics
816    ///
817    /// Panics if the event stream was already taken.
818    pub fn take_event_stream(&self) -> FactoryDriverEventStream {
819        FactoryDriverEventStream { event_receiver: self.client.take_event_receiver() }
820    }
821
822    /// Used to obtain a `FactoryDevice` protocol instance.
823    pub fn r#get_factory_device(
824        &self,
825        mut device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
826    ) -> Result<(), fidl::Error> {
827        FactoryDriverProxyInterface::r#get_factory_device(self, device_factory)
828    }
829}
830
831impl FactoryDriverProxyInterface for FactoryDriverProxy {
832    fn r#get_factory_device(
833        &self,
834        mut device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
835    ) -> Result<(), fidl::Error> {
836        self.client.send::<FactoryDriverGetFactoryDeviceRequest>(
837            (device_factory,),
838            0x7b3a42b6d35a7e1d,
839            fidl::encoding::DynamicFlags::empty(),
840        )
841    }
842}
843
844pub struct FactoryDriverEventStream {
845    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
846}
847
848impl std::marker::Unpin for FactoryDriverEventStream {}
849
850impl futures::stream::FusedStream for FactoryDriverEventStream {
851    fn is_terminated(&self) -> bool {
852        self.event_receiver.is_terminated()
853    }
854}
855
856impl futures::Stream for FactoryDriverEventStream {
857    type Item = Result<FactoryDriverEvent, fidl::Error>;
858
859    fn poll_next(
860        mut self: std::pin::Pin<&mut Self>,
861        cx: &mut std::task::Context<'_>,
862    ) -> std::task::Poll<Option<Self::Item>> {
863        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
864            &mut self.event_receiver,
865            cx
866        )?) {
867            Some(buf) => std::task::Poll::Ready(Some(FactoryDriverEvent::decode(buf))),
868            None => std::task::Poll::Ready(None),
869        }
870    }
871}
872
873#[derive(Debug)]
874pub enum FactoryDriverEvent {}
875
876impl FactoryDriverEvent {
877    /// Decodes a message buffer as a [`FactoryDriverEvent`].
878    fn decode(
879        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
880    ) -> Result<FactoryDriverEvent, fidl::Error> {
881        let (bytes, _handles) = buf.split_mut();
882        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
883        debug_assert_eq!(tx_header.tx_id, 0);
884        match tx_header.ordinal {
885            _ => Err(fidl::Error::UnknownOrdinal {
886                ordinal: tx_header.ordinal,
887                protocol_name: <FactoryDriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
888            }),
889        }
890    }
891}
892
893/// A Stream of incoming requests for fuchsia.factory.lowpan/FactoryDriver.
894pub struct FactoryDriverRequestStream {
895    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
896    is_terminated: bool,
897}
898
899impl std::marker::Unpin for FactoryDriverRequestStream {}
900
901impl futures::stream::FusedStream for FactoryDriverRequestStream {
902    fn is_terminated(&self) -> bool {
903        self.is_terminated
904    }
905}
906
907impl fidl::endpoints::RequestStream for FactoryDriverRequestStream {
908    type Protocol = FactoryDriverMarker;
909    type ControlHandle = FactoryDriverControlHandle;
910
911    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
912        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
913    }
914
915    fn control_handle(&self) -> Self::ControlHandle {
916        FactoryDriverControlHandle { inner: self.inner.clone() }
917    }
918
919    fn into_inner(
920        self,
921    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
922    {
923        (self.inner, self.is_terminated)
924    }
925
926    fn from_inner(
927        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
928        is_terminated: bool,
929    ) -> Self {
930        Self { inner, is_terminated }
931    }
932}
933
934impl futures::Stream for FactoryDriverRequestStream {
935    type Item = Result<FactoryDriverRequest, fidl::Error>;
936
937    fn poll_next(
938        mut self: std::pin::Pin<&mut Self>,
939        cx: &mut std::task::Context<'_>,
940    ) -> std::task::Poll<Option<Self::Item>> {
941        let this = &mut *self;
942        if this.inner.check_shutdown(cx) {
943            this.is_terminated = true;
944            return std::task::Poll::Ready(None);
945        }
946        if this.is_terminated {
947            panic!("polled FactoryDriverRequestStream after completion");
948        }
949        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
950            |bytes, handles| {
951                match this.inner.channel().read_etc(cx, bytes, handles) {
952                    std::task::Poll::Ready(Ok(())) => {}
953                    std::task::Poll::Pending => return std::task::Poll::Pending,
954                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
955                        this.is_terminated = true;
956                        return std::task::Poll::Ready(None);
957                    }
958                    std::task::Poll::Ready(Err(e)) => {
959                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
960                            e.into(),
961                        ))));
962                    }
963                }
964
965                // A message has been received from the channel
966                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
967
968                std::task::Poll::Ready(Some(match header.ordinal {
969                    0x7b3a42b6d35a7e1d => {
970                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
971                        let mut req = fidl::new_empty!(
972                            FactoryDriverGetFactoryDeviceRequest,
973                            fidl::encoding::DefaultFuchsiaResourceDialect
974                        );
975                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryDriverGetFactoryDeviceRequest>(&header, _body_bytes, handles, &mut req)?;
976                        let control_handle =
977                            FactoryDriverControlHandle { inner: this.inner.clone() };
978                        Ok(FactoryDriverRequest::GetFactoryDevice {
979                            device_factory: req.device_factory,
980
981                            control_handle,
982                        })
983                    }
984                    _ => Err(fidl::Error::UnknownOrdinal {
985                        ordinal: header.ordinal,
986                        protocol_name:
987                            <FactoryDriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
988                    }),
989                }))
990            },
991        )
992    }
993}
994
995/// Protocol representing a LoWPAN driver instance that can serve `FactoryDevice` instances.
996///
997/// Not to be confused with `FactoryDevice`.
998///
999/// This protocol is implemented by LoWPAN drivers and used by the LoWPAN service when
1000/// handling calls to `FactoryLookup.Lookup()`. It is registered with the service via
1001/// a call to `FactoryRegister.Register()`.
1002#[derive(Debug)]
1003pub enum FactoryDriverRequest {
1004    /// Used to obtain a `FactoryDevice` protocol instance.
1005    GetFactoryDevice {
1006        device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
1007        control_handle: FactoryDriverControlHandle,
1008    },
1009}
1010
1011impl FactoryDriverRequest {
1012    #[allow(irrefutable_let_patterns)]
1013    pub fn into_get_factory_device(
1014        self,
1015    ) -> Option<(fidl::endpoints::ServerEnd<FactoryDeviceMarker>, FactoryDriverControlHandle)> {
1016        if let FactoryDriverRequest::GetFactoryDevice { device_factory, control_handle } = self {
1017            Some((device_factory, control_handle))
1018        } else {
1019            None
1020        }
1021    }
1022
1023    /// Name of the method defined in FIDL
1024    pub fn method_name(&self) -> &'static str {
1025        match *self {
1026            FactoryDriverRequest::GetFactoryDevice { .. } => "get_factory_device",
1027        }
1028    }
1029}
1030
1031#[derive(Debug, Clone)]
1032pub struct FactoryDriverControlHandle {
1033    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1034}
1035
1036impl fidl::endpoints::ControlHandle for FactoryDriverControlHandle {
1037    fn shutdown(&self) {
1038        self.inner.shutdown()
1039    }
1040
1041    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1042        self.inner.shutdown_with_epitaph(status)
1043    }
1044
1045    fn is_closed(&self) -> bool {
1046        self.inner.channel().is_closed()
1047    }
1048    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1049        self.inner.channel().on_closed()
1050    }
1051
1052    #[cfg(target_os = "fuchsia")]
1053    fn signal_peer(
1054        &self,
1055        clear_mask: zx::Signals,
1056        set_mask: zx::Signals,
1057    ) -> Result<(), zx_status::Status> {
1058        use fidl::Peered;
1059        self.inner.channel().signal_peer(clear_mask, set_mask)
1060    }
1061}
1062
1063impl FactoryDriverControlHandle {}
1064
1065#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1066pub struct FactoryLookupMarker;
1067
1068impl fidl::endpoints::ProtocolMarker for FactoryLookupMarker {
1069    type Proxy = FactoryLookupProxy;
1070    type RequestStream = FactoryLookupRequestStream;
1071    #[cfg(target_os = "fuchsia")]
1072    type SynchronousProxy = FactoryLookupSynchronousProxy;
1073
1074    const DEBUG_NAME: &'static str = "fuchsia.factory.lowpan.FactoryLookup";
1075}
1076impl fidl::endpoints::DiscoverableProtocolMarker for FactoryLookupMarker {}
1077
1078pub trait FactoryLookupProxyInterface: Send + Sync {
1079    fn r#lookup(
1080        &self,
1081        name: &str,
1082        device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
1083    ) -> Result<(), fidl::Error>;
1084}
1085#[derive(Debug)]
1086#[cfg(target_os = "fuchsia")]
1087pub struct FactoryLookupSynchronousProxy {
1088    client: fidl::client::sync::Client,
1089}
1090
1091#[cfg(target_os = "fuchsia")]
1092impl fidl::endpoints::SynchronousProxy for FactoryLookupSynchronousProxy {
1093    type Proxy = FactoryLookupProxy;
1094    type Protocol = FactoryLookupMarker;
1095
1096    fn from_channel(inner: fidl::Channel) -> Self {
1097        Self::new(inner)
1098    }
1099
1100    fn into_channel(self) -> fidl::Channel {
1101        self.client.into_channel()
1102    }
1103
1104    fn as_channel(&self) -> &fidl::Channel {
1105        self.client.as_channel()
1106    }
1107}
1108
1109#[cfg(target_os = "fuchsia")]
1110impl FactoryLookupSynchronousProxy {
1111    pub fn new(channel: fidl::Channel) -> Self {
1112        let protocol_name = <FactoryLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1113        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1114    }
1115
1116    pub fn into_channel(self) -> fidl::Channel {
1117        self.client.into_channel()
1118    }
1119
1120    /// Waits until an event arrives and returns it. It is safe for other
1121    /// threads to make concurrent requests while waiting for an event.
1122    pub fn wait_for_event(
1123        &self,
1124        deadline: zx::MonotonicInstant,
1125    ) -> Result<FactoryLookupEvent, fidl::Error> {
1126        FactoryLookupEvent::decode(self.client.wait_for_event(deadline)?)
1127    }
1128
1129    /// Connects the the associated `FactoryDevice` API for the given LoWPAN interface name.
1130    pub fn r#lookup(
1131        &self,
1132        mut name: &str,
1133        mut device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
1134    ) -> Result<(), fidl::Error> {
1135        self.client.send::<FactoryLookupLookupRequest>(
1136            (name, device_factory),
1137            0x7b8dc96a8fbf4885,
1138            fidl::encoding::DynamicFlags::empty(),
1139        )
1140    }
1141}
1142
1143#[cfg(target_os = "fuchsia")]
1144impl From<FactoryLookupSynchronousProxy> for zx::NullableHandle {
1145    fn from(value: FactoryLookupSynchronousProxy) -> Self {
1146        value.into_channel().into()
1147    }
1148}
1149
1150#[cfg(target_os = "fuchsia")]
1151impl From<fidl::Channel> for FactoryLookupSynchronousProxy {
1152    fn from(value: fidl::Channel) -> Self {
1153        Self::new(value)
1154    }
1155}
1156
1157#[cfg(target_os = "fuchsia")]
1158impl fidl::endpoints::FromClient for FactoryLookupSynchronousProxy {
1159    type Protocol = FactoryLookupMarker;
1160
1161    fn from_client(value: fidl::endpoints::ClientEnd<FactoryLookupMarker>) -> Self {
1162        Self::new(value.into_channel())
1163    }
1164}
1165
1166#[derive(Debug, Clone)]
1167pub struct FactoryLookupProxy {
1168    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1169}
1170
1171impl fidl::endpoints::Proxy for FactoryLookupProxy {
1172    type Protocol = FactoryLookupMarker;
1173
1174    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1175        Self::new(inner)
1176    }
1177
1178    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1179        self.client.into_channel().map_err(|client| Self { client })
1180    }
1181
1182    fn as_channel(&self) -> &::fidl::AsyncChannel {
1183        self.client.as_channel()
1184    }
1185}
1186
1187impl FactoryLookupProxy {
1188    /// Create a new Proxy for fuchsia.factory.lowpan/FactoryLookup.
1189    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1190        let protocol_name = <FactoryLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1191        Self { client: fidl::client::Client::new(channel, protocol_name) }
1192    }
1193
1194    /// Get a Stream of events from the remote end of the protocol.
1195    ///
1196    /// # Panics
1197    ///
1198    /// Panics if the event stream was already taken.
1199    pub fn take_event_stream(&self) -> FactoryLookupEventStream {
1200        FactoryLookupEventStream { event_receiver: self.client.take_event_receiver() }
1201    }
1202
1203    /// Connects the the associated `FactoryDevice` API for the given LoWPAN interface name.
1204    pub fn r#lookup(
1205        &self,
1206        mut name: &str,
1207        mut device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
1208    ) -> Result<(), fidl::Error> {
1209        FactoryLookupProxyInterface::r#lookup(self, name, device_factory)
1210    }
1211}
1212
1213impl FactoryLookupProxyInterface for FactoryLookupProxy {
1214    fn r#lookup(
1215        &self,
1216        mut name: &str,
1217        mut device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
1218    ) -> Result<(), fidl::Error> {
1219        self.client.send::<FactoryLookupLookupRequest>(
1220            (name, device_factory),
1221            0x7b8dc96a8fbf4885,
1222            fidl::encoding::DynamicFlags::empty(),
1223        )
1224    }
1225}
1226
1227pub struct FactoryLookupEventStream {
1228    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1229}
1230
1231impl std::marker::Unpin for FactoryLookupEventStream {}
1232
1233impl futures::stream::FusedStream for FactoryLookupEventStream {
1234    fn is_terminated(&self) -> bool {
1235        self.event_receiver.is_terminated()
1236    }
1237}
1238
1239impl futures::Stream for FactoryLookupEventStream {
1240    type Item = Result<FactoryLookupEvent, fidl::Error>;
1241
1242    fn poll_next(
1243        mut self: std::pin::Pin<&mut Self>,
1244        cx: &mut std::task::Context<'_>,
1245    ) -> std::task::Poll<Option<Self::Item>> {
1246        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1247            &mut self.event_receiver,
1248            cx
1249        )?) {
1250            Some(buf) => std::task::Poll::Ready(Some(FactoryLookupEvent::decode(buf))),
1251            None => std::task::Poll::Ready(None),
1252        }
1253    }
1254}
1255
1256#[derive(Debug)]
1257pub enum FactoryLookupEvent {}
1258
1259impl FactoryLookupEvent {
1260    /// Decodes a message buffer as a [`FactoryLookupEvent`].
1261    fn decode(
1262        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1263    ) -> Result<FactoryLookupEvent, fidl::Error> {
1264        let (bytes, _handles) = buf.split_mut();
1265        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1266        debug_assert_eq!(tx_header.tx_id, 0);
1267        match tx_header.ordinal {
1268            _ => Err(fidl::Error::UnknownOrdinal {
1269                ordinal: tx_header.ordinal,
1270                protocol_name: <FactoryLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1271            }),
1272        }
1273    }
1274}
1275
1276/// A Stream of incoming requests for fuchsia.factory.lowpan/FactoryLookup.
1277pub struct FactoryLookupRequestStream {
1278    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1279    is_terminated: bool,
1280}
1281
1282impl std::marker::Unpin for FactoryLookupRequestStream {}
1283
1284impl futures::stream::FusedStream for FactoryLookupRequestStream {
1285    fn is_terminated(&self) -> bool {
1286        self.is_terminated
1287    }
1288}
1289
1290impl fidl::endpoints::RequestStream for FactoryLookupRequestStream {
1291    type Protocol = FactoryLookupMarker;
1292    type ControlHandle = FactoryLookupControlHandle;
1293
1294    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1295        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1296    }
1297
1298    fn control_handle(&self) -> Self::ControlHandle {
1299        FactoryLookupControlHandle { inner: self.inner.clone() }
1300    }
1301
1302    fn into_inner(
1303        self,
1304    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1305    {
1306        (self.inner, self.is_terminated)
1307    }
1308
1309    fn from_inner(
1310        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1311        is_terminated: bool,
1312    ) -> Self {
1313        Self { inner, is_terminated }
1314    }
1315}
1316
1317impl futures::Stream for FactoryLookupRequestStream {
1318    type Item = Result<FactoryLookupRequest, fidl::Error>;
1319
1320    fn poll_next(
1321        mut self: std::pin::Pin<&mut Self>,
1322        cx: &mut std::task::Context<'_>,
1323    ) -> std::task::Poll<Option<Self::Item>> {
1324        let this = &mut *self;
1325        if this.inner.check_shutdown(cx) {
1326            this.is_terminated = true;
1327            return std::task::Poll::Ready(None);
1328        }
1329        if this.is_terminated {
1330            panic!("polled FactoryLookupRequestStream after completion");
1331        }
1332        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1333            |bytes, handles| {
1334                match this.inner.channel().read_etc(cx, bytes, handles) {
1335                    std::task::Poll::Ready(Ok(())) => {}
1336                    std::task::Poll::Pending => return std::task::Poll::Pending,
1337                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1338                        this.is_terminated = true;
1339                        return std::task::Poll::Ready(None);
1340                    }
1341                    std::task::Poll::Ready(Err(e)) => {
1342                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1343                            e.into(),
1344                        ))));
1345                    }
1346                }
1347
1348                // A message has been received from the channel
1349                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1350
1351                std::task::Poll::Ready(Some(match header.ordinal {
1352                    0x7b8dc96a8fbf4885 => {
1353                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1354                        let mut req = fidl::new_empty!(
1355                            FactoryLookupLookupRequest,
1356                            fidl::encoding::DefaultFuchsiaResourceDialect
1357                        );
1358                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryLookupLookupRequest>(&header, _body_bytes, handles, &mut req)?;
1359                        let control_handle =
1360                            FactoryLookupControlHandle { inner: this.inner.clone() };
1361                        Ok(FactoryLookupRequest::Lookup {
1362                            name: req.name,
1363                            device_factory: req.device_factory,
1364
1365                            control_handle,
1366                        })
1367                    }
1368                    _ => Err(fidl::Error::UnknownOrdinal {
1369                        ordinal: header.ordinal,
1370                        protocol_name:
1371                            <FactoryLookupMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1372                    }),
1373                }))
1374            },
1375        )
1376    }
1377}
1378
1379/// Protocol for looking up the LoWPAN factory protocol for a LoWPAN interface.
1380///
1381/// This protocol is implemented by the LoWPAN service and used by client tools that need to issue
1382/// factory commands.
1383#[derive(Debug)]
1384pub enum FactoryLookupRequest {
1385    /// Connects the the associated `FactoryDevice` API for the given LoWPAN interface name.
1386    Lookup {
1387        name: String,
1388        device_factory: fidl::endpoints::ServerEnd<FactoryDeviceMarker>,
1389        control_handle: FactoryLookupControlHandle,
1390    },
1391}
1392
1393impl FactoryLookupRequest {
1394    #[allow(irrefutable_let_patterns)]
1395    pub fn into_lookup(
1396        self,
1397    ) -> Option<(String, fidl::endpoints::ServerEnd<FactoryDeviceMarker>, FactoryLookupControlHandle)>
1398    {
1399        if let FactoryLookupRequest::Lookup { name, device_factory, control_handle } = self {
1400            Some((name, device_factory, control_handle))
1401        } else {
1402            None
1403        }
1404    }
1405
1406    /// Name of the method defined in FIDL
1407    pub fn method_name(&self) -> &'static str {
1408        match *self {
1409            FactoryLookupRequest::Lookup { .. } => "lookup",
1410        }
1411    }
1412}
1413
1414#[derive(Debug, Clone)]
1415pub struct FactoryLookupControlHandle {
1416    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1417}
1418
1419impl fidl::endpoints::ControlHandle for FactoryLookupControlHandle {
1420    fn shutdown(&self) {
1421        self.inner.shutdown()
1422    }
1423
1424    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1425        self.inner.shutdown_with_epitaph(status)
1426    }
1427
1428    fn is_closed(&self) -> bool {
1429        self.inner.channel().is_closed()
1430    }
1431    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1432        self.inner.channel().on_closed()
1433    }
1434
1435    #[cfg(target_os = "fuchsia")]
1436    fn signal_peer(
1437        &self,
1438        clear_mask: zx::Signals,
1439        set_mask: zx::Signals,
1440    ) -> Result<(), zx_status::Status> {
1441        use fidl::Peered;
1442        self.inner.channel().signal_peer(clear_mask, set_mask)
1443    }
1444}
1445
1446impl FactoryLookupControlHandle {}
1447
1448#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1449pub struct FactoryRegisterMarker;
1450
1451impl fidl::endpoints::ProtocolMarker for FactoryRegisterMarker {
1452    type Proxy = FactoryRegisterProxy;
1453    type RequestStream = FactoryRegisterRequestStream;
1454    #[cfg(target_os = "fuchsia")]
1455    type SynchronousProxy = FactoryRegisterSynchronousProxy;
1456
1457    const DEBUG_NAME: &'static str = "fuchsia.factory.lowpan.FactoryRegister";
1458}
1459impl fidl::endpoints::DiscoverableProtocolMarker for FactoryRegisterMarker {}
1460
1461pub trait FactoryRegisterProxyInterface: Send + Sync {
1462    fn r#register(
1463        &self,
1464        name: &str,
1465        driver: fidl::endpoints::ClientEnd<FactoryDriverMarker>,
1466    ) -> Result<(), fidl::Error>;
1467}
1468#[derive(Debug)]
1469#[cfg(target_os = "fuchsia")]
1470pub struct FactoryRegisterSynchronousProxy {
1471    client: fidl::client::sync::Client,
1472}
1473
1474#[cfg(target_os = "fuchsia")]
1475impl fidl::endpoints::SynchronousProxy for FactoryRegisterSynchronousProxy {
1476    type Proxy = FactoryRegisterProxy;
1477    type Protocol = FactoryRegisterMarker;
1478
1479    fn from_channel(inner: fidl::Channel) -> Self {
1480        Self::new(inner)
1481    }
1482
1483    fn into_channel(self) -> fidl::Channel {
1484        self.client.into_channel()
1485    }
1486
1487    fn as_channel(&self) -> &fidl::Channel {
1488        self.client.as_channel()
1489    }
1490}
1491
1492#[cfg(target_os = "fuchsia")]
1493impl FactoryRegisterSynchronousProxy {
1494    pub fn new(channel: fidl::Channel) -> Self {
1495        let protocol_name = <FactoryRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1496        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
1497    }
1498
1499    pub fn into_channel(self) -> fidl::Channel {
1500        self.client.into_channel()
1501    }
1502
1503    /// Waits until an event arrives and returns it. It is safe for other
1504    /// threads to make concurrent requests while waiting for an event.
1505    pub fn wait_for_event(
1506        &self,
1507        deadline: zx::MonotonicInstant,
1508    ) -> Result<FactoryRegisterEvent, fidl::Error> {
1509        FactoryRegisterEvent::decode(self.client.wait_for_event(deadline)?)
1510    }
1511
1512    /// Registers the given LoWPAN device factory API with the LoWPAN Service
1513    /// using the given interface name.
1514    ///
1515    /// The provided `FactoryDriver` will be used to connect requests made via
1516    /// `FactoryLookup.Lookup()` for `FactoryDevice`.
1517    pub fn r#register(
1518        &self,
1519        mut name: &str,
1520        mut driver: fidl::endpoints::ClientEnd<FactoryDriverMarker>,
1521    ) -> Result<(), fidl::Error> {
1522        self.client.send::<FactoryRegisterRegisterRequest>(
1523            (name, driver),
1524            0x1d167c20bdcccf1f,
1525            fidl::encoding::DynamicFlags::empty(),
1526        )
1527    }
1528}
1529
1530#[cfg(target_os = "fuchsia")]
1531impl From<FactoryRegisterSynchronousProxy> for zx::NullableHandle {
1532    fn from(value: FactoryRegisterSynchronousProxy) -> Self {
1533        value.into_channel().into()
1534    }
1535}
1536
1537#[cfg(target_os = "fuchsia")]
1538impl From<fidl::Channel> for FactoryRegisterSynchronousProxy {
1539    fn from(value: fidl::Channel) -> Self {
1540        Self::new(value)
1541    }
1542}
1543
1544#[cfg(target_os = "fuchsia")]
1545impl fidl::endpoints::FromClient for FactoryRegisterSynchronousProxy {
1546    type Protocol = FactoryRegisterMarker;
1547
1548    fn from_client(value: fidl::endpoints::ClientEnd<FactoryRegisterMarker>) -> Self {
1549        Self::new(value.into_channel())
1550    }
1551}
1552
1553#[derive(Debug, Clone)]
1554pub struct FactoryRegisterProxy {
1555    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1556}
1557
1558impl fidl::endpoints::Proxy for FactoryRegisterProxy {
1559    type Protocol = FactoryRegisterMarker;
1560
1561    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1562        Self::new(inner)
1563    }
1564
1565    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1566        self.client.into_channel().map_err(|client| Self { client })
1567    }
1568
1569    fn as_channel(&self) -> &::fidl::AsyncChannel {
1570        self.client.as_channel()
1571    }
1572}
1573
1574impl FactoryRegisterProxy {
1575    /// Create a new Proxy for fuchsia.factory.lowpan/FactoryRegister.
1576    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1577        let protocol_name = <FactoryRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1578        Self { client: fidl::client::Client::new(channel, protocol_name) }
1579    }
1580
1581    /// Get a Stream of events from the remote end of the protocol.
1582    ///
1583    /// # Panics
1584    ///
1585    /// Panics if the event stream was already taken.
1586    pub fn take_event_stream(&self) -> FactoryRegisterEventStream {
1587        FactoryRegisterEventStream { event_receiver: self.client.take_event_receiver() }
1588    }
1589
1590    /// Registers the given LoWPAN device factory API with the LoWPAN Service
1591    /// using the given interface name.
1592    ///
1593    /// The provided `FactoryDriver` will be used to connect requests made via
1594    /// `FactoryLookup.Lookup()` for `FactoryDevice`.
1595    pub fn r#register(
1596        &self,
1597        mut name: &str,
1598        mut driver: fidl::endpoints::ClientEnd<FactoryDriverMarker>,
1599    ) -> Result<(), fidl::Error> {
1600        FactoryRegisterProxyInterface::r#register(self, name, driver)
1601    }
1602}
1603
1604impl FactoryRegisterProxyInterface for FactoryRegisterProxy {
1605    fn r#register(
1606        &self,
1607        mut name: &str,
1608        mut driver: fidl::endpoints::ClientEnd<FactoryDriverMarker>,
1609    ) -> Result<(), fidl::Error> {
1610        self.client.send::<FactoryRegisterRegisterRequest>(
1611            (name, driver),
1612            0x1d167c20bdcccf1f,
1613            fidl::encoding::DynamicFlags::empty(),
1614        )
1615    }
1616}
1617
1618pub struct FactoryRegisterEventStream {
1619    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1620}
1621
1622impl std::marker::Unpin for FactoryRegisterEventStream {}
1623
1624impl futures::stream::FusedStream for FactoryRegisterEventStream {
1625    fn is_terminated(&self) -> bool {
1626        self.event_receiver.is_terminated()
1627    }
1628}
1629
1630impl futures::Stream for FactoryRegisterEventStream {
1631    type Item = Result<FactoryRegisterEvent, fidl::Error>;
1632
1633    fn poll_next(
1634        mut self: std::pin::Pin<&mut Self>,
1635        cx: &mut std::task::Context<'_>,
1636    ) -> std::task::Poll<Option<Self::Item>> {
1637        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1638            &mut self.event_receiver,
1639            cx
1640        )?) {
1641            Some(buf) => std::task::Poll::Ready(Some(FactoryRegisterEvent::decode(buf))),
1642            None => std::task::Poll::Ready(None),
1643        }
1644    }
1645}
1646
1647#[derive(Debug)]
1648pub enum FactoryRegisterEvent {}
1649
1650impl FactoryRegisterEvent {
1651    /// Decodes a message buffer as a [`FactoryRegisterEvent`].
1652    fn decode(
1653        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1654    ) -> Result<FactoryRegisterEvent, fidl::Error> {
1655        let (bytes, _handles) = buf.split_mut();
1656        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1657        debug_assert_eq!(tx_header.tx_id, 0);
1658        match tx_header.ordinal {
1659            _ => Err(fidl::Error::UnknownOrdinal {
1660                ordinal: tx_header.ordinal,
1661                protocol_name:
1662                    <FactoryRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1663            }),
1664        }
1665    }
1666}
1667
1668/// A Stream of incoming requests for fuchsia.factory.lowpan/FactoryRegister.
1669pub struct FactoryRegisterRequestStream {
1670    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1671    is_terminated: bool,
1672}
1673
1674impl std::marker::Unpin for FactoryRegisterRequestStream {}
1675
1676impl futures::stream::FusedStream for FactoryRegisterRequestStream {
1677    fn is_terminated(&self) -> bool {
1678        self.is_terminated
1679    }
1680}
1681
1682impl fidl::endpoints::RequestStream for FactoryRegisterRequestStream {
1683    type Protocol = FactoryRegisterMarker;
1684    type ControlHandle = FactoryRegisterControlHandle;
1685
1686    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1687        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1688    }
1689
1690    fn control_handle(&self) -> Self::ControlHandle {
1691        FactoryRegisterControlHandle { inner: self.inner.clone() }
1692    }
1693
1694    fn into_inner(
1695        self,
1696    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1697    {
1698        (self.inner, self.is_terminated)
1699    }
1700
1701    fn from_inner(
1702        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1703        is_terminated: bool,
1704    ) -> Self {
1705        Self { inner, is_terminated }
1706    }
1707}
1708
1709impl futures::Stream for FactoryRegisterRequestStream {
1710    type Item = Result<FactoryRegisterRequest, fidl::Error>;
1711
1712    fn poll_next(
1713        mut self: std::pin::Pin<&mut Self>,
1714        cx: &mut std::task::Context<'_>,
1715    ) -> std::task::Poll<Option<Self::Item>> {
1716        let this = &mut *self;
1717        if this.inner.check_shutdown(cx) {
1718            this.is_terminated = true;
1719            return std::task::Poll::Ready(None);
1720        }
1721        if this.is_terminated {
1722            panic!("polled FactoryRegisterRequestStream after completion");
1723        }
1724        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1725            |bytes, handles| {
1726                match this.inner.channel().read_etc(cx, bytes, handles) {
1727                    std::task::Poll::Ready(Ok(())) => {}
1728                    std::task::Poll::Pending => return std::task::Poll::Pending,
1729                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1730                        this.is_terminated = true;
1731                        return std::task::Poll::Ready(None);
1732                    }
1733                    std::task::Poll::Ready(Err(e)) => {
1734                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1735                            e.into(),
1736                        ))));
1737                    }
1738                }
1739
1740                // A message has been received from the channel
1741                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1742
1743                std::task::Poll::Ready(Some(match header.ordinal {
1744                    0x1d167c20bdcccf1f => {
1745                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
1746                        let mut req = fidl::new_empty!(
1747                            FactoryRegisterRegisterRequest,
1748                            fidl::encoding::DefaultFuchsiaResourceDialect
1749                        );
1750                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<FactoryRegisterRegisterRequest>(&header, _body_bytes, handles, &mut req)?;
1751                        let control_handle =
1752                            FactoryRegisterControlHandle { inner: this.inner.clone() };
1753                        Ok(FactoryRegisterRequest::Register {
1754                            name: req.name,
1755                            driver: req.driver,
1756
1757                            control_handle,
1758                        })
1759                    }
1760                    _ => Err(fidl::Error::UnknownOrdinal {
1761                        ordinal: header.ordinal,
1762                        protocol_name:
1763                            <FactoryRegisterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1764                    }),
1765                }))
1766            },
1767        )
1768    }
1769}
1770
1771/// Protocol for registering the factory instance of a LoWPAN driver with the LoWPAN service.
1772///
1773/// This protocol is implemented by the LoWPAN service and used by LoWPAN drivers.
1774#[derive(Debug)]
1775pub enum FactoryRegisterRequest {
1776    /// Registers the given LoWPAN device factory API with the LoWPAN Service
1777    /// using the given interface name.
1778    ///
1779    /// The provided `FactoryDriver` will be used to connect requests made via
1780    /// `FactoryLookup.Lookup()` for `FactoryDevice`.
1781    Register {
1782        name: String,
1783        driver: fidl::endpoints::ClientEnd<FactoryDriverMarker>,
1784        control_handle: FactoryRegisterControlHandle,
1785    },
1786}
1787
1788impl FactoryRegisterRequest {
1789    #[allow(irrefutable_let_patterns)]
1790    pub fn into_register(
1791        self,
1792    ) -> Option<(
1793        String,
1794        fidl::endpoints::ClientEnd<FactoryDriverMarker>,
1795        FactoryRegisterControlHandle,
1796    )> {
1797        if let FactoryRegisterRequest::Register { name, driver, control_handle } = self {
1798            Some((name, driver, control_handle))
1799        } else {
1800            None
1801        }
1802    }
1803
1804    /// Name of the method defined in FIDL
1805    pub fn method_name(&self) -> &'static str {
1806        match *self {
1807            FactoryRegisterRequest::Register { .. } => "register",
1808        }
1809    }
1810}
1811
1812#[derive(Debug, Clone)]
1813pub struct FactoryRegisterControlHandle {
1814    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1815}
1816
1817impl fidl::endpoints::ControlHandle for FactoryRegisterControlHandle {
1818    fn shutdown(&self) {
1819        self.inner.shutdown()
1820    }
1821
1822    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1823        self.inner.shutdown_with_epitaph(status)
1824    }
1825
1826    fn is_closed(&self) -> bool {
1827        self.inner.channel().is_closed()
1828    }
1829    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1830        self.inner.channel().on_closed()
1831    }
1832
1833    #[cfg(target_os = "fuchsia")]
1834    fn signal_peer(
1835        &self,
1836        clear_mask: zx::Signals,
1837        set_mask: zx::Signals,
1838    ) -> Result<(), zx_status::Status> {
1839        use fidl::Peered;
1840        self.inner.channel().signal_peer(clear_mask, set_mask)
1841    }
1842}
1843
1844impl FactoryRegisterControlHandle {}
1845
1846mod internal {
1847    use super::*;
1848
1849    impl fidl::encoding::ResourceTypeMarker for FactoryDeviceSetupOtCliRequest {
1850        type Borrowed<'a> = &'a mut Self;
1851        fn take_or_borrow<'a>(
1852            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1853        ) -> Self::Borrowed<'a> {
1854            value
1855        }
1856    }
1857
1858    unsafe impl fidl::encoding::TypeMarker for FactoryDeviceSetupOtCliRequest {
1859        type Owned = Self;
1860
1861        #[inline(always)]
1862        fn inline_align(_context: fidl::encoding::Context) -> usize {
1863            4
1864        }
1865
1866        #[inline(always)]
1867        fn inline_size(_context: fidl::encoding::Context) -> usize {
1868            4
1869        }
1870    }
1871
1872    unsafe impl
1873        fidl::encoding::Encode<
1874            FactoryDeviceSetupOtCliRequest,
1875            fidl::encoding::DefaultFuchsiaResourceDialect,
1876        > for &mut FactoryDeviceSetupOtCliRequest
1877    {
1878        #[inline]
1879        unsafe fn encode(
1880            self,
1881            encoder: &mut fidl::encoding::Encoder<
1882                '_,
1883                fidl::encoding::DefaultFuchsiaResourceDialect,
1884            >,
1885            offset: usize,
1886            _depth: fidl::encoding::Depth,
1887        ) -> fidl::Result<()> {
1888            encoder.debug_check_bounds::<FactoryDeviceSetupOtCliRequest>(offset);
1889            // Delegate to tuple encoding.
1890            fidl::encoding::Encode::<
1891                FactoryDeviceSetupOtCliRequest,
1892                fidl::encoding::DefaultFuchsiaResourceDialect,
1893            >::encode(
1894                (<fidl::encoding::HandleType<
1895                    fidl::Socket,
1896                    { fidl::ObjectType::SOCKET.into_raw() },
1897                    16396,
1898                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1899                    &mut self.server_socket
1900                ),),
1901                encoder,
1902                offset,
1903                _depth,
1904            )
1905        }
1906    }
1907    unsafe impl<
1908        T0: fidl::encoding::Encode<
1909                fidl::encoding::HandleType<
1910                    fidl::Socket,
1911                    { fidl::ObjectType::SOCKET.into_raw() },
1912                    16396,
1913                >,
1914                fidl::encoding::DefaultFuchsiaResourceDialect,
1915            >,
1916    >
1917        fidl::encoding::Encode<
1918            FactoryDeviceSetupOtCliRequest,
1919            fidl::encoding::DefaultFuchsiaResourceDialect,
1920        > for (T0,)
1921    {
1922        #[inline]
1923        unsafe fn encode(
1924            self,
1925            encoder: &mut fidl::encoding::Encoder<
1926                '_,
1927                fidl::encoding::DefaultFuchsiaResourceDialect,
1928            >,
1929            offset: usize,
1930            depth: fidl::encoding::Depth,
1931        ) -> fidl::Result<()> {
1932            encoder.debug_check_bounds::<FactoryDeviceSetupOtCliRequest>(offset);
1933            // Zero out padding regions. There's no need to apply masks
1934            // because the unmasked parts will be overwritten by fields.
1935            // Write the fields.
1936            self.0.encode(encoder, offset + 0, depth)?;
1937            Ok(())
1938        }
1939    }
1940
1941    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1942        for FactoryDeviceSetupOtCliRequest
1943    {
1944        #[inline(always)]
1945        fn new_empty() -> Self {
1946            Self {
1947                server_socket: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16396>, fidl::encoding::DefaultFuchsiaResourceDialect),
1948            }
1949        }
1950
1951        #[inline]
1952        unsafe fn decode(
1953            &mut self,
1954            decoder: &mut fidl::encoding::Decoder<
1955                '_,
1956                fidl::encoding::DefaultFuchsiaResourceDialect,
1957            >,
1958            offset: usize,
1959            _depth: fidl::encoding::Depth,
1960        ) -> fidl::Result<()> {
1961            decoder.debug_check_bounds::<Self>(offset);
1962            // Verify that padding bytes are zero.
1963            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 16396>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_socket, decoder, offset + 0, _depth)?;
1964            Ok(())
1965        }
1966    }
1967
1968    impl fidl::encoding::ResourceTypeMarker for FactoryDriverGetFactoryDeviceRequest {
1969        type Borrowed<'a> = &'a mut Self;
1970        fn take_or_borrow<'a>(
1971            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1972        ) -> Self::Borrowed<'a> {
1973            value
1974        }
1975    }
1976
1977    unsafe impl fidl::encoding::TypeMarker for FactoryDriverGetFactoryDeviceRequest {
1978        type Owned = Self;
1979
1980        #[inline(always)]
1981        fn inline_align(_context: fidl::encoding::Context) -> usize {
1982            4
1983        }
1984
1985        #[inline(always)]
1986        fn inline_size(_context: fidl::encoding::Context) -> usize {
1987            4
1988        }
1989    }
1990
1991    unsafe impl
1992        fidl::encoding::Encode<
1993            FactoryDriverGetFactoryDeviceRequest,
1994            fidl::encoding::DefaultFuchsiaResourceDialect,
1995        > for &mut FactoryDriverGetFactoryDeviceRequest
1996    {
1997        #[inline]
1998        unsafe fn encode(
1999            self,
2000            encoder: &mut fidl::encoding::Encoder<
2001                '_,
2002                fidl::encoding::DefaultFuchsiaResourceDialect,
2003            >,
2004            offset: usize,
2005            _depth: fidl::encoding::Depth,
2006        ) -> fidl::Result<()> {
2007            encoder.debug_check_bounds::<FactoryDriverGetFactoryDeviceRequest>(offset);
2008            // Delegate to tuple encoding.
2009            fidl::encoding::Encode::<FactoryDriverGetFactoryDeviceRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2010                (
2011                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device_factory),
2012                ),
2013                encoder, offset, _depth
2014            )
2015        }
2016    }
2017    unsafe impl<
2018        T0: fidl::encoding::Encode<
2019                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>>,
2020                fidl::encoding::DefaultFuchsiaResourceDialect,
2021            >,
2022    >
2023        fidl::encoding::Encode<
2024            FactoryDriverGetFactoryDeviceRequest,
2025            fidl::encoding::DefaultFuchsiaResourceDialect,
2026        > for (T0,)
2027    {
2028        #[inline]
2029        unsafe fn encode(
2030            self,
2031            encoder: &mut fidl::encoding::Encoder<
2032                '_,
2033                fidl::encoding::DefaultFuchsiaResourceDialect,
2034            >,
2035            offset: usize,
2036            depth: fidl::encoding::Depth,
2037        ) -> fidl::Result<()> {
2038            encoder.debug_check_bounds::<FactoryDriverGetFactoryDeviceRequest>(offset);
2039            // Zero out padding regions. There's no need to apply masks
2040            // because the unmasked parts will be overwritten by fields.
2041            // Write the fields.
2042            self.0.encode(encoder, offset + 0, depth)?;
2043            Ok(())
2044        }
2045    }
2046
2047    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2048        for FactoryDriverGetFactoryDeviceRequest
2049    {
2050        #[inline(always)]
2051        fn new_empty() -> Self {
2052            Self {
2053                device_factory: fidl::new_empty!(
2054                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>>,
2055                    fidl::encoding::DefaultFuchsiaResourceDialect
2056                ),
2057            }
2058        }
2059
2060        #[inline]
2061        unsafe fn decode(
2062            &mut self,
2063            decoder: &mut fidl::encoding::Decoder<
2064                '_,
2065                fidl::encoding::DefaultFuchsiaResourceDialect,
2066            >,
2067            offset: usize,
2068            _depth: fidl::encoding::Depth,
2069        ) -> fidl::Result<()> {
2070            decoder.debug_check_bounds::<Self>(offset);
2071            // Verify that padding bytes are zero.
2072            fidl::decode!(
2073                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>>,
2074                fidl::encoding::DefaultFuchsiaResourceDialect,
2075                &mut self.device_factory,
2076                decoder,
2077                offset + 0,
2078                _depth
2079            )?;
2080            Ok(())
2081        }
2082    }
2083
2084    impl fidl::encoding::ResourceTypeMarker for FactoryLookupLookupRequest {
2085        type Borrowed<'a> = &'a mut Self;
2086        fn take_or_borrow<'a>(
2087            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2088        ) -> Self::Borrowed<'a> {
2089            value
2090        }
2091    }
2092
2093    unsafe impl fidl::encoding::TypeMarker for FactoryLookupLookupRequest {
2094        type Owned = Self;
2095
2096        #[inline(always)]
2097        fn inline_align(_context: fidl::encoding::Context) -> usize {
2098            8
2099        }
2100
2101        #[inline(always)]
2102        fn inline_size(_context: fidl::encoding::Context) -> usize {
2103            24
2104        }
2105    }
2106
2107    unsafe impl
2108        fidl::encoding::Encode<
2109            FactoryLookupLookupRequest,
2110            fidl::encoding::DefaultFuchsiaResourceDialect,
2111        > for &mut FactoryLookupLookupRequest
2112    {
2113        #[inline]
2114        unsafe fn encode(
2115            self,
2116            encoder: &mut fidl::encoding::Encoder<
2117                '_,
2118                fidl::encoding::DefaultFuchsiaResourceDialect,
2119            >,
2120            offset: usize,
2121            _depth: fidl::encoding::Depth,
2122        ) -> fidl::Result<()> {
2123            encoder.debug_check_bounds::<FactoryLookupLookupRequest>(offset);
2124            // Delegate to tuple encoding.
2125            fidl::encoding::Encode::<FactoryLookupLookupRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2126                (
2127                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
2128                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.device_factory),
2129                ),
2130                encoder, offset, _depth
2131            )
2132        }
2133    }
2134    unsafe impl<
2135        T0: fidl::encoding::Encode<
2136                fidl::encoding::BoundedString<32>,
2137                fidl::encoding::DefaultFuchsiaResourceDialect,
2138            >,
2139        T1: fidl::encoding::Encode<
2140                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>>,
2141                fidl::encoding::DefaultFuchsiaResourceDialect,
2142            >,
2143    >
2144        fidl::encoding::Encode<
2145            FactoryLookupLookupRequest,
2146            fidl::encoding::DefaultFuchsiaResourceDialect,
2147        > for (T0, T1)
2148    {
2149        #[inline]
2150        unsafe fn encode(
2151            self,
2152            encoder: &mut fidl::encoding::Encoder<
2153                '_,
2154                fidl::encoding::DefaultFuchsiaResourceDialect,
2155            >,
2156            offset: usize,
2157            depth: fidl::encoding::Depth,
2158        ) -> fidl::Result<()> {
2159            encoder.debug_check_bounds::<FactoryLookupLookupRequest>(offset);
2160            // Zero out padding regions. There's no need to apply masks
2161            // because the unmasked parts will be overwritten by fields.
2162            unsafe {
2163                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2164                (ptr as *mut u64).write_unaligned(0);
2165            }
2166            // Write the fields.
2167            self.0.encode(encoder, offset + 0, depth)?;
2168            self.1.encode(encoder, offset + 16, depth)?;
2169            Ok(())
2170        }
2171    }
2172
2173    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2174        for FactoryLookupLookupRequest
2175    {
2176        #[inline(always)]
2177        fn new_empty() -> Self {
2178            Self {
2179                name: fidl::new_empty!(
2180                    fidl::encoding::BoundedString<32>,
2181                    fidl::encoding::DefaultFuchsiaResourceDialect
2182                ),
2183                device_factory: fidl::new_empty!(
2184                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>>,
2185                    fidl::encoding::DefaultFuchsiaResourceDialect
2186                ),
2187            }
2188        }
2189
2190        #[inline]
2191        unsafe fn decode(
2192            &mut self,
2193            decoder: &mut fidl::encoding::Decoder<
2194                '_,
2195                fidl::encoding::DefaultFuchsiaResourceDialect,
2196            >,
2197            offset: usize,
2198            _depth: fidl::encoding::Depth,
2199        ) -> fidl::Result<()> {
2200            decoder.debug_check_bounds::<Self>(offset);
2201            // Verify that padding bytes are zero.
2202            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2203            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2204            let mask = 0xffffffff00000000u64;
2205            let maskedval = padval & mask;
2206            if maskedval != 0 {
2207                return Err(fidl::Error::NonZeroPadding {
2208                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2209                });
2210            }
2211            fidl::decode!(
2212                fidl::encoding::BoundedString<32>,
2213                fidl::encoding::DefaultFuchsiaResourceDialect,
2214                &mut self.name,
2215                decoder,
2216                offset + 0,
2217                _depth
2218            )?;
2219            fidl::decode!(
2220                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<FactoryDeviceMarker>>,
2221                fidl::encoding::DefaultFuchsiaResourceDialect,
2222                &mut self.device_factory,
2223                decoder,
2224                offset + 16,
2225                _depth
2226            )?;
2227            Ok(())
2228        }
2229    }
2230
2231    impl fidl::encoding::ResourceTypeMarker for FactoryRegisterRegisterRequest {
2232        type Borrowed<'a> = &'a mut Self;
2233        fn take_or_borrow<'a>(
2234            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
2235        ) -> Self::Borrowed<'a> {
2236            value
2237        }
2238    }
2239
2240    unsafe impl fidl::encoding::TypeMarker for FactoryRegisterRegisterRequest {
2241        type Owned = Self;
2242
2243        #[inline(always)]
2244        fn inline_align(_context: fidl::encoding::Context) -> usize {
2245            8
2246        }
2247
2248        #[inline(always)]
2249        fn inline_size(_context: fidl::encoding::Context) -> usize {
2250            24
2251        }
2252    }
2253
2254    unsafe impl
2255        fidl::encoding::Encode<
2256            FactoryRegisterRegisterRequest,
2257            fidl::encoding::DefaultFuchsiaResourceDialect,
2258        > for &mut FactoryRegisterRegisterRequest
2259    {
2260        #[inline]
2261        unsafe fn encode(
2262            self,
2263            encoder: &mut fidl::encoding::Encoder<
2264                '_,
2265                fidl::encoding::DefaultFuchsiaResourceDialect,
2266            >,
2267            offset: usize,
2268            _depth: fidl::encoding::Depth,
2269        ) -> fidl::Result<()> {
2270            encoder.debug_check_bounds::<FactoryRegisterRegisterRequest>(offset);
2271            // Delegate to tuple encoding.
2272            fidl::encoding::Encode::<FactoryRegisterRegisterRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
2273                (
2274                    <fidl::encoding::BoundedString<32> as fidl::encoding::ValueTypeMarker>::borrow(&self.name),
2275                    <fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FactoryDriverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.driver),
2276                ),
2277                encoder, offset, _depth
2278            )
2279        }
2280    }
2281    unsafe impl<
2282        T0: fidl::encoding::Encode<
2283                fidl::encoding::BoundedString<32>,
2284                fidl::encoding::DefaultFuchsiaResourceDialect,
2285            >,
2286        T1: fidl::encoding::Encode<
2287                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FactoryDriverMarker>>,
2288                fidl::encoding::DefaultFuchsiaResourceDialect,
2289            >,
2290    >
2291        fidl::encoding::Encode<
2292            FactoryRegisterRegisterRequest,
2293            fidl::encoding::DefaultFuchsiaResourceDialect,
2294        > for (T0, T1)
2295    {
2296        #[inline]
2297        unsafe fn encode(
2298            self,
2299            encoder: &mut fidl::encoding::Encoder<
2300                '_,
2301                fidl::encoding::DefaultFuchsiaResourceDialect,
2302            >,
2303            offset: usize,
2304            depth: fidl::encoding::Depth,
2305        ) -> fidl::Result<()> {
2306            encoder.debug_check_bounds::<FactoryRegisterRegisterRequest>(offset);
2307            // Zero out padding regions. There's no need to apply masks
2308            // because the unmasked parts will be overwritten by fields.
2309            unsafe {
2310                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
2311                (ptr as *mut u64).write_unaligned(0);
2312            }
2313            // Write the fields.
2314            self.0.encode(encoder, offset + 0, depth)?;
2315            self.1.encode(encoder, offset + 16, depth)?;
2316            Ok(())
2317        }
2318    }
2319
2320    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
2321        for FactoryRegisterRegisterRequest
2322    {
2323        #[inline(always)]
2324        fn new_empty() -> Self {
2325            Self {
2326                name: fidl::new_empty!(
2327                    fidl::encoding::BoundedString<32>,
2328                    fidl::encoding::DefaultFuchsiaResourceDialect
2329                ),
2330                driver: fidl::new_empty!(
2331                    fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FactoryDriverMarker>>,
2332                    fidl::encoding::DefaultFuchsiaResourceDialect
2333                ),
2334            }
2335        }
2336
2337        #[inline]
2338        unsafe fn decode(
2339            &mut self,
2340            decoder: &mut fidl::encoding::Decoder<
2341                '_,
2342                fidl::encoding::DefaultFuchsiaResourceDialect,
2343            >,
2344            offset: usize,
2345            _depth: fidl::encoding::Depth,
2346        ) -> fidl::Result<()> {
2347            decoder.debug_check_bounds::<Self>(offset);
2348            // Verify that padding bytes are zero.
2349            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
2350            let padval = unsafe { (ptr as *const u64).read_unaligned() };
2351            let mask = 0xffffffff00000000u64;
2352            let maskedval = padval & mask;
2353            if maskedval != 0 {
2354                return Err(fidl::Error::NonZeroPadding {
2355                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
2356                });
2357            }
2358            fidl::decode!(
2359                fidl::encoding::BoundedString<32>,
2360                fidl::encoding::DefaultFuchsiaResourceDialect,
2361                &mut self.name,
2362                decoder,
2363                offset + 0,
2364                _depth
2365            )?;
2366            fidl::decode!(
2367                fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<FactoryDriverMarker>>,
2368                fidl::encoding::DefaultFuchsiaResourceDialect,
2369                &mut self.driver,
2370                decoder,
2371                offset + 16,
2372                _depth
2373            )?;
2374            Ok(())
2375        }
2376    }
2377}