Skip to main content

fidl_fuchsia_session/
fidl_fuchsia_session.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::client::QueryResponseFut;
8use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
9use fidl::endpoints::{ControlHandle as _, Responder as _};
10pub use fidl_fuchsia_session__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct LauncherMarker;
16
17impl fidl::endpoints::ProtocolMarker for LauncherMarker {
18    type Proxy = LauncherProxy;
19    type RequestStream = LauncherRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = LauncherSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.session.Launcher";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for LauncherMarker {}
26pub type LauncherLaunchResult = Result<(), LaunchError>;
27
28pub trait LauncherProxyInterface: Send + Sync {
29    type LaunchResponseFut: std::future::Future<Output = Result<LauncherLaunchResult, fidl::Error>>
30        + Send;
31    fn r#launch(&self, configuration: &LaunchConfiguration) -> Self::LaunchResponseFut;
32}
33#[derive(Debug)]
34#[cfg(target_os = "fuchsia")]
35pub struct LauncherSynchronousProxy {
36    client: fidl::client::sync::Client,
37}
38
39#[cfg(target_os = "fuchsia")]
40impl fidl::endpoints::SynchronousProxy for LauncherSynchronousProxy {
41    type Proxy = LauncherProxy;
42    type Protocol = LauncherMarker;
43
44    fn from_channel(inner: fidl::Channel) -> Self {
45        Self::new(inner)
46    }
47
48    fn into_channel(self) -> fidl::Channel {
49        self.client.into_channel()
50    }
51
52    fn as_channel(&self) -> &fidl::Channel {
53        self.client.as_channel()
54    }
55}
56
57#[cfg(target_os = "fuchsia")]
58impl LauncherSynchronousProxy {
59    pub fn new(channel: fidl::Channel) -> Self {
60        Self { client: fidl::client::sync::Client::new(channel) }
61    }
62
63    pub fn into_channel(self) -> fidl::Channel {
64        self.client.into_channel()
65    }
66
67    /// Waits until an event arrives and returns it. It is safe for other
68    /// threads to make concurrent requests while waiting for an event.
69    pub fn wait_for_event(
70        &self,
71        deadline: zx::MonotonicInstant,
72    ) -> Result<LauncherEvent, fidl::Error> {
73        LauncherEvent::decode(self.client.wait_for_event::<LauncherMarker>(deadline)?)
74    }
75
76    /// Launches the session detailed in `configuration`.
77    ///
78    /// If a session is currently running, the component associated with the running
79    /// session will be destroyed.
80    ///
81    /// + `configuration` describes the session to launch.
82    /// * error `LaunchError.INVALID_ARGS` if `configuration.session_url` is not set.
83    /// * error `LaunchError.NOT_FOUND` if `configuration.session_url`
84    ///   could not be resolved.
85    /// * error `LaunchError.DESTROY_COMPONENT_FAILED` if an existing session component
86    ///   could not be destroyed. The existing session remains running at this point.
87    /// * error `LaunchError.CREATE_COMPONENT_FAILED` if the session component
88    ///   could not be started. No session will be running at this point.
89    pub fn r#launch(
90        &self,
91        mut configuration: &LaunchConfiguration,
92        ___deadline: zx::MonotonicInstant,
93    ) -> Result<LauncherLaunchResult, fidl::Error> {
94        let _response = self.client.send_query::<
95            LauncherLaunchRequest,
96            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LaunchError>,
97            LauncherMarker,
98        >(
99            (configuration,),
100            0x7674a4287f8a385a,
101            fidl::encoding::DynamicFlags::empty(),
102            ___deadline,
103        )?;
104        Ok(_response.map(|x| x))
105    }
106}
107
108#[cfg(target_os = "fuchsia")]
109impl From<LauncherSynchronousProxy> for zx::NullableHandle {
110    fn from(value: LauncherSynchronousProxy) -> Self {
111        value.into_channel().into()
112    }
113}
114
115#[cfg(target_os = "fuchsia")]
116impl From<fidl::Channel> for LauncherSynchronousProxy {
117    fn from(value: fidl::Channel) -> Self {
118        Self::new(value)
119    }
120}
121
122#[cfg(target_os = "fuchsia")]
123impl fidl::endpoints::FromClient for LauncherSynchronousProxy {
124    type Protocol = LauncherMarker;
125
126    fn from_client(value: fidl::endpoints::ClientEnd<LauncherMarker>) -> Self {
127        Self::new(value.into_channel())
128    }
129}
130
131#[derive(Debug, Clone)]
132pub struct LauncherProxy {
133    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
134}
135
136impl fidl::endpoints::Proxy for LauncherProxy {
137    type Protocol = LauncherMarker;
138
139    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
140        Self::new(inner)
141    }
142
143    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
144        self.client.into_channel().map_err(|client| Self { client })
145    }
146
147    fn as_channel(&self) -> &::fidl::AsyncChannel {
148        self.client.as_channel()
149    }
150}
151
152impl LauncherProxy {
153    /// Create a new Proxy for fuchsia.session/Launcher.
154    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
155        let protocol_name = <LauncherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
156        Self { client: fidl::client::Client::new(channel, protocol_name) }
157    }
158
159    /// Get a Stream of events from the remote end of the protocol.
160    ///
161    /// # Panics
162    ///
163    /// Panics if the event stream was already taken.
164    pub fn take_event_stream(&self) -> LauncherEventStream {
165        LauncherEventStream { event_receiver: self.client.take_event_receiver() }
166    }
167
168    /// Launches the session detailed in `configuration`.
169    ///
170    /// If a session is currently running, the component associated with the running
171    /// session will be destroyed.
172    ///
173    /// + `configuration` describes the session to launch.
174    /// * error `LaunchError.INVALID_ARGS` if `configuration.session_url` is not set.
175    /// * error `LaunchError.NOT_FOUND` if `configuration.session_url`
176    ///   could not be resolved.
177    /// * error `LaunchError.DESTROY_COMPONENT_FAILED` if an existing session component
178    ///   could not be destroyed. The existing session remains running at this point.
179    /// * error `LaunchError.CREATE_COMPONENT_FAILED` if the session component
180    ///   could not be started. No session will be running at this point.
181    pub fn r#launch(
182        &self,
183        mut configuration: &LaunchConfiguration,
184    ) -> fidl::client::QueryResponseFut<
185        LauncherLaunchResult,
186        fidl::encoding::DefaultFuchsiaResourceDialect,
187    > {
188        LauncherProxyInterface::r#launch(self, configuration)
189    }
190}
191
192impl LauncherProxyInterface for LauncherProxy {
193    type LaunchResponseFut = fidl::client::QueryResponseFut<
194        LauncherLaunchResult,
195        fidl::encoding::DefaultFuchsiaResourceDialect,
196    >;
197    fn r#launch(&self, mut configuration: &LaunchConfiguration) -> Self::LaunchResponseFut {
198        fn _decode(
199            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
200        ) -> Result<LauncherLaunchResult, fidl::Error> {
201            let _response = fidl::client::decode_transaction_body::<
202                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, LaunchError>,
203                fidl::encoding::DefaultFuchsiaResourceDialect,
204                0x7674a4287f8a385a,
205            >(_buf?)?;
206            Ok(_response.map(|x| x))
207        }
208        self.client.send_query_and_decode::<LauncherLaunchRequest, LauncherLaunchResult>(
209            (configuration,),
210            0x7674a4287f8a385a,
211            fidl::encoding::DynamicFlags::empty(),
212            _decode,
213        )
214    }
215}
216
217pub struct LauncherEventStream {
218    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
219}
220
221impl std::marker::Unpin for LauncherEventStream {}
222
223impl futures::stream::FusedStream for LauncherEventStream {
224    fn is_terminated(&self) -> bool {
225        self.event_receiver.is_terminated()
226    }
227}
228
229impl futures::Stream for LauncherEventStream {
230    type Item = Result<LauncherEvent, fidl::Error>;
231
232    fn poll_next(
233        mut self: std::pin::Pin<&mut Self>,
234        cx: &mut std::task::Context<'_>,
235    ) -> std::task::Poll<Option<Self::Item>> {
236        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
237            &mut self.event_receiver,
238            cx
239        )?) {
240            Some(buf) => std::task::Poll::Ready(Some(LauncherEvent::decode(buf))),
241            None => std::task::Poll::Ready(None),
242        }
243    }
244}
245
246#[derive(Debug)]
247pub enum LauncherEvent {}
248
249impl LauncherEvent {
250    /// Decodes a message buffer as a [`LauncherEvent`].
251    fn decode(
252        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
253    ) -> Result<LauncherEvent, fidl::Error> {
254        let (bytes, _handles) = buf.split_mut();
255        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
256        debug_assert_eq!(tx_header.tx_id, 0);
257        match tx_header.ordinal {
258            _ => Err(fidl::Error::UnknownOrdinal {
259                ordinal: tx_header.ordinal,
260                protocol_name: <LauncherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
261            }),
262        }
263    }
264}
265
266/// A Stream of incoming requests for fuchsia.session/Launcher.
267pub struct LauncherRequestStream {
268    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
269    is_terminated: bool,
270}
271
272impl std::marker::Unpin for LauncherRequestStream {}
273
274impl futures::stream::FusedStream for LauncherRequestStream {
275    fn is_terminated(&self) -> bool {
276        self.is_terminated
277    }
278}
279
280impl fidl::endpoints::RequestStream for LauncherRequestStream {
281    type Protocol = LauncherMarker;
282    type ControlHandle = LauncherControlHandle;
283
284    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
285        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
286    }
287
288    fn control_handle(&self) -> Self::ControlHandle {
289        LauncherControlHandle { inner: self.inner.clone() }
290    }
291
292    fn into_inner(
293        self,
294    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
295    {
296        (self.inner, self.is_terminated)
297    }
298
299    fn from_inner(
300        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
301        is_terminated: bool,
302    ) -> Self {
303        Self { inner, is_terminated }
304    }
305}
306
307impl futures::Stream for LauncherRequestStream {
308    type Item = Result<LauncherRequest, fidl::Error>;
309
310    fn poll_next(
311        mut self: std::pin::Pin<&mut Self>,
312        cx: &mut std::task::Context<'_>,
313    ) -> std::task::Poll<Option<Self::Item>> {
314        let this = &mut *self;
315        if this.inner.check_shutdown(cx) {
316            this.is_terminated = true;
317            return std::task::Poll::Ready(None);
318        }
319        if this.is_terminated {
320            panic!("polled LauncherRequestStream after completion");
321        }
322        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
323            |bytes, handles| {
324                match this.inner.channel().read_etc(cx, bytes, handles) {
325                    std::task::Poll::Ready(Ok(())) => {}
326                    std::task::Poll::Pending => return std::task::Poll::Pending,
327                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
328                        this.is_terminated = true;
329                        return std::task::Poll::Ready(None);
330                    }
331                    std::task::Poll::Ready(Err(e)) => {
332                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
333                            e.into(),
334                        ))));
335                    }
336                }
337
338                // A message has been received from the channel
339                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
340
341                std::task::Poll::Ready(Some(match header.ordinal {
342                    0x7674a4287f8a385a => {
343                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
344                        let mut req = fidl::new_empty!(
345                            LauncherLaunchRequest,
346                            fidl::encoding::DefaultFuchsiaResourceDialect
347                        );
348                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LauncherLaunchRequest>(&header, _body_bytes, handles, &mut req)?;
349                        let control_handle = LauncherControlHandle { inner: this.inner.clone() };
350                        Ok(LauncherRequest::Launch {
351                            configuration: req.configuration,
352
353                            responder: LauncherLaunchResponder {
354                                control_handle: std::mem::ManuallyDrop::new(control_handle),
355                                tx_id: header.tx_id,
356                            },
357                        })
358                    }
359                    _ => Err(fidl::Error::UnknownOrdinal {
360                        ordinal: header.ordinal,
361                        protocol_name:
362                            <LauncherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
363                    }),
364                }))
365            },
366        )
367    }
368}
369
370/// A protocol used to launch sessions.
371#[derive(Debug)]
372pub enum LauncherRequest {
373    /// Launches the session detailed in `configuration`.
374    ///
375    /// If a session is currently running, the component associated with the running
376    /// session will be destroyed.
377    ///
378    /// + `configuration` describes the session to launch.
379    /// * error `LaunchError.INVALID_ARGS` if `configuration.session_url` is not set.
380    /// * error `LaunchError.NOT_FOUND` if `configuration.session_url`
381    ///   could not be resolved.
382    /// * error `LaunchError.DESTROY_COMPONENT_FAILED` if an existing session component
383    ///   could not be destroyed. The existing session remains running at this point.
384    /// * error `LaunchError.CREATE_COMPONENT_FAILED` if the session component
385    ///   could not be started. No session will be running at this point.
386    Launch { configuration: LaunchConfiguration, responder: LauncherLaunchResponder },
387}
388
389impl LauncherRequest {
390    #[allow(irrefutable_let_patterns)]
391    pub fn into_launch(self) -> Option<(LaunchConfiguration, LauncherLaunchResponder)> {
392        if let LauncherRequest::Launch { configuration, responder } = self {
393            Some((configuration, responder))
394        } else {
395            None
396        }
397    }
398
399    /// Name of the method defined in FIDL
400    pub fn method_name(&self) -> &'static str {
401        match *self {
402            LauncherRequest::Launch { .. } => "launch",
403        }
404    }
405}
406
407#[derive(Debug, Clone)]
408pub struct LauncherControlHandle {
409    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
410}
411
412impl fidl::endpoints::ControlHandle for LauncherControlHandle {
413    fn shutdown(&self) {
414        self.inner.shutdown()
415    }
416
417    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
418        self.inner.shutdown_with_epitaph(status)
419    }
420
421    fn is_closed(&self) -> bool {
422        self.inner.channel().is_closed()
423    }
424    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
425        self.inner.channel().on_closed()
426    }
427
428    #[cfg(target_os = "fuchsia")]
429    fn signal_peer(
430        &self,
431        clear_mask: zx::Signals,
432        set_mask: zx::Signals,
433    ) -> Result<(), zx_status::Status> {
434        use fidl::Peered;
435        self.inner.channel().signal_peer(clear_mask, set_mask)
436    }
437}
438
439impl LauncherControlHandle {}
440
441#[must_use = "FIDL methods require a response to be sent"]
442#[derive(Debug)]
443pub struct LauncherLaunchResponder {
444    control_handle: std::mem::ManuallyDrop<LauncherControlHandle>,
445    tx_id: u32,
446}
447
448/// Set the the channel to be shutdown (see [`LauncherControlHandle::shutdown`])
449/// if the responder is dropped without sending a response, so that the client
450/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
451impl std::ops::Drop for LauncherLaunchResponder {
452    fn drop(&mut self) {
453        self.control_handle.shutdown();
454        // Safety: drops once, never accessed again
455        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
456    }
457}
458
459impl fidl::endpoints::Responder for LauncherLaunchResponder {
460    type ControlHandle = LauncherControlHandle;
461
462    fn control_handle(&self) -> &LauncherControlHandle {
463        &self.control_handle
464    }
465
466    fn drop_without_shutdown(mut self) {
467        // Safety: drops once, never accessed again due to mem::forget
468        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
469        // Prevent Drop from running (which would shut down the channel)
470        std::mem::forget(self);
471    }
472}
473
474impl LauncherLaunchResponder {
475    /// Sends a response to the FIDL transaction.
476    ///
477    /// Sets the channel to shutdown if an error occurs.
478    pub fn send(self, mut result: Result<(), LaunchError>) -> Result<(), fidl::Error> {
479        let _result = self.send_raw(result);
480        if _result.is_err() {
481            self.control_handle.shutdown();
482        }
483        self.drop_without_shutdown();
484        _result
485    }
486
487    /// Similar to "send" but does not shutdown the channel if an error occurs.
488    pub fn send_no_shutdown_on_err(
489        self,
490        mut result: Result<(), LaunchError>,
491    ) -> Result<(), fidl::Error> {
492        let _result = self.send_raw(result);
493        self.drop_without_shutdown();
494        _result
495    }
496
497    fn send_raw(&self, mut result: Result<(), LaunchError>) -> Result<(), fidl::Error> {
498        self.control_handle.inner.send::<fidl::encoding::ResultType<
499            fidl::encoding::EmptyStruct,
500            LaunchError,
501        >>(
502            result,
503            self.tx_id,
504            0x7674a4287f8a385a,
505            fidl::encoding::DynamicFlags::empty(),
506        )
507    }
508}
509
510#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
511pub struct LifecycleMarker;
512
513impl fidl::endpoints::ProtocolMarker for LifecycleMarker {
514    type Proxy = LifecycleProxy;
515    type RequestStream = LifecycleRequestStream;
516    #[cfg(target_os = "fuchsia")]
517    type SynchronousProxy = LifecycleSynchronousProxy;
518
519    const DEBUG_NAME: &'static str = "fuchsia.session.Lifecycle";
520}
521impl fidl::endpoints::DiscoverableProtocolMarker for LifecycleMarker {}
522pub type LifecycleStartResult = Result<(), LifecycleError>;
523pub type LifecycleStopResult = Result<(), LifecycleError>;
524pub type LifecycleRestartResult = Result<(), LifecycleError>;
525
526pub trait LifecycleProxyInterface: Send + Sync {
527    type StartResponseFut: std::future::Future<Output = Result<LifecycleStartResult, fidl::Error>>
528        + Send;
529    fn r#start(&self, payload: &LifecycleStartRequest) -> Self::StartResponseFut;
530    type StopResponseFut: std::future::Future<Output = Result<LifecycleStopResult, fidl::Error>>
531        + Send;
532    fn r#stop(&self) -> Self::StopResponseFut;
533    type RestartResponseFut: std::future::Future<Output = Result<LifecycleRestartResult, fidl::Error>>
534        + Send;
535    fn r#restart(&self) -> Self::RestartResponseFut;
536}
537#[derive(Debug)]
538#[cfg(target_os = "fuchsia")]
539pub struct LifecycleSynchronousProxy {
540    client: fidl::client::sync::Client,
541}
542
543#[cfg(target_os = "fuchsia")]
544impl fidl::endpoints::SynchronousProxy for LifecycleSynchronousProxy {
545    type Proxy = LifecycleProxy;
546    type Protocol = LifecycleMarker;
547
548    fn from_channel(inner: fidl::Channel) -> Self {
549        Self::new(inner)
550    }
551
552    fn into_channel(self) -> fidl::Channel {
553        self.client.into_channel()
554    }
555
556    fn as_channel(&self) -> &fidl::Channel {
557        self.client.as_channel()
558    }
559}
560
561#[cfg(target_os = "fuchsia")]
562impl LifecycleSynchronousProxy {
563    pub fn new(channel: fidl::Channel) -> Self {
564        Self { client: fidl::client::sync::Client::new(channel) }
565    }
566
567    pub fn into_channel(self) -> fidl::Channel {
568        self.client.into_channel()
569    }
570
571    /// Waits until an event arrives and returns it. It is safe for other
572    /// threads to make concurrent requests while waiting for an event.
573    pub fn wait_for_event(
574        &self,
575        deadline: zx::MonotonicInstant,
576    ) -> Result<LifecycleEvent, fidl::Error> {
577        LifecycleEvent::decode(self.client.wait_for_event::<LifecycleMarker>(deadline)?)
578    }
579
580    /// Starts the session.
581    ///
582    /// Returns after the session component has been created and started.
583    ///
584    /// * error `LifecycleError.NOT_FOUND` if `session_url` has not been provided
585    ///   and there is no configured default session URL.
586    /// * error `LifecycleError.ALREADY_STARTED` if a session has already been started.
587    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if `session_url` could not be
588    ///   resolved to a component.
589    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if an existing session component
590    ///   could not be destroyed. The existing session remains running at this point.
591    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
592    ///   could not be started. No session will be running at this point.
593    pub fn r#start(
594        &self,
595        mut payload: &LifecycleStartRequest,
596        ___deadline: zx::MonotonicInstant,
597    ) -> Result<LifecycleStartResult, fidl::Error> {
598        let _response = self.client.send_query::<
599            LifecycleStartRequest,
600            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
601            LifecycleMarker,
602        >(
603            payload,
604            0x2fda381d2cc41ce0,
605            fidl::encoding::DynamicFlags::FLEXIBLE,
606            ___deadline,
607        )?
608        .into_result::<LifecycleMarker>("start")?;
609        Ok(_response.map(|x| x))
610    }
611
612    /// Stops the session.
613    ///
614    /// Returns after the session component has been destroyed.
615    ///
616    /// * error `LifecycleError.NOT_FOUND` if the session has not been started.
617    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
618    ///   could not be destroyed. The previous session will continue to exist at
619    ///   this point and the component may be running.
620    pub fn r#stop(
621        &self,
622        ___deadline: zx::MonotonicInstant,
623    ) -> Result<LifecycleStopResult, fidl::Error> {
624        let _response = self.client.send_query::<
625            fidl::encoding::EmptyPayload,
626            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
627            LifecycleMarker,
628        >(
629            (),
630            0x453a9158431b4a2,
631            fidl::encoding::DynamicFlags::FLEXIBLE,
632            ___deadline,
633        )?
634        .into_result::<LifecycleMarker>("stop")?;
635        Ok(_response.map(|x| x))
636    }
637
638    /// Restarts the session.
639    ///
640    /// This stops the existing session and starts a new session with the same
641    /// session URL as the previous one.
642    ///
643    /// Returns once the new session component has been created and started.
644    ///
645    /// * error `LifecycleError.NOT_FOUND` if there is no existing session.
646    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if the session URL
647    ///   could not be resolved to a component.
648    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
649    ///   could not be destroyed. The previous session will continue to exist at
650    ///   this point and the component may be running.
651    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
652    ///   could not be started. No session will be running at this point.
653    pub fn r#restart(
654        &self,
655        ___deadline: zx::MonotonicInstant,
656    ) -> Result<LifecycleRestartResult, fidl::Error> {
657        let _response = self.client.send_query::<
658            fidl::encoding::EmptyPayload,
659            fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
660            LifecycleMarker,
661        >(
662            (),
663            0x31faeac257bf1abb,
664            fidl::encoding::DynamicFlags::FLEXIBLE,
665            ___deadline,
666        )?
667        .into_result::<LifecycleMarker>("restart")?;
668        Ok(_response.map(|x| x))
669    }
670}
671
672#[cfg(target_os = "fuchsia")]
673impl From<LifecycleSynchronousProxy> for zx::NullableHandle {
674    fn from(value: LifecycleSynchronousProxy) -> Self {
675        value.into_channel().into()
676    }
677}
678
679#[cfg(target_os = "fuchsia")]
680impl From<fidl::Channel> for LifecycleSynchronousProxy {
681    fn from(value: fidl::Channel) -> Self {
682        Self::new(value)
683    }
684}
685
686#[cfg(target_os = "fuchsia")]
687impl fidl::endpoints::FromClient for LifecycleSynchronousProxy {
688    type Protocol = LifecycleMarker;
689
690    fn from_client(value: fidl::endpoints::ClientEnd<LifecycleMarker>) -> Self {
691        Self::new(value.into_channel())
692    }
693}
694
695#[derive(Debug, Clone)]
696pub struct LifecycleProxy {
697    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
698}
699
700impl fidl::endpoints::Proxy for LifecycleProxy {
701    type Protocol = LifecycleMarker;
702
703    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
704        Self::new(inner)
705    }
706
707    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
708        self.client.into_channel().map_err(|client| Self { client })
709    }
710
711    fn as_channel(&self) -> &::fidl::AsyncChannel {
712        self.client.as_channel()
713    }
714}
715
716impl LifecycleProxy {
717    /// Create a new Proxy for fuchsia.session/Lifecycle.
718    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
719        let protocol_name = <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
720        Self { client: fidl::client::Client::new(channel, protocol_name) }
721    }
722
723    /// Get a Stream of events from the remote end of the protocol.
724    ///
725    /// # Panics
726    ///
727    /// Panics if the event stream was already taken.
728    pub fn take_event_stream(&self) -> LifecycleEventStream {
729        LifecycleEventStream { event_receiver: self.client.take_event_receiver() }
730    }
731
732    /// Starts the session.
733    ///
734    /// Returns after the session component has been created and started.
735    ///
736    /// * error `LifecycleError.NOT_FOUND` if `session_url` has not been provided
737    ///   and there is no configured default session URL.
738    /// * error `LifecycleError.ALREADY_STARTED` if a session has already been started.
739    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if `session_url` could not be
740    ///   resolved to a component.
741    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if an existing session component
742    ///   could not be destroyed. The existing session remains running at this point.
743    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
744    ///   could not be started. No session will be running at this point.
745    pub fn r#start(
746        &self,
747        mut payload: &LifecycleStartRequest,
748    ) -> fidl::client::QueryResponseFut<
749        LifecycleStartResult,
750        fidl::encoding::DefaultFuchsiaResourceDialect,
751    > {
752        LifecycleProxyInterface::r#start(self, payload)
753    }
754
755    /// Stops the session.
756    ///
757    /// Returns after the session component has been destroyed.
758    ///
759    /// * error `LifecycleError.NOT_FOUND` if the session has not been started.
760    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
761    ///   could not be destroyed. The previous session will continue to exist at
762    ///   this point and the component may be running.
763    pub fn r#stop(
764        &self,
765    ) -> fidl::client::QueryResponseFut<
766        LifecycleStopResult,
767        fidl::encoding::DefaultFuchsiaResourceDialect,
768    > {
769        LifecycleProxyInterface::r#stop(self)
770    }
771
772    /// Restarts the session.
773    ///
774    /// This stops the existing session and starts a new session with the same
775    /// session URL as the previous one.
776    ///
777    /// Returns once the new session component has been created and started.
778    ///
779    /// * error `LifecycleError.NOT_FOUND` if there is no existing session.
780    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if the session URL
781    ///   could not be resolved to a component.
782    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
783    ///   could not be destroyed. The previous session will continue to exist at
784    ///   this point and the component may be running.
785    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
786    ///   could not be started. No session will be running at this point.
787    pub fn r#restart(
788        &self,
789    ) -> fidl::client::QueryResponseFut<
790        LifecycleRestartResult,
791        fidl::encoding::DefaultFuchsiaResourceDialect,
792    > {
793        LifecycleProxyInterface::r#restart(self)
794    }
795}
796
797impl LifecycleProxyInterface for LifecycleProxy {
798    type StartResponseFut = fidl::client::QueryResponseFut<
799        LifecycleStartResult,
800        fidl::encoding::DefaultFuchsiaResourceDialect,
801    >;
802    fn r#start(&self, mut payload: &LifecycleStartRequest) -> Self::StartResponseFut {
803        fn _decode(
804            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
805        ) -> Result<LifecycleStartResult, fidl::Error> {
806            let _response = fidl::client::decode_transaction_body::<
807                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
808                fidl::encoding::DefaultFuchsiaResourceDialect,
809                0x2fda381d2cc41ce0,
810            >(_buf?)?
811            .into_result::<LifecycleMarker>("start")?;
812            Ok(_response.map(|x| x))
813        }
814        self.client.send_query_and_decode::<LifecycleStartRequest, LifecycleStartResult>(
815            payload,
816            0x2fda381d2cc41ce0,
817            fidl::encoding::DynamicFlags::FLEXIBLE,
818            _decode,
819        )
820    }
821
822    type StopResponseFut = fidl::client::QueryResponseFut<
823        LifecycleStopResult,
824        fidl::encoding::DefaultFuchsiaResourceDialect,
825    >;
826    fn r#stop(&self) -> Self::StopResponseFut {
827        fn _decode(
828            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
829        ) -> Result<LifecycleStopResult, fidl::Error> {
830            let _response = fidl::client::decode_transaction_body::<
831                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
832                fidl::encoding::DefaultFuchsiaResourceDialect,
833                0x453a9158431b4a2,
834            >(_buf?)?
835            .into_result::<LifecycleMarker>("stop")?;
836            Ok(_response.map(|x| x))
837        }
838        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LifecycleStopResult>(
839            (),
840            0x453a9158431b4a2,
841            fidl::encoding::DynamicFlags::FLEXIBLE,
842            _decode,
843        )
844    }
845
846    type RestartResponseFut = fidl::client::QueryResponseFut<
847        LifecycleRestartResult,
848        fidl::encoding::DefaultFuchsiaResourceDialect,
849    >;
850    fn r#restart(&self) -> Self::RestartResponseFut {
851        fn _decode(
852            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
853        ) -> Result<LifecycleRestartResult, fidl::Error> {
854            let _response = fidl::client::decode_transaction_body::<
855                fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, LifecycleError>,
856                fidl::encoding::DefaultFuchsiaResourceDialect,
857                0x31faeac257bf1abb,
858            >(_buf?)?
859            .into_result::<LifecycleMarker>("restart")?;
860            Ok(_response.map(|x| x))
861        }
862        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, LifecycleRestartResult>(
863            (),
864            0x31faeac257bf1abb,
865            fidl::encoding::DynamicFlags::FLEXIBLE,
866            _decode,
867        )
868    }
869}
870
871pub struct LifecycleEventStream {
872    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
873}
874
875impl std::marker::Unpin for LifecycleEventStream {}
876
877impl futures::stream::FusedStream for LifecycleEventStream {
878    fn is_terminated(&self) -> bool {
879        self.event_receiver.is_terminated()
880    }
881}
882
883impl futures::Stream for LifecycleEventStream {
884    type Item = Result<LifecycleEvent, fidl::Error>;
885
886    fn poll_next(
887        mut self: std::pin::Pin<&mut Self>,
888        cx: &mut std::task::Context<'_>,
889    ) -> std::task::Poll<Option<Self::Item>> {
890        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
891            &mut self.event_receiver,
892            cx
893        )?) {
894            Some(buf) => std::task::Poll::Ready(Some(LifecycleEvent::decode(buf))),
895            None => std::task::Poll::Ready(None),
896        }
897    }
898}
899
900#[derive(Debug)]
901pub enum LifecycleEvent {
902    #[non_exhaustive]
903    _UnknownEvent {
904        /// Ordinal of the event that was sent.
905        ordinal: u64,
906    },
907}
908
909impl LifecycleEvent {
910    /// Decodes a message buffer as a [`LifecycleEvent`].
911    fn decode(
912        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
913    ) -> Result<LifecycleEvent, fidl::Error> {
914        let (bytes, _handles) = buf.split_mut();
915        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
916        debug_assert_eq!(tx_header.tx_id, 0);
917        match tx_header.ordinal {
918            _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
919                Ok(LifecycleEvent::_UnknownEvent { ordinal: tx_header.ordinal })
920            }
921            _ => Err(fidl::Error::UnknownOrdinal {
922                ordinal: tx_header.ordinal,
923                protocol_name: <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
924            }),
925        }
926    }
927}
928
929/// A Stream of incoming requests for fuchsia.session/Lifecycle.
930pub struct LifecycleRequestStream {
931    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
932    is_terminated: bool,
933}
934
935impl std::marker::Unpin for LifecycleRequestStream {}
936
937impl futures::stream::FusedStream for LifecycleRequestStream {
938    fn is_terminated(&self) -> bool {
939        self.is_terminated
940    }
941}
942
943impl fidl::endpoints::RequestStream for LifecycleRequestStream {
944    type Protocol = LifecycleMarker;
945    type ControlHandle = LifecycleControlHandle;
946
947    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
948        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
949    }
950
951    fn control_handle(&self) -> Self::ControlHandle {
952        LifecycleControlHandle { inner: self.inner.clone() }
953    }
954
955    fn into_inner(
956        self,
957    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
958    {
959        (self.inner, self.is_terminated)
960    }
961
962    fn from_inner(
963        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
964        is_terminated: bool,
965    ) -> Self {
966        Self { inner, is_terminated }
967    }
968}
969
970impl futures::Stream for LifecycleRequestStream {
971    type Item = Result<LifecycleRequest, fidl::Error>;
972
973    fn poll_next(
974        mut self: std::pin::Pin<&mut Self>,
975        cx: &mut std::task::Context<'_>,
976    ) -> std::task::Poll<Option<Self::Item>> {
977        let this = &mut *self;
978        if this.inner.check_shutdown(cx) {
979            this.is_terminated = true;
980            return std::task::Poll::Ready(None);
981        }
982        if this.is_terminated {
983            panic!("polled LifecycleRequestStream after completion");
984        }
985        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
986            |bytes, handles| {
987                match this.inner.channel().read_etc(cx, bytes, handles) {
988                    std::task::Poll::Ready(Ok(())) => {}
989                    std::task::Poll::Pending => return std::task::Poll::Pending,
990                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
991                        this.is_terminated = true;
992                        return std::task::Poll::Ready(None);
993                    }
994                    std::task::Poll::Ready(Err(e)) => {
995                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
996                            e.into(),
997                        ))));
998                    }
999                }
1000
1001                // A message has been received from the channel
1002                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1003
1004                std::task::Poll::Ready(Some(match header.ordinal {
1005                    0x2fda381d2cc41ce0 => {
1006                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1007                        let mut req = fidl::new_empty!(
1008                            LifecycleStartRequest,
1009                            fidl::encoding::DefaultFuchsiaResourceDialect
1010                        );
1011                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<LifecycleStartRequest>(&header, _body_bytes, handles, &mut req)?;
1012                        let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
1013                        Ok(LifecycleRequest::Start {
1014                            payload: req,
1015                            responder: LifecycleStartResponder {
1016                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1017                                tx_id: header.tx_id,
1018                            },
1019                        })
1020                    }
1021                    0x453a9158431b4a2 => {
1022                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1023                        let mut req = fidl::new_empty!(
1024                            fidl::encoding::EmptyPayload,
1025                            fidl::encoding::DefaultFuchsiaResourceDialect
1026                        );
1027                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1028                        let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
1029                        Ok(LifecycleRequest::Stop {
1030                            responder: LifecycleStopResponder {
1031                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1032                                tx_id: header.tx_id,
1033                            },
1034                        })
1035                    }
1036                    0x31faeac257bf1abb => {
1037                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1038                        let mut req = fidl::new_empty!(
1039                            fidl::encoding::EmptyPayload,
1040                            fidl::encoding::DefaultFuchsiaResourceDialect
1041                        );
1042                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1043                        let control_handle = LifecycleControlHandle { inner: this.inner.clone() };
1044                        Ok(LifecycleRequest::Restart {
1045                            responder: LifecycleRestartResponder {
1046                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1047                                tx_id: header.tx_id,
1048                            },
1049                        })
1050                    }
1051                    _ if header.tx_id == 0
1052                        && header
1053                            .dynamic_flags()
1054                            .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1055                    {
1056                        Ok(LifecycleRequest::_UnknownMethod {
1057                            ordinal: header.ordinal,
1058                            control_handle: LifecycleControlHandle { inner: this.inner.clone() },
1059                            method_type: fidl::MethodType::OneWay,
1060                        })
1061                    }
1062                    _ if header
1063                        .dynamic_flags()
1064                        .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
1065                    {
1066                        this.inner.send_framework_err(
1067                            fidl::encoding::FrameworkErr::UnknownMethod,
1068                            header.tx_id,
1069                            header.ordinal,
1070                            header.dynamic_flags(),
1071                            (bytes, handles),
1072                        )?;
1073                        Ok(LifecycleRequest::_UnknownMethod {
1074                            ordinal: header.ordinal,
1075                            control_handle: LifecycleControlHandle { inner: this.inner.clone() },
1076                            method_type: fidl::MethodType::TwoWay,
1077                        })
1078                    }
1079                    _ => Err(fidl::Error::UnknownOrdinal {
1080                        ordinal: header.ordinal,
1081                        protocol_name:
1082                            <LifecycleMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1083                    }),
1084                }))
1085            },
1086        )
1087    }
1088}
1089
1090/// A protocol used to control the session's lifecycle.
1091#[derive(Debug)]
1092pub enum LifecycleRequest {
1093    /// Starts the session.
1094    ///
1095    /// Returns after the session component has been created and started.
1096    ///
1097    /// * error `LifecycleError.NOT_FOUND` if `session_url` has not been provided
1098    ///   and there is no configured default session URL.
1099    /// * error `LifecycleError.ALREADY_STARTED` if a session has already been started.
1100    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if `session_url` could not be
1101    ///   resolved to a component.
1102    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if an existing session component
1103    ///   could not be destroyed. The existing session remains running at this point.
1104    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
1105    ///   could not be started. No session will be running at this point.
1106    Start { payload: LifecycleStartRequest, responder: LifecycleStartResponder },
1107    /// Stops the session.
1108    ///
1109    /// Returns after the session component has been destroyed.
1110    ///
1111    /// * error `LifecycleError.NOT_FOUND` if the session has not been started.
1112    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
1113    ///   could not be destroyed. The previous session will continue to exist at
1114    ///   this point and the component may be running.
1115    Stop { responder: LifecycleStopResponder },
1116    /// Restarts the session.
1117    ///
1118    /// This stops the existing session and starts a new session with the same
1119    /// session URL as the previous one.
1120    ///
1121    /// Returns once the new session component has been created and started.
1122    ///
1123    /// * error `LifecycleError.NOT_FOUND` if there is no existing session.
1124    /// * error `LifecycleError.RESOLVE_COMPONENT_FAILED` if the session URL
1125    ///   could not be resolved to a component.
1126    /// * error `LifecycleError.DESTROY_COMPONENT_FAILED` if the session component
1127    ///   could not be destroyed. The previous session will continue to exist at
1128    ///   this point and the component may be running.
1129    /// * error `LifecycleError.CREATE_COMPONENT_FAILED` if the session component
1130    ///   could not be started. No session will be running at this point.
1131    Restart { responder: LifecycleRestartResponder },
1132    /// An interaction was received which does not match any known method.
1133    #[non_exhaustive]
1134    _UnknownMethod {
1135        /// Ordinal of the method that was called.
1136        ordinal: u64,
1137        control_handle: LifecycleControlHandle,
1138        method_type: fidl::MethodType,
1139    },
1140}
1141
1142impl LifecycleRequest {
1143    #[allow(irrefutable_let_patterns)]
1144    pub fn into_start(self) -> Option<(LifecycleStartRequest, LifecycleStartResponder)> {
1145        if let LifecycleRequest::Start { payload, responder } = self {
1146            Some((payload, responder))
1147        } else {
1148            None
1149        }
1150    }
1151
1152    #[allow(irrefutable_let_patterns)]
1153    pub fn into_stop(self) -> Option<(LifecycleStopResponder)> {
1154        if let LifecycleRequest::Stop { responder } = self { Some((responder)) } else { None }
1155    }
1156
1157    #[allow(irrefutable_let_patterns)]
1158    pub fn into_restart(self) -> Option<(LifecycleRestartResponder)> {
1159        if let LifecycleRequest::Restart { responder } = self { Some((responder)) } else { None }
1160    }
1161
1162    /// Name of the method defined in FIDL
1163    pub fn method_name(&self) -> &'static str {
1164        match *self {
1165            LifecycleRequest::Start { .. } => "start",
1166            LifecycleRequest::Stop { .. } => "stop",
1167            LifecycleRequest::Restart { .. } => "restart",
1168            LifecycleRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
1169                "unknown one-way method"
1170            }
1171            LifecycleRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
1172                "unknown two-way method"
1173            }
1174        }
1175    }
1176}
1177
1178#[derive(Debug, Clone)]
1179pub struct LifecycleControlHandle {
1180    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1181}
1182
1183impl fidl::endpoints::ControlHandle for LifecycleControlHandle {
1184    fn shutdown(&self) {
1185        self.inner.shutdown()
1186    }
1187
1188    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1189        self.inner.shutdown_with_epitaph(status)
1190    }
1191
1192    fn is_closed(&self) -> bool {
1193        self.inner.channel().is_closed()
1194    }
1195    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1196        self.inner.channel().on_closed()
1197    }
1198
1199    #[cfg(target_os = "fuchsia")]
1200    fn signal_peer(
1201        &self,
1202        clear_mask: zx::Signals,
1203        set_mask: zx::Signals,
1204    ) -> Result<(), zx_status::Status> {
1205        use fidl::Peered;
1206        self.inner.channel().signal_peer(clear_mask, set_mask)
1207    }
1208}
1209
1210impl LifecycleControlHandle {}
1211
1212#[must_use = "FIDL methods require a response to be sent"]
1213#[derive(Debug)]
1214pub struct LifecycleStartResponder {
1215    control_handle: std::mem::ManuallyDrop<LifecycleControlHandle>,
1216    tx_id: u32,
1217}
1218
1219/// Set the the channel to be shutdown (see [`LifecycleControlHandle::shutdown`])
1220/// if the responder is dropped without sending a response, so that the client
1221/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1222impl std::ops::Drop for LifecycleStartResponder {
1223    fn drop(&mut self) {
1224        self.control_handle.shutdown();
1225        // Safety: drops once, never accessed again
1226        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1227    }
1228}
1229
1230impl fidl::endpoints::Responder for LifecycleStartResponder {
1231    type ControlHandle = LifecycleControlHandle;
1232
1233    fn control_handle(&self) -> &LifecycleControlHandle {
1234        &self.control_handle
1235    }
1236
1237    fn drop_without_shutdown(mut self) {
1238        // Safety: drops once, never accessed again due to mem::forget
1239        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1240        // Prevent Drop from running (which would shut down the channel)
1241        std::mem::forget(self);
1242    }
1243}
1244
1245impl LifecycleStartResponder {
1246    /// Sends a response to the FIDL transaction.
1247    ///
1248    /// Sets the channel to shutdown if an error occurs.
1249    pub fn send(self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1250        let _result = self.send_raw(result);
1251        if _result.is_err() {
1252            self.control_handle.shutdown();
1253        }
1254        self.drop_without_shutdown();
1255        _result
1256    }
1257
1258    /// Similar to "send" but does not shutdown the channel if an error occurs.
1259    pub fn send_no_shutdown_on_err(
1260        self,
1261        mut result: Result<(), LifecycleError>,
1262    ) -> Result<(), fidl::Error> {
1263        let _result = self.send_raw(result);
1264        self.drop_without_shutdown();
1265        _result
1266    }
1267
1268    fn send_raw(&self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1269        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1270            fidl::encoding::EmptyStruct,
1271            LifecycleError,
1272        >>(
1273            fidl::encoding::FlexibleResult::new(result),
1274            self.tx_id,
1275            0x2fda381d2cc41ce0,
1276            fidl::encoding::DynamicFlags::FLEXIBLE,
1277        )
1278    }
1279}
1280
1281#[must_use = "FIDL methods require a response to be sent"]
1282#[derive(Debug)]
1283pub struct LifecycleStopResponder {
1284    control_handle: std::mem::ManuallyDrop<LifecycleControlHandle>,
1285    tx_id: u32,
1286}
1287
1288/// Set the the channel to be shutdown (see [`LifecycleControlHandle::shutdown`])
1289/// if the responder is dropped without sending a response, so that the client
1290/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1291impl std::ops::Drop for LifecycleStopResponder {
1292    fn drop(&mut self) {
1293        self.control_handle.shutdown();
1294        // Safety: drops once, never accessed again
1295        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1296    }
1297}
1298
1299impl fidl::endpoints::Responder for LifecycleStopResponder {
1300    type ControlHandle = LifecycleControlHandle;
1301
1302    fn control_handle(&self) -> &LifecycleControlHandle {
1303        &self.control_handle
1304    }
1305
1306    fn drop_without_shutdown(mut self) {
1307        // Safety: drops once, never accessed again due to mem::forget
1308        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1309        // Prevent Drop from running (which would shut down the channel)
1310        std::mem::forget(self);
1311    }
1312}
1313
1314impl LifecycleStopResponder {
1315    /// Sends a response to the FIDL transaction.
1316    ///
1317    /// Sets the channel to shutdown if an error occurs.
1318    pub fn send(self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1319        let _result = self.send_raw(result);
1320        if _result.is_err() {
1321            self.control_handle.shutdown();
1322        }
1323        self.drop_without_shutdown();
1324        _result
1325    }
1326
1327    /// Similar to "send" but does not shutdown the channel if an error occurs.
1328    pub fn send_no_shutdown_on_err(
1329        self,
1330        mut result: Result<(), LifecycleError>,
1331    ) -> Result<(), fidl::Error> {
1332        let _result = self.send_raw(result);
1333        self.drop_without_shutdown();
1334        _result
1335    }
1336
1337    fn send_raw(&self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1338        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1339            fidl::encoding::EmptyStruct,
1340            LifecycleError,
1341        >>(
1342            fidl::encoding::FlexibleResult::new(result),
1343            self.tx_id,
1344            0x453a9158431b4a2,
1345            fidl::encoding::DynamicFlags::FLEXIBLE,
1346        )
1347    }
1348}
1349
1350#[must_use = "FIDL methods require a response to be sent"]
1351#[derive(Debug)]
1352pub struct LifecycleRestartResponder {
1353    control_handle: std::mem::ManuallyDrop<LifecycleControlHandle>,
1354    tx_id: u32,
1355}
1356
1357/// Set the the channel to be shutdown (see [`LifecycleControlHandle::shutdown`])
1358/// if the responder is dropped without sending a response, so that the client
1359/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1360impl std::ops::Drop for LifecycleRestartResponder {
1361    fn drop(&mut self) {
1362        self.control_handle.shutdown();
1363        // Safety: drops once, never accessed again
1364        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1365    }
1366}
1367
1368impl fidl::endpoints::Responder for LifecycleRestartResponder {
1369    type ControlHandle = LifecycleControlHandle;
1370
1371    fn control_handle(&self) -> &LifecycleControlHandle {
1372        &self.control_handle
1373    }
1374
1375    fn drop_without_shutdown(mut self) {
1376        // Safety: drops once, never accessed again due to mem::forget
1377        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1378        // Prevent Drop from running (which would shut down the channel)
1379        std::mem::forget(self);
1380    }
1381}
1382
1383impl LifecycleRestartResponder {
1384    /// Sends a response to the FIDL transaction.
1385    ///
1386    /// Sets the channel to shutdown if an error occurs.
1387    pub fn send(self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1388        let _result = self.send_raw(result);
1389        if _result.is_err() {
1390            self.control_handle.shutdown();
1391        }
1392        self.drop_without_shutdown();
1393        _result
1394    }
1395
1396    /// Similar to "send" but does not shutdown the channel if an error occurs.
1397    pub fn send_no_shutdown_on_err(
1398        self,
1399        mut result: Result<(), LifecycleError>,
1400    ) -> Result<(), fidl::Error> {
1401        let _result = self.send_raw(result);
1402        self.drop_without_shutdown();
1403        _result
1404    }
1405
1406    fn send_raw(&self, mut result: Result<(), LifecycleError>) -> Result<(), fidl::Error> {
1407        self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
1408            fidl::encoding::EmptyStruct,
1409            LifecycleError,
1410        >>(
1411            fidl::encoding::FlexibleResult::new(result),
1412            self.tx_id,
1413            0x31faeac257bf1abb,
1414            fidl::encoding::DynamicFlags::FLEXIBLE,
1415        )
1416    }
1417}
1418
1419#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1420pub struct RestarterMarker;
1421
1422impl fidl::endpoints::ProtocolMarker for RestarterMarker {
1423    type Proxy = RestarterProxy;
1424    type RequestStream = RestarterRequestStream;
1425    #[cfg(target_os = "fuchsia")]
1426    type SynchronousProxy = RestarterSynchronousProxy;
1427
1428    const DEBUG_NAME: &'static str = "fuchsia.session.Restarter";
1429}
1430impl fidl::endpoints::DiscoverableProtocolMarker for RestarterMarker {}
1431pub type RestarterRestartResult = Result<(), RestartError>;
1432
1433pub trait RestarterProxyInterface: Send + Sync {
1434    type RestartResponseFut: std::future::Future<Output = Result<RestarterRestartResult, fidl::Error>>
1435        + Send;
1436    fn r#restart(&self) -> Self::RestartResponseFut;
1437}
1438#[derive(Debug)]
1439#[cfg(target_os = "fuchsia")]
1440pub struct RestarterSynchronousProxy {
1441    client: fidl::client::sync::Client,
1442}
1443
1444#[cfg(target_os = "fuchsia")]
1445impl fidl::endpoints::SynchronousProxy for RestarterSynchronousProxy {
1446    type Proxy = RestarterProxy;
1447    type Protocol = RestarterMarker;
1448
1449    fn from_channel(inner: fidl::Channel) -> Self {
1450        Self::new(inner)
1451    }
1452
1453    fn into_channel(self) -> fidl::Channel {
1454        self.client.into_channel()
1455    }
1456
1457    fn as_channel(&self) -> &fidl::Channel {
1458        self.client.as_channel()
1459    }
1460}
1461
1462#[cfg(target_os = "fuchsia")]
1463impl RestarterSynchronousProxy {
1464    pub fn new(channel: fidl::Channel) -> Self {
1465        Self { client: fidl::client::sync::Client::new(channel) }
1466    }
1467
1468    pub fn into_channel(self) -> fidl::Channel {
1469        self.client.into_channel()
1470    }
1471
1472    /// Waits until an event arrives and returns it. It is safe for other
1473    /// threads to make concurrent requests while waiting for an event.
1474    pub fn wait_for_event(
1475        &self,
1476        deadline: zx::MonotonicInstant,
1477    ) -> Result<RestarterEvent, fidl::Error> {
1478        RestarterEvent::decode(self.client.wait_for_event::<RestarterMarker>(deadline)?)
1479    }
1480
1481    /// Restarts the session.
1482    ///
1483    /// * error `RestartError.NOT_RUNNING` if there is no
1484    ///   currently running session to restart.
1485    /// * error `RestartError.DESTROY_COMPONENT_FAILED` if an existing session component
1486    ///   could not be destroyed. The existing session remains running at this point.
1487    /// * error `RestartError.CREATE_COMPONENT_FAILED` if the session component
1488    ///   could not be started. No session will be running at this point.
1489    pub fn r#restart(
1490        &self,
1491        ___deadline: zx::MonotonicInstant,
1492    ) -> Result<RestarterRestartResult, fidl::Error> {
1493        let _response = self.client.send_query::<
1494            fidl::encoding::EmptyPayload,
1495            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RestartError>,
1496            RestarterMarker,
1497        >(
1498            (),
1499            0x50cd09e53189e5ae,
1500            fidl::encoding::DynamicFlags::empty(),
1501            ___deadline,
1502        )?;
1503        Ok(_response.map(|x| x))
1504    }
1505}
1506
1507#[cfg(target_os = "fuchsia")]
1508impl From<RestarterSynchronousProxy> for zx::NullableHandle {
1509    fn from(value: RestarterSynchronousProxy) -> Self {
1510        value.into_channel().into()
1511    }
1512}
1513
1514#[cfg(target_os = "fuchsia")]
1515impl From<fidl::Channel> for RestarterSynchronousProxy {
1516    fn from(value: fidl::Channel) -> Self {
1517        Self::new(value)
1518    }
1519}
1520
1521#[cfg(target_os = "fuchsia")]
1522impl fidl::endpoints::FromClient for RestarterSynchronousProxy {
1523    type Protocol = RestarterMarker;
1524
1525    fn from_client(value: fidl::endpoints::ClientEnd<RestarterMarker>) -> Self {
1526        Self::new(value.into_channel())
1527    }
1528}
1529
1530#[derive(Debug, Clone)]
1531pub struct RestarterProxy {
1532    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
1533}
1534
1535impl fidl::endpoints::Proxy for RestarterProxy {
1536    type Protocol = RestarterMarker;
1537
1538    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
1539        Self::new(inner)
1540    }
1541
1542    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
1543        self.client.into_channel().map_err(|client| Self { client })
1544    }
1545
1546    fn as_channel(&self) -> &::fidl::AsyncChannel {
1547        self.client.as_channel()
1548    }
1549}
1550
1551impl RestarterProxy {
1552    /// Create a new Proxy for fuchsia.session/Restarter.
1553    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
1554        let protocol_name = <RestarterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
1555        Self { client: fidl::client::Client::new(channel, protocol_name) }
1556    }
1557
1558    /// Get a Stream of events from the remote end of the protocol.
1559    ///
1560    /// # Panics
1561    ///
1562    /// Panics if the event stream was already taken.
1563    pub fn take_event_stream(&self) -> RestarterEventStream {
1564        RestarterEventStream { event_receiver: self.client.take_event_receiver() }
1565    }
1566
1567    /// Restarts the session.
1568    ///
1569    /// * error `RestartError.NOT_RUNNING` if there is no
1570    ///   currently running session to restart.
1571    /// * error `RestartError.DESTROY_COMPONENT_FAILED` if an existing session component
1572    ///   could not be destroyed. The existing session remains running at this point.
1573    /// * error `RestartError.CREATE_COMPONENT_FAILED` if the session component
1574    ///   could not be started. No session will be running at this point.
1575    pub fn r#restart(
1576        &self,
1577    ) -> fidl::client::QueryResponseFut<
1578        RestarterRestartResult,
1579        fidl::encoding::DefaultFuchsiaResourceDialect,
1580    > {
1581        RestarterProxyInterface::r#restart(self)
1582    }
1583}
1584
1585impl RestarterProxyInterface for RestarterProxy {
1586    type RestartResponseFut = fidl::client::QueryResponseFut<
1587        RestarterRestartResult,
1588        fidl::encoding::DefaultFuchsiaResourceDialect,
1589    >;
1590    fn r#restart(&self) -> Self::RestartResponseFut {
1591        fn _decode(
1592            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
1593        ) -> Result<RestarterRestartResult, fidl::Error> {
1594            let _response = fidl::client::decode_transaction_body::<
1595                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RestartError>,
1596                fidl::encoding::DefaultFuchsiaResourceDialect,
1597                0x50cd09e53189e5ae,
1598            >(_buf?)?;
1599            Ok(_response.map(|x| x))
1600        }
1601        self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, RestarterRestartResult>(
1602            (),
1603            0x50cd09e53189e5ae,
1604            fidl::encoding::DynamicFlags::empty(),
1605            _decode,
1606        )
1607    }
1608}
1609
1610pub struct RestarterEventStream {
1611    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
1612}
1613
1614impl std::marker::Unpin for RestarterEventStream {}
1615
1616impl futures::stream::FusedStream for RestarterEventStream {
1617    fn is_terminated(&self) -> bool {
1618        self.event_receiver.is_terminated()
1619    }
1620}
1621
1622impl futures::Stream for RestarterEventStream {
1623    type Item = Result<RestarterEvent, fidl::Error>;
1624
1625    fn poll_next(
1626        mut self: std::pin::Pin<&mut Self>,
1627        cx: &mut std::task::Context<'_>,
1628    ) -> std::task::Poll<Option<Self::Item>> {
1629        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
1630            &mut self.event_receiver,
1631            cx
1632        )?) {
1633            Some(buf) => std::task::Poll::Ready(Some(RestarterEvent::decode(buf))),
1634            None => std::task::Poll::Ready(None),
1635        }
1636    }
1637}
1638
1639#[derive(Debug)]
1640pub enum RestarterEvent {}
1641
1642impl RestarterEvent {
1643    /// Decodes a message buffer as a [`RestarterEvent`].
1644    fn decode(
1645        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1646    ) -> Result<RestarterEvent, fidl::Error> {
1647        let (bytes, _handles) = buf.split_mut();
1648        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1649        debug_assert_eq!(tx_header.tx_id, 0);
1650        match tx_header.ordinal {
1651            _ => Err(fidl::Error::UnknownOrdinal {
1652                ordinal: tx_header.ordinal,
1653                protocol_name: <RestarterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1654            }),
1655        }
1656    }
1657}
1658
1659/// A Stream of incoming requests for fuchsia.session/Restarter.
1660pub struct RestarterRequestStream {
1661    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1662    is_terminated: bool,
1663}
1664
1665impl std::marker::Unpin for RestarterRequestStream {}
1666
1667impl futures::stream::FusedStream for RestarterRequestStream {
1668    fn is_terminated(&self) -> bool {
1669        self.is_terminated
1670    }
1671}
1672
1673impl fidl::endpoints::RequestStream for RestarterRequestStream {
1674    type Protocol = RestarterMarker;
1675    type ControlHandle = RestarterControlHandle;
1676
1677    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1678        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1679    }
1680
1681    fn control_handle(&self) -> Self::ControlHandle {
1682        RestarterControlHandle { inner: self.inner.clone() }
1683    }
1684
1685    fn into_inner(
1686        self,
1687    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1688    {
1689        (self.inner, self.is_terminated)
1690    }
1691
1692    fn from_inner(
1693        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1694        is_terminated: bool,
1695    ) -> Self {
1696        Self { inner, is_terminated }
1697    }
1698}
1699
1700impl futures::Stream for RestarterRequestStream {
1701    type Item = Result<RestarterRequest, fidl::Error>;
1702
1703    fn poll_next(
1704        mut self: std::pin::Pin<&mut Self>,
1705        cx: &mut std::task::Context<'_>,
1706    ) -> std::task::Poll<Option<Self::Item>> {
1707        let this = &mut *self;
1708        if this.inner.check_shutdown(cx) {
1709            this.is_terminated = true;
1710            return std::task::Poll::Ready(None);
1711        }
1712        if this.is_terminated {
1713            panic!("polled RestarterRequestStream after completion");
1714        }
1715        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1716            |bytes, handles| {
1717                match this.inner.channel().read_etc(cx, bytes, handles) {
1718                    std::task::Poll::Ready(Ok(())) => {}
1719                    std::task::Poll::Pending => return std::task::Poll::Pending,
1720                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1721                        this.is_terminated = true;
1722                        return std::task::Poll::Ready(None);
1723                    }
1724                    std::task::Poll::Ready(Err(e)) => {
1725                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1726                            e.into(),
1727                        ))));
1728                    }
1729                }
1730
1731                // A message has been received from the channel
1732                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1733
1734                std::task::Poll::Ready(Some(match header.ordinal {
1735                    0x50cd09e53189e5ae => {
1736                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1737                        let mut req = fidl::new_empty!(
1738                            fidl::encoding::EmptyPayload,
1739                            fidl::encoding::DefaultFuchsiaResourceDialect
1740                        );
1741                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
1742                        let control_handle = RestarterControlHandle { inner: this.inner.clone() };
1743                        Ok(RestarterRequest::Restart {
1744                            responder: RestarterRestartResponder {
1745                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1746                                tx_id: header.tx_id,
1747                            },
1748                        })
1749                    }
1750                    _ => Err(fidl::Error::UnknownOrdinal {
1751                        ordinal: header.ordinal,
1752                        protocol_name:
1753                            <RestarterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1754                    }),
1755                }))
1756            },
1757        )
1758    }
1759}
1760
1761/// A protocol used to restart the currently running session.
1762#[derive(Debug)]
1763pub enum RestarterRequest {
1764    /// Restarts the session.
1765    ///
1766    /// * error `RestartError.NOT_RUNNING` if there is no
1767    ///   currently running session to restart.
1768    /// * error `RestartError.DESTROY_COMPONENT_FAILED` if an existing session component
1769    ///   could not be destroyed. The existing session remains running at this point.
1770    /// * error `RestartError.CREATE_COMPONENT_FAILED` if the session component
1771    ///   could not be started. No session will be running at this point.
1772    Restart { responder: RestarterRestartResponder },
1773}
1774
1775impl RestarterRequest {
1776    #[allow(irrefutable_let_patterns)]
1777    pub fn into_restart(self) -> Option<(RestarterRestartResponder)> {
1778        if let RestarterRequest::Restart { responder } = self { Some((responder)) } else { None }
1779    }
1780
1781    /// Name of the method defined in FIDL
1782    pub fn method_name(&self) -> &'static str {
1783        match *self {
1784            RestarterRequest::Restart { .. } => "restart",
1785        }
1786    }
1787}
1788
1789#[derive(Debug, Clone)]
1790pub struct RestarterControlHandle {
1791    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1792}
1793
1794impl fidl::endpoints::ControlHandle for RestarterControlHandle {
1795    fn shutdown(&self) {
1796        self.inner.shutdown()
1797    }
1798
1799    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1800        self.inner.shutdown_with_epitaph(status)
1801    }
1802
1803    fn is_closed(&self) -> bool {
1804        self.inner.channel().is_closed()
1805    }
1806    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1807        self.inner.channel().on_closed()
1808    }
1809
1810    #[cfg(target_os = "fuchsia")]
1811    fn signal_peer(
1812        &self,
1813        clear_mask: zx::Signals,
1814        set_mask: zx::Signals,
1815    ) -> Result<(), zx_status::Status> {
1816        use fidl::Peered;
1817        self.inner.channel().signal_peer(clear_mask, set_mask)
1818    }
1819}
1820
1821impl RestarterControlHandle {}
1822
1823#[must_use = "FIDL methods require a response to be sent"]
1824#[derive(Debug)]
1825pub struct RestarterRestartResponder {
1826    control_handle: std::mem::ManuallyDrop<RestarterControlHandle>,
1827    tx_id: u32,
1828}
1829
1830/// Set the the channel to be shutdown (see [`RestarterControlHandle::shutdown`])
1831/// if the responder is dropped without sending a response, so that the client
1832/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1833impl std::ops::Drop for RestarterRestartResponder {
1834    fn drop(&mut self) {
1835        self.control_handle.shutdown();
1836        // Safety: drops once, never accessed again
1837        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1838    }
1839}
1840
1841impl fidl::endpoints::Responder for RestarterRestartResponder {
1842    type ControlHandle = RestarterControlHandle;
1843
1844    fn control_handle(&self) -> &RestarterControlHandle {
1845        &self.control_handle
1846    }
1847
1848    fn drop_without_shutdown(mut self) {
1849        // Safety: drops once, never accessed again due to mem::forget
1850        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1851        // Prevent Drop from running (which would shut down the channel)
1852        std::mem::forget(self);
1853    }
1854}
1855
1856impl RestarterRestartResponder {
1857    /// Sends a response to the FIDL transaction.
1858    ///
1859    /// Sets the channel to shutdown if an error occurs.
1860    pub fn send(self, mut result: Result<(), RestartError>) -> Result<(), fidl::Error> {
1861        let _result = self.send_raw(result);
1862        if _result.is_err() {
1863            self.control_handle.shutdown();
1864        }
1865        self.drop_without_shutdown();
1866        _result
1867    }
1868
1869    /// Similar to "send" but does not shutdown the channel if an error occurs.
1870    pub fn send_no_shutdown_on_err(
1871        self,
1872        mut result: Result<(), RestartError>,
1873    ) -> Result<(), fidl::Error> {
1874        let _result = self.send_raw(result);
1875        self.drop_without_shutdown();
1876        _result
1877    }
1878
1879    fn send_raw(&self, mut result: Result<(), RestartError>) -> Result<(), fidl::Error> {
1880        self.control_handle.inner.send::<fidl::encoding::ResultType<
1881            fidl::encoding::EmptyStruct,
1882            RestartError,
1883        >>(
1884            result,
1885            self.tx_id,
1886            0x50cd09e53189e5ae,
1887            fidl::encoding::DynamicFlags::empty(),
1888        )
1889    }
1890}
1891
1892mod internal {
1893    use super::*;
1894}