Skip to main content

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 LoaderControlHandle {
478    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
479        self.inner.shutdown_with_epitaph(status.into())
480    }
481}
482
483impl fdomain_client::fidl::ControlHandle for LoaderControlHandle {
484    fn shutdown(&self) {
485        self.inner.shutdown()
486    }
487
488    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
489        self.inner.shutdown_with_epitaph(status)
490    }
491
492    fn is_closed(&self) -> bool {
493        self.inner.channel().is_closed()
494    }
495    fn on_closed(&self) -> fdomain_client::OnFDomainSignals {
496        self.inner.channel().on_closed()
497    }
498}
499
500impl LoaderControlHandle {}
501
502#[must_use = "FIDL methods require a response to be sent"]
503#[derive(Debug)]
504pub struct LoaderLoadObjectResponder {
505    control_handle: std::mem::ManuallyDrop<LoaderControlHandle>,
506    tx_id: u32,
507}
508
509/// Set the the channel to be shutdown (see [`LoaderControlHandle::shutdown`])
510/// if the responder is dropped without sending a response, so that the client
511/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
512impl std::ops::Drop for LoaderLoadObjectResponder {
513    fn drop(&mut self) {
514        self.control_handle.shutdown();
515        // Safety: drops once, never accessed again
516        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
517    }
518}
519
520impl fdomain_client::fidl::Responder for LoaderLoadObjectResponder {
521    type ControlHandle = LoaderControlHandle;
522
523    fn control_handle(&self) -> &LoaderControlHandle {
524        &self.control_handle
525    }
526
527    fn drop_without_shutdown(mut self) {
528        // Safety: drops once, never accessed again due to mem::forget
529        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
530        // Prevent Drop from running (which would shut down the channel)
531        std::mem::forget(self);
532    }
533}
534
535impl LoaderLoadObjectResponder {
536    /// Sends a response to the FIDL transaction.
537    ///
538    /// Sets the channel to shutdown if an error occurs.
539    pub fn send(
540        self,
541        mut rv: i32,
542        mut object: Option<fdomain_client::Vmo>,
543    ) -> Result<(), fidl::Error> {
544        let _result = self.send_raw(rv, object);
545        if _result.is_err() {
546            self.control_handle.shutdown();
547        }
548        self.drop_without_shutdown();
549        _result
550    }
551
552    /// Similar to "send" but does not shutdown the channel if an error occurs.
553    pub fn send_no_shutdown_on_err(
554        self,
555        mut rv: i32,
556        mut object: Option<fdomain_client::Vmo>,
557    ) -> Result<(), fidl::Error> {
558        let _result = self.send_raw(rv, object);
559        self.drop_without_shutdown();
560        _result
561    }
562
563    fn send_raw(
564        &self,
565        mut rv: i32,
566        mut object: Option<fdomain_client::Vmo>,
567    ) -> Result<(), fidl::Error> {
568        self.control_handle.inner.send::<LoaderLoadObjectResponse>(
569            (rv, object),
570            self.tx_id,
571            0x48c5a151d6df2853,
572            fidl::encoding::DynamicFlags::empty(),
573        )
574    }
575}
576
577#[must_use = "FIDL methods require a response to be sent"]
578#[derive(Debug)]
579pub struct LoaderConfigResponder {
580    control_handle: std::mem::ManuallyDrop<LoaderControlHandle>,
581    tx_id: u32,
582}
583
584/// Set the the channel to be shutdown (see [`LoaderControlHandle::shutdown`])
585/// if the responder is dropped without sending a response, so that the client
586/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
587impl std::ops::Drop for LoaderConfigResponder {
588    fn drop(&mut self) {
589        self.control_handle.shutdown();
590        // Safety: drops once, never accessed again
591        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
592    }
593}
594
595impl fdomain_client::fidl::Responder for LoaderConfigResponder {
596    type ControlHandle = LoaderControlHandle;
597
598    fn control_handle(&self) -> &LoaderControlHandle {
599        &self.control_handle
600    }
601
602    fn drop_without_shutdown(mut self) {
603        // Safety: drops once, never accessed again due to mem::forget
604        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
605        // Prevent Drop from running (which would shut down the channel)
606        std::mem::forget(self);
607    }
608}
609
610impl LoaderConfigResponder {
611    /// Sends a response to the FIDL transaction.
612    ///
613    /// Sets the channel to shutdown if an error occurs.
614    pub fn send(self, mut rv: i32) -> Result<(), fidl::Error> {
615        let _result = self.send_raw(rv);
616        if _result.is_err() {
617            self.control_handle.shutdown();
618        }
619        self.drop_without_shutdown();
620        _result
621    }
622
623    /// Similar to "send" but does not shutdown the channel if an error occurs.
624    pub fn send_no_shutdown_on_err(self, mut rv: i32) -> Result<(), fidl::Error> {
625        let _result = self.send_raw(rv);
626        self.drop_without_shutdown();
627        _result
628    }
629
630    fn send_raw(&self, mut rv: i32) -> Result<(), fidl::Error> {
631        self.control_handle.inner.send::<LoaderConfigResponse>(
632            (rv,),
633            self.tx_id,
634            0x6a8a1a1464632841,
635            fidl::encoding::DynamicFlags::empty(),
636        )
637    }
638}
639
640#[must_use = "FIDL methods require a response to be sent"]
641#[derive(Debug)]
642pub struct LoaderCloneResponder {
643    control_handle: std::mem::ManuallyDrop<LoaderControlHandle>,
644    tx_id: u32,
645}
646
647/// Set the the channel to be shutdown (see [`LoaderControlHandle::shutdown`])
648/// if the responder is dropped without sending a response, so that the client
649/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
650impl std::ops::Drop for LoaderCloneResponder {
651    fn drop(&mut self) {
652        self.control_handle.shutdown();
653        // Safety: drops once, never accessed again
654        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
655    }
656}
657
658impl fdomain_client::fidl::Responder for LoaderCloneResponder {
659    type ControlHandle = LoaderControlHandle;
660
661    fn control_handle(&self) -> &LoaderControlHandle {
662        &self.control_handle
663    }
664
665    fn drop_without_shutdown(mut self) {
666        // Safety: drops once, never accessed again due to mem::forget
667        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
668        // Prevent Drop from running (which would shut down the channel)
669        std::mem::forget(self);
670    }
671}
672
673impl LoaderCloneResponder {
674    /// Sends a response to the FIDL transaction.
675    ///
676    /// Sets the channel to shutdown if an error occurs.
677    pub fn send(self, mut rv: i32) -> Result<(), fidl::Error> {
678        let _result = self.send_raw(rv);
679        if _result.is_err() {
680            self.control_handle.shutdown();
681        }
682        self.drop_without_shutdown();
683        _result
684    }
685
686    /// Similar to "send" but does not shutdown the channel if an error occurs.
687    pub fn send_no_shutdown_on_err(self, mut rv: i32) -> Result<(), fidl::Error> {
688        let _result = self.send_raw(rv);
689        self.drop_without_shutdown();
690        _result
691    }
692
693    fn send_raw(&self, mut rv: i32) -> Result<(), fidl::Error> {
694        self.control_handle.inner.send::<LoaderCloneResponse>(
695            (rv,),
696            self.tx_id,
697            0x57e643a9ab6e4c29,
698            fidl::encoding::DynamicFlags::empty(),
699        )
700    }
701}
702
703mod internal {
704    use super::*;
705
706    impl fidl::encoding::ResourceTypeMarker for LoaderCloneRequest {
707        type Borrowed<'a> = &'a mut Self;
708        fn take_or_borrow<'a>(
709            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
710        ) -> Self::Borrowed<'a> {
711            value
712        }
713    }
714
715    unsafe impl fidl::encoding::TypeMarker for LoaderCloneRequest {
716        type Owned = Self;
717
718        #[inline(always)]
719        fn inline_align(_context: fidl::encoding::Context) -> usize {
720            4
721        }
722
723        #[inline(always)]
724        fn inline_size(_context: fidl::encoding::Context) -> usize {
725            4
726        }
727    }
728
729    unsafe impl
730        fidl::encoding::Encode<LoaderCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
731        for &mut LoaderCloneRequest
732    {
733        #[inline]
734        unsafe fn encode(
735            self,
736            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
737            offset: usize,
738            _depth: fidl::encoding::Depth,
739        ) -> fidl::Result<()> {
740            encoder.debug_check_bounds::<LoaderCloneRequest>(offset);
741            // Delegate to tuple encoding.
742            fidl::encoding::Encode::<LoaderCloneRequest, fdomain_client::fidl::FDomainResourceDialect>::encode(
743                (
744                    <fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<LoaderMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.loader),
745                ),
746                encoder, offset, _depth
747            )
748        }
749    }
750    unsafe impl<
751        T0: fidl::encoding::Encode<
752                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<LoaderMarker>>,
753                fdomain_client::fidl::FDomainResourceDialect,
754            >,
755    > fidl::encoding::Encode<LoaderCloneRequest, fdomain_client::fidl::FDomainResourceDialect>
756        for (T0,)
757    {
758        #[inline]
759        unsafe fn encode(
760            self,
761            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
762            offset: usize,
763            depth: fidl::encoding::Depth,
764        ) -> fidl::Result<()> {
765            encoder.debug_check_bounds::<LoaderCloneRequest>(offset);
766            // Zero out padding regions. There's no need to apply masks
767            // because the unmasked parts will be overwritten by fields.
768            // Write the fields.
769            self.0.encode(encoder, offset + 0, depth)?;
770            Ok(())
771        }
772    }
773
774    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
775        for LoaderCloneRequest
776    {
777        #[inline(always)]
778        fn new_empty() -> Self {
779            Self {
780                loader: fidl::new_empty!(
781                    fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<LoaderMarker>>,
782                    fdomain_client::fidl::FDomainResourceDialect
783                ),
784            }
785        }
786
787        #[inline]
788        unsafe fn decode(
789            &mut self,
790            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
791            offset: usize,
792            _depth: fidl::encoding::Depth,
793        ) -> fidl::Result<()> {
794            decoder.debug_check_bounds::<Self>(offset);
795            // Verify that padding bytes are zero.
796            fidl::decode!(
797                fidl::encoding::Endpoint<fdomain_client::fidl::ServerEnd<LoaderMarker>>,
798                fdomain_client::fidl::FDomainResourceDialect,
799                &mut self.loader,
800                decoder,
801                offset + 0,
802                _depth
803            )?;
804            Ok(())
805        }
806    }
807
808    impl fidl::encoding::ResourceTypeMarker for LoaderLoadObjectResponse {
809        type Borrowed<'a> = &'a mut Self;
810        fn take_or_borrow<'a>(
811            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
812        ) -> Self::Borrowed<'a> {
813            value
814        }
815    }
816
817    unsafe impl fidl::encoding::TypeMarker for LoaderLoadObjectResponse {
818        type Owned = Self;
819
820        #[inline(always)]
821        fn inline_align(_context: fidl::encoding::Context) -> usize {
822            4
823        }
824
825        #[inline(always)]
826        fn inline_size(_context: fidl::encoding::Context) -> usize {
827            8
828        }
829    }
830
831    unsafe impl
832        fidl::encoding::Encode<
833            LoaderLoadObjectResponse,
834            fdomain_client::fidl::FDomainResourceDialect,
835        > for &mut LoaderLoadObjectResponse
836    {
837        #[inline]
838        unsafe fn encode(
839            self,
840            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
841            offset: usize,
842            _depth: fidl::encoding::Depth,
843        ) -> fidl::Result<()> {
844            encoder.debug_check_bounds::<LoaderLoadObjectResponse>(offset);
845            // Delegate to tuple encoding.
846            fidl::encoding::Encode::<
847                LoaderLoadObjectResponse,
848                fdomain_client::fidl::FDomainResourceDialect,
849            >::encode(
850                (
851                    <i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.rv),
852                    <fidl::encoding::Optional<
853                        fidl::encoding::HandleType<
854                            fdomain_client::Vmo,
855                            { fidl::ObjectType::VMO.into_raw() },
856                            2147483648,
857                        >,
858                    > as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
859                        &mut self.object
860                    ),
861                ),
862                encoder,
863                offset,
864                _depth,
865            )
866        }
867    }
868    unsafe impl<
869        T0: fidl::encoding::Encode<i32, fdomain_client::fidl::FDomainResourceDialect>,
870        T1: fidl::encoding::Encode<
871                fidl::encoding::Optional<
872                    fidl::encoding::HandleType<
873                        fdomain_client::Vmo,
874                        { fidl::ObjectType::VMO.into_raw() },
875                        2147483648,
876                    >,
877                >,
878                fdomain_client::fidl::FDomainResourceDialect,
879            >,
880    >
881        fidl::encoding::Encode<
882            LoaderLoadObjectResponse,
883            fdomain_client::fidl::FDomainResourceDialect,
884        > for (T0, T1)
885    {
886        #[inline]
887        unsafe fn encode(
888            self,
889            encoder: &mut fidl::encoding::Encoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
890            offset: usize,
891            depth: fidl::encoding::Depth,
892        ) -> fidl::Result<()> {
893            encoder.debug_check_bounds::<LoaderLoadObjectResponse>(offset);
894            // Zero out padding regions. There's no need to apply masks
895            // because the unmasked parts will be overwritten by fields.
896            // Write the fields.
897            self.0.encode(encoder, offset + 0, depth)?;
898            self.1.encode(encoder, offset + 4, depth)?;
899            Ok(())
900        }
901    }
902
903    impl fidl::encoding::Decode<Self, fdomain_client::fidl::FDomainResourceDialect>
904        for LoaderLoadObjectResponse
905    {
906        #[inline(always)]
907        fn new_empty() -> Self {
908            Self {
909                rv: fidl::new_empty!(i32, fdomain_client::fidl::FDomainResourceDialect),
910                object: fidl::new_empty!(
911                    fidl::encoding::Optional<
912                        fidl::encoding::HandleType<
913                            fdomain_client::Vmo,
914                            { fidl::ObjectType::VMO.into_raw() },
915                            2147483648,
916                        >,
917                    >,
918                    fdomain_client::fidl::FDomainResourceDialect
919                ),
920            }
921        }
922
923        #[inline]
924        unsafe fn decode(
925            &mut self,
926            decoder: &mut fidl::encoding::Decoder<'_, fdomain_client::fidl::FDomainResourceDialect>,
927            offset: usize,
928            _depth: fidl::encoding::Depth,
929        ) -> fidl::Result<()> {
930            decoder.debug_check_bounds::<Self>(offset);
931            // Verify that padding bytes are zero.
932            fidl::decode!(
933                i32,
934                fdomain_client::fidl::FDomainResourceDialect,
935                &mut self.rv,
936                decoder,
937                offset + 0,
938                _depth
939            )?;
940            fidl::decode!(
941                fidl::encoding::Optional<
942                    fidl::encoding::HandleType<
943                        fdomain_client::Vmo,
944                        { fidl::ObjectType::VMO.into_raw() },
945                        2147483648,
946                    >,
947                >,
948                fdomain_client::fidl::FDomainResourceDialect,
949                &mut self.object,
950                decoder,
951                offset + 4,
952                _depth
953            )?;
954            Ok(())
955        }
956    }
957}