Skip to main content

fidl_fuchsia_driver_host/
fidl_fuchsia_driver_host.rs

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