Skip to main content

fidl_fuchsia_driver_debug/
fidl_fuchsia_driver_debug.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_driver_debug_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DebugExecuteRequest {
16    /// The argument vector passed to the driver's command handler as-is,
17    /// without in-flight modification. Follows standard command-line
18    /// conventions (analogous to argv), where the first argument
19    /// (`args[0]`) is typically the command or subcommand name, followed
20    /// by any flags or positional arguments.
21    pub args: Vec<String>,
22    /// Socket to which standard output from command execution is streamed.
23    /// The driver or command handler writes to this socket and closes it
24    /// upon or before returning the response.
25    pub stdout: fidl::Socket,
26    /// Socket to which standard error from command execution is streamed.
27    /// The driver or command handler writes to this socket and closes it
28    /// upon or before returning the response.
29    pub stderr: fidl::Socket,
30}
31
32impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DebugExecuteRequest {}
33
34#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
35pub struct DebugMarker;
36
37impl fidl::endpoints::ProtocolMarker for DebugMarker {
38    type Proxy = DebugProxy;
39    type RequestStream = DebugRequestStream;
40    #[cfg(target_os = "fuchsia")]
41    type SynchronousProxy = DebugSynchronousProxy;
42
43    const DEBUG_NAME: &'static str = "fuchsia.driver.debug.Debug";
44}
45impl fidl::endpoints::DiscoverableProtocolMarker for DebugMarker {}
46pub type DebugExecuteResult = Result<i32, i32>;
47pub type DebugListCommandsResult = Result<Vec<CommandInfo>, i32>;
48
49pub trait DebugProxyInterface: Send + Sync {
50    type ExecuteResponseFut: std::future::Future<Output = Result<DebugExecuteResult, fidl::Error>>
51        + Send;
52    fn r#execute(
53        &self,
54        args: &[String],
55        stdout: fidl::Socket,
56        stderr: fidl::Socket,
57    ) -> Self::ExecuteResponseFut;
58    type ListCommandsResponseFut: std::future::Future<Output = Result<DebugListCommandsResult, fidl::Error>>
59        + Send;
60    fn r#list_commands(&self) -> Self::ListCommandsResponseFut;
61}
62#[derive(Debug)]
63#[cfg(target_os = "fuchsia")]
64pub struct DebugSynchronousProxy {
65    client: fidl::client::sync::Client,
66}
67
68#[cfg(target_os = "fuchsia")]
69impl fidl::endpoints::SynchronousProxy for DebugSynchronousProxy {
70    type Proxy = DebugProxy;
71    type Protocol = DebugMarker;
72
73    fn from_channel(inner: fidl::Channel) -> Self {
74        Self::new(inner)
75    }
76
77    fn into_channel(self) -> fidl::Channel {
78        self.client.into_channel()
79    }
80
81    fn as_channel(&self) -> &fidl::Channel {
82        self.client.as_channel()
83    }
84}
85
86#[cfg(target_os = "fuchsia")]
87impl DebugSynchronousProxy {
88    pub fn new(channel: fidl::Channel) -> Self {
89        Self { client: fidl::client::sync::Client::new(channel) }
90    }
91
92    pub fn into_channel(self) -> fidl::Channel {
93        self.client.into_channel()
94    }
95
96    /// Waits until an event arrives and returns it. It is safe for other
97    /// threads to make concurrent requests while waiting for an event.
98    pub fn wait_for_event(
99        &self,
100        deadline: zx::MonotonicInstant,
101    ) -> Result<DebugEvent, fidl::Error> {
102        DebugEvent::decode(self.client.wait_for_event::<DebugMarker>(deadline)?)
103    }
104
105    /// Executes a command with the provided argument vector.
106    ///
107    /// The argument vector `args` is passed to the driver's command handler
108    /// as-is, without in-flight modification. The argument vector follows
109    /// standard command-line conventions (analogous to argv), where the first
110    /// argument (`args[0]`) is typically the command or subcommand name,
111    /// followed by any flags or positional arguments.
112    ///
113    /// Standard output and standard error from command execution are streamed
114    /// to the provided `stdout` and `stderr` sockets. The driver or command
115    /// handler writes to these sockets and closes them upon or before
116    /// returning the response.
117    ///
118    /// Returns the command's process exit code (`exit_code`), where 0
119    /// typically denotes success.
120    ///
121    /// ## Error
122    ///
123    /// Returns a `zx.Status` error if the execution request itself fails:
124    ///
125    /// * `ZX_ERR_INVALID_ARGS`: `args` is empty.
126    /// * `ZX_ERR_NOT_FOUND`: The requested command in `args[0]` is unknown.
127    pub fn r#execute(
128        &self,
129        mut args: &[String],
130        mut stdout: fidl::Socket,
131        mut stderr: fidl::Socket,
132        ___deadline: zx::MonotonicInstant,
133    ) -> Result<DebugExecuteResult, fidl::Error> {
134        let _response = self.client.send_query::<
135            DebugExecuteRequest,
136            fidl::encoding::FlexibleResultType<DebugExecuteResponse, i32>,
137            DebugMarker,
138        >(
139            (args, stdout, stderr,),
140            0x5304f66cffdbed45,
141            fidl::encoding::DynamicFlags::FLEXIBLE,
142            ___deadline,
143        )?
144        .into_result::<DebugMarker>("execute")?;
145        Ok(_response.map(|x| x.exit_code))
146    }
147
148    /// Lists all supported commands and their descriptions.
149    pub fn r#list_commands(
150        &self,
151        ___deadline: zx::MonotonicInstant,
152    ) -> Result<DebugListCommandsResult, fidl::Error> {
153        let _response = self.client.send_query::<
154            fidl::encoding::EmptyPayload,
155            fidl::encoding::FlexibleResultType<DebugListCommandsResponse, i32>,
156            DebugMarker,
157        >(
158            (),
159            0x64f45f16f35cf381,
160            fidl::encoding::DynamicFlags::FLEXIBLE,
161            ___deadline,
162        )?
163        .into_result::<DebugMarker>("list_commands")?;
164        Ok(_response.map(|x| x.commands))
165    }
166}
167
168#[cfg(target_os = "fuchsia")]
169impl From<DebugSynchronousProxy> for zx::NullableHandle {
170    fn from(value: DebugSynchronousProxy) -> Self {
171        value.into_channel().into()
172    }
173}
174
175#[cfg(target_os = "fuchsia")]
176impl From<fidl::Channel> for DebugSynchronousProxy {
177    fn from(value: fidl::Channel) -> Self {
178        Self::new(value)
179    }
180}
181
182#[cfg(target_os = "fuchsia")]
183impl fidl::endpoints::FromClient for DebugSynchronousProxy {
184    type Protocol = DebugMarker;
185
186    fn from_client(value: fidl::endpoints::ClientEnd<DebugMarker>) -> Self {
187        Self::new(value.into_channel())
188    }
189}
190
191#[derive(Debug, Clone)]
192pub struct DebugProxy {
193    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
194}
195
196impl fidl::endpoints::Proxy for DebugProxy {
197    type Protocol = DebugMarker;
198
199    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
200        Self::new(inner)
201    }
202
203    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
204        self.client.into_channel().map_err(|client| Self { client })
205    }
206
207    fn as_channel(&self) -> &::fidl::AsyncChannel {
208        self.client.as_channel()
209    }
210}
211
212impl DebugProxy {
213    /// Create a new Proxy for fuchsia.driver.debug/Debug.
214    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
215        let protocol_name = <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
216        Self { client: fidl::client::Client::new(channel, protocol_name) }
217    }
218
219    /// Get a Stream of events from the remote end of the protocol.
220    ///
221    /// # Panics
222    ///
223    /// Panics if the event stream was already taken.
224    pub fn take_event_stream(&self) -> DebugEventStream {
225        DebugEventStream { event_receiver: self.client.take_event_receiver() }
226    }
227
228    /// Executes a command with the provided argument vector.
229    ///
230    /// The argument vector `args` is passed to the driver's command handler
231    /// as-is, without in-flight modification. The argument vector follows
232    /// standard command-line conventions (analogous to argv), where the first
233    /// argument (`args[0]`) is typically the command or subcommand name,
234    /// followed by any flags or positional arguments.
235    ///
236    /// Standard output and standard error from command execution are streamed
237    /// to the provided `stdout` and `stderr` sockets. The driver or command
238    /// handler writes to these sockets and closes them upon or before
239    /// returning the response.
240    ///
241    /// Returns the command's process exit code (`exit_code`), where 0
242    /// typically denotes success.
243    ///
244    /// ## Error
245    ///
246    /// Returns a `zx.Status` error if the execution request itself fails:
247    ///
248    /// * `ZX_ERR_INVALID_ARGS`: `args` is empty.
249    /// * `ZX_ERR_NOT_FOUND`: The requested command in `args[0]` is unknown.
250    pub fn r#execute(
251        &self,
252        mut args: &[String],
253        mut stdout: fidl::Socket,
254        mut stderr: fidl::Socket,
255    ) -> fidl::client::QueryResponseFut<
256        DebugExecuteResult,
257        fidl::encoding::DefaultFuchsiaResourceDialect,
258    > {
259        DebugProxyInterface::r#execute(self, args, stdout, stderr)
260    }
261
262    /// Lists all supported commands and their descriptions.
263    pub fn r#list_commands(
264        &self,
265    ) -> fidl::client::QueryResponseFut<
266        DebugListCommandsResult,
267        fidl::encoding::DefaultFuchsiaResourceDialect,
268    > {
269        DebugProxyInterface::r#list_commands(self)
270    }
271}
272
273impl DebugProxyInterface for DebugProxy {
274    type ExecuteResponseFut = fidl::client::QueryResponseFut<
275        DebugExecuteResult,
276        fidl::encoding::DefaultFuchsiaResourceDialect,
277    >;
278    fn r#execute(
279        &self,
280        mut args: &[String],
281        mut stdout: fidl::Socket,
282        mut stderr: fidl::Socket,
283    ) -> Self::ExecuteResponseFut {
284        fn _decode(
285            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
286        ) -> Result<DebugExecuteResult, fidl::Error> {
287            let _response = fidl::client::decode_transaction_body::<
288                fidl::encoding::FlexibleResultType<DebugExecuteResponse, i32>,
289                fidl::encoding::DefaultFuchsiaResourceDialect,
290                0x5304f66cffdbed45,
291            >(_buf?)?
292            .into_result::<DebugMarker>("execute")?;
293            Ok(_response.map(|x| x.exit_code))
294        }
295        self.client.send_query_and_decode::<DebugExecuteRequest, DebugExecuteResult>(
296            (args, stdout, stderr),
297            0x5304f66cffdbed45,
298            fidl::encoding::DynamicFlags::FLEXIBLE,
299            _decode,
300        )
301    }
302
303    type ListCommandsResponseFut = fidl::client::QueryResponseFut<
304        DebugListCommandsResult,
305        fidl::encoding::DefaultFuchsiaResourceDialect,
306    >;
307    fn r#list_commands(&self) -> Self::ListCommandsResponseFut {
308        fn _decode(
309            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
310        ) -> Result<DebugListCommandsResult, fidl::Error> {
311            let _response = fidl::client::decode_transaction_body::<
312                fidl::encoding::FlexibleResultType<DebugListCommandsResponse, i32>,
313                fidl::encoding::DefaultFuchsiaResourceDialect,
314                0x64f45f16f35cf381,
315            >(_buf?)?
316            .into_result::<DebugMarker>("list_commands")?;
317            Ok(_response.map(|x| x.commands))
318        }
319        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, DebugListCommandsResult>(
320            (),
321            0x64f45f16f35cf381,
322            fidl::encoding::DynamicFlags::FLEXIBLE,
323            _decode,
324        )
325    }
326}
327
328pub struct DebugEventStream {
329    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
330}
331
332impl std::marker::Unpin for DebugEventStream {}
333
334impl futures::stream::FusedStream for DebugEventStream {
335    fn is_terminated(&self) -> bool {
336        self.event_receiver.is_terminated()
337    }
338}
339
340impl futures::Stream for DebugEventStream {
341    type Item = Result<DebugEvent, fidl::Error>;
342
343    fn poll_next(
344        mut self: std::pin::Pin<&mut Self>,
345        cx: &mut std::task::Context<'_>,
346    ) -> std::task::Poll<Option<Self::Item>> {
347        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
348            &mut self.event_receiver,
349            cx
350        )?) {
351            Some(buf) => std::task::Poll::Ready(Some(DebugEvent::decode(buf))),
352            None => std::task::Poll::Ready(None),
353        }
354    }
355}
356
357#[derive(Debug)]
358pub enum DebugEvent {
359    #[non_exhaustive]
360    _UnknownEvent {
361        /// Ordinal of the event that was sent.
362        ordinal: u64,
363    },
364}
365
366impl DebugEvent {
367    /// Decodes a message buffer as a [`DebugEvent`].
368    fn decode(
369        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
370    ) -> Result<DebugEvent, fidl::Error> {
371        let (bytes, _handles) = buf.split_mut();
372        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
373        debug_assert_eq!(tx_header.tx_id, 0);
374        match tx_header.ordinal {
375            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
376                Ok(DebugEvent::_UnknownEvent { ordinal: tx_header.ordinal })
377            }
378            _ => Err(fidl::Error::UnknownOrdinal {
379                ordinal: tx_header.ordinal,
380                protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
381            }),
382        }
383    }
384}
385
386/// A Stream of incoming requests for fuchsia.driver.debug/Debug.
387pub struct DebugRequestStream {
388    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
389    is_terminated: bool,
390}
391
392impl std::marker::Unpin for DebugRequestStream {}
393
394impl futures::stream::FusedStream for DebugRequestStream {
395    fn is_terminated(&self) -> bool {
396        self.is_terminated
397    }
398}
399
400impl fidl::endpoints::RequestStream for DebugRequestStream {
401    type Protocol = DebugMarker;
402    type ControlHandle = DebugControlHandle;
403
404    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
405        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
406    }
407
408    fn control_handle(&self) -> Self::ControlHandle {
409        DebugControlHandle { inner: self.inner.clone() }
410    }
411
412    fn into_inner(
413        self,
414    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
415    {
416        (self.inner, self.is_terminated)
417    }
418
419    fn from_inner(
420        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
421        is_terminated: bool,
422    ) -> Self {
423        Self { inner, is_terminated }
424    }
425}
426
427impl futures::Stream for DebugRequestStream {
428    type Item = Result<DebugRequest, fidl::Error>;
429
430    fn poll_next(
431        mut self: std::pin::Pin<&mut Self>,
432        cx: &mut std::task::Context<'_>,
433    ) -> std::task::Poll<Option<Self::Item>> {
434        let this = &mut *self;
435        if this.inner.check_shutdown(cx) {
436            this.is_terminated = true;
437            return std::task::Poll::Ready(None);
438        }
439        if this.is_terminated {
440            panic!("polled DebugRequestStream after completion");
441        }
442        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
443            |bytes, handles| {
444                match this.inner.channel().read_etc(cx, bytes, handles) {
445                    std::task::Poll::Ready(Ok(())) => {}
446                    std::task::Poll::Pending => return std::task::Poll::Pending,
447                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
448                        this.is_terminated = true;
449                        return std::task::Poll::Ready(None);
450                    }
451                    std::task::Poll::Ready(Err(e)) => {
452                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
453                            e.into(),
454                        ))));
455                    }
456                }
457
458                // A message has been received from the channel
459                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
460
461                std::task::Poll::Ready(Some(match header.ordinal {
462                    0x5304f66cffdbed45 => {
463                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
464                        let mut req = fidl::new_empty!(
465                            DebugExecuteRequest,
466                            fidl::encoding::DefaultFuchsiaResourceDialect
467                        );
468                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DebugExecuteRequest>(&header, _body_bytes, handles, &mut req)?;
469                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
470                        Ok(DebugRequest::Execute {
471                            args: req.args,
472                            stdout: req.stdout,
473                            stderr: req.stderr,
474
475                            responder: DebugExecuteResponder {
476                                control_handle: std::mem::ManuallyDrop::new(control_handle),
477                                tx_id: header.tx_id,
478                            },
479                        })
480                    }
481                    0x64f45f16f35cf381 => {
482                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
483                        let mut req = fidl::new_empty!(
484                            fidl::encoding::EmptyPayload,
485                            fidl::encoding::DefaultFuchsiaResourceDialect
486                        );
487                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
488                        let control_handle = DebugControlHandle { inner: this.inner.clone() };
489                        Ok(DebugRequest::ListCommands {
490                            responder: DebugListCommandsResponder {
491                                control_handle: std::mem::ManuallyDrop::new(control_handle),
492                                tx_id: header.tx_id,
493                            },
494                        })
495                    }
496                    _ if header.tx_id == 0
497                        && header
498                            .dynamic_flags()
499                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
500                    {
501                        Ok(DebugRequest::_UnknownMethod {
502                            ordinal: header.ordinal,
503                            control_handle: DebugControlHandle { inner: this.inner.clone() },
504                            method_type: fidl::MethodType::OneWay,
505                        })
506                    }
507                    _ if header
508                        .dynamic_flags()
509                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
510                    {
511                        this.inner.send_framework_err(
512                            fidl::encoding::FrameworkErr::UnknownMethod,
513                            header.tx_id,
514                            header.ordinal,
515                            header.dynamic_flags(),
516                            (bytes, handles),
517                        )?;
518                        Ok(DebugRequest::_UnknownMethod {
519                            ordinal: header.ordinal,
520                            control_handle: DebugControlHandle { inner: this.inner.clone() },
521                            method_type: fidl::MethodType::TwoWay,
522                        })
523                    }
524                    _ => Err(fidl::Error::UnknownOrdinal {
525                        ordinal: header.ordinal,
526                        protocol_name: <DebugMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
527                    }),
528                }))
529            },
530        )
531    }
532}
533
534/// Protocol for executing interactive driver debug commands.
535#[derive(Debug)]
536pub enum DebugRequest {
537    /// Executes a command with the provided argument vector.
538    ///
539    /// The argument vector `args` is passed to the driver's command handler
540    /// as-is, without in-flight modification. The argument vector follows
541    /// standard command-line conventions (analogous to argv), where the first
542    /// argument (`args[0]`) is typically the command or subcommand name,
543    /// followed by any flags or positional arguments.
544    ///
545    /// Standard output and standard error from command execution are streamed
546    /// to the provided `stdout` and `stderr` sockets. The driver or command
547    /// handler writes to these sockets and closes them upon or before
548    /// returning the response.
549    ///
550    /// Returns the command's process exit code (`exit_code`), where 0
551    /// typically denotes success.
552    ///
553    /// ## Error
554    ///
555    /// Returns a `zx.Status` error if the execution request itself fails:
556    ///
557    /// * `ZX_ERR_INVALID_ARGS`: `args` is empty.
558    /// * `ZX_ERR_NOT_FOUND`: The requested command in `args[0]` is unknown.
559    Execute {
560        args: Vec<String>,
561        stdout: fidl::Socket,
562        stderr: fidl::Socket,
563        responder: DebugExecuteResponder,
564    },
565    /// Lists all supported commands and their descriptions.
566    ListCommands { responder: DebugListCommandsResponder },
567    /// An interaction was received which does not match any known method.
568    #[non_exhaustive]
569    _UnknownMethod {
570        /// Ordinal of the method that was called.
571        ordinal: u64,
572        control_handle: DebugControlHandle,
573        method_type: fidl::MethodType,
574    },
575}
576
577impl DebugRequest {
578    #[allow(irrefutable_let_patterns)]
579    pub fn into_execute(
580        self,
581    ) -> Option<(Vec<String>, fidl::Socket, fidl::Socket, DebugExecuteResponder)> {
582        if let DebugRequest::Execute { args, stdout, stderr, responder } = self {
583            Some((args, stdout, stderr, responder))
584        } else {
585            None
586        }
587    }
588
589    #[allow(irrefutable_let_patterns)]
590    pub fn into_list_commands(self) -> Option<(DebugListCommandsResponder)> {
591        if let DebugRequest::ListCommands { responder } = self { Some((responder)) } else { None }
592    }
593
594    /// Name of the method defined in FIDL
595    pub fn method_name(&self) -> &'static str {
596        match *self {
597            DebugRequest::Execute { .. } => "execute",
598            DebugRequest::ListCommands { .. } => "list_commands",
599            DebugRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
600                "unknown one-way method"
601            }
602            DebugRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
603                "unknown two-way method"
604            }
605        }
606    }
607}
608
609#[derive(Debug, Clone)]
610pub struct DebugControlHandle {
611    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
612}
613
614impl DebugControlHandle {
615    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
616        self.inner.shutdown_with_epitaph(status.into())
617    }
618}
619
620impl fidl::endpoints::ControlHandle for DebugControlHandle {
621    fn shutdown(&self) {
622        self.inner.shutdown()
623    }
624
625    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
626        self.inner.shutdown_with_epitaph(status)
627    }
628
629    fn is_closed(&self) -> bool {
630        self.inner.channel().is_closed()
631    }
632    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
633        self.inner.channel().on_closed()
634    }
635
636    #[cfg(target_os = "fuchsia")]
637    fn signal_peer(
638        &self,
639        clear_mask: zx::Signals,
640        set_mask: zx::Signals,
641    ) -> Result<(), zx_status::Status> {
642        use fidl::Peered;
643        self.inner.channel().signal_peer(clear_mask, set_mask)
644    }
645}
646
647impl DebugControlHandle {}
648
649#[must_use = "FIDL methods require a response to be sent"]
650#[derive(Debug)]
651pub struct DebugExecuteResponder {
652    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
653    tx_id: u32,
654}
655
656/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
657/// if the responder is dropped without sending a response, so that the client
658/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
659impl std::ops::Drop for DebugExecuteResponder {
660    fn drop(&mut self) {
661        self.control_handle.shutdown();
662        // Safety: drops once, never accessed again
663        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
664    }
665}
666
667impl fidl::endpoints::Responder for DebugExecuteResponder {
668    type ControlHandle = DebugControlHandle;
669
670    fn control_handle(&self) -> &DebugControlHandle {
671        &self.control_handle
672    }
673
674    fn drop_without_shutdown(mut self) {
675        // Safety: drops once, never accessed again due to mem::forget
676        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
677        // Prevent Drop from running (which would shut down the channel)
678        std::mem::forget(self);
679    }
680}
681
682impl DebugExecuteResponder {
683    /// Sends a response to the FIDL transaction.
684    ///
685    /// Sets the channel to shutdown if an error occurs.
686    pub fn send(self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
687        let _result = self.send_raw(result);
688        if _result.is_err() {
689            self.control_handle.shutdown();
690        }
691        self.drop_without_shutdown();
692        _result
693    }
694
695    /// Similar to "send" but does not shutdown the channel if an error occurs.
696    pub fn send_no_shutdown_on_err(self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
697        let _result = self.send_raw(result);
698        self.drop_without_shutdown();
699        _result
700    }
701
702    fn send_raw(&self, mut result: Result<i32, i32>) -> Result<(), fidl::Error> {
703        self.control_handle
704            .inner
705            .send::<fidl::encoding::FlexibleResultType<DebugExecuteResponse, i32>>(
706                fidl::encoding::FlexibleResult::new(result.map(|exit_code| (exit_code,))),
707                self.tx_id,
708                0x5304f66cffdbed45,
709                fidl::encoding::DynamicFlags::FLEXIBLE,
710            )
711    }
712}
713
714#[must_use = "FIDL methods require a response to be sent"]
715#[derive(Debug)]
716pub struct DebugListCommandsResponder {
717    control_handle: std::mem::ManuallyDrop<DebugControlHandle>,
718    tx_id: u32,
719}
720
721/// Set the the channel to be shutdown (see [`DebugControlHandle::shutdown`])
722/// if the responder is dropped without sending a response, so that the client
723/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
724impl std::ops::Drop for DebugListCommandsResponder {
725    fn drop(&mut self) {
726        self.control_handle.shutdown();
727        // Safety: drops once, never accessed again
728        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
729    }
730}
731
732impl fidl::endpoints::Responder for DebugListCommandsResponder {
733    type ControlHandle = DebugControlHandle;
734
735    fn control_handle(&self) -> &DebugControlHandle {
736        &self.control_handle
737    }
738
739    fn drop_without_shutdown(mut self) {
740        // Safety: drops once, never accessed again due to mem::forget
741        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
742        // Prevent Drop from running (which would shut down the channel)
743        std::mem::forget(self);
744    }
745}
746
747impl DebugListCommandsResponder {
748    /// Sends a response to the FIDL transaction.
749    ///
750    /// Sets the channel to shutdown if an error occurs.
751    pub fn send(self, mut result: Result<&[CommandInfo], i32>) -> Result<(), fidl::Error> {
752        let _result = self.send_raw(result);
753        if _result.is_err() {
754            self.control_handle.shutdown();
755        }
756        self.drop_without_shutdown();
757        _result
758    }
759
760    /// Similar to "send" but does not shutdown the channel if an error occurs.
761    pub fn send_no_shutdown_on_err(
762        self,
763        mut result: Result<&[CommandInfo], i32>,
764    ) -> Result<(), fidl::Error> {
765        let _result = self.send_raw(result);
766        self.drop_without_shutdown();
767        _result
768    }
769
770    fn send_raw(&self, mut result: Result<&[CommandInfo], i32>) -> Result<(), fidl::Error> {
771        self.control_handle
772            .inner
773            .send::<fidl::encoding::FlexibleResultType<DebugListCommandsResponse, i32>>(
774                fidl::encoding::FlexibleResult::new(result.map(|commands| (commands,))),
775                self.tx_id,
776                0x64f45f16f35cf381,
777                fidl::encoding::DynamicFlags::FLEXIBLE,
778            )
779    }
780}
781
782mod internal {
783    use super::*;
784
785    impl fidl::encoding::ResourceTypeMarker for DebugExecuteRequest {
786        type Borrowed<'a> = &'a mut Self;
787        fn take_or_borrow<'a>(
788            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
789        ) -> Self::Borrowed<'a> {
790            value
791        }
792    }
793
794    unsafe impl fidl::encoding::TypeMarker for DebugExecuteRequest {
795        type Owned = Self;
796
797        #[inline(always)]
798        fn inline_align(_context: fidl::encoding::Context) -> usize {
799            8
800        }
801
802        #[inline(always)]
803        fn inline_size(_context: fidl::encoding::Context) -> usize {
804            24
805        }
806    }
807
808    unsafe impl
809        fidl::encoding::Encode<DebugExecuteRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
810        for &mut DebugExecuteRequest
811    {
812        #[inline]
813        unsafe fn encode(
814            self,
815            encoder: &mut fidl::encoding::Encoder<
816                '_,
817                fidl::encoding::DefaultFuchsiaResourceDialect,
818            >,
819            offset: usize,
820            _depth: fidl::encoding::Depth,
821        ) -> fidl::Result<()> {
822            encoder.debug_check_bounds::<DebugExecuteRequest>(offset);
823            // Delegate to tuple encoding.
824            fidl::encoding::Encode::<DebugExecuteRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
825                (
826                    <fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128> as fidl::encoding::ValueTypeMarker>::borrow(&self.args),
827                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stdout),
828                    <fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.stderr),
829                ),
830                encoder, offset, _depth
831            )
832        }
833    }
834    unsafe impl<
835        T0: fidl::encoding::Encode<
836                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128>,
837                fidl::encoding::DefaultFuchsiaResourceDialect,
838            >,
839        T1: fidl::encoding::Encode<
840                fidl::encoding::HandleType<
841                    fidl::Socket,
842                    { fidl::ObjectType::SOCKET.into_raw() },
843                    2147483648,
844                >,
845                fidl::encoding::DefaultFuchsiaResourceDialect,
846            >,
847        T2: fidl::encoding::Encode<
848                fidl::encoding::HandleType<
849                    fidl::Socket,
850                    { fidl::ObjectType::SOCKET.into_raw() },
851                    2147483648,
852                >,
853                fidl::encoding::DefaultFuchsiaResourceDialect,
854            >,
855    > fidl::encoding::Encode<DebugExecuteRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
856        for (T0, T1, T2)
857    {
858        #[inline]
859        unsafe fn encode(
860            self,
861            encoder: &mut fidl::encoding::Encoder<
862                '_,
863                fidl::encoding::DefaultFuchsiaResourceDialect,
864            >,
865            offset: usize,
866            depth: fidl::encoding::Depth,
867        ) -> fidl::Result<()> {
868            encoder.debug_check_bounds::<DebugExecuteRequest>(offset);
869            // Zero out padding regions. There's no need to apply masks
870            // because the unmasked parts will be overwritten by fields.
871            // Write the fields.
872            self.0.encode(encoder, offset + 0, depth)?;
873            self.1.encode(encoder, offset + 16, depth)?;
874            self.2.encode(encoder, offset + 20, depth)?;
875            Ok(())
876        }
877    }
878
879    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
880        for DebugExecuteRequest
881    {
882        #[inline(always)]
883        fn new_empty() -> Self {
884            Self {
885                args: fidl::new_empty!(
886                    fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128>,
887                    fidl::encoding::DefaultFuchsiaResourceDialect
888                ),
889                stdout: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
890                stderr: fidl::new_empty!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
891            }
892        }
893
894        #[inline]
895        unsafe fn decode(
896            &mut self,
897            decoder: &mut fidl::encoding::Decoder<
898                '_,
899                fidl::encoding::DefaultFuchsiaResourceDialect,
900            >,
901            offset: usize,
902            _depth: fidl::encoding::Depth,
903        ) -> fidl::Result<()> {
904            decoder.debug_check_bounds::<Self>(offset);
905            // Verify that padding bytes are zero.
906            fidl::decode!(
907                fidl::encoding::Vector<fidl::encoding::BoundedString<1024>, 128>,
908                fidl::encoding::DefaultFuchsiaResourceDialect,
909                &mut self.args,
910                decoder,
911                offset + 0,
912                _depth
913            )?;
914            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.stdout, decoder, offset + 16, _depth)?;
915            fidl::decode!(fidl::encoding::HandleType<fidl::Socket, { fidl::ObjectType::SOCKET.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.stderr, decoder, offset + 20, _depth)?;
916            Ok(())
917        }
918    }
919}