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