fidl_fuchsia_driver_host/
fidl_fuchsia_driver_host.rs

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