Skip to main content

fidl_fuchsia_driver_host/
fidl_fuchsia_driver_host.rs

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