fidl_fuchsia_driver_host/
fidl_fuchsia_driver_host.rs

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