Skip to main content

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