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)]
15pub struct DriverHostInstallLoaderRequest {
16    pub loader: fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
20    for DriverHostInstallLoaderRequest
21{
22}
23
24#[derive(Debug, PartialEq)]
25pub struct DriverHostStartRequest {
26    pub start_args: fidl_fuchsia_driver_framework::DriverStartArgs,
27    pub driver: fidl::endpoints::ServerEnd<DriverMarker>,
28}
29
30impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DriverHostStartRequest {}
31
32#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
33pub struct DriverMarker;
34
35impl fidl::endpoints::ProtocolMarker for DriverMarker {
36    type Proxy = DriverProxy;
37    type RequestStream = DriverRequestStream;
38    #[cfg(target_os = "fuchsia")]
39    type SynchronousProxy = DriverSynchronousProxy;
40
41    const DEBUG_NAME: &'static str = "(anonymous) Driver";
42}
43
44pub trait DriverProxyInterface: Send + Sync {
45    fn r#stop(&self) -> Result<(), fidl::Error>;
46}
47#[derive(Debug)]
48#[cfg(target_os = "fuchsia")]
49pub struct DriverSynchronousProxy {
50    client: fidl::client::sync::Client,
51}
52
53#[cfg(target_os = "fuchsia")]
54impl fidl::endpoints::SynchronousProxy for DriverSynchronousProxy {
55    type Proxy = DriverProxy;
56    type Protocol = DriverMarker;
57
58    fn from_channel(inner: fidl::Channel) -> Self {
59        Self::new(inner)
60    }
61
62    fn into_channel(self) -> fidl::Channel {
63        self.client.into_channel()
64    }
65
66    fn as_channel(&self) -> &fidl::Channel {
67        self.client.as_channel()
68    }
69}
70
71#[cfg(target_os = "fuchsia")]
72impl DriverSynchronousProxy {
73    pub fn new(channel: fidl::Channel) -> Self {
74        let protocol_name = <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
75        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
76    }
77
78    pub fn into_channel(self) -> fidl::Channel {
79        self.client.into_channel()
80    }
81
82    /// Waits until an event arrives and returns it. It is safe for other
83    /// threads to make concurrent requests while waiting for an event.
84    pub fn wait_for_event(
85        &self,
86        deadline: zx::MonotonicInstant,
87    ) -> Result<DriverEvent, fidl::Error> {
88        DriverEvent::decode(self.client.wait_for_event(deadline)?)
89    }
90
91    /// Request that the Driver is Stopped.
92    ///
93    /// After stopping the driver instance, the server should close this
94    /// connection with an epitath. This signals that the Driver has been
95    /// stopped.
96    pub fn r#stop(&self) -> Result<(), fidl::Error> {
97        self.client.send::<fidl::encoding::EmptyPayload>(
98            (),
99            0x4039e87556689b5f,
100            fidl::encoding::DynamicFlags::empty(),
101        )
102    }
103}
104
105#[derive(Debug, Clone)]
106pub struct DriverProxy {
107    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
108}
109
110impl fidl::endpoints::Proxy for DriverProxy {
111    type Protocol = DriverMarker;
112
113    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
114        Self::new(inner)
115    }
116
117    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
118        self.client.into_channel().map_err(|client| Self { client })
119    }
120
121    fn as_channel(&self) -> &::fidl::AsyncChannel {
122        self.client.as_channel()
123    }
124}
125
126impl DriverProxy {
127    /// Create a new Proxy for fuchsia.driver.host/Driver.
128    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
129        let protocol_name = <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
130        Self { client: fidl::client::Client::new(channel, protocol_name) }
131    }
132
133    /// Get a Stream of events from the remote end of the protocol.
134    ///
135    /// # Panics
136    ///
137    /// Panics if the event stream was already taken.
138    pub fn take_event_stream(&self) -> DriverEventStream {
139        DriverEventStream { event_receiver: self.client.take_event_receiver() }
140    }
141
142    /// Request that the Driver is Stopped.
143    ///
144    /// After stopping the driver instance, the server should close this
145    /// connection with an epitath. This signals that the Driver has been
146    /// stopped.
147    pub fn r#stop(&self) -> Result<(), fidl::Error> {
148        DriverProxyInterface::r#stop(self)
149    }
150}
151
152impl DriverProxyInterface for DriverProxy {
153    fn r#stop(&self) -> Result<(), fidl::Error> {
154        self.client.send::<fidl::encoding::EmptyPayload>(
155            (),
156            0x4039e87556689b5f,
157            fidl::encoding::DynamicFlags::empty(),
158        )
159    }
160}
161
162pub struct DriverEventStream {
163    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
164}
165
166impl std::marker::Unpin for DriverEventStream {}
167
168impl futures::stream::FusedStream for DriverEventStream {
169    fn is_terminated(&self) -> bool {
170        self.event_receiver.is_terminated()
171    }
172}
173
174impl futures::Stream for DriverEventStream {
175    type Item = Result<DriverEvent, fidl::Error>;
176
177    fn poll_next(
178        mut self: std::pin::Pin<&mut Self>,
179        cx: &mut std::task::Context<'_>,
180    ) -> std::task::Poll<Option<Self::Item>> {
181        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
182            &mut self.event_receiver,
183            cx
184        )?) {
185            Some(buf) => std::task::Poll::Ready(Some(DriverEvent::decode(buf))),
186            None => std::task::Poll::Ready(None),
187        }
188    }
189}
190
191#[derive(Debug)]
192pub enum DriverEvent {}
193
194impl DriverEvent {
195    /// Decodes a message buffer as a [`DriverEvent`].
196    fn decode(
197        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
198    ) -> Result<DriverEvent, fidl::Error> {
199        let (bytes, _handles) = buf.split_mut();
200        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
201        debug_assert_eq!(tx_header.tx_id, 0);
202        match tx_header.ordinal {
203            _ => Err(fidl::Error::UnknownOrdinal {
204                ordinal: tx_header.ordinal,
205                protocol_name: <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
206            }),
207        }
208    }
209}
210
211/// A Stream of incoming requests for fuchsia.driver.host/Driver.
212pub struct DriverRequestStream {
213    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
214    is_terminated: bool,
215}
216
217impl std::marker::Unpin for DriverRequestStream {}
218
219impl futures::stream::FusedStream for DriverRequestStream {
220    fn is_terminated(&self) -> bool {
221        self.is_terminated
222    }
223}
224
225impl fidl::endpoints::RequestStream for DriverRequestStream {
226    type Protocol = DriverMarker;
227    type ControlHandle = DriverControlHandle;
228
229    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
230        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
231    }
232
233    fn control_handle(&self) -> Self::ControlHandle {
234        DriverControlHandle { inner: self.inner.clone() }
235    }
236
237    fn into_inner(
238        self,
239    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
240    {
241        (self.inner, self.is_terminated)
242    }
243
244    fn from_inner(
245        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
246        is_terminated: bool,
247    ) -> Self {
248        Self { inner, is_terminated }
249    }
250}
251
252impl futures::Stream for DriverRequestStream {
253    type Item = Result<DriverRequest, fidl::Error>;
254
255    fn poll_next(
256        mut self: std::pin::Pin<&mut Self>,
257        cx: &mut std::task::Context<'_>,
258    ) -> std::task::Poll<Option<Self::Item>> {
259        let this = &mut *self;
260        if this.inner.check_shutdown(cx) {
261            this.is_terminated = true;
262            return std::task::Poll::Ready(None);
263        }
264        if this.is_terminated {
265            panic!("polled DriverRequestStream after completion");
266        }
267        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
268            |bytes, handles| {
269                match this.inner.channel().read_etc(cx, bytes, handles) {
270                    std::task::Poll::Ready(Ok(())) => {}
271                    std::task::Poll::Pending => return std::task::Poll::Pending,
272                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
273                        this.is_terminated = true;
274                        return std::task::Poll::Ready(None);
275                    }
276                    std::task::Poll::Ready(Err(e)) => {
277                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
278                            e.into(),
279                        ))))
280                    }
281                }
282
283                // A message has been received from the channel
284                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
285
286                std::task::Poll::Ready(Some(match header.ordinal {
287                    0x4039e87556689b5f => {
288                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
289                        let mut req = fidl::new_empty!(
290                            fidl::encoding::EmptyPayload,
291                            fidl::encoding::DefaultFuchsiaResourceDialect
292                        );
293                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
294                        let control_handle = DriverControlHandle { inner: this.inner.clone() };
295                        Ok(DriverRequest::Stop { control_handle })
296                    }
297                    _ => Err(fidl::Error::UnknownOrdinal {
298                        ordinal: header.ordinal,
299                        protocol_name:
300                            <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
301                    }),
302                }))
303            },
304        )
305    }
306}
307
308/// Protocol through which a driver's lifecycle can be managed.
309///
310/// The Driver Runner will call Stop() on this protocol to indicate that the
311/// Driver Host should stop the Driver. The Driver Host should close the
312/// server end of the channel with an epitath to signal that the driver has
313/// been stopped.
314///
315/// EPITAPH
316///
317/// This protocol sends a FIDL epitaph to indicate that the driver instance
318/// has been terminated correctly. The Driver Host must send an epitaph of
319/// ZX_OK in order to indicate the Driver was Stopped correctly.
320/// Not sending an epitaph, or sending an error, will cause Driver Runner
321/// to log an error.
322#[derive(Debug)]
323pub enum DriverRequest {
324    /// Request that the Driver is Stopped.
325    ///
326    /// After stopping the driver instance, the server should close this
327    /// connection with an epitath. This signals that the Driver has been
328    /// stopped.
329    Stop { control_handle: DriverControlHandle },
330}
331
332impl DriverRequest {
333    #[allow(irrefutable_let_patterns)]
334    pub fn into_stop(self) -> Option<(DriverControlHandle)> {
335        if let DriverRequest::Stop { control_handle } = self {
336            Some((control_handle))
337        } else {
338            None
339        }
340    }
341
342    /// Name of the method defined in FIDL
343    pub fn method_name(&self) -> &'static str {
344        match *self {
345            DriverRequest::Stop { .. } => "stop",
346        }
347    }
348}
349
350#[derive(Debug, Clone)]
351pub struct DriverControlHandle {
352    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
353}
354
355impl fidl::endpoints::ControlHandle for DriverControlHandle {
356    fn shutdown(&self) {
357        self.inner.shutdown()
358    }
359    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
360        self.inner.shutdown_with_epitaph(status)
361    }
362
363    fn is_closed(&self) -> bool {
364        self.inner.channel().is_closed()
365    }
366    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
367        self.inner.channel().on_closed()
368    }
369
370    #[cfg(target_os = "fuchsia")]
371    fn signal_peer(
372        &self,
373        clear_mask: zx::Signals,
374        set_mask: zx::Signals,
375    ) -> Result<(), zx_status::Status> {
376        use fidl::Peered;
377        self.inner.channel().signal_peer(clear_mask, set_mask)
378    }
379}
380
381impl DriverControlHandle {}
382
383#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
384pub struct DriverHostMarker;
385
386impl fidl::endpoints::ProtocolMarker for DriverHostMarker {
387    type Proxy = DriverHostProxy;
388    type RequestStream = DriverHostRequestStream;
389    #[cfg(target_os = "fuchsia")]
390    type SynchronousProxy = DriverHostSynchronousProxy;
391
392    const DEBUG_NAME: &'static str = "fuchsia.driver.host.DriverHost";
393}
394impl fidl::endpoints::DiscoverableProtocolMarker for DriverHostMarker {}
395pub type DriverHostStartResult = Result<(), i32>;
396pub type DriverHostGetProcessInfoResult =
397    Result<(u64, u64, Vec<ThreadInfo>, Vec<DispatcherInfo>), i32>;
398
399pub trait DriverHostProxyInterface: Send + Sync {
400    type StartResponseFut: std::future::Future<Output = Result<DriverHostStartResult, fidl::Error>>
401        + Send;
402    fn r#start(
403        &self,
404        start_args: fidl_fuchsia_driver_framework::DriverStartArgs,
405        driver: fidl::endpoints::ServerEnd<DriverMarker>,
406    ) -> Self::StartResponseFut;
407    type GetProcessInfoResponseFut: std::future::Future<Output = Result<DriverHostGetProcessInfoResult, fidl::Error>>
408        + Send;
409    fn r#get_process_info(&self) -> Self::GetProcessInfoResponseFut;
410    fn r#install_loader(
411        &self,
412        loader: fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
413    ) -> Result<(), fidl::Error>;
414}
415#[derive(Debug)]
416#[cfg(target_os = "fuchsia")]
417pub struct DriverHostSynchronousProxy {
418    client: fidl::client::sync::Client,
419}
420
421#[cfg(target_os = "fuchsia")]
422impl fidl::endpoints::SynchronousProxy for DriverHostSynchronousProxy {
423    type Proxy = DriverHostProxy;
424    type Protocol = DriverHostMarker;
425
426    fn from_channel(inner: fidl::Channel) -> Self {
427        Self::new(inner)
428    }
429
430    fn into_channel(self) -> fidl::Channel {
431        self.client.into_channel()
432    }
433
434    fn as_channel(&self) -> &fidl::Channel {
435        self.client.as_channel()
436    }
437}
438
439#[cfg(target_os = "fuchsia")]
440impl DriverHostSynchronousProxy {
441    pub fn new(channel: fidl::Channel) -> Self {
442        let protocol_name = <DriverHostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
443        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
444    }
445
446    pub fn into_channel(self) -> fidl::Channel {
447        self.client.into_channel()
448    }
449
450    /// Waits until an event arrives and returns it. It is safe for other
451    /// threads to make concurrent requests while waiting for an event.
452    pub fn wait_for_event(
453        &self,
454        deadline: zx::MonotonicInstant,
455    ) -> Result<DriverHostEvent, fidl::Error> {
456        DriverHostEvent::decode(self.client.wait_for_event(deadline)?)
457    }
458
459    /// Start a driver within a driver host.
460    pub fn r#start(
461        &self,
462        mut start_args: fidl_fuchsia_driver_framework::DriverStartArgs,
463        mut driver: fidl::endpoints::ServerEnd<DriverMarker>,
464        ___deadline: zx::MonotonicInstant,
465    ) -> Result<DriverHostStartResult, fidl::Error> {
466        let _response = self.client.send_query::<
467            DriverHostStartRequest,
468            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
469        >(
470            (&mut start_args, driver,),
471            0x1848852bd195bde5,
472            fidl::encoding::DynamicFlags::empty(),
473            ___deadline,
474        )?;
475        Ok(_response.map(|x| x))
476    }
477
478    /// Returns the job and process KOIDs of the driver host.
479    pub fn r#get_process_info(
480        &self,
481        ___deadline: zx::MonotonicInstant,
482    ) -> Result<DriverHostGetProcessInfoResult, fidl::Error> {
483        let _response = self.client.send_query::<
484            fidl::encoding::EmptyPayload,
485            fidl::encoding::ResultType<ProcessInfo, i32>,
486        >(
487            (),
488            0x1b2d1b727a614973,
489            fidl::encoding::DynamicFlags::empty(),
490            ___deadline,
491        )?;
492        Ok(_response.map(|x| (x.job_koid, x.process_koid, x.threads, x.dispatchers)))
493    }
494
495    /// Provides a loader service which should be installed via
496    /// `dl_set_loader_service`.
497    pub fn r#install_loader(
498        &self,
499        mut loader: fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
500    ) -> Result<(), fidl::Error> {
501        self.client.send::<DriverHostInstallLoaderRequest>(
502            (loader,),
503            0x7022edafc5fcf5a3,
504            fidl::encoding::DynamicFlags::empty(),
505        )
506    }
507}
508
509#[derive(Debug, Clone)]
510pub struct DriverHostProxy {
511    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
512}
513
514impl fidl::endpoints::Proxy for DriverHostProxy {
515    type Protocol = DriverHostMarker;
516
517    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
518        Self::new(inner)
519    }
520
521    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
522        self.client.into_channel().map_err(|client| Self { client })
523    }
524
525    fn as_channel(&self) -> &::fidl::AsyncChannel {
526        self.client.as_channel()
527    }
528}
529
530impl DriverHostProxy {
531    /// Create a new Proxy for fuchsia.driver.host/DriverHost.
532    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
533        let protocol_name = <DriverHostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
534        Self { client: fidl::client::Client::new(channel, protocol_name) }
535    }
536
537    /// Get a Stream of events from the remote end of the protocol.
538    ///
539    /// # Panics
540    ///
541    /// Panics if the event stream was already taken.
542    pub fn take_event_stream(&self) -> DriverHostEventStream {
543        DriverHostEventStream { event_receiver: self.client.take_event_receiver() }
544    }
545
546    /// Start a driver within a driver host.
547    pub fn r#start(
548        &self,
549        mut start_args: fidl_fuchsia_driver_framework::DriverStartArgs,
550        mut driver: fidl::endpoints::ServerEnd<DriverMarker>,
551    ) -> fidl::client::QueryResponseFut<
552        DriverHostStartResult,
553        fidl::encoding::DefaultFuchsiaResourceDialect,
554    > {
555        DriverHostProxyInterface::r#start(self, start_args, driver)
556    }
557
558    /// Returns the job and process KOIDs of the driver host.
559    pub fn r#get_process_info(
560        &self,
561    ) -> fidl::client::QueryResponseFut<
562        DriverHostGetProcessInfoResult,
563        fidl::encoding::DefaultFuchsiaResourceDialect,
564    > {
565        DriverHostProxyInterface::r#get_process_info(self)
566    }
567
568    /// Provides a loader service which should be installed via
569    /// `dl_set_loader_service`.
570    pub fn r#install_loader(
571        &self,
572        mut loader: fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
573    ) -> Result<(), fidl::Error> {
574        DriverHostProxyInterface::r#install_loader(self, loader)
575    }
576}
577
578impl DriverHostProxyInterface for DriverHostProxy {
579    type StartResponseFut = fidl::client::QueryResponseFut<
580        DriverHostStartResult,
581        fidl::encoding::DefaultFuchsiaResourceDialect,
582    >;
583    fn r#start(
584        &self,
585        mut start_args: fidl_fuchsia_driver_framework::DriverStartArgs,
586        mut driver: fidl::endpoints::ServerEnd<DriverMarker>,
587    ) -> Self::StartResponseFut {
588        fn _decode(
589            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
590        ) -> Result<DriverHostStartResult, fidl::Error> {
591            let _response = fidl::client::decode_transaction_body::<
592                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
593                fidl::encoding::DefaultFuchsiaResourceDialect,
594                0x1848852bd195bde5,
595            >(_buf?)?;
596            Ok(_response.map(|x| x))
597        }
598        self.client.send_query_and_decode::<DriverHostStartRequest, DriverHostStartResult>(
599            (&mut start_args, driver),
600            0x1848852bd195bde5,
601            fidl::encoding::DynamicFlags::empty(),
602            _decode,
603        )
604    }
605
606    type GetProcessInfoResponseFut = fidl::client::QueryResponseFut<
607        DriverHostGetProcessInfoResult,
608        fidl::encoding::DefaultFuchsiaResourceDialect,
609    >;
610    fn r#get_process_info(&self) -> Self::GetProcessInfoResponseFut {
611        fn _decode(
612            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
613        ) -> Result<DriverHostGetProcessInfoResult, fidl::Error> {
614            let _response = fidl::client::decode_transaction_body::<
615                fidl::encoding::ResultType<ProcessInfo, i32>,
616                fidl::encoding::DefaultFuchsiaResourceDialect,
617                0x1b2d1b727a614973,
618            >(_buf?)?;
619            Ok(_response.map(|x| (x.job_koid, x.process_koid, x.threads, x.dispatchers)))
620        }
621        self.client
622            .send_query_and_decode::<fidl::encoding::EmptyPayload, DriverHostGetProcessInfoResult>(
623                (),
624                0x1b2d1b727a614973,
625                fidl::encoding::DynamicFlags::empty(),
626                _decode,
627            )
628    }
629
630    fn r#install_loader(
631        &self,
632        mut loader: fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
633    ) -> Result<(), fidl::Error> {
634        self.client.send::<DriverHostInstallLoaderRequest>(
635            (loader,),
636            0x7022edafc5fcf5a3,
637            fidl::encoding::DynamicFlags::empty(),
638        )
639    }
640}
641
642pub struct DriverHostEventStream {
643    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
644}
645
646impl std::marker::Unpin for DriverHostEventStream {}
647
648impl futures::stream::FusedStream for DriverHostEventStream {
649    fn is_terminated(&self) -> bool {
650        self.event_receiver.is_terminated()
651    }
652}
653
654impl futures::Stream for DriverHostEventStream {
655    type Item = Result<DriverHostEvent, fidl::Error>;
656
657    fn poll_next(
658        mut self: std::pin::Pin<&mut Self>,
659        cx: &mut std::task::Context<'_>,
660    ) -> std::task::Poll<Option<Self::Item>> {
661        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
662            &mut self.event_receiver,
663            cx
664        )?) {
665            Some(buf) => std::task::Poll::Ready(Some(DriverHostEvent::decode(buf))),
666            None => std::task::Poll::Ready(None),
667        }
668    }
669}
670
671#[derive(Debug)]
672pub enum DriverHostEvent {}
673
674impl DriverHostEvent {
675    /// Decodes a message buffer as a [`DriverHostEvent`].
676    fn decode(
677        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
678    ) -> Result<DriverHostEvent, fidl::Error> {
679        let (bytes, _handles) = buf.split_mut();
680        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
681        debug_assert_eq!(tx_header.tx_id, 0);
682        match tx_header.ordinal {
683            _ => Err(fidl::Error::UnknownOrdinal {
684                ordinal: tx_header.ordinal,
685                protocol_name: <DriverHostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
686            }),
687        }
688    }
689}
690
691/// A Stream of incoming requests for fuchsia.driver.host/DriverHost.
692pub struct DriverHostRequestStream {
693    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
694    is_terminated: bool,
695}
696
697impl std::marker::Unpin for DriverHostRequestStream {}
698
699impl futures::stream::FusedStream for DriverHostRequestStream {
700    fn is_terminated(&self) -> bool {
701        self.is_terminated
702    }
703}
704
705impl fidl::endpoints::RequestStream for DriverHostRequestStream {
706    type Protocol = DriverHostMarker;
707    type ControlHandle = DriverHostControlHandle;
708
709    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
710        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
711    }
712
713    fn control_handle(&self) -> Self::ControlHandle {
714        DriverHostControlHandle { inner: self.inner.clone() }
715    }
716
717    fn into_inner(
718        self,
719    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
720    {
721        (self.inner, self.is_terminated)
722    }
723
724    fn from_inner(
725        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
726        is_terminated: bool,
727    ) -> Self {
728        Self { inner, is_terminated }
729    }
730}
731
732impl futures::Stream for DriverHostRequestStream {
733    type Item = Result<DriverHostRequest, fidl::Error>;
734
735    fn poll_next(
736        mut self: std::pin::Pin<&mut Self>,
737        cx: &mut std::task::Context<'_>,
738    ) -> std::task::Poll<Option<Self::Item>> {
739        let this = &mut *self;
740        if this.inner.check_shutdown(cx) {
741            this.is_terminated = true;
742            return std::task::Poll::Ready(None);
743        }
744        if this.is_terminated {
745            panic!("polled DriverHostRequestStream after completion");
746        }
747        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
748            |bytes, handles| {
749                match this.inner.channel().read_etc(cx, bytes, handles) {
750                    std::task::Poll::Ready(Ok(())) => {}
751                    std::task::Poll::Pending => return std::task::Poll::Pending,
752                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
753                        this.is_terminated = true;
754                        return std::task::Poll::Ready(None);
755                    }
756                    std::task::Poll::Ready(Err(e)) => {
757                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
758                            e.into(),
759                        ))))
760                    }
761                }
762
763                // A message has been received from the channel
764                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
765
766                std::task::Poll::Ready(Some(match header.ordinal {
767                    0x1848852bd195bde5 => {
768                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
769                        let mut req = fidl::new_empty!(
770                            DriverHostStartRequest,
771                            fidl::encoding::DefaultFuchsiaResourceDialect
772                        );
773                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverHostStartRequest>(&header, _body_bytes, handles, &mut req)?;
774                        let control_handle = DriverHostControlHandle { inner: this.inner.clone() };
775                        Ok(DriverHostRequest::Start {
776                            start_args: req.start_args,
777                            driver: req.driver,
778
779                            responder: DriverHostStartResponder {
780                                control_handle: std::mem::ManuallyDrop::new(control_handle),
781                                tx_id: header.tx_id,
782                            },
783                        })
784                    }
785                    0x1b2d1b727a614973 => {
786                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
787                        let mut req = fidl::new_empty!(
788                            fidl::encoding::EmptyPayload,
789                            fidl::encoding::DefaultFuchsiaResourceDialect
790                        );
791                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
792                        let control_handle = DriverHostControlHandle { inner: this.inner.clone() };
793                        Ok(DriverHostRequest::GetProcessInfo {
794                            responder: DriverHostGetProcessInfoResponder {
795                                control_handle: std::mem::ManuallyDrop::new(control_handle),
796                                tx_id: header.tx_id,
797                            },
798                        })
799                    }
800                    0x7022edafc5fcf5a3 => {
801                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
802                        let mut req = fidl::new_empty!(
803                            DriverHostInstallLoaderRequest,
804                            fidl::encoding::DefaultFuchsiaResourceDialect
805                        );
806                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverHostInstallLoaderRequest>(&header, _body_bytes, handles, &mut req)?;
807                        let control_handle = DriverHostControlHandle { inner: this.inner.clone() };
808                        Ok(DriverHostRequest::InstallLoader { loader: req.loader, control_handle })
809                    }
810                    _ => Err(fidl::Error::UnknownOrdinal {
811                        ordinal: header.ordinal,
812                        protocol_name:
813                            <DriverHostMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
814                    }),
815                }))
816            },
817        )
818    }
819}
820
821/// Protocol through which a driver host can be managed.
822#[derive(Debug)]
823pub enum DriverHostRequest {
824    /// Start a driver within a driver host.
825    Start {
826        start_args: fidl_fuchsia_driver_framework::DriverStartArgs,
827        driver: fidl::endpoints::ServerEnd<DriverMarker>,
828        responder: DriverHostStartResponder,
829    },
830    /// Returns the job and process KOIDs of the driver host.
831    GetProcessInfo { responder: DriverHostGetProcessInfoResponder },
832    /// Provides a loader service which should be installed via
833    /// `dl_set_loader_service`.
834    InstallLoader {
835        loader: fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
836        control_handle: DriverHostControlHandle,
837    },
838}
839
840impl DriverHostRequest {
841    #[allow(irrefutable_let_patterns)]
842    pub fn into_start(
843        self,
844    ) -> Option<(
845        fidl_fuchsia_driver_framework::DriverStartArgs,
846        fidl::endpoints::ServerEnd<DriverMarker>,
847        DriverHostStartResponder,
848    )> {
849        if let DriverHostRequest::Start { start_args, driver, responder } = self {
850            Some((start_args, driver, responder))
851        } else {
852            None
853        }
854    }
855
856    #[allow(irrefutable_let_patterns)]
857    pub fn into_get_process_info(self) -> Option<(DriverHostGetProcessInfoResponder)> {
858        if let DriverHostRequest::GetProcessInfo { responder } = self {
859            Some((responder))
860        } else {
861            None
862        }
863    }
864
865    #[allow(irrefutable_let_patterns)]
866    pub fn into_install_loader(
867        self,
868    ) -> Option<(
869        fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
870        DriverHostControlHandle,
871    )> {
872        if let DriverHostRequest::InstallLoader { loader, control_handle } = self {
873            Some((loader, control_handle))
874        } else {
875            None
876        }
877    }
878
879    /// Name of the method defined in FIDL
880    pub fn method_name(&self) -> &'static str {
881        match *self {
882            DriverHostRequest::Start { .. } => "start",
883            DriverHostRequest::GetProcessInfo { .. } => "get_process_info",
884            DriverHostRequest::InstallLoader { .. } => "install_loader",
885        }
886    }
887}
888
889#[derive(Debug, Clone)]
890pub struct DriverHostControlHandle {
891    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
892}
893
894impl fidl::endpoints::ControlHandle for DriverHostControlHandle {
895    fn shutdown(&self) {
896        self.inner.shutdown()
897    }
898    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
899        self.inner.shutdown_with_epitaph(status)
900    }
901
902    fn is_closed(&self) -> bool {
903        self.inner.channel().is_closed()
904    }
905    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
906        self.inner.channel().on_closed()
907    }
908
909    #[cfg(target_os = "fuchsia")]
910    fn signal_peer(
911        &self,
912        clear_mask: zx::Signals,
913        set_mask: zx::Signals,
914    ) -> Result<(), zx_status::Status> {
915        use fidl::Peered;
916        self.inner.channel().signal_peer(clear_mask, set_mask)
917    }
918}
919
920impl DriverHostControlHandle {}
921
922#[must_use = "FIDL methods require a response to be sent"]
923#[derive(Debug)]
924pub struct DriverHostStartResponder {
925    control_handle: std::mem::ManuallyDrop<DriverHostControlHandle>,
926    tx_id: u32,
927}
928
929/// Set the the channel to be shutdown (see [`DriverHostControlHandle::shutdown`])
930/// if the responder is dropped without sending a response, so that the client
931/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
932impl std::ops::Drop for DriverHostStartResponder {
933    fn drop(&mut self) {
934        self.control_handle.shutdown();
935        // Safety: drops once, never accessed again
936        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
937    }
938}
939
940impl fidl::endpoints::Responder for DriverHostStartResponder {
941    type ControlHandle = DriverHostControlHandle;
942
943    fn control_handle(&self) -> &DriverHostControlHandle {
944        &self.control_handle
945    }
946
947    fn drop_without_shutdown(mut self) {
948        // Safety: drops once, never accessed again due to mem::forget
949        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
950        // Prevent Drop from running (which would shut down the channel)
951        std::mem::forget(self);
952    }
953}
954
955impl DriverHostStartResponder {
956    /// Sends a response to the FIDL transaction.
957    ///
958    /// Sets the channel to shutdown if an error occurs.
959    pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
960        let _result = self.send_raw(result);
961        if _result.is_err() {
962            self.control_handle.shutdown();
963        }
964        self.drop_without_shutdown();
965        _result
966    }
967
968    /// Similar to "send" but does not shutdown the channel if an error occurs.
969    pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
970        let _result = self.send_raw(result);
971        self.drop_without_shutdown();
972        _result
973    }
974
975    fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
976        self.control_handle
977            .inner
978            .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
979                result,
980                self.tx_id,
981                0x1848852bd195bde5,
982                fidl::encoding::DynamicFlags::empty(),
983            )
984    }
985}
986
987#[must_use = "FIDL methods require a response to be sent"]
988#[derive(Debug)]
989pub struct DriverHostGetProcessInfoResponder {
990    control_handle: std::mem::ManuallyDrop<DriverHostControlHandle>,
991    tx_id: u32,
992}
993
994/// Set the the channel to be shutdown (see [`DriverHostControlHandle::shutdown`])
995/// if the responder is dropped without sending a response, so that the client
996/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
997impl std::ops::Drop for DriverHostGetProcessInfoResponder {
998    fn drop(&mut self) {
999        self.control_handle.shutdown();
1000        // Safety: drops once, never accessed again
1001        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1002    }
1003}
1004
1005impl fidl::endpoints::Responder for DriverHostGetProcessInfoResponder {
1006    type ControlHandle = DriverHostControlHandle;
1007
1008    fn control_handle(&self) -> &DriverHostControlHandle {
1009        &self.control_handle
1010    }
1011
1012    fn drop_without_shutdown(mut self) {
1013        // Safety: drops once, never accessed again due to mem::forget
1014        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1015        // Prevent Drop from running (which would shut down the channel)
1016        std::mem::forget(self);
1017    }
1018}
1019
1020impl DriverHostGetProcessInfoResponder {
1021    /// Sends a response to the FIDL transaction.
1022    ///
1023    /// Sets the channel to shutdown if an error occurs.
1024    pub fn send(
1025        self,
1026        mut result: Result<(u64, u64, &[ThreadInfo], &[DispatcherInfo]), i32>,
1027    ) -> Result<(), fidl::Error> {
1028        let _result = self.send_raw(result);
1029        if _result.is_err() {
1030            self.control_handle.shutdown();
1031        }
1032        self.drop_without_shutdown();
1033        _result
1034    }
1035
1036    /// Similar to "send" but does not shutdown the channel if an error occurs.
1037    pub fn send_no_shutdown_on_err(
1038        self,
1039        mut result: Result<(u64, u64, &[ThreadInfo], &[DispatcherInfo]), i32>,
1040    ) -> Result<(), fidl::Error> {
1041        let _result = self.send_raw(result);
1042        self.drop_without_shutdown();
1043        _result
1044    }
1045
1046    fn send_raw(
1047        &self,
1048        mut result: Result<(u64, u64, &[ThreadInfo], &[DispatcherInfo]), i32>,
1049    ) -> Result<(), fidl::Error> {
1050        self.control_handle.inner.send::<fidl::encoding::ResultType<ProcessInfo, i32>>(
1051            result,
1052            self.tx_id,
1053            0x1b2d1b727a614973,
1054            fidl::encoding::DynamicFlags::empty(),
1055        )
1056    }
1057}
1058
1059mod internal {
1060    use super::*;
1061
1062    impl fidl::encoding::ResourceTypeMarker for DriverHostInstallLoaderRequest {
1063        type Borrowed<'a> = &'a mut Self;
1064        fn take_or_borrow<'a>(
1065            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1066        ) -> Self::Borrowed<'a> {
1067            value
1068        }
1069    }
1070
1071    unsafe impl fidl::encoding::TypeMarker for DriverHostInstallLoaderRequest {
1072        type Owned = Self;
1073
1074        #[inline(always)]
1075        fn inline_align(_context: fidl::encoding::Context) -> usize {
1076            4
1077        }
1078
1079        #[inline(always)]
1080        fn inline_size(_context: fidl::encoding::Context) -> usize {
1081            4
1082        }
1083    }
1084
1085    unsafe impl
1086        fidl::encoding::Encode<
1087            DriverHostInstallLoaderRequest,
1088            fidl::encoding::DefaultFuchsiaResourceDialect,
1089        > for &mut DriverHostInstallLoaderRequest
1090    {
1091        #[inline]
1092        unsafe fn encode(
1093            self,
1094            encoder: &mut fidl::encoding::Encoder<
1095                '_,
1096                fidl::encoding::DefaultFuchsiaResourceDialect,
1097            >,
1098            offset: usize,
1099            _depth: fidl::encoding::Depth,
1100        ) -> fidl::Result<()> {
1101            encoder.debug_check_bounds::<DriverHostInstallLoaderRequest>(offset);
1102            // Delegate to tuple encoding.
1103            fidl::encoding::Encode::<
1104                DriverHostInstallLoaderRequest,
1105                fidl::encoding::DefaultFuchsiaResourceDialect,
1106            >::encode(
1107                (<fidl::encoding::Endpoint<
1108                    fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
1109                > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
1110                    &mut self.loader
1111                ),),
1112                encoder,
1113                offset,
1114                _depth,
1115            )
1116        }
1117    }
1118    unsafe impl<
1119            T0: fidl::encoding::Encode<
1120                fidl::encoding::Endpoint<
1121                    fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
1122                >,
1123                fidl::encoding::DefaultFuchsiaResourceDialect,
1124            >,
1125        >
1126        fidl::encoding::Encode<
1127            DriverHostInstallLoaderRequest,
1128            fidl::encoding::DefaultFuchsiaResourceDialect,
1129        > for (T0,)
1130    {
1131        #[inline]
1132        unsafe fn encode(
1133            self,
1134            encoder: &mut fidl::encoding::Encoder<
1135                '_,
1136                fidl::encoding::DefaultFuchsiaResourceDialect,
1137            >,
1138            offset: usize,
1139            depth: fidl::encoding::Depth,
1140        ) -> fidl::Result<()> {
1141            encoder.debug_check_bounds::<DriverHostInstallLoaderRequest>(offset);
1142            // Zero out padding regions. There's no need to apply masks
1143            // because the unmasked parts will be overwritten by fields.
1144            // Write the fields.
1145            self.0.encode(encoder, offset + 0, depth)?;
1146            Ok(())
1147        }
1148    }
1149
1150    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1151        for DriverHostInstallLoaderRequest
1152    {
1153        #[inline(always)]
1154        fn new_empty() -> Self {
1155            Self {
1156                loader: fidl::new_empty!(
1157                    fidl::encoding::Endpoint<
1158                        fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
1159                    >,
1160                    fidl::encoding::DefaultFuchsiaResourceDialect
1161                ),
1162            }
1163        }
1164
1165        #[inline]
1166        unsafe fn decode(
1167            &mut self,
1168            decoder: &mut fidl::encoding::Decoder<
1169                '_,
1170                fidl::encoding::DefaultFuchsiaResourceDialect,
1171            >,
1172            offset: usize,
1173            _depth: fidl::encoding::Depth,
1174        ) -> fidl::Result<()> {
1175            decoder.debug_check_bounds::<Self>(offset);
1176            // Verify that padding bytes are zero.
1177            fidl::decode!(
1178                fidl::encoding::Endpoint<
1179                    fidl::endpoints::ClientEnd<fidl_fuchsia_ldsvc::LoaderMarker>,
1180                >,
1181                fidl::encoding::DefaultFuchsiaResourceDialect,
1182                &mut self.loader,
1183                decoder,
1184                offset + 0,
1185                _depth
1186            )?;
1187            Ok(())
1188        }
1189    }
1190
1191    impl fidl::encoding::ResourceTypeMarker for DriverHostStartRequest {
1192        type Borrowed<'a> = &'a mut Self;
1193        fn take_or_borrow<'a>(
1194            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
1195        ) -> Self::Borrowed<'a> {
1196            value
1197        }
1198    }
1199
1200    unsafe impl fidl::encoding::TypeMarker for DriverHostStartRequest {
1201        type Owned = Self;
1202
1203        #[inline(always)]
1204        fn inline_align(_context: fidl::encoding::Context) -> usize {
1205            8
1206        }
1207
1208        #[inline(always)]
1209        fn inline_size(_context: fidl::encoding::Context) -> usize {
1210            24
1211        }
1212    }
1213
1214    unsafe impl
1215        fidl::encoding::Encode<
1216            DriverHostStartRequest,
1217            fidl::encoding::DefaultFuchsiaResourceDialect,
1218        > for &mut DriverHostStartRequest
1219    {
1220        #[inline]
1221        unsafe fn encode(
1222            self,
1223            encoder: &mut fidl::encoding::Encoder<
1224                '_,
1225                fidl::encoding::DefaultFuchsiaResourceDialect,
1226            >,
1227            offset: usize,
1228            _depth: fidl::encoding::Depth,
1229        ) -> fidl::Result<()> {
1230            encoder.debug_check_bounds::<DriverHostStartRequest>(offset);
1231            // Delegate to tuple encoding.
1232            fidl::encoding::Encode::<DriverHostStartRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
1233                (
1234                    <fidl_fuchsia_driver_framework::DriverStartArgs as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.start_args),
1235                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DriverMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.driver),
1236                ),
1237                encoder, offset, _depth
1238            )
1239        }
1240    }
1241    unsafe impl<
1242            T0: fidl::encoding::Encode<
1243                fidl_fuchsia_driver_framework::DriverStartArgs,
1244                fidl::encoding::DefaultFuchsiaResourceDialect,
1245            >,
1246            T1: fidl::encoding::Encode<
1247                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DriverMarker>>,
1248                fidl::encoding::DefaultFuchsiaResourceDialect,
1249            >,
1250        >
1251        fidl::encoding::Encode<
1252            DriverHostStartRequest,
1253            fidl::encoding::DefaultFuchsiaResourceDialect,
1254        > for (T0, T1)
1255    {
1256        #[inline]
1257        unsafe fn encode(
1258            self,
1259            encoder: &mut fidl::encoding::Encoder<
1260                '_,
1261                fidl::encoding::DefaultFuchsiaResourceDialect,
1262            >,
1263            offset: usize,
1264            depth: fidl::encoding::Depth,
1265        ) -> fidl::Result<()> {
1266            encoder.debug_check_bounds::<DriverHostStartRequest>(offset);
1267            // Zero out padding regions. There's no need to apply masks
1268            // because the unmasked parts will be overwritten by fields.
1269            unsafe {
1270                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
1271                (ptr as *mut u64).write_unaligned(0);
1272            }
1273            // Write the fields.
1274            self.0.encode(encoder, offset + 0, depth)?;
1275            self.1.encode(encoder, offset + 16, depth)?;
1276            Ok(())
1277        }
1278    }
1279
1280    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1281        for DriverHostStartRequest
1282    {
1283        #[inline(always)]
1284        fn new_empty() -> Self {
1285            Self {
1286                start_args: fidl::new_empty!(
1287                    fidl_fuchsia_driver_framework::DriverStartArgs,
1288                    fidl::encoding::DefaultFuchsiaResourceDialect
1289                ),
1290                driver: fidl::new_empty!(
1291                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DriverMarker>>,
1292                    fidl::encoding::DefaultFuchsiaResourceDialect
1293                ),
1294            }
1295        }
1296
1297        #[inline]
1298        unsafe fn decode(
1299            &mut self,
1300            decoder: &mut fidl::encoding::Decoder<
1301                '_,
1302                fidl::encoding::DefaultFuchsiaResourceDialect,
1303            >,
1304            offset: usize,
1305            _depth: fidl::encoding::Depth,
1306        ) -> fidl::Result<()> {
1307            decoder.debug_check_bounds::<Self>(offset);
1308            // Verify that padding bytes are zero.
1309            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
1310            let padval = unsafe { (ptr as *const u64).read_unaligned() };
1311            let mask = 0xffffffff00000000u64;
1312            let maskedval = padval & mask;
1313            if maskedval != 0 {
1314                return Err(fidl::Error::NonZeroPadding {
1315                    padding_start: offset + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
1316                });
1317            }
1318            fidl::decode!(
1319                fidl_fuchsia_driver_framework::DriverStartArgs,
1320                fidl::encoding::DefaultFuchsiaResourceDialect,
1321                &mut self.start_args,
1322                decoder,
1323                offset + 0,
1324                _depth
1325            )?;
1326            fidl::decode!(
1327                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<DriverMarker>>,
1328                fidl::encoding::DefaultFuchsiaResourceDialect,
1329                &mut self.driver,
1330                decoder,
1331                offset + 16,
1332                _depth
1333            )?;
1334            Ok(())
1335        }
1336    }
1337}