fidl_fuchsia_developer_remotecontrol/
fidl_fuchsia_developer_remotecontrol.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_developer_remotecontrol__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct RemoteControlConnectCapabilityRequest {
16    pub moniker: String,
17    pub capability_set: fidl_fuchsia_sys2::OpenDirType,
18    pub capability_name: String,
19    pub server_channel: fidl::Channel,
20}
21
22impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
23    for RemoteControlConnectCapabilityRequest
24{
25}
26
27#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
28pub struct RemoteControlMarker;
29
30impl fidl::endpoints::ProtocolMarker for RemoteControlMarker {
31    type Proxy = RemoteControlProxy;
32    type RequestStream = RemoteControlRequestStream;
33    #[cfg(target_os = "fuchsia")]
34    type SynchronousProxy = RemoteControlSynchronousProxy;
35
36    const DEBUG_NAME: &'static str = "fuchsia.developer.remotecontrol.RemoteControl";
37}
38impl fidl::endpoints::DiscoverableProtocolMarker for RemoteControlMarker {}
39pub type RemoteControlIdentifyHostResult = Result<IdentifyHostResponse, IdentifyHostError>;
40pub type RemoteControlConnectCapabilityResult = Result<(), ConnectCapabilityError>;
41
42pub trait RemoteControlProxyInterface: Send + Sync {
43    type EchoStringResponseFut: std::future::Future<Output = Result<String, fidl::Error>> + Send;
44    fn r#echo_string(&self, value: &str) -> Self::EchoStringResponseFut;
45    type LogMessageResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
46    fn r#log_message(
47        &self,
48        tag: &str,
49        message: &str,
50        severity: fidl_fuchsia_diagnostics_types::Severity,
51    ) -> Self::LogMessageResponseFut;
52    type IdentifyHostResponseFut: std::future::Future<Output = Result<RemoteControlIdentifyHostResult, fidl::Error>>
53        + Send;
54    fn r#identify_host(&self) -> Self::IdentifyHostResponseFut;
55    type ConnectCapabilityResponseFut: std::future::Future<Output = Result<RemoteControlConnectCapabilityResult, fidl::Error>>
56        + Send;
57    fn r#connect_capability(
58        &self,
59        moniker: &str,
60        capability_set: fidl_fuchsia_sys2::OpenDirType,
61        capability_name: &str,
62        server_channel: fidl::Channel,
63    ) -> Self::ConnectCapabilityResponseFut;
64    type GetTimeResponseFut: std::future::Future<Output = Result<fidl::MonotonicInstant, fidl::Error>>
65        + Send;
66    fn r#get_time(&self) -> Self::GetTimeResponseFut;
67    type GetBootTimeResponseFut: std::future::Future<Output = Result<fidl::BootInstant, fidl::Error>>
68        + Send;
69    fn r#get_boot_time(&self) -> Self::GetBootTimeResponseFut;
70}
71#[derive(Debug)]
72#[cfg(target_os = "fuchsia")]
73pub struct RemoteControlSynchronousProxy {
74    client: fidl::client::sync::Client,
75}
76
77#[cfg(target_os = "fuchsia")]
78impl fidl::endpoints::SynchronousProxy for RemoteControlSynchronousProxy {
79    type Proxy = RemoteControlProxy;
80    type Protocol = RemoteControlMarker;
81
82    fn from_channel(inner: fidl::Channel) -> Self {
83        Self::new(inner)
84    }
85
86    fn into_channel(self) -> fidl::Channel {
87        self.client.into_channel()
88    }
89
90    fn as_channel(&self) -> &fidl::Channel {
91        self.client.as_channel()
92    }
93}
94
95#[cfg(target_os = "fuchsia")]
96impl RemoteControlSynchronousProxy {
97    pub fn new(channel: fidl::Channel) -> Self {
98        let protocol_name = <RemoteControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
99        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
100    }
101
102    pub fn into_channel(self) -> fidl::Channel {
103        self.client.into_channel()
104    }
105
106    /// Waits until an event arrives and returns it. It is safe for other
107    /// threads to make concurrent requests while waiting for an event.
108    pub fn wait_for_event(
109        &self,
110        deadline: zx::MonotonicInstant,
111    ) -> Result<RemoteControlEvent, fidl::Error> {
112        RemoteControlEvent::decode(self.client.wait_for_event(deadline)?)
113    }
114
115    /// Returns the input.
116    pub fn r#echo_string(
117        &self,
118        mut value: &str,
119        ___deadline: zx::MonotonicInstant,
120    ) -> Result<String, fidl::Error> {
121        let _response = self
122            .client
123            .send_query::<RemoteControlEchoStringRequest, RemoteControlEchoStringResponse>(
124                (value,),
125                0x2bbec7ca8a72e82b,
126                fidl::encoding::DynamicFlags::empty(),
127                ___deadline,
128            )?;
129        Ok(_response.response)
130    }
131
132    /// Writes a string to the syslog on the device.
133    pub fn r#log_message(
134        &self,
135        mut tag: &str,
136        mut message: &str,
137        mut severity: fidl_fuchsia_diagnostics_types::Severity,
138        ___deadline: zx::MonotonicInstant,
139    ) -> Result<(), fidl::Error> {
140        let _response = self
141            .client
142            .send_query::<RemoteControlLogMessageRequest, fidl::encoding::EmptyPayload>(
143                (tag, message, severity),
144                0x3da84acd5bbf3926,
145                fidl::encoding::DynamicFlags::empty(),
146                ___deadline,
147            )?;
148        Ok(_response)
149    }
150
151    pub fn r#identify_host(
152        &self,
153        ___deadline: zx::MonotonicInstant,
154    ) -> Result<RemoteControlIdentifyHostResult, fidl::Error> {
155        let _response = self
156            .client
157            .send_query::<fidl::encoding::EmptyPayload, fidl::encoding::FlexibleResultType<
158                RemoteControlIdentifyHostResponse,
159                IdentifyHostError,
160            >>(
161                (), 0x6035e1ab368deee1, fidl::encoding::DynamicFlags::FLEXIBLE, ___deadline
162            )?
163            .into_result::<RemoteControlMarker>("identify_host")?;
164        Ok(_response.map(|x| x.response))
165    }
166
167    /// Connects a channel to a service, given a moniker and a channel iff the component identified
168    /// by the given moniker exposes a capability of the requested name.
169    pub fn r#connect_capability(
170        &self,
171        mut moniker: &str,
172        mut capability_set: fidl_fuchsia_sys2::OpenDirType,
173        mut capability_name: &str,
174        mut server_channel: fidl::Channel,
175        ___deadline: zx::MonotonicInstant,
176    ) -> Result<RemoteControlConnectCapabilityResult, fidl::Error> {
177        let _response = self.client.send_query::<
178            RemoteControlConnectCapabilityRequest,
179            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, ConnectCapabilityError>,
180        >(
181            (moniker, capability_set, capability_name, server_channel,),
182            0x3ae7a7c874dceceb,
183            fidl::encoding::DynamicFlags::FLEXIBLE,
184            ___deadline,
185        )?
186        .into_result::<RemoteControlMarker>("connect_capability")?;
187        Ok(_response.map(|x| x))
188    }
189
190    pub fn r#get_time(
191        &self,
192        ___deadline: zx::MonotonicInstant,
193    ) -> Result<fidl::MonotonicInstant, fidl::Error> {
194        let _response =
195            self.client.send_query::<fidl::encoding::EmptyPayload, RemoteControlGetTimeResponse>(
196                (),
197                0x3588f31e9067748d,
198                fidl::encoding::DynamicFlags::empty(),
199                ___deadline,
200            )?;
201        Ok(_response.time)
202    }
203
204    pub fn r#get_boot_time(
205        &self,
206        ___deadline: zx::MonotonicInstant,
207    ) -> Result<fidl::BootInstant, fidl::Error> {
208        let _response = self
209            .client
210            .send_query::<fidl::encoding::EmptyPayload, RemoteControlGetBootTimeResponse>(
211                (),
212                0x55706f013cd79ebd,
213                fidl::encoding::DynamicFlags::empty(),
214                ___deadline,
215            )?;
216        Ok(_response.time)
217    }
218}
219
220#[cfg(target_os = "fuchsia")]
221impl From<RemoteControlSynchronousProxy> for zx::Handle {
222    fn from(value: RemoteControlSynchronousProxy) -> Self {
223        value.into_channel().into()
224    }
225}
226
227#[cfg(target_os = "fuchsia")]
228impl From<fidl::Channel> for RemoteControlSynchronousProxy {
229    fn from(value: fidl::Channel) -> Self {
230        Self::new(value)
231    }
232}
233
234#[cfg(target_os = "fuchsia")]
235impl fidl::endpoints::FromClient for RemoteControlSynchronousProxy {
236    type Protocol = RemoteControlMarker;
237
238    fn from_client(value: fidl::endpoints::ClientEnd<RemoteControlMarker>) -> Self {
239        Self::new(value.into_channel())
240    }
241}
242
243#[derive(Debug, Clone)]
244pub struct RemoteControlProxy {
245    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
246}
247
248impl fidl::endpoints::Proxy for RemoteControlProxy {
249    type Protocol = RemoteControlMarker;
250
251    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
252        Self::new(inner)
253    }
254
255    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
256        self.client.into_channel().map_err(|client| Self { client })
257    }
258
259    fn as_channel(&self) -> &::fidl::AsyncChannel {
260        self.client.as_channel()
261    }
262}
263
264impl RemoteControlProxy {
265    /// Create a new Proxy for fuchsia.developer.remotecontrol/RemoteControl.
266    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
267        let protocol_name = <RemoteControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
268        Self { client: fidl::client::Client::new(channel, protocol_name) }
269    }
270
271    /// Get a Stream of events from the remote end of the protocol.
272    ///
273    /// # Panics
274    ///
275    /// Panics if the event stream was already taken.
276    pub fn take_event_stream(&self) -> RemoteControlEventStream {
277        RemoteControlEventStream { event_receiver: self.client.take_event_receiver() }
278    }
279
280    /// Returns the input.
281    pub fn r#echo_string(
282        &self,
283        mut value: &str,
284    ) -> fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect> {
285        RemoteControlProxyInterface::r#echo_string(self, value)
286    }
287
288    /// Writes a string to the syslog on the device.
289    pub fn r#log_message(
290        &self,
291        mut tag: &str,
292        mut message: &str,
293        mut severity: fidl_fuchsia_diagnostics_types::Severity,
294    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
295        RemoteControlProxyInterface::r#log_message(self, tag, message, severity)
296    }
297
298    pub fn r#identify_host(
299        &self,
300    ) -> fidl::client::QueryResponseFut<
301        RemoteControlIdentifyHostResult,
302        fidl::encoding::DefaultFuchsiaResourceDialect,
303    > {
304        RemoteControlProxyInterface::r#identify_host(self)
305    }
306
307    /// Connects a channel to a service, given a moniker and a channel iff the component identified
308    /// by the given moniker exposes a capability of the requested name.
309    pub fn r#connect_capability(
310        &self,
311        mut moniker: &str,
312        mut capability_set: fidl_fuchsia_sys2::OpenDirType,
313        mut capability_name: &str,
314        mut server_channel: fidl::Channel,
315    ) -> fidl::client::QueryResponseFut<
316        RemoteControlConnectCapabilityResult,
317        fidl::encoding::DefaultFuchsiaResourceDialect,
318    > {
319        RemoteControlProxyInterface::r#connect_capability(
320            self,
321            moniker,
322            capability_set,
323            capability_name,
324            server_channel,
325        )
326    }
327
328    pub fn r#get_time(
329        &self,
330    ) -> fidl::client::QueryResponseFut<
331        fidl::MonotonicInstant,
332        fidl::encoding::DefaultFuchsiaResourceDialect,
333    > {
334        RemoteControlProxyInterface::r#get_time(self)
335    }
336
337    pub fn r#get_boot_time(
338        &self,
339    ) -> fidl::client::QueryResponseFut<
340        fidl::BootInstant,
341        fidl::encoding::DefaultFuchsiaResourceDialect,
342    > {
343        RemoteControlProxyInterface::r#get_boot_time(self)
344    }
345}
346
347impl RemoteControlProxyInterface for RemoteControlProxy {
348    type EchoStringResponseFut =
349        fidl::client::QueryResponseFut<String, fidl::encoding::DefaultFuchsiaResourceDialect>;
350    fn r#echo_string(&self, mut value: &str) -> Self::EchoStringResponseFut {
351        fn _decode(
352            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
353        ) -> Result<String, fidl::Error> {
354            let _response = fidl::client::decode_transaction_body::<
355                RemoteControlEchoStringResponse,
356                fidl::encoding::DefaultFuchsiaResourceDialect,
357                0x2bbec7ca8a72e82b,
358            >(_buf?)?;
359            Ok(_response.response)
360        }
361        self.client.send_query_and_decode::<RemoteControlEchoStringRequest, String>(
362            (value,),
363            0x2bbec7ca8a72e82b,
364            fidl::encoding::DynamicFlags::empty(),
365            _decode,
366        )
367    }
368
369    type LogMessageResponseFut =
370        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
371    fn r#log_message(
372        &self,
373        mut tag: &str,
374        mut message: &str,
375        mut severity: fidl_fuchsia_diagnostics_types::Severity,
376    ) -> Self::LogMessageResponseFut {
377        fn _decode(
378            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
379        ) -> Result<(), fidl::Error> {
380            let _response = fidl::client::decode_transaction_body::<
381                fidl::encoding::EmptyPayload,
382                fidl::encoding::DefaultFuchsiaResourceDialect,
383                0x3da84acd5bbf3926,
384            >(_buf?)?;
385            Ok(_response)
386        }
387        self.client.send_query_and_decode::<RemoteControlLogMessageRequest, ()>(
388            (tag, message, severity),
389            0x3da84acd5bbf3926,
390            fidl::encoding::DynamicFlags::empty(),
391            _decode,
392        )
393    }
394
395    type IdentifyHostResponseFut = fidl::client::QueryResponseFut<
396        RemoteControlIdentifyHostResult,
397        fidl::encoding::DefaultFuchsiaResourceDialect,
398    >;
399    fn r#identify_host(&self) -> Self::IdentifyHostResponseFut {
400        fn _decode(
401            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
402        ) -> Result<RemoteControlIdentifyHostResult, fidl::Error> {
403            let _response = fidl::client::decode_transaction_body::<
404                fidl::encoding::FlexibleResultType<
405                    RemoteControlIdentifyHostResponse,
406                    IdentifyHostError,
407                >,
408                fidl::encoding::DefaultFuchsiaResourceDialect,
409                0x6035e1ab368deee1,
410            >(_buf?)?
411            .into_result::<RemoteControlMarker>("identify_host")?;
412            Ok(_response.map(|x| x.response))
413        }
414        self.client
415            .send_query_and_decode::<fidl::encoding::EmptyPayload, RemoteControlIdentifyHostResult>(
416                (),
417                0x6035e1ab368deee1,
418                fidl::encoding::DynamicFlags::FLEXIBLE,
419                _decode,
420            )
421    }
422
423    type ConnectCapabilityResponseFut = fidl::client::QueryResponseFut<
424        RemoteControlConnectCapabilityResult,
425        fidl::encoding::DefaultFuchsiaResourceDialect,
426    >;
427    fn r#connect_capability(
428        &self,
429        mut moniker: &str,
430        mut capability_set: fidl_fuchsia_sys2::OpenDirType,
431        mut capability_name: &str,
432        mut server_channel: fidl::Channel,
433    ) -> Self::ConnectCapabilityResponseFut {
434        fn _decode(
435            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
436        ) -> Result<RemoteControlConnectCapabilityResult, fidl::Error> {
437            let _response = fidl::client::decode_transaction_body::<
438                fidl::encoding::FlexibleResultType<
439                    fidl::encoding::EmptyStruct,
440                    ConnectCapabilityError,
441                >,
442                fidl::encoding::DefaultFuchsiaResourceDialect,
443                0x3ae7a7c874dceceb,
444            >(_buf?)?
445            .into_result::<RemoteControlMarker>("connect_capability")?;
446            Ok(_response.map(|x| x))
447        }
448        self.client.send_query_and_decode::<
449            RemoteControlConnectCapabilityRequest,
450            RemoteControlConnectCapabilityResult,
451        >(
452            (moniker, capability_set, capability_name, server_channel,),
453            0x3ae7a7c874dceceb,
454            fidl::encoding::DynamicFlags::FLEXIBLE,
455            _decode,
456        )
457    }
458
459    type GetTimeResponseFut = fidl::client::QueryResponseFut<
460        fidl::MonotonicInstant,
461        fidl::encoding::DefaultFuchsiaResourceDialect,
462    >;
463    fn r#get_time(&self) -> Self::GetTimeResponseFut {
464        fn _decode(
465            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
466        ) -> Result<fidl::MonotonicInstant, fidl::Error> {
467            let _response = fidl::client::decode_transaction_body::<
468                RemoteControlGetTimeResponse,
469                fidl::encoding::DefaultFuchsiaResourceDialect,
470                0x3588f31e9067748d,
471            >(_buf?)?;
472            Ok(_response.time)
473        }
474        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::MonotonicInstant>(
475            (),
476            0x3588f31e9067748d,
477            fidl::encoding::DynamicFlags::empty(),
478            _decode,
479        )
480    }
481
482    type GetBootTimeResponseFut = fidl::client::QueryResponseFut<
483        fidl::BootInstant,
484        fidl::encoding::DefaultFuchsiaResourceDialect,
485    >;
486    fn r#get_boot_time(&self) -> Self::GetBootTimeResponseFut {
487        fn _decode(
488            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
489        ) -> Result<fidl::BootInstant, fidl::Error> {
490            let _response = fidl::client::decode_transaction_body::<
491                RemoteControlGetBootTimeResponse,
492                fidl::encoding::DefaultFuchsiaResourceDialect,
493                0x55706f013cd79ebd,
494            >(_buf?)?;
495            Ok(_response.time)
496        }
497        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, fidl::BootInstant>(
498            (),
499            0x55706f013cd79ebd,
500            fidl::encoding::DynamicFlags::empty(),
501            _decode,
502        )
503    }
504}
505
506pub struct RemoteControlEventStream {
507    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
508}
509
510impl std::marker::Unpin for RemoteControlEventStream {}
511
512impl futures::stream::FusedStream for RemoteControlEventStream {
513    fn is_terminated(&self) -> bool {
514        self.event_receiver.is_terminated()
515    }
516}
517
518impl futures::Stream for RemoteControlEventStream {
519    type Item = Result<RemoteControlEvent, fidl::Error>;
520
521    fn poll_next(
522        mut self: std::pin::Pin<&mut Self>,
523        cx: &mut std::task::Context<'_>,
524    ) -> std::task::Poll<Option<Self::Item>> {
525        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
526            &mut self.event_receiver,
527            cx
528        )?) {
529            Some(buf) => std::task::Poll::Ready(Some(RemoteControlEvent::decode(buf))),
530            None => std::task::Poll::Ready(None),
531        }
532    }
533}
534
535#[derive(Debug)]
536pub enum RemoteControlEvent {
537    #[non_exhaustive]
538    _UnknownEvent {
539        /// Ordinal of the event that was sent.
540        ordinal: u64,
541    },
542}
543
544impl RemoteControlEvent {
545    /// Decodes a message buffer as a [`RemoteControlEvent`].
546    fn decode(
547        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
548    ) -> Result<RemoteControlEvent, fidl::Error> {
549        let (bytes, _handles) = buf.split_mut();
550        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
551        debug_assert_eq!(tx_header.tx_id, 0);
552        match tx_header.ordinal {
553            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
554                Ok(RemoteControlEvent::_UnknownEvent { ordinal: tx_header.ordinal })
555            }
556            _ => Err(fidl::Error::UnknownOrdinal {
557                ordinal: tx_header.ordinal,
558                protocol_name: <RemoteControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
559            }),
560        }
561    }
562}
563
564/// A Stream of incoming requests for fuchsia.developer.remotecontrol/RemoteControl.
565pub struct RemoteControlRequestStream {
566    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
567    is_terminated: bool,
568}
569
570impl std::marker::Unpin for RemoteControlRequestStream {}
571
572impl futures::stream::FusedStream for RemoteControlRequestStream {
573    fn is_terminated(&self) -> bool {
574        self.is_terminated
575    }
576}
577
578impl fidl::endpoints::RequestStream for RemoteControlRequestStream {
579    type Protocol = RemoteControlMarker;
580    type ControlHandle = RemoteControlControlHandle;
581
582    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
583        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
584    }
585
586    fn control_handle(&self) -> Self::ControlHandle {
587        RemoteControlControlHandle { inner: self.inner.clone() }
588    }
589
590    fn into_inner(
591        self,
592    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
593    {
594        (self.inner, self.is_terminated)
595    }
596
597    fn from_inner(
598        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
599        is_terminated: bool,
600    ) -> Self {
601        Self { inner, is_terminated }
602    }
603}
604
605impl futures::Stream for RemoteControlRequestStream {
606    type Item = Result<RemoteControlRequest, fidl::Error>;
607
608    fn poll_next(
609        mut self: std::pin::Pin<&mut Self>,
610        cx: &mut std::task::Context<'_>,
611    ) -> std::task::Poll<Option<Self::Item>> {
612        let this = &mut *self;
613        if this.inner.check_shutdown(cx) {
614            this.is_terminated = true;
615            return std::task::Poll::Ready(None);
616        }
617        if this.is_terminated {
618            panic!("polled RemoteControlRequestStream after completion");
619        }
620        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
621            |bytes, handles| {
622                match this.inner.channel().read_etc(cx, bytes, handles) {
623                    std::task::Poll::Ready(Ok(())) => {}
624                    std::task::Poll::Pending => return std::task::Poll::Pending,
625                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
626                        this.is_terminated = true;
627                        return std::task::Poll::Ready(None);
628                    }
629                    std::task::Poll::Ready(Err(e)) => {
630                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
631                            e.into(),
632                        ))));
633                    }
634                }
635
636                // A message has been received from the channel
637                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
638
639                std::task::Poll::Ready(Some(match header.ordinal {
640                    0x2bbec7ca8a72e82b => {
641                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
642                        let mut req = fidl::new_empty!(
643                            RemoteControlEchoStringRequest,
644                            fidl::encoding::DefaultFuchsiaResourceDialect
645                        );
646                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteControlEchoStringRequest>(&header, _body_bytes, handles, &mut req)?;
647                        let control_handle =
648                            RemoteControlControlHandle { inner: this.inner.clone() };
649                        Ok(RemoteControlRequest::EchoString {
650                            value: req.value,
651
652                            responder: RemoteControlEchoStringResponder {
653                                control_handle: std::mem::ManuallyDrop::new(control_handle),
654                                tx_id: header.tx_id,
655                            },
656                        })
657                    }
658                    0x3da84acd5bbf3926 => {
659                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
660                        let mut req = fidl::new_empty!(
661                            RemoteControlLogMessageRequest,
662                            fidl::encoding::DefaultFuchsiaResourceDialect
663                        );
664                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteControlLogMessageRequest>(&header, _body_bytes, handles, &mut req)?;
665                        let control_handle =
666                            RemoteControlControlHandle { inner: this.inner.clone() };
667                        Ok(RemoteControlRequest::LogMessage {
668                            tag: req.tag,
669                            message: req.message,
670                            severity: req.severity,
671
672                            responder: RemoteControlLogMessageResponder {
673                                control_handle: std::mem::ManuallyDrop::new(control_handle),
674                                tx_id: header.tx_id,
675                            },
676                        })
677                    }
678                    0x6035e1ab368deee1 => {
679                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
680                        let mut req = fidl::new_empty!(
681                            fidl::encoding::EmptyPayload,
682                            fidl::encoding::DefaultFuchsiaResourceDialect
683                        );
684                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
685                        let control_handle =
686                            RemoteControlControlHandle { inner: this.inner.clone() };
687                        Ok(RemoteControlRequest::IdentifyHost {
688                            responder: RemoteControlIdentifyHostResponder {
689                                control_handle: std::mem::ManuallyDrop::new(control_handle),
690                                tx_id: header.tx_id,
691                            },
692                        })
693                    }
694                    0x3ae7a7c874dceceb => {
695                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
696                        let mut req = fidl::new_empty!(
697                            RemoteControlConnectCapabilityRequest,
698                            fidl::encoding::DefaultFuchsiaResourceDialect
699                        );
700                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RemoteControlConnectCapabilityRequest>(&header, _body_bytes, handles, &mut req)?;
701                        let control_handle =
702                            RemoteControlControlHandle { inner: this.inner.clone() };
703                        Ok(RemoteControlRequest::ConnectCapability {
704                            moniker: req.moniker,
705                            capability_set: req.capability_set,
706                            capability_name: req.capability_name,
707                            server_channel: req.server_channel,
708
709                            responder: RemoteControlConnectCapabilityResponder {
710                                control_handle: std::mem::ManuallyDrop::new(control_handle),
711                                tx_id: header.tx_id,
712                            },
713                        })
714                    }
715                    0x3588f31e9067748d => {
716                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
717                        let mut req = fidl::new_empty!(
718                            fidl::encoding::EmptyPayload,
719                            fidl::encoding::DefaultFuchsiaResourceDialect
720                        );
721                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
722                        let control_handle =
723                            RemoteControlControlHandle { inner: this.inner.clone() };
724                        Ok(RemoteControlRequest::GetTime {
725                            responder: RemoteControlGetTimeResponder {
726                                control_handle: std::mem::ManuallyDrop::new(control_handle),
727                                tx_id: header.tx_id,
728                            },
729                        })
730                    }
731                    0x55706f013cd79ebd => {
732                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
733                        let mut req = fidl::new_empty!(
734                            fidl::encoding::EmptyPayload,
735                            fidl::encoding::DefaultFuchsiaResourceDialect
736                        );
737                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
738                        let control_handle =
739                            RemoteControlControlHandle { inner: this.inner.clone() };
740                        Ok(RemoteControlRequest::GetBootTime {
741                            responder: RemoteControlGetBootTimeResponder {
742                                control_handle: std::mem::ManuallyDrop::new(control_handle),
743                                tx_id: header.tx_id,
744                            },
745                        })
746                    }
747                    _ if header.tx_id == 0
748                        && header
749                            .dynamic_flags()
750                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
751                    {
752                        Ok(RemoteControlRequest::_UnknownMethod {
753                            ordinal: header.ordinal,
754                            control_handle: RemoteControlControlHandle {
755                                inner: this.inner.clone(),
756                            },
757                            method_type: fidl::MethodType::OneWay,
758                        })
759                    }
760                    _ if header
761                        .dynamic_flags()
762                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
763                    {
764                        this.inner.send_framework_err(
765                            fidl::encoding::FrameworkErr::UnknownMethod,
766                            header.tx_id,
767                            header.ordinal,
768                            header.dynamic_flags(),
769                            (bytes, handles),
770                        )?;
771                        Ok(RemoteControlRequest::_UnknownMethod {
772                            ordinal: header.ordinal,
773                            control_handle: RemoteControlControlHandle {
774                                inner: this.inner.clone(),
775                            },
776                            method_type: fidl::MethodType::TwoWay,
777                        })
778                    }
779                    _ => Err(fidl::Error::UnknownOrdinal {
780                        ordinal: header.ordinal,
781                        protocol_name:
782                            <RemoteControlMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
783                    }),
784                }))
785            },
786        )
787    }
788}
789
790#[derive(Debug)]
791pub enum RemoteControlRequest {
792    /// Returns the input.
793    EchoString {
794        value: String,
795        responder: RemoteControlEchoStringResponder,
796    },
797    /// Writes a string to the syslog on the device.
798    LogMessage {
799        tag: String,
800        message: String,
801        severity: fidl_fuchsia_diagnostics_types::Severity,
802        responder: RemoteControlLogMessageResponder,
803    },
804    IdentifyHost {
805        responder: RemoteControlIdentifyHostResponder,
806    },
807    /// Connects a channel to a service, given a moniker and a channel iff the component identified
808    /// by the given moniker exposes a capability of the requested name.
809    ConnectCapability {
810        moniker: String,
811        capability_set: fidl_fuchsia_sys2::OpenDirType,
812        capability_name: String,
813        server_channel: fidl::Channel,
814        responder: RemoteControlConnectCapabilityResponder,
815    },
816    GetTime {
817        responder: RemoteControlGetTimeResponder,
818    },
819    GetBootTime {
820        responder: RemoteControlGetBootTimeResponder,
821    },
822    /// An interaction was received which does not match any known method.
823    #[non_exhaustive]
824    _UnknownMethod {
825        /// Ordinal of the method that was called.
826        ordinal: u64,
827        control_handle: RemoteControlControlHandle,
828        method_type: fidl::MethodType,
829    },
830}
831
832impl RemoteControlRequest {
833    #[allow(irrefutable_let_patterns)]
834    pub fn into_echo_string(self) -> Option<(String, RemoteControlEchoStringResponder)> {
835        if let RemoteControlRequest::EchoString { value, responder } = self {
836            Some((value, responder))
837        } else {
838            None
839        }
840    }
841
842    #[allow(irrefutable_let_patterns)]
843    pub fn into_log_message(
844        self,
845    ) -> Option<(
846        String,
847        String,
848        fidl_fuchsia_diagnostics_types::Severity,
849        RemoteControlLogMessageResponder,
850    )> {
851        if let RemoteControlRequest::LogMessage { tag, message, severity, responder } = self {
852            Some((tag, message, severity, responder))
853        } else {
854            None
855        }
856    }
857
858    #[allow(irrefutable_let_patterns)]
859    pub fn into_identify_host(self) -> Option<(RemoteControlIdentifyHostResponder)> {
860        if let RemoteControlRequest::IdentifyHost { responder } = self {
861            Some((responder))
862        } else {
863            None
864        }
865    }
866
867    #[allow(irrefutable_let_patterns)]
868    pub fn into_connect_capability(
869        self,
870    ) -> Option<(
871        String,
872        fidl_fuchsia_sys2::OpenDirType,
873        String,
874        fidl::Channel,
875        RemoteControlConnectCapabilityResponder,
876    )> {
877        if let RemoteControlRequest::ConnectCapability {
878            moniker,
879            capability_set,
880            capability_name,
881            server_channel,
882            responder,
883        } = self
884        {
885            Some((moniker, capability_set, capability_name, server_channel, responder))
886        } else {
887            None
888        }
889    }
890
891    #[allow(irrefutable_let_patterns)]
892    pub fn into_get_time(self) -> Option<(RemoteControlGetTimeResponder)> {
893        if let RemoteControlRequest::GetTime { responder } = self {
894            Some((responder))
895        } else {
896            None
897        }
898    }
899
900    #[allow(irrefutable_let_patterns)]
901    pub fn into_get_boot_time(self) -> Option<(RemoteControlGetBootTimeResponder)> {
902        if let RemoteControlRequest::GetBootTime { responder } = self {
903            Some((responder))
904        } else {
905            None
906        }
907    }
908
909    /// Name of the method defined in FIDL
910    pub fn method_name(&self) -> &'static str {
911        match *self {
912            RemoteControlRequest::EchoString { .. } => "echo_string",
913            RemoteControlRequest::LogMessage { .. } => "log_message",
914            RemoteControlRequest::IdentifyHost { .. } => "identify_host",
915            RemoteControlRequest::ConnectCapability { .. } => "connect_capability",
916            RemoteControlRequest::GetTime { .. } => "get_time",
917            RemoteControlRequest::GetBootTime { .. } => "get_boot_time",
918            RemoteControlRequest::_UnknownMethod {
919                method_type: fidl::MethodType::OneWay, ..
920            } => "unknown one-way method",
921            RemoteControlRequest::_UnknownMethod {
922                method_type: fidl::MethodType::TwoWay, ..
923            } => "unknown two-way method",
924        }
925    }
926}
927
928#[derive(Debug, Clone)]
929pub struct RemoteControlControlHandle {
930    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
931}
932
933impl fidl::endpoints::ControlHandle for RemoteControlControlHandle {
934    fn shutdown(&self) {
935        self.inner.shutdown()
936    }
937    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
938        self.inner.shutdown_with_epitaph(status)
939    }
940
941    fn is_closed(&self) -> bool {
942        self.inner.channel().is_closed()
943    }
944    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
945        self.inner.channel().on_closed()
946    }
947
948    #[cfg(target_os = "fuchsia")]
949    fn signal_peer(
950        &self,
951        clear_mask: zx::Signals,
952        set_mask: zx::Signals,
953    ) -> Result<(), zx_status::Status> {
954        use fidl::Peered;
955        self.inner.channel().signal_peer(clear_mask, set_mask)
956    }
957}
958
959impl RemoteControlControlHandle {}
960
961#[must_use = "FIDL methods require a response to be sent"]
962#[derive(Debug)]
963pub struct RemoteControlEchoStringResponder {
964    control_handle: std::mem::ManuallyDrop<RemoteControlControlHandle>,
965    tx_id: u32,
966}
967
968/// Set the the channel to be shutdown (see [`RemoteControlControlHandle::shutdown`])
969/// if the responder is dropped without sending a response, so that the client
970/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
971impl std::ops::Drop for RemoteControlEchoStringResponder {
972    fn drop(&mut self) {
973        self.control_handle.shutdown();
974        // Safety: drops once, never accessed again
975        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
976    }
977}
978
979impl fidl::endpoints::Responder for RemoteControlEchoStringResponder {
980    type ControlHandle = RemoteControlControlHandle;
981
982    fn control_handle(&self) -> &RemoteControlControlHandle {
983        &self.control_handle
984    }
985
986    fn drop_without_shutdown(mut self) {
987        // Safety: drops once, never accessed again due to mem::forget
988        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
989        // Prevent Drop from running (which would shut down the channel)
990        std::mem::forget(self);
991    }
992}
993
994impl RemoteControlEchoStringResponder {
995    /// Sends a response to the FIDL transaction.
996    ///
997    /// Sets the channel to shutdown if an error occurs.
998    pub fn send(self, mut response: &str) -> Result<(), fidl::Error> {
999        let _result = self.send_raw(response);
1000        if _result.is_err() {
1001            self.control_handle.shutdown();
1002        }
1003        self.drop_without_shutdown();
1004        _result
1005    }
1006
1007    /// Similar to "send" but does not shutdown the channel if an error occurs.
1008    pub fn send_no_shutdown_on_err(self, mut response: &str) -> Result<(), fidl::Error> {
1009        let _result = self.send_raw(response);
1010        self.drop_without_shutdown();
1011        _result
1012    }
1013
1014    fn send_raw(&self, mut response: &str) -> Result<(), fidl::Error> {
1015        self.control_handle.inner.send::<RemoteControlEchoStringResponse>(
1016            (response,),
1017            self.tx_id,
1018            0x2bbec7ca8a72e82b,
1019            fidl::encoding::DynamicFlags::empty(),
1020        )
1021    }
1022}
1023
1024#[must_use = "FIDL methods require a response to be sent"]
1025#[derive(Debug)]
1026pub struct RemoteControlLogMessageResponder {
1027    control_handle: std::mem::ManuallyDrop<RemoteControlControlHandle>,
1028    tx_id: u32,
1029}
1030
1031/// Set the the channel to be shutdown (see [`RemoteControlControlHandle::shutdown`])
1032/// if the responder is dropped without sending a response, so that the client
1033/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1034impl std::ops::Drop for RemoteControlLogMessageResponder {
1035    fn drop(&mut self) {
1036        self.control_handle.shutdown();
1037        // Safety: drops once, never accessed again
1038        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1039    }
1040}
1041
1042impl fidl::endpoints::Responder for RemoteControlLogMessageResponder {
1043    type ControlHandle = RemoteControlControlHandle;
1044
1045    fn control_handle(&self) -> &RemoteControlControlHandle {
1046        &self.control_handle
1047    }
1048
1049    fn drop_without_shutdown(mut self) {
1050        // Safety: drops once, never accessed again due to mem::forget
1051        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1052        // Prevent Drop from running (which would shut down the channel)
1053        std::mem::forget(self);
1054    }
1055}
1056
1057impl RemoteControlLogMessageResponder {
1058    /// Sends a response to the FIDL transaction.
1059    ///
1060    /// Sets the channel to shutdown if an error occurs.
1061    pub fn send(self) -> Result<(), fidl::Error> {
1062        let _result = self.send_raw();
1063        if _result.is_err() {
1064            self.control_handle.shutdown();
1065        }
1066        self.drop_without_shutdown();
1067        _result
1068    }
1069
1070    /// Similar to "send" but does not shutdown the channel if an error occurs.
1071    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
1072        let _result = self.send_raw();
1073        self.drop_without_shutdown();
1074        _result
1075    }
1076
1077    fn send_raw(&self) -> Result<(), fidl::Error> {
1078        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
1079            (),
1080            self.tx_id,
1081            0x3da84acd5bbf3926,
1082            fidl::encoding::DynamicFlags::empty(),
1083        )
1084    }
1085}
1086
1087#[must_use = "FIDL methods require a response to be sent"]
1088#[derive(Debug)]
1089pub struct RemoteControlIdentifyHostResponder {
1090    control_handle: std::mem::ManuallyDrop<RemoteControlControlHandle>,
1091    tx_id: u32,
1092}
1093
1094/// Set the the channel to be shutdown (see [`RemoteControlControlHandle::shutdown`])
1095/// if the responder is dropped without sending a response, so that the client
1096/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1097impl std::ops::Drop for RemoteControlIdentifyHostResponder {
1098    fn drop(&mut self) {
1099        self.control_handle.shutdown();
1100        // Safety: drops once, never accessed again
1101        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1102    }
1103}
1104
1105impl fidl::endpoints::Responder for RemoteControlIdentifyHostResponder {
1106    type ControlHandle = RemoteControlControlHandle;
1107
1108    fn control_handle(&self) -> &RemoteControlControlHandle {
1109        &self.control_handle
1110    }
1111
1112    fn drop_without_shutdown(mut self) {
1113        // Safety: drops once, never accessed again due to mem::forget
1114        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1115        // Prevent Drop from running (which would shut down the channel)
1116        std::mem::forget(self);
1117    }
1118}
1119
1120impl RemoteControlIdentifyHostResponder {
1121    /// Sends a response to the FIDL transaction.
1122    ///
1123    /// Sets the channel to shutdown if an error occurs.
1124    pub fn send(
1125        self,
1126        mut result: Result<&IdentifyHostResponse, IdentifyHostError>,
1127    ) -> Result<(), fidl::Error> {
1128        let _result = self.send_raw(result);
1129        if _result.is_err() {
1130            self.control_handle.shutdown();
1131        }
1132        self.drop_without_shutdown();
1133        _result
1134    }
1135
1136    /// Similar to "send" but does not shutdown the channel if an error occurs.
1137    pub fn send_no_shutdown_on_err(
1138        self,
1139        mut result: Result<&IdentifyHostResponse, IdentifyHostError>,
1140    ) -> Result<(), fidl::Error> {
1141        let _result = self.send_raw(result);
1142        self.drop_without_shutdown();
1143        _result
1144    }
1145
1146    fn send_raw(
1147        &self,
1148        mut result: Result<&IdentifyHostResponse, IdentifyHostError>,
1149    ) -> Result<(), fidl::Error> {
1150        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1151            RemoteControlIdentifyHostResponse,
1152            IdentifyHostError,
1153        >>(
1154            fidl::encoding::FlexibleResult::new(result.map(|response| (response,))),
1155            self.tx_id,
1156            0x6035e1ab368deee1,
1157            fidl::encoding::DynamicFlags::FLEXIBLE,
1158        )
1159    }
1160}
1161
1162#[must_use = "FIDL methods require a response to be sent"]
1163#[derive(Debug)]
1164pub struct RemoteControlConnectCapabilityResponder {
1165    control_handle: std::mem::ManuallyDrop<RemoteControlControlHandle>,
1166    tx_id: u32,
1167}
1168
1169/// Set the the channel to be shutdown (see [`RemoteControlControlHandle::shutdown`])
1170/// if the responder is dropped without sending a response, so that the client
1171/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1172impl std::ops::Drop for RemoteControlConnectCapabilityResponder {
1173    fn drop(&mut self) {
1174        self.control_handle.shutdown();
1175        // Safety: drops once, never accessed again
1176        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1177    }
1178}
1179
1180impl fidl::endpoints::Responder for RemoteControlConnectCapabilityResponder {
1181    type ControlHandle = RemoteControlControlHandle;
1182
1183    fn control_handle(&self) -> &RemoteControlControlHandle {
1184        &self.control_handle
1185    }
1186
1187    fn drop_without_shutdown(mut self) {
1188        // Safety: drops once, never accessed again due to mem::forget
1189        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1190        // Prevent Drop from running (which would shut down the channel)
1191        std::mem::forget(self);
1192    }
1193}
1194
1195impl RemoteControlConnectCapabilityResponder {
1196    /// Sends a response to the FIDL transaction.
1197    ///
1198    /// Sets the channel to shutdown if an error occurs.
1199    pub fn send(self, mut result: Result<(), ConnectCapabilityError>) -> Result<(), fidl::Error> {
1200        let _result = self.send_raw(result);
1201        if _result.is_err() {
1202            self.control_handle.shutdown();
1203        }
1204        self.drop_without_shutdown();
1205        _result
1206    }
1207
1208    /// Similar to "send" but does not shutdown the channel if an error occurs.
1209    pub fn send_no_shutdown_on_err(
1210        self,
1211        mut result: Result<(), ConnectCapabilityError>,
1212    ) -> Result<(), fidl::Error> {
1213        let _result = self.send_raw(result);
1214        self.drop_without_shutdown();
1215        _result
1216    }
1217
1218    fn send_raw(&self, mut result: Result<(), ConnectCapabilityError>) -> Result<(), fidl::Error> {
1219        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1220            fidl::encoding::EmptyStruct,
1221            ConnectCapabilityError,
1222        >>(
1223            fidl::encoding::FlexibleResult::new(result),
1224            self.tx_id,
1225            0x3ae7a7c874dceceb,
1226            fidl::encoding::DynamicFlags::FLEXIBLE,
1227        )
1228    }
1229}
1230
1231#[must_use = "FIDL methods require a response to be sent"]
1232#[derive(Debug)]
1233pub struct RemoteControlGetTimeResponder {
1234    control_handle: std::mem::ManuallyDrop<RemoteControlControlHandle>,
1235    tx_id: u32,
1236}
1237
1238/// Set the the channel to be shutdown (see [`RemoteControlControlHandle::shutdown`])
1239/// if the responder is dropped without sending a response, so that the client
1240/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1241impl std::ops::Drop for RemoteControlGetTimeResponder {
1242    fn drop(&mut self) {
1243        self.control_handle.shutdown();
1244        // Safety: drops once, never accessed again
1245        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1246    }
1247}
1248
1249impl fidl::endpoints::Responder for RemoteControlGetTimeResponder {
1250    type ControlHandle = RemoteControlControlHandle;
1251
1252    fn control_handle(&self) -> &RemoteControlControlHandle {
1253        &self.control_handle
1254    }
1255
1256    fn drop_without_shutdown(mut self) {
1257        // Safety: drops once, never accessed again due to mem::forget
1258        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1259        // Prevent Drop from running (which would shut down the channel)
1260        std::mem::forget(self);
1261    }
1262}
1263
1264impl RemoteControlGetTimeResponder {
1265    /// Sends a response to the FIDL transaction.
1266    ///
1267    /// Sets the channel to shutdown if an error occurs.
1268    pub fn send(self, mut time: fidl::MonotonicInstant) -> Result<(), fidl::Error> {
1269        let _result = self.send_raw(time);
1270        if _result.is_err() {
1271            self.control_handle.shutdown();
1272        }
1273        self.drop_without_shutdown();
1274        _result
1275    }
1276
1277    /// Similar to "send" but does not shutdown the channel if an error occurs.
1278    pub fn send_no_shutdown_on_err(
1279        self,
1280        mut time: fidl::MonotonicInstant,
1281    ) -> Result<(), fidl::Error> {
1282        let _result = self.send_raw(time);
1283        self.drop_without_shutdown();
1284        _result
1285    }
1286
1287    fn send_raw(&self, mut time: fidl::MonotonicInstant) -> Result<(), fidl::Error> {
1288        self.control_handle.inner.send::<RemoteControlGetTimeResponse>(
1289            (time,),
1290            self.tx_id,
1291            0x3588f31e9067748d,
1292            fidl::encoding::DynamicFlags::empty(),
1293        )
1294    }
1295}
1296
1297#[must_use = "FIDL methods require a response to be sent"]
1298#[derive(Debug)]
1299pub struct RemoteControlGetBootTimeResponder {
1300    control_handle: std::mem::ManuallyDrop<RemoteControlControlHandle>,
1301    tx_id: u32,
1302}
1303
1304/// Set the the channel to be shutdown (see [`RemoteControlControlHandle::shutdown`])
1305/// if the responder is dropped without sending a response, so that the client
1306/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1307impl std::ops::Drop for RemoteControlGetBootTimeResponder {
1308    fn drop(&mut self) {
1309        self.control_handle.shutdown();
1310        // Safety: drops once, never accessed again
1311        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1312    }
1313}
1314
1315impl fidl::endpoints::Responder for RemoteControlGetBootTimeResponder {
1316    type ControlHandle = RemoteControlControlHandle;
1317
1318    fn control_handle(&self) -> &RemoteControlControlHandle {
1319        &self.control_handle
1320    }
1321
1322    fn drop_without_shutdown(mut self) {
1323        // Safety: drops once, never accessed again due to mem::forget
1324        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1325        // Prevent Drop from running (which would shut down the channel)
1326        std::mem::forget(self);
1327    }
1328}
1329
1330impl RemoteControlGetBootTimeResponder {
1331    /// Sends a response to the FIDL transaction.
1332    ///
1333    /// Sets the channel to shutdown if an error occurs.
1334    pub fn send(self, mut time: fidl::BootInstant) -> Result<(), fidl::Error> {
1335        let _result = self.send_raw(time);
1336        if _result.is_err() {
1337            self.control_handle.shutdown();
1338        }
1339        self.drop_without_shutdown();
1340        _result
1341    }
1342
1343    /// Similar to "send" but does not shutdown the channel if an error occurs.
1344    pub fn send_no_shutdown_on_err(self, mut time: fidl::BootInstant) -> Result<(), fidl::Error> {
1345        let _result = self.send_raw(time);
1346        self.drop_without_shutdown();
1347        _result
1348    }
1349
1350    fn send_raw(&self, mut time: fidl::BootInstant) -> Result<(), fidl::Error> {
1351        self.control_handle.inner.send::<RemoteControlGetBootTimeResponse>(
1352            (time,),
1353            self.tx_id,
1354            0x55706f013cd79ebd,
1355            fidl::encoding::DynamicFlags::empty(),
1356        )
1357    }
1358}
1359
1360mod internal {
1361    use super::*;
1362
1363    impl fidl::encoding::ResourceTypeMarker for RemoteControlConnectCapabilityRequest {
1364        type Borrowed<'a> = &'a mut Self;
1365        fn take_or_borrow<'a>(
1366            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1367        ) -> Self::Borrowed<'a> {
1368            value
1369        }
1370    }
1371
1372    unsafe impl fidl::encoding::TypeMarker for RemoteControlConnectCapabilityRequest {
1373        type Owned = Self;
1374
1375        #[inline(always)]
1376        fn inline_align(_context: fidl::encoding::Context) -> usize {
1377            8
1378        }
1379
1380        #[inline(always)]
1381        fn inline_size(_context: fidl::encoding::Context) -> usize {
1382            48
1383        }
1384    }
1385
1386    unsafe impl
1387        fidl::encoding::Encode<
1388            RemoteControlConnectCapabilityRequest,
1389            fidl::encoding::DefaultFuchsiaResourceDialect,
1390        > for &mut RemoteControlConnectCapabilityRequest
1391    {
1392        #[inline]
1393        unsafe fn encode(
1394            self,
1395            encoder: &mut fidl::encoding::Encoder<
1396                '_,
1397                fidl::encoding::DefaultFuchsiaResourceDialect,
1398            >,
1399            offset: usize,
1400            _depth: fidl::encoding::Depth,
1401        ) -> fidl::Result<()> {
1402            encoder.debug_check_bounds::<RemoteControlConnectCapabilityRequest>(offset);
1403            // Delegate to tuple encoding.
1404            fidl::encoding::Encode::<RemoteControlConnectCapabilityRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1405                (
1406                    <fidl::encoding::BoundedString<4096> as fidl::encoding::ValueTypeMarker>::borrow(&self.moniker),
1407                    <fidl_fuchsia_sys2::OpenDirType as fidl::encoding::ValueTypeMarker>::borrow(&self.capability_set),
1408                    <fidl::encoding::BoundedString<255> as fidl::encoding::ValueTypeMarker>::borrow(&self.capability_name),
1409                    <fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.server_channel),
1410                ),
1411                encoder, offset, _depth
1412            )
1413        }
1414    }
1415    unsafe impl<
1416        T0: fidl::encoding::Encode<
1417                fidl::encoding::BoundedString<4096>,
1418                fidl::encoding::DefaultFuchsiaResourceDialect,
1419            >,
1420        T1: fidl::encoding::Encode<
1421                fidl_fuchsia_sys2::OpenDirType,
1422                fidl::encoding::DefaultFuchsiaResourceDialect,
1423            >,
1424        T2: fidl::encoding::Encode<
1425                fidl::encoding::BoundedString<255>,
1426                fidl::encoding::DefaultFuchsiaResourceDialect,
1427            >,
1428        T3: fidl::encoding::Encode<
1429                fidl::encoding::HandleType<
1430                    fidl::Channel,
1431                    { fidl::ObjectType::CHANNEL.into_raw() },
1432                    2147483648,
1433                >,
1434                fidl::encoding::DefaultFuchsiaResourceDialect,
1435            >,
1436    >
1437        fidl::encoding::Encode<
1438            RemoteControlConnectCapabilityRequest,
1439            fidl::encoding::DefaultFuchsiaResourceDialect,
1440        > for (T0, T1, T2, T3)
1441    {
1442        #[inline]
1443        unsafe fn encode(
1444            self,
1445            encoder: &mut fidl::encoding::Encoder<
1446                '_,
1447                fidl::encoding::DefaultFuchsiaResourceDialect,
1448            >,
1449            offset: usize,
1450            depth: fidl::encoding::Depth,
1451        ) -> fidl::Result<()> {
1452            encoder.debug_check_bounds::<RemoteControlConnectCapabilityRequest>(offset);
1453            // Zero out padding regions. There's no need to apply masks
1454            // because the unmasked parts will be overwritten by fields.
1455            unsafe {
1456                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1457                (ptr as *mut u64).write_unaligned(0);
1458            }
1459            unsafe {
1460                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(40);
1461                (ptr as *mut u64).write_unaligned(0);
1462            }
1463            // Write the fields.
1464            self.0.encode(encoder, offset + 0, depth)?;
1465            self.1.encode(encoder, offset + 16, depth)?;
1466            self.2.encode(encoder, offset + 24, depth)?;
1467            self.3.encode(encoder, offset + 40, depth)?;
1468            Ok(())
1469        }
1470    }
1471
1472    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1473        for RemoteControlConnectCapabilityRequest
1474    {
1475        #[inline(always)]
1476        fn new_empty() -> Self {
1477            Self {
1478                moniker: fidl::new_empty!(
1479                    fidl::encoding::BoundedString<4096>,
1480                    fidl::encoding::DefaultFuchsiaResourceDialect
1481                ),
1482                capability_set: fidl::new_empty!(
1483                    fidl_fuchsia_sys2::OpenDirType,
1484                    fidl::encoding::DefaultFuchsiaResourceDialect
1485                ),
1486                capability_name: fidl::new_empty!(
1487                    fidl::encoding::BoundedString<255>,
1488                    fidl::encoding::DefaultFuchsiaResourceDialect
1489                ),
1490                server_channel: fidl::new_empty!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
1491            }
1492        }
1493
1494        #[inline]
1495        unsafe fn decode(
1496            &mut self,
1497            decoder: &mut fidl::encoding::Decoder<
1498                '_,
1499                fidl::encoding::DefaultFuchsiaResourceDialect,
1500            >,
1501            offset: usize,
1502            _depth: fidl::encoding::Depth,
1503        ) -> fidl::Result<()> {
1504            decoder.debug_check_bounds::<Self>(offset);
1505            // Verify that padding bytes are zero.
1506            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1507            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1508            let mask = 0xffffffff00000000u64;
1509            let maskedval = padval & mask;
1510            if maskedval != 0 {
1511                return Err(fidl::Error::NonZeroPadding {
1512                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1513                });
1514            }
1515            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(40) };
1516            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1517            let mask = 0xffffffff00000000u64;
1518            let maskedval = padval & mask;
1519            if maskedval != 0 {
1520                return Err(fidl::Error::NonZeroPadding {
1521                    padding_start: offset + 40 + ((mask as u64).trailing_zeros() / 8) as usize,
1522                });
1523            }
1524            fidl::decode!(
1525                fidl::encoding::BoundedString<4096>,
1526                fidl::encoding::DefaultFuchsiaResourceDialect,
1527                &mut self.moniker,
1528                decoder,
1529                offset + 0,
1530                _depth
1531            )?;
1532            fidl::decode!(
1533                fidl_fuchsia_sys2::OpenDirType,
1534                fidl::encoding::DefaultFuchsiaResourceDialect,
1535                &mut self.capability_set,
1536                decoder,
1537                offset + 16,
1538                _depth
1539            )?;
1540            fidl::decode!(
1541                fidl::encoding::BoundedString<255>,
1542                fidl::encoding::DefaultFuchsiaResourceDialect,
1543                &mut self.capability_name,
1544                decoder,
1545                offset + 24,
1546                _depth
1547            )?;
1548            fidl::decode!(fidl::encoding::HandleType<fidl::Channel, { fidl::ObjectType::CHANNEL.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.server_channel, decoder, offset + 40, _depth)?;
1549            Ok(())
1550        }
1551    }
1552}