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