fidl_fuchsia_driver_host/
fidl_fuchsia_driver_host.rs

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