fidl_fuchsia_ldsvc/
fidl_fuchsia_ldsvc.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_ldsvc__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct LoaderCloneRequest {
16    pub loader: fidl::endpoints::ServerEnd<LoaderMarker>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LoaderCloneRequest {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct LoaderLoadObjectResponse {
23    pub rv: i32,
24    pub object: Option<fidl::Vmo>,
25}
26
27impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for LoaderLoadObjectResponse {}
28
29#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
30pub struct LoaderMarker;
31
32impl fidl::endpoints::ProtocolMarker for LoaderMarker {
33    type Proxy = LoaderProxy;
34    type RequestStream = LoaderRequestStream;
35    #[cfg(target_os = "fuchsia")]
36    type SynchronousProxy = LoaderSynchronousProxy;
37
38    const DEBUG_NAME: &'static str = "(anonymous) Loader";
39}
40
41pub trait LoaderProxyInterface: Send + Sync {
42    fn r#done(&self) -> Result<(), fidl::Error>;
43    type LoadObjectResponseFut: std::future::Future<Output = Result<(i32, Option<fidl::Vmo>), fidl::Error>>
44        + Send;
45    fn r#load_object(&self, object_name: &str) -> Self::LoadObjectResponseFut;
46    type ConfigResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
47    fn r#config(&self, config: &str) -> Self::ConfigResponseFut;
48    type CloneResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
49    fn r#clone(&self, loader: fidl::endpoints::ServerEnd<LoaderMarker>) -> Self::CloneResponseFut;
50}
51#[derive(Debug)]
52#[cfg(target_os = "fuchsia")]
53pub struct LoaderSynchronousProxy {
54    client: fidl::client::sync::Client,
55}
56
57#[cfg(target_os = "fuchsia")]
58impl fidl::endpoints::SynchronousProxy for LoaderSynchronousProxy {
59    type Proxy = LoaderProxy;
60    type Protocol = LoaderMarker;
61
62    fn from_channel(inner: fidl::Channel) -> Self {
63        Self::new(inner)
64    }
65
66    fn into_channel(self) -> fidl::Channel {
67        self.client.into_channel()
68    }
69
70    fn as_channel(&self) -> &fidl::Channel {
71        self.client.as_channel()
72    }
73}
74
75#[cfg(target_os = "fuchsia")]
76impl LoaderSynchronousProxy {
77    pub fn new(channel: fidl::Channel) -> Self {
78        let protocol_name = <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
79        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
80    }
81
82    pub fn into_channel(self) -> fidl::Channel {
83        self.client.into_channel()
84    }
85
86    /// Waits until an event arrives and returns it. It is safe for other
87    /// threads to make concurrent requests while waiting for an event.
88    pub fn wait_for_event(
89        &self,
90        deadline: zx::MonotonicInstant,
91    ) -> Result<LoaderEvent, fidl::Error> {
92        LoaderEvent::decode(self.client.wait_for_event(deadline)?)
93    }
94
95    /// Cleanly shutdown the connection to the Loader service.
96    pub fn r#done(&self) -> Result<(), fidl::Error> {
97        self.client.send::<fidl::encoding::EmptyPayload>(
98            (),
99            0x63ba6b76d3671001,
100            fidl::encoding::DynamicFlags::empty(),
101        )
102    }
103
104    /// The dynamic linker sends `object_name` and gets back a VMO
105    /// handle containing the file.
106    pub fn r#load_object(
107        &self,
108        mut object_name: &str,
109        ___deadline: zx::MonotonicInstant,
110    ) -> Result<(i32, Option<fidl::Vmo>), fidl::Error> {
111        let _response =
112            self.client.send_query::<LoaderLoadObjectRequest, LoaderLoadObjectResponse>(
113                (object_name,),
114                0x48c5a151d6df2853,
115                fidl::encoding::DynamicFlags::empty(),
116                ___deadline,
117            )?;
118        Ok((_response.rv, _response.object))
119    }
120
121    /// The dynamic linker sends a `config` identifying its load
122    /// configuration.  This is intended to affect how later
123    /// `LoadObject` requests decide what particular implementation
124    /// file to supply for a given name.
125    pub fn r#config(
126        &self,
127        mut config: &str,
128        ___deadline: zx::MonotonicInstant,
129    ) -> Result<i32, fidl::Error> {
130        let _response = self.client.send_query::<LoaderConfigRequest, LoaderConfigResponse>(
131            (config,),
132            0x6a8a1a1464632841,
133            fidl::encoding::DynamicFlags::empty(),
134            ___deadline,
135        )?;
136        Ok(_response.rv)
137    }
138
139    /// Obtain a new loader service connection.
140    pub fn r#clone(
141        &self,
142        mut loader: fidl::endpoints::ServerEnd<LoaderMarker>,
143        ___deadline: zx::MonotonicInstant,
144    ) -> Result<i32, fidl::Error> {
145        let _response = self.client.send_query::<LoaderCloneRequest, LoaderCloneResponse>(
146            (loader,),
147            0x57e643a9ab6e4c29,
148            fidl::encoding::DynamicFlags::empty(),
149            ___deadline,
150        )?;
151        Ok(_response.rv)
152    }
153}
154
155#[cfg(target_os = "fuchsia")]
156impl From<LoaderSynchronousProxy> for zx::Handle {
157    fn from(value: LoaderSynchronousProxy) -> Self {
158        value.into_channel().into()
159    }
160}
161
162#[cfg(target_os = "fuchsia")]
163impl From<fidl::Channel> for LoaderSynchronousProxy {
164    fn from(value: fidl::Channel) -> Self {
165        Self::new(value)
166    }
167}
168
169#[cfg(target_os = "fuchsia")]
170impl fidl::endpoints::FromClient for LoaderSynchronousProxy {
171    type Protocol = LoaderMarker;
172
173    fn from_client(value: fidl::endpoints::ClientEnd<LoaderMarker>) -> Self {
174        Self::new(value.into_channel())
175    }
176}
177
178#[derive(Debug, Clone)]
179pub struct LoaderProxy {
180    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
181}
182
183impl fidl::endpoints::Proxy for LoaderProxy {
184    type Protocol = LoaderMarker;
185
186    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
187        Self::new(inner)
188    }
189
190    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
191        self.client.into_channel().map_err(|client| Self { client })
192    }
193
194    fn as_channel(&self) -> &::fidl::AsyncChannel {
195        self.client.as_channel()
196    }
197}
198
199impl LoaderProxy {
200    /// Create a new Proxy for fuchsia.ldsvc/Loader.
201    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
202        let protocol_name = <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
203        Self { client: fidl::client::Client::new(channel, protocol_name) }
204    }
205
206    /// Get a Stream of events from the remote end of the protocol.
207    ///
208    /// # Panics
209    ///
210    /// Panics if the event stream was already taken.
211    pub fn take_event_stream(&self) -> LoaderEventStream {
212        LoaderEventStream { event_receiver: self.client.take_event_receiver() }
213    }
214
215    /// Cleanly shutdown the connection to the Loader service.
216    pub fn r#done(&self) -> Result<(), fidl::Error> {
217        LoaderProxyInterface::r#done(self)
218    }
219
220    /// The dynamic linker sends `object_name` and gets back a VMO
221    /// handle containing the file.
222    pub fn r#load_object(
223        &self,
224        mut object_name: &str,
225    ) -> fidl::client::QueryResponseFut<
226        (i32, Option<fidl::Vmo>),
227        fidl::encoding::DefaultFuchsiaResourceDialect,
228    > {
229        LoaderProxyInterface::r#load_object(self, object_name)
230    }
231
232    /// The dynamic linker sends a `config` identifying its load
233    /// configuration.  This is intended to affect how later
234    /// `LoadObject` requests decide what particular implementation
235    /// file to supply for a given name.
236    pub fn r#config(
237        &self,
238        mut config: &str,
239    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
240        LoaderProxyInterface::r#config(self, config)
241    }
242
243    /// Obtain a new loader service connection.
244    pub fn r#clone(
245        &self,
246        mut loader: fidl::endpoints::ServerEnd<LoaderMarker>,
247    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
248        LoaderProxyInterface::r#clone(self, loader)
249    }
250}
251
252impl LoaderProxyInterface for LoaderProxy {
253    fn r#done(&self) -> Result<(), fidl::Error> {
254        self.client.send::<fidl::encoding::EmptyPayload>(
255            (),
256            0x63ba6b76d3671001,
257            fidl::encoding::DynamicFlags::empty(),
258        )
259    }
260
261    type LoadObjectResponseFut = fidl::client::QueryResponseFut<
262        (i32, Option<fidl::Vmo>),
263        fidl::encoding::DefaultFuchsiaResourceDialect,
264    >;
265    fn r#load_object(&self, mut object_name: &str) -> Self::LoadObjectResponseFut {
266        fn _decode(
267            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
268        ) -> Result<(i32, Option<fidl::Vmo>), fidl::Error> {
269            let _response = fidl::client::decode_transaction_body::<
270                LoaderLoadObjectResponse,
271                fidl::encoding::DefaultFuchsiaResourceDialect,
272                0x48c5a151d6df2853,
273            >(_buf?)?;
274            Ok((_response.rv, _response.object))
275        }
276        self.client.send_query_and_decode::<LoaderLoadObjectRequest, (i32, Option<fidl::Vmo>)>(
277            (object_name,),
278            0x48c5a151d6df2853,
279            fidl::encoding::DynamicFlags::empty(),
280            _decode,
281        )
282    }
283
284    type ConfigResponseFut =
285        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
286    fn r#config(&self, mut config: &str) -> Self::ConfigResponseFut {
287        fn _decode(
288            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
289        ) -> Result<i32, fidl::Error> {
290            let _response = fidl::client::decode_transaction_body::<
291                LoaderConfigResponse,
292                fidl::encoding::DefaultFuchsiaResourceDialect,
293                0x6a8a1a1464632841,
294            >(_buf?)?;
295            Ok(_response.rv)
296        }
297        self.client.send_query_and_decode::<LoaderConfigRequest, i32>(
298            (config,),
299            0x6a8a1a1464632841,
300            fidl::encoding::DynamicFlags::empty(),
301            _decode,
302        )
303    }
304
305    type CloneResponseFut =
306        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
307    fn r#clone(
308        &self,
309        mut loader: fidl::endpoints::ServerEnd<LoaderMarker>,
310    ) -> Self::CloneResponseFut {
311        fn _decode(
312            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
313        ) -> Result<i32, fidl::Error> {
314            let _response = fidl::client::decode_transaction_body::<
315                LoaderCloneResponse,
316                fidl::encoding::DefaultFuchsiaResourceDialect,
317                0x57e643a9ab6e4c29,
318            >(_buf?)?;
319            Ok(_response.rv)
320        }
321        self.client.send_query_and_decode::<LoaderCloneRequest, i32>(
322            (loader,),
323            0x57e643a9ab6e4c29,
324            fidl::encoding::DynamicFlags::empty(),
325            _decode,
326        )
327    }
328}
329
330pub struct LoaderEventStream {
331    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
332}
333
334impl std::marker::Unpin for LoaderEventStream {}
335
336impl futures::stream::FusedStream for LoaderEventStream {
337    fn is_terminated(&self) -> bool {
338        self.event_receiver.is_terminated()
339    }
340}
341
342impl futures::Stream for LoaderEventStream {
343    type Item = Result<LoaderEvent, fidl::Error>;
344
345    fn poll_next(
346        mut self: std::pin::Pin<&mut Self>,
347        cx: &mut std::task::Context<'_>,
348    ) -> std::task::Poll<Option<Self::Item>> {
349        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
350            &mut self.event_receiver,
351            cx
352        )?) {
353            Some(buf) => std::task::Poll::Ready(Some(LoaderEvent::decode(buf))),
354            None => std::task::Poll::Ready(None),
355        }
356    }
357}
358
359#[derive(Debug)]
360pub enum LoaderEvent {}
361
362impl LoaderEvent {
363    /// Decodes a message buffer as a [`LoaderEvent`].
364    fn decode(
365        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
366    ) -> Result<LoaderEvent, fidl::Error> {
367        let (bytes, _handles) = buf.split_mut();
368        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
369        debug_assert_eq!(tx_header.tx_id, 0);
370        match tx_header.ordinal {
371            _ => Err(fidl::Error::UnknownOrdinal {
372                ordinal: tx_header.ordinal,
373                protocol_name: <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
374            }),
375        }
376    }
377}
378
379/// A Stream of incoming requests for fuchsia.ldsvc/Loader.
380pub struct LoaderRequestStream {
381    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
382    is_terminated: bool,
383}
384
385impl std::marker::Unpin for LoaderRequestStream {}
386
387impl futures::stream::FusedStream for LoaderRequestStream {
388    fn is_terminated(&self) -> bool {
389        self.is_terminated
390    }
391}
392
393impl fidl::endpoints::RequestStream for LoaderRequestStream {
394    type Protocol = LoaderMarker;
395    type ControlHandle = LoaderControlHandle;
396
397    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
398        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
399    }
400
401    fn control_handle(&self) -> Self::ControlHandle {
402        LoaderControlHandle { inner: self.inner.clone() }
403    }
404
405    fn into_inner(
406        self,
407    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
408    {
409        (self.inner, self.is_terminated)
410    }
411
412    fn from_inner(
413        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
414        is_terminated: bool,
415    ) -> Self {
416        Self { inner, is_terminated }
417    }
418}
419
420impl futures::Stream for LoaderRequestStream {
421    type Item = Result<LoaderRequest, fidl::Error>;
422
423    fn poll_next(
424        mut self: std::pin::Pin<&mut Self>,
425        cx: &mut std::task::Context<'_>,
426    ) -> std::task::Poll<Option<Self::Item>> {
427        let this = &mut *self;
428        if this.inner.check_shutdown(cx) {
429            this.is_terminated = true;
430            return std::task::Poll::Ready(None);
431        }
432        if this.is_terminated {
433            panic!("polled LoaderRequestStream after completion");
434        }
435        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
436            |bytes, handles| {
437                match this.inner.channel().read_etc(cx, bytes, handles) {
438                    std::task::Poll::Ready(Ok(())) => {}
439                    std::task::Poll::Pending => return std::task::Poll::Pending,
440                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
441                        this.is_terminated = true;
442                        return std::task::Poll::Ready(None);
443                    }
444                    std::task::Poll::Ready(Err(e)) => {
445                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
446                            e.into(),
447                        ))))
448                    }
449                }
450
451                // A message has been received from the channel
452                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
453
454                std::task::Poll::Ready(Some(match header.ordinal {
455                    0x63ba6b76d3671001 => {
456                        header.validate_request_tx_id(fidl::MethodType::OneWay)?;
457                        let mut req = fidl::new_empty!(
458                            fidl::encoding::EmptyPayload,
459                            fidl::encoding::DefaultFuchsiaResourceDialect
460                        );
461                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
462                        let control_handle = LoaderControlHandle { inner: this.inner.clone() };
463                        Ok(LoaderRequest::Done { control_handle })
464                    }
465                    0x48c5a151d6df2853 => {
466                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
467                        let mut req = fidl::new_empty!(
468                            LoaderLoadObjectRequest,
469                            fidl::encoding::DefaultFuchsiaResourceDialect
470                        );
471                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LoaderLoadObjectRequest>(&header, _body_bytes, handles, &mut req)?;
472                        let control_handle = LoaderControlHandle { inner: this.inner.clone() };
473                        Ok(LoaderRequest::LoadObject {
474                            object_name: req.object_name,
475
476                            responder: LoaderLoadObjectResponder {
477                                control_handle: std::mem::ManuallyDrop::new(control_handle),
478                                tx_id: header.tx_id,
479                            },
480                        })
481                    }
482                    0x6a8a1a1464632841 => {
483                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
484                        let mut req = fidl::new_empty!(
485                            LoaderConfigRequest,
486                            fidl::encoding::DefaultFuchsiaResourceDialect
487                        );
488                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LoaderConfigRequest>(&header, _body_bytes, handles, &mut req)?;
489                        let control_handle = LoaderControlHandle { inner: this.inner.clone() };
490                        Ok(LoaderRequest::Config {
491                            config: req.config,
492
493                            responder: LoaderConfigResponder {
494                                control_handle: std::mem::ManuallyDrop::new(control_handle),
495                                tx_id: header.tx_id,
496                            },
497                        })
498                    }
499                    0x57e643a9ab6e4c29 => {
500                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
501                        let mut req = fidl::new_empty!(
502                            LoaderCloneRequest,
503                            fidl::encoding::DefaultFuchsiaResourceDialect
504                        );
505                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LoaderCloneRequest>(&header, _body_bytes, handles, &mut req)?;
506                        let control_handle = LoaderControlHandle { inner: this.inner.clone() };
507                        Ok(LoaderRequest::Clone {
508                            loader: req.loader,
509
510                            responder: LoaderCloneResponder {
511                                control_handle: std::mem::ManuallyDrop::new(control_handle),
512                                tx_id: header.tx_id,
513                            },
514                        })
515                    }
516                    _ => Err(fidl::Error::UnknownOrdinal {
517                        ordinal: header.ordinal,
518                        protocol_name:
519                            <LoaderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
520                    }),
521                }))
522            },
523        )
524    }
525}
526
527/// See //docs/concepts/process/program_loading.md for a more complete
528/// description of this and related process bootstrapping protocols, and
529/// for specifics about the default global loader service's
530/// interpretation of names, paths, and configurations.
531#[derive(Debug)]
532pub enum LoaderRequest {
533    /// Cleanly shutdown the connection to the Loader service.
534    Done { control_handle: LoaderControlHandle },
535    /// The dynamic linker sends `object_name` and gets back a VMO
536    /// handle containing the file.
537    LoadObject { object_name: String, responder: LoaderLoadObjectResponder },
538    /// The dynamic linker sends a `config` identifying its load
539    /// configuration.  This is intended to affect how later
540    /// `LoadObject` requests decide what particular implementation
541    /// file to supply for a given name.
542    Config { config: String, responder: LoaderConfigResponder },
543    /// Obtain a new loader service connection.
544    Clone { loader: fidl::endpoints::ServerEnd<LoaderMarker>, responder: LoaderCloneResponder },
545}
546
547impl LoaderRequest {
548    #[allow(irrefutable_let_patterns)]
549    pub fn into_done(self) -> Option<(LoaderControlHandle)> {
550        if let LoaderRequest::Done { control_handle } = self {
551            Some((control_handle))
552        } else {
553            None
554        }
555    }
556
557    #[allow(irrefutable_let_patterns)]
558    pub fn into_load_object(self) -> Option<(String, LoaderLoadObjectResponder)> {
559        if let LoaderRequest::LoadObject { object_name, responder } = self {
560            Some((object_name, responder))
561        } else {
562            None
563        }
564    }
565
566    #[allow(irrefutable_let_patterns)]
567    pub fn into_config(self) -> Option<(String, LoaderConfigResponder)> {
568        if let LoaderRequest::Config { config, responder } = self {
569            Some((config, responder))
570        } else {
571            None
572        }
573    }
574
575    #[allow(irrefutable_let_patterns)]
576    pub fn into_clone(
577        self,
578    ) -> Option<(fidl::endpoints::ServerEnd<LoaderMarker>, LoaderCloneResponder)> {
579        if let LoaderRequest::Clone { loader, responder } = self {
580            Some((loader, responder))
581        } else {
582            None
583        }
584    }
585
586    /// Name of the method defined in FIDL
587    pub fn method_name(&self) -> &'static str {
588        match *self {
589            LoaderRequest::Done { .. } => "done",
590            LoaderRequest::LoadObject { .. } => "load_object",
591            LoaderRequest::Config { .. } => "config",
592            LoaderRequest::Clone { .. } => "clone",
593        }
594    }
595}
596
597#[derive(Debug, Clone)]
598pub struct LoaderControlHandle {
599    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
600}
601
602impl fidl::endpoints::ControlHandle for LoaderControlHandle {
603    fn shutdown(&self) {
604        self.inner.shutdown()
605    }
606    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
607        self.inner.shutdown_with_epitaph(status)
608    }
609
610    fn is_closed(&self) -> bool {
611        self.inner.channel().is_closed()
612    }
613    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
614        self.inner.channel().on_closed()
615    }
616
617    #[cfg(target_os = "fuchsia")]
618    fn signal_peer(
619        &self,
620        clear_mask: zx::Signals,
621        set_mask: zx::Signals,
622    ) -> Result<(), zx_status::Status> {
623        use fidl::Peered;
624        self.inner.channel().signal_peer(clear_mask, set_mask)
625    }
626}
627
628impl LoaderControlHandle {}
629
630#[must_use = "FIDL methods require a response to be sent"]
631#[derive(Debug)]
632pub struct LoaderLoadObjectResponder {
633    control_handle: std::mem::ManuallyDrop<LoaderControlHandle>,
634    tx_id: u32,
635}
636
637/// Set the the channel to be shutdown (see [`LoaderControlHandle::shutdown`])
638/// if the responder is dropped without sending a response, so that the client
639/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
640impl std::ops::Drop for LoaderLoadObjectResponder {
641    fn drop(&mut self) {
642        self.control_handle.shutdown();
643        // Safety: drops once, never accessed again
644        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
645    }
646}
647
648impl fidl::endpoints::Responder for LoaderLoadObjectResponder {
649    type ControlHandle = LoaderControlHandle;
650
651    fn control_handle(&self) -> &LoaderControlHandle {
652        &self.control_handle
653    }
654
655    fn drop_without_shutdown(mut self) {
656        // Safety: drops once, never accessed again due to mem::forget
657        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
658        // Prevent Drop from running (which would shut down the channel)
659        std::mem::forget(self);
660    }
661}
662
663impl LoaderLoadObjectResponder {
664    /// Sends a response to the FIDL transaction.
665    ///
666    /// Sets the channel to shutdown if an error occurs.
667    pub fn send(self, mut rv: i32, mut object: Option<fidl::Vmo>) -> Result<(), fidl::Error> {
668        let _result = self.send_raw(rv, object);
669        if _result.is_err() {
670            self.control_handle.shutdown();
671        }
672        self.drop_without_shutdown();
673        _result
674    }
675
676    /// Similar to "send" but does not shutdown the channel if an error occurs.
677    pub fn send_no_shutdown_on_err(
678        self,
679        mut rv: i32,
680        mut object: Option<fidl::Vmo>,
681    ) -> Result<(), fidl::Error> {
682        let _result = self.send_raw(rv, object);
683        self.drop_without_shutdown();
684        _result
685    }
686
687    fn send_raw(&self, mut rv: i32, mut object: Option<fidl::Vmo>) -> Result<(), fidl::Error> {
688        self.control_handle.inner.send::<LoaderLoadObjectResponse>(
689            (rv, object),
690            self.tx_id,
691            0x48c5a151d6df2853,
692            fidl::encoding::DynamicFlags::empty(),
693        )
694    }
695}
696
697#[must_use = "FIDL methods require a response to be sent"]
698#[derive(Debug)]
699pub struct LoaderConfigResponder {
700    control_handle: std::mem::ManuallyDrop<LoaderControlHandle>,
701    tx_id: u32,
702}
703
704/// Set the the channel to be shutdown (see [`LoaderControlHandle::shutdown`])
705/// if the responder is dropped without sending a response, so that the client
706/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
707impl std::ops::Drop for LoaderConfigResponder {
708    fn drop(&mut self) {
709        self.control_handle.shutdown();
710        // Safety: drops once, never accessed again
711        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
712    }
713}
714
715impl fidl::endpoints::Responder for LoaderConfigResponder {
716    type ControlHandle = LoaderControlHandle;
717
718    fn control_handle(&self) -> &LoaderControlHandle {
719        &self.control_handle
720    }
721
722    fn drop_without_shutdown(mut self) {
723        // Safety: drops once, never accessed again due to mem::forget
724        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
725        // Prevent Drop from running (which would shut down the channel)
726        std::mem::forget(self);
727    }
728}
729
730impl LoaderConfigResponder {
731    /// Sends a response to the FIDL transaction.
732    ///
733    /// Sets the channel to shutdown if an error occurs.
734    pub fn send(self, mut rv: i32) -> Result<(), fidl::Error> {
735        let _result = self.send_raw(rv);
736        if _result.is_err() {
737            self.control_handle.shutdown();
738        }
739        self.drop_without_shutdown();
740        _result
741    }
742
743    /// Similar to "send" but does not shutdown the channel if an error occurs.
744    pub fn send_no_shutdown_on_err(self, mut rv: i32) -> Result<(), fidl::Error> {
745        let _result = self.send_raw(rv);
746        self.drop_without_shutdown();
747        _result
748    }
749
750    fn send_raw(&self, mut rv: i32) -> Result<(), fidl::Error> {
751        self.control_handle.inner.send::<LoaderConfigResponse>(
752            (rv,),
753            self.tx_id,
754            0x6a8a1a1464632841,
755            fidl::encoding::DynamicFlags::empty(),
756        )
757    }
758}
759
760#[must_use = "FIDL methods require a response to be sent"]
761#[derive(Debug)]
762pub struct LoaderCloneResponder {
763    control_handle: std::mem::ManuallyDrop<LoaderControlHandle>,
764    tx_id: u32,
765}
766
767/// Set the the channel to be shutdown (see [`LoaderControlHandle::shutdown`])
768/// if the responder is dropped without sending a response, so that the client
769/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
770impl std::ops::Drop for LoaderCloneResponder {
771    fn drop(&mut self) {
772        self.control_handle.shutdown();
773        // Safety: drops once, never accessed again
774        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
775    }
776}
777
778impl fidl::endpoints::Responder for LoaderCloneResponder {
779    type ControlHandle = LoaderControlHandle;
780
781    fn control_handle(&self) -> &LoaderControlHandle {
782        &self.control_handle
783    }
784
785    fn drop_without_shutdown(mut self) {
786        // Safety: drops once, never accessed again due to mem::forget
787        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
788        // Prevent Drop from running (which would shut down the channel)
789        std::mem::forget(self);
790    }
791}
792
793impl LoaderCloneResponder {
794    /// Sends a response to the FIDL transaction.
795    ///
796    /// Sets the channel to shutdown if an error occurs.
797    pub fn send(self, mut rv: i32) -> Result<(), fidl::Error> {
798        let _result = self.send_raw(rv);
799        if _result.is_err() {
800            self.control_handle.shutdown();
801        }
802        self.drop_without_shutdown();
803        _result
804    }
805
806    /// Similar to "send" but does not shutdown the channel if an error occurs.
807    pub fn send_no_shutdown_on_err(self, mut rv: i32) -> Result<(), fidl::Error> {
808        let _result = self.send_raw(rv);
809        self.drop_without_shutdown();
810        _result
811    }
812
813    fn send_raw(&self, mut rv: i32) -> Result<(), fidl::Error> {
814        self.control_handle.inner.send::<LoaderCloneResponse>(
815            (rv,),
816            self.tx_id,
817            0x57e643a9ab6e4c29,
818            fidl::encoding::DynamicFlags::empty(),
819        )
820    }
821}
822
823mod internal {
824    use super::*;
825
826    impl fidl::encoding::ResourceTypeMarker for LoaderCloneRequest {
827        type Borrowed<'a> = &'a mut Self;
828        fn take_or_borrow<'a>(
829            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
830        ) -> Self::Borrowed<'a> {
831            value
832        }
833    }
834
835    unsafe impl fidl::encoding::TypeMarker for LoaderCloneRequest {
836        type Owned = Self;
837
838        #[inline(always)]
839        fn inline_align(_context: fidl::encoding::Context) -> usize {
840            4
841        }
842
843        #[inline(always)]
844        fn inline_size(_context: fidl::encoding::Context) -> usize {
845            4
846        }
847    }
848
849    unsafe impl
850        fidl::encoding::Encode<LoaderCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
851        for &mut LoaderCloneRequest
852    {
853        #[inline]
854        unsafe fn encode(
855            self,
856            encoder: &mut fidl::encoding::Encoder<
857                '_,
858                fidl::encoding::DefaultFuchsiaResourceDialect,
859            >,
860            offset: usize,
861            _depth: fidl::encoding::Depth,
862        ) -> fidl::Result<()> {
863            encoder.debug_check_bounds::<LoaderCloneRequest>(offset);
864            // Delegate to tuple encoding.
865            fidl::encoding::Encode::<LoaderCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
866                (
867                    <fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<LoaderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.loader),
868                ),
869                encoder, offset, _depth
870            )
871        }
872    }
873    unsafe impl<
874            T0: fidl::encoding::Encode<
875                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<LoaderMarker>>,
876                fidl::encoding::DefaultFuchsiaResourceDialect,
877            >,
878        >
879        fidl::encoding::Encode<LoaderCloneRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
880        for (T0,)
881    {
882        #[inline]
883        unsafe fn encode(
884            self,
885            encoder: &mut fidl::encoding::Encoder<
886                '_,
887                fidl::encoding::DefaultFuchsiaResourceDialect,
888            >,
889            offset: usize,
890            depth: fidl::encoding::Depth,
891        ) -> fidl::Result<()> {
892            encoder.debug_check_bounds::<LoaderCloneRequest>(offset);
893            // Zero out padding regions. There's no need to apply masks
894            // because the unmasked parts will be overwritten by fields.
895            // Write the fields.
896            self.0.encode(encoder, offset + 0, depth)?;
897            Ok(())
898        }
899    }
900
901    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
902        for LoaderCloneRequest
903    {
904        #[inline(always)]
905        fn new_empty() -> Self {
906            Self {
907                loader: fidl::new_empty!(
908                    fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<LoaderMarker>>,
909                    fidl::encoding::DefaultFuchsiaResourceDialect
910                ),
911            }
912        }
913
914        #[inline]
915        unsafe fn decode(
916            &mut self,
917            decoder: &mut fidl::encoding::Decoder<
918                '_,
919                fidl::encoding::DefaultFuchsiaResourceDialect,
920            >,
921            offset: usize,
922            _depth: fidl::encoding::Depth,
923        ) -> fidl::Result<()> {
924            decoder.debug_check_bounds::<Self>(offset);
925            // Verify that padding bytes are zero.
926            fidl::decode!(
927                fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<LoaderMarker>>,
928                fidl::encoding::DefaultFuchsiaResourceDialect,
929                &mut self.loader,
930                decoder,
931                offset + 0,
932                _depth
933            )?;
934            Ok(())
935        }
936    }
937
938    impl fidl::encoding::ResourceTypeMarker for LoaderLoadObjectResponse {
939        type Borrowed<'a> = &'a mut Self;
940        fn take_or_borrow<'a>(
941            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
942        ) -> Self::Borrowed<'a> {
943            value
944        }
945    }
946
947    unsafe impl fidl::encoding::TypeMarker for LoaderLoadObjectResponse {
948        type Owned = Self;
949
950        #[inline(always)]
951        fn inline_align(_context: fidl::encoding::Context) -> usize {
952            4
953        }
954
955        #[inline(always)]
956        fn inline_size(_context: fidl::encoding::Context) -> usize {
957            8
958        }
959    }
960
961    unsafe impl
962        fidl::encoding::Encode<
963            LoaderLoadObjectResponse,
964            fidl::encoding::DefaultFuchsiaResourceDialect,
965        > for &mut LoaderLoadObjectResponse
966    {
967        #[inline]
968        unsafe fn encode(
969            self,
970            encoder: &mut fidl::encoding::Encoder<
971                '_,
972                fidl::encoding::DefaultFuchsiaResourceDialect,
973            >,
974            offset: usize,
975            _depth: fidl::encoding::Depth,
976        ) -> fidl::Result<()> {
977            encoder.debug_check_bounds::<LoaderLoadObjectResponse>(offset);
978            // Delegate to tuple encoding.
979            fidl::encoding::Encode::<
980                LoaderLoadObjectResponse,
981                fidl::encoding::DefaultFuchsiaResourceDialect,
982            >::encode(
983                (
984                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rv),
985                    <fidl::encoding::Optional<
986                        fidl::encoding::HandleType<
987                            fidl::Vmo,
988                            { fidl::ObjectType::VMO.into_raw() },
989                            2147483648,
990                        >,
991                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
992                        &mut self.object
993                    ),
994                ),
995                encoder,
996                offset,
997                _depth,
998            )
999        }
1000    }
1001    unsafe impl<
1002            T0: fidl::encoding::Encode<i32, fidl::encoding::DefaultFuchsiaResourceDialect>,
1003            T1: fidl::encoding::Encode<
1004                fidl::encoding::Optional<
1005                    fidl::encoding::HandleType<
1006                        fidl::Vmo,
1007                        { fidl::ObjectType::VMO.into_raw() },
1008                        2147483648,
1009                    >,
1010                >,
1011                fidl::encoding::DefaultFuchsiaResourceDialect,
1012            >,
1013        >
1014        fidl::encoding::Encode<
1015            LoaderLoadObjectResponse,
1016            fidl::encoding::DefaultFuchsiaResourceDialect,
1017        > for (T0, T1)
1018    {
1019        #[inline]
1020        unsafe fn encode(
1021            self,
1022            encoder: &mut fidl::encoding::Encoder<
1023                '_,
1024                fidl::encoding::DefaultFuchsiaResourceDialect,
1025            >,
1026            offset: usize,
1027            depth: fidl::encoding::Depth,
1028        ) -> fidl::Result<()> {
1029            encoder.debug_check_bounds::<LoaderLoadObjectResponse>(offset);
1030            // Zero out padding regions. There's no need to apply masks
1031            // because the unmasked parts will be overwritten by fields.
1032            // Write the fields.
1033            self.0.encode(encoder, offset + 0, depth)?;
1034            self.1.encode(encoder, offset + 4, depth)?;
1035            Ok(())
1036        }
1037    }
1038
1039    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
1040        for LoaderLoadObjectResponse
1041    {
1042        #[inline(always)]
1043        fn new_empty() -> Self {
1044            Self {
1045                rv: fidl::new_empty!(i32, fidl::encoding::DefaultFuchsiaResourceDialect),
1046                object: fidl::new_empty!(
1047                    fidl::encoding::Optional<
1048                        fidl::encoding::HandleType<
1049                            fidl::Vmo,
1050                            { fidl::ObjectType::VMO.into_raw() },
1051                            2147483648,
1052                        >,
1053                    >,
1054                    fidl::encoding::DefaultFuchsiaResourceDialect
1055                ),
1056            }
1057        }
1058
1059        #[inline]
1060        unsafe fn decode(
1061            &mut self,
1062            decoder: &mut fidl::encoding::Decoder<
1063                '_,
1064                fidl::encoding::DefaultFuchsiaResourceDialect,
1065            >,
1066            offset: usize,
1067            _depth: fidl::encoding::Depth,
1068        ) -> fidl::Result<()> {
1069            decoder.debug_check_bounds::<Self>(offset);
1070            // Verify that padding bytes are zero.
1071            fidl::decode!(
1072                i32,
1073                fidl::encoding::DefaultFuchsiaResourceDialect,
1074                &mut self.rv,
1075                decoder,
1076                offset + 0,
1077                _depth
1078            )?;
1079            fidl::decode!(
1080                fidl::encoding::Optional<
1081                    fidl::encoding::HandleType<
1082                        fidl::Vmo,
1083                        { fidl::ObjectType::VMO.into_raw() },
1084                        2147483648,
1085                    >,
1086                >,
1087                fidl::encoding::DefaultFuchsiaResourceDialect,
1088                &mut self.object,
1089                decoder,
1090                offset + 4,
1091                _depth
1092            )?;
1093            Ok(())
1094        }
1095    }
1096}