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