Skip to main content

fidl_fuchsia_power_systemmode/
fidl_fuchsia_power_systemmode.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_power_systemmode__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct ClientConfiguratorMarker;
16
17impl fidl::endpoints::ProtocolMarker for ClientConfiguratorMarker {
18    type Proxy = ClientConfiguratorProxy;
19    type RequestStream = ClientConfiguratorRequestStream;
20    #[cfg(target_os = "fuchsia")]
21    type SynchronousProxy = ClientConfiguratorSynchronousProxy;
22
23    const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.ClientConfigurator";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for ClientConfiguratorMarker {}
26
27pub trait ClientConfiguratorProxyInterface: Send + Sync {
28    type GetResponseFut: std::future::Future<Output = Result<Option<Box<ClientConfig>>, fidl::Error>>
29        + Send;
30    fn r#get(
31        &self,
32        client_type: fidl_fuchsia_power_clientlevel::ClientType,
33    ) -> Self::GetResponseFut;
34    type SetResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
35    fn r#set(
36        &self,
37        client_type: fidl_fuchsia_power_clientlevel::ClientType,
38        config: &ClientConfig,
39    ) -> Self::SetResponseFut;
40}
41#[derive(Debug)]
42#[cfg(target_os = "fuchsia")]
43pub struct ClientConfiguratorSynchronousProxy {
44    client: fidl::client::sync::Client,
45}
46
47#[cfg(target_os = "fuchsia")]
48impl fidl::endpoints::SynchronousProxy for ClientConfiguratorSynchronousProxy {
49    type Proxy = ClientConfiguratorProxy;
50    type Protocol = ClientConfiguratorMarker;
51
52    fn from_channel(inner: fidl::Channel) -> Self {
53        Self::new(inner)
54    }
55
56    fn into_channel(self) -> fidl::Channel {
57        self.client.into_channel()
58    }
59
60    fn as_channel(&self) -> &fidl::Channel {
61        self.client.as_channel()
62    }
63}
64
65#[cfg(target_os = "fuchsia")]
66impl ClientConfiguratorSynchronousProxy {
67    pub fn new(channel: fidl::Channel) -> Self {
68        Self { client: fidl::client::sync::Client::new(channel) }
69    }
70
71    pub fn into_channel(self) -> fidl::Channel {
72        self.client.into_channel()
73    }
74
75    /// Waits until an event arrives and returns it. It is safe for other
76    /// threads to make concurrent requests while waiting for an event.
77    pub fn wait_for_event(
78        &self,
79        deadline: zx::MonotonicInstant,
80    ) -> Result<ClientConfiguratorEvent, fidl::Error> {
81        ClientConfiguratorEvent::decode(
82            self.client.wait_for_event::<ClientConfiguratorMarker>(deadline)?,
83        )
84    }
85
86    /// Gets the power configuration for the given [`ClientType`].
87    ///
88    /// If there is no power configuration for `client_type` then the returned
89    /// value will be absent.
90    ///
91    /// + `client_type` specifies which [`ClientType`] [`ClientConfig`] to get
92    /// - `config` is the returned client-specific configuration, or an absent
93    /// value if `client_type` does not have an existing configuration
94    pub fn r#get(
95        &self,
96        mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
97        ___deadline: zx::MonotonicInstant,
98    ) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
99        let _response = self.client.send_query::<
100            ClientConfiguratorGetRequest,
101            ClientConfiguratorGetResponse,
102            ClientConfiguratorMarker,
103        >(
104            (client_type,),
105            0x1e37597b4d247d7b,
106            fidl::encoding::DynamicFlags::empty(),
107            ___deadline,
108        )?;
109        Ok(_response.config)
110    }
111
112    /// Sets the power configuration for the given [`ClientType`].
113    ///
114    /// This method should be used in tandem with [`GetConfig`] in order to
115    /// update the existing power configuration for a given [`ClientType`]
116    /// without fully overwriting it.
117    ///
118    /// When the power configuration for a given [`ClientType`] is changed, the
119    /// Power Manager will reevaluate current power level of that [`ClientType`]
120    /// according to the new configuration. This reevaluation may result in a
121    /// new power level being sent to the connected client.
122    ///
123    /// The call returns immediately after the new config has been received and
124    /// validated. Actual system changes to be applied as a result of changing a
125    /// client's configuration will occur after the call has returned.
126    /// Therefore, any errors that occur while updating clients according to the
127    /// new system power mode are not propagated back to the caller. Instead,
128    /// client updates are applied on a "best effort" basis.
129    ///
130    /// If the provided `config` is not valid, then no changes will be applied
131    /// and the channel will be closed. Validation will fail if a given
132    /// `SystemMode` is repeated across multiple `mode_match` entries contained
133    /// by the `ClientConfig`.
134    ///
135    /// + `client_type` specifies which [`ClientType`]'s [`ClientConfig`] to set
136    /// + `config` is the [`ClientConfig`] that will be set for [`client_type`]
137    pub fn r#set(
138        &self,
139        mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
140        mut config: &ClientConfig,
141        ___deadline: zx::MonotonicInstant,
142    ) -> Result<(), fidl::Error> {
143        let _response = self.client.send_query::<
144            ClientConfiguratorSetRequest,
145            fidl::encoding::EmptyPayload,
146            ClientConfiguratorMarker,
147        >(
148            (client_type, config,),
149            0x2204fb91b32f6435,
150            fidl::encoding::DynamicFlags::empty(),
151            ___deadline,
152        )?;
153        Ok(_response)
154    }
155}
156
157#[cfg(target_os = "fuchsia")]
158impl From<ClientConfiguratorSynchronousProxy> for zx::NullableHandle {
159    fn from(value: ClientConfiguratorSynchronousProxy) -> Self {
160        value.into_channel().into()
161    }
162}
163
164#[cfg(target_os = "fuchsia")]
165impl From<fidl::Channel> for ClientConfiguratorSynchronousProxy {
166    fn from(value: fidl::Channel) -> Self {
167        Self::new(value)
168    }
169}
170
171#[cfg(target_os = "fuchsia")]
172impl fidl::endpoints::FromClient for ClientConfiguratorSynchronousProxy {
173    type Protocol = ClientConfiguratorMarker;
174
175    fn from_client(value: fidl::endpoints::ClientEnd<ClientConfiguratorMarker>) -> Self {
176        Self::new(value.into_channel())
177    }
178}
179
180#[derive(Debug, Clone)]
181pub struct ClientConfiguratorProxy {
182    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
183}
184
185impl fidl::endpoints::Proxy for ClientConfiguratorProxy {
186    type Protocol = ClientConfiguratorMarker;
187
188    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
189        Self::new(inner)
190    }
191
192    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
193        self.client.into_channel().map_err(|client| Self { client })
194    }
195
196    fn as_channel(&self) -> &::fidl::AsyncChannel {
197        self.client.as_channel()
198    }
199}
200
201impl ClientConfiguratorProxy {
202    /// Create a new Proxy for fuchsia.power.systemmode/ClientConfigurator.
203    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
204        let protocol_name =
205            <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
206        Self { client: fidl::client::Client::new(channel, protocol_name) }
207    }
208
209    /// Get a Stream of events from the remote end of the protocol.
210    ///
211    /// # Panics
212    ///
213    /// Panics if the event stream was already taken.
214    pub fn take_event_stream(&self) -> ClientConfiguratorEventStream {
215        ClientConfiguratorEventStream { event_receiver: self.client.take_event_receiver() }
216    }
217
218    /// Gets the power configuration for the given [`ClientType`].
219    ///
220    /// If there is no power configuration for `client_type` then the returned
221    /// value will be absent.
222    ///
223    /// + `client_type` specifies which [`ClientType`] [`ClientConfig`] to get
224    /// - `config` is the returned client-specific configuration, or an absent
225    /// value if `client_type` does not have an existing configuration
226    pub fn r#get(
227        &self,
228        mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
229    ) -> fidl::client::QueryResponseFut<
230        Option<Box<ClientConfig>>,
231        fidl::encoding::DefaultFuchsiaResourceDialect,
232    > {
233        ClientConfiguratorProxyInterface::r#get(self, client_type)
234    }
235
236    /// Sets the power configuration for the given [`ClientType`].
237    ///
238    /// This method should be used in tandem with [`GetConfig`] in order to
239    /// update the existing power configuration for a given [`ClientType`]
240    /// without fully overwriting it.
241    ///
242    /// When the power configuration for a given [`ClientType`] is changed, the
243    /// Power Manager will reevaluate current power level of that [`ClientType`]
244    /// according to the new configuration. This reevaluation may result in a
245    /// new power level being sent to the connected client.
246    ///
247    /// The call returns immediately after the new config has been received and
248    /// validated. Actual system changes to be applied as a result of changing a
249    /// client's configuration will occur after the call has returned.
250    /// Therefore, any errors that occur while updating clients according to the
251    /// new system power mode are not propagated back to the caller. Instead,
252    /// client updates are applied on a "best effort" basis.
253    ///
254    /// If the provided `config` is not valid, then no changes will be applied
255    /// and the channel will be closed. Validation will fail if a given
256    /// `SystemMode` is repeated across multiple `mode_match` entries contained
257    /// by the `ClientConfig`.
258    ///
259    /// + `client_type` specifies which [`ClientType`]'s [`ClientConfig`] to set
260    /// + `config` is the [`ClientConfig`] that will be set for [`client_type`]
261    pub fn r#set(
262        &self,
263        mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
264        mut config: &ClientConfig,
265    ) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
266        ClientConfiguratorProxyInterface::r#set(self, client_type, config)
267    }
268}
269
270impl ClientConfiguratorProxyInterface for ClientConfiguratorProxy {
271    type GetResponseFut = fidl::client::QueryResponseFut<
272        Option<Box<ClientConfig>>,
273        fidl::encoding::DefaultFuchsiaResourceDialect,
274    >;
275    fn r#get(
276        &self,
277        mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
278    ) -> Self::GetResponseFut {
279        fn _decode(
280            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
281        ) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
282            let _response = fidl::client::decode_transaction_body::<
283                ClientConfiguratorGetResponse,
284                fidl::encoding::DefaultFuchsiaResourceDialect,
285                0x1e37597b4d247d7b,
286            >(_buf?)?;
287            Ok(_response.config)
288        }
289        self.client
290            .send_query_and_decode::<ClientConfiguratorGetRequest, Option<Box<ClientConfig>>>(
291                (client_type,),
292                0x1e37597b4d247d7b,
293                fidl::encoding::DynamicFlags::empty(),
294                _decode,
295            )
296    }
297
298    type SetResponseFut =
299        fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
300    fn r#set(
301        &self,
302        mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
303        mut config: &ClientConfig,
304    ) -> Self::SetResponseFut {
305        fn _decode(
306            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
307        ) -> Result<(), fidl::Error> {
308            let _response = fidl::client::decode_transaction_body::<
309                fidl::encoding::EmptyPayload,
310                fidl::encoding::DefaultFuchsiaResourceDialect,
311                0x2204fb91b32f6435,
312            >(_buf?)?;
313            Ok(_response)
314        }
315        self.client.send_query_and_decode::<ClientConfiguratorSetRequest, ()>(
316            (client_type, config),
317            0x2204fb91b32f6435,
318            fidl::encoding::DynamicFlags::empty(),
319            _decode,
320        )
321    }
322}
323
324pub struct ClientConfiguratorEventStream {
325    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
326}
327
328impl std::marker::Unpin for ClientConfiguratorEventStream {}
329
330impl futures::stream::FusedStream for ClientConfiguratorEventStream {
331    fn is_terminated(&self) -> bool {
332        self.event_receiver.is_terminated()
333    }
334}
335
336impl futures::Stream for ClientConfiguratorEventStream {
337    type Item = Result<ClientConfiguratorEvent, fidl::Error>;
338
339    fn poll_next(
340        mut self: std::pin::Pin<&mut Self>,
341        cx: &mut std::task::Context<'_>,
342    ) -> std::task::Poll<Option<Self::Item>> {
343        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
344            &mut self.event_receiver,
345            cx
346        )?) {
347            Some(buf) => std::task::Poll::Ready(Some(ClientConfiguratorEvent::decode(buf))),
348            None => std::task::Poll::Ready(None),
349        }
350    }
351}
352
353#[derive(Debug)]
354pub enum ClientConfiguratorEvent {}
355
356impl ClientConfiguratorEvent {
357    /// Decodes a message buffer as a [`ClientConfiguratorEvent`].
358    fn decode(
359        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
360    ) -> Result<ClientConfiguratorEvent, fidl::Error> {
361        let (bytes, _handles) = buf.split_mut();
362        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
363        debug_assert_eq!(tx_header.tx_id, 0);
364        match tx_header.ordinal {
365            _ => Err(fidl::Error::UnknownOrdinal {
366                ordinal: tx_header.ordinal,
367                protocol_name:
368                    <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
369            }),
370        }
371    }
372}
373
374/// A Stream of incoming requests for fuchsia.power.systemmode/ClientConfigurator.
375pub struct ClientConfiguratorRequestStream {
376    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
377    is_terminated: bool,
378}
379
380impl std::marker::Unpin for ClientConfiguratorRequestStream {}
381
382impl futures::stream::FusedStream for ClientConfiguratorRequestStream {
383    fn is_terminated(&self) -> bool {
384        self.is_terminated
385    }
386}
387
388impl fidl::endpoints::RequestStream for ClientConfiguratorRequestStream {
389    type Protocol = ClientConfiguratorMarker;
390    type ControlHandle = ClientConfiguratorControlHandle;
391
392    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
393        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
394    }
395
396    fn control_handle(&self) -> Self::ControlHandle {
397        ClientConfiguratorControlHandle { inner: self.inner.clone() }
398    }
399
400    fn into_inner(
401        self,
402    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
403    {
404        (self.inner, self.is_terminated)
405    }
406
407    fn from_inner(
408        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
409        is_terminated: bool,
410    ) -> Self {
411        Self { inner, is_terminated }
412    }
413}
414
415impl futures::Stream for ClientConfiguratorRequestStream {
416    type Item = Result<ClientConfiguratorRequest, fidl::Error>;
417
418    fn poll_next(
419        mut self: std::pin::Pin<&mut Self>,
420        cx: &mut std::task::Context<'_>,
421    ) -> std::task::Poll<Option<Self::Item>> {
422        let this = &mut *self;
423        if this.inner.check_shutdown(cx) {
424            this.is_terminated = true;
425            return std::task::Poll::Ready(None);
426        }
427        if this.is_terminated {
428            panic!("polled ClientConfiguratorRequestStream after completion");
429        }
430        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
431            |bytes, handles| {
432                match this.inner.channel().read_etc(cx, bytes, handles) {
433                    std::task::Poll::Ready(Ok(())) => {}
434                    std::task::Poll::Pending => return std::task::Poll::Pending,
435                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
436                        this.is_terminated = true;
437                        return std::task::Poll::Ready(None);
438                    }
439                    std::task::Poll::Ready(Err(e)) => {
440                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
441                            e.into(),
442                        ))));
443                    }
444                }
445
446                // A message has been received from the channel
447                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
448
449                std::task::Poll::Ready(Some(match header.ordinal {
450                0x1e37597b4d247d7b => {
451                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
452                    let mut req = fidl::new_empty!(ClientConfiguratorGetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
453                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorGetRequest>(&header, _body_bytes, handles, &mut req)?;
454                    let control_handle = ClientConfiguratorControlHandle {
455                        inner: this.inner.clone(),
456                    };
457                    Ok(ClientConfiguratorRequest::Get {client_type: req.client_type,
458
459                        responder: ClientConfiguratorGetResponder {
460                            control_handle: std::mem::ManuallyDrop::new(control_handle),
461                            tx_id: header.tx_id,
462                        },
463                    })
464                }
465                0x2204fb91b32f6435 => {
466                    header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
467                    let mut req = fidl::new_empty!(ClientConfiguratorSetRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
468                    fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ClientConfiguratorSetRequest>(&header, _body_bytes, handles, &mut req)?;
469                    let control_handle = ClientConfiguratorControlHandle {
470                        inner: this.inner.clone(),
471                    };
472                    Ok(ClientConfiguratorRequest::Set {client_type: req.client_type,
473config: req.config,
474
475                        responder: ClientConfiguratorSetResponder {
476                            control_handle: std::mem::ManuallyDrop::new(control_handle),
477                            tx_id: header.tx_id,
478                        },
479                    })
480                }
481                _ => Err(fidl::Error::UnknownOrdinal {
482                    ordinal: header.ordinal,
483                    protocol_name: <ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
484                }),
485            }))
486            },
487        )
488    }
489}
490
491/// A protocol that can be used to update the power configuration for a given
492/// [`ClientType`].
493#[derive(Debug)]
494pub enum ClientConfiguratorRequest {
495    /// Gets the power configuration for the given [`ClientType`].
496    ///
497    /// If there is no power configuration for `client_type` then the returned
498    /// value will be absent.
499    ///
500    /// + `client_type` specifies which [`ClientType`] [`ClientConfig`] to get
501    /// - `config` is the returned client-specific configuration, or an absent
502    /// value if `client_type` does not have an existing configuration
503    Get {
504        client_type: fidl_fuchsia_power_clientlevel::ClientType,
505        responder: ClientConfiguratorGetResponder,
506    },
507    /// Sets the power configuration for the given [`ClientType`].
508    ///
509    /// This method should be used in tandem with [`GetConfig`] in order to
510    /// update the existing power configuration for a given [`ClientType`]
511    /// without fully overwriting it.
512    ///
513    /// When the power configuration for a given [`ClientType`] is changed, the
514    /// Power Manager will reevaluate current power level of that [`ClientType`]
515    /// according to the new configuration. This reevaluation may result in a
516    /// new power level being sent to the connected client.
517    ///
518    /// The call returns immediately after the new config has been received and
519    /// validated. Actual system changes to be applied as a result of changing a
520    /// client's configuration will occur after the call has returned.
521    /// Therefore, any errors that occur while updating clients according to the
522    /// new system power mode are not propagated back to the caller. Instead,
523    /// client updates are applied on a "best effort" basis.
524    ///
525    /// If the provided `config` is not valid, then no changes will be applied
526    /// and the channel will be closed. Validation will fail if a given
527    /// `SystemMode` is repeated across multiple `mode_match` entries contained
528    /// by the `ClientConfig`.
529    ///
530    /// + `client_type` specifies which [`ClientType`]'s [`ClientConfig`] to set
531    /// + `config` is the [`ClientConfig`] that will be set for [`client_type`]
532    Set {
533        client_type: fidl_fuchsia_power_clientlevel::ClientType,
534        config: ClientConfig,
535        responder: ClientConfiguratorSetResponder,
536    },
537}
538
539impl ClientConfiguratorRequest {
540    #[allow(irrefutable_let_patterns)]
541    pub fn into_get(
542        self,
543    ) -> Option<(fidl_fuchsia_power_clientlevel::ClientType, ClientConfiguratorGetResponder)> {
544        if let ClientConfiguratorRequest::Get { client_type, responder } = self {
545            Some((client_type, responder))
546        } else {
547            None
548        }
549    }
550
551    #[allow(irrefutable_let_patterns)]
552    pub fn into_set(
553        self,
554    ) -> Option<(
555        fidl_fuchsia_power_clientlevel::ClientType,
556        ClientConfig,
557        ClientConfiguratorSetResponder,
558    )> {
559        if let ClientConfiguratorRequest::Set { client_type, config, responder } = self {
560            Some((client_type, config, responder))
561        } else {
562            None
563        }
564    }
565
566    /// Name of the method defined in FIDL
567    pub fn method_name(&self) -> &'static str {
568        match *self {
569            ClientConfiguratorRequest::Get { .. } => "get",
570            ClientConfiguratorRequest::Set { .. } => "set",
571        }
572    }
573}
574
575#[derive(Debug, Clone)]
576pub struct ClientConfiguratorControlHandle {
577    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
578}
579
580impl fidl::endpoints::ControlHandle for ClientConfiguratorControlHandle {
581    fn shutdown(&self) {
582        self.inner.shutdown()
583    }
584
585    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
586        self.inner.shutdown_with_epitaph(status)
587    }
588
589    fn is_closed(&self) -> bool {
590        self.inner.channel().is_closed()
591    }
592    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
593        self.inner.channel().on_closed()
594    }
595
596    #[cfg(target_os = "fuchsia")]
597    fn signal_peer(
598        &self,
599        clear_mask: zx::Signals,
600        set_mask: zx::Signals,
601    ) -> Result<(), zx_status::Status> {
602        use fidl::Peered;
603        self.inner.channel().signal_peer(clear_mask, set_mask)
604    }
605}
606
607impl ClientConfiguratorControlHandle {}
608
609#[must_use = "FIDL methods require a response to be sent"]
610#[derive(Debug)]
611pub struct ClientConfiguratorGetResponder {
612    control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
613    tx_id: u32,
614}
615
616/// Set the the channel to be shutdown (see [`ClientConfiguratorControlHandle::shutdown`])
617/// if the responder is dropped without sending a response, so that the client
618/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
619impl std::ops::Drop for ClientConfiguratorGetResponder {
620    fn drop(&mut self) {
621        self.control_handle.shutdown();
622        // Safety: drops once, never accessed again
623        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
624    }
625}
626
627impl fidl::endpoints::Responder for ClientConfiguratorGetResponder {
628    type ControlHandle = ClientConfiguratorControlHandle;
629
630    fn control_handle(&self) -> &ClientConfiguratorControlHandle {
631        &self.control_handle
632    }
633
634    fn drop_without_shutdown(mut self) {
635        // Safety: drops once, never accessed again due to mem::forget
636        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
637        // Prevent Drop from running (which would shut down the channel)
638        std::mem::forget(self);
639    }
640}
641
642impl ClientConfiguratorGetResponder {
643    /// Sends a response to the FIDL transaction.
644    ///
645    /// Sets the channel to shutdown if an error occurs.
646    pub fn send(self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
647        let _result = self.send_raw(config);
648        if _result.is_err() {
649            self.control_handle.shutdown();
650        }
651        self.drop_without_shutdown();
652        _result
653    }
654
655    /// Similar to "send" but does not shutdown the channel if an error occurs.
656    pub fn send_no_shutdown_on_err(
657        self,
658        mut config: Option<&ClientConfig>,
659    ) -> Result<(), fidl::Error> {
660        let _result = self.send_raw(config);
661        self.drop_without_shutdown();
662        _result
663    }
664
665    fn send_raw(&self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
666        self.control_handle.inner.send::<ClientConfiguratorGetResponse>(
667            (config,),
668            self.tx_id,
669            0x1e37597b4d247d7b,
670            fidl::encoding::DynamicFlags::empty(),
671        )
672    }
673}
674
675#[must_use = "FIDL methods require a response to be sent"]
676#[derive(Debug)]
677pub struct ClientConfiguratorSetResponder {
678    control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
679    tx_id: u32,
680}
681
682/// Set the the channel to be shutdown (see [`ClientConfiguratorControlHandle::shutdown`])
683/// if the responder is dropped without sending a response, so that the client
684/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
685impl std::ops::Drop for ClientConfiguratorSetResponder {
686    fn drop(&mut self) {
687        self.control_handle.shutdown();
688        // Safety: drops once, never accessed again
689        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
690    }
691}
692
693impl fidl::endpoints::Responder for ClientConfiguratorSetResponder {
694    type ControlHandle = ClientConfiguratorControlHandle;
695
696    fn control_handle(&self) -> &ClientConfiguratorControlHandle {
697        &self.control_handle
698    }
699
700    fn drop_without_shutdown(mut self) {
701        // Safety: drops once, never accessed again due to mem::forget
702        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
703        // Prevent Drop from running (which would shut down the channel)
704        std::mem::forget(self);
705    }
706}
707
708impl ClientConfiguratorSetResponder {
709    /// Sends a response to the FIDL transaction.
710    ///
711    /// Sets the channel to shutdown if an error occurs.
712    pub fn send(self) -> Result<(), fidl::Error> {
713        let _result = self.send_raw();
714        if _result.is_err() {
715            self.control_handle.shutdown();
716        }
717        self.drop_without_shutdown();
718        _result
719    }
720
721    /// Similar to "send" but does not shutdown the channel if an error occurs.
722    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
723        let _result = self.send_raw();
724        self.drop_without_shutdown();
725        _result
726    }
727
728    fn send_raw(&self) -> Result<(), fidl::Error> {
729        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
730            (),
731            self.tx_id,
732            0x2204fb91b32f6435,
733            fidl::encoding::DynamicFlags::empty(),
734        )
735    }
736}
737
738#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
739pub struct RequesterMarker;
740
741impl fidl::endpoints::ProtocolMarker for RequesterMarker {
742    type Proxy = RequesterProxy;
743    type RequestStream = RequesterRequestStream;
744    #[cfg(target_os = "fuchsia")]
745    type SynchronousProxy = RequesterSynchronousProxy;
746
747    const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.Requester";
748}
749impl fidl::endpoints::DiscoverableProtocolMarker for RequesterMarker {}
750pub type RequesterRequestResult = Result<(), ModeRequestError>;
751
752pub trait RequesterProxyInterface: Send + Sync {
753    type RequestResponseFut: std::future::Future<Output = Result<RequesterRequestResult, fidl::Error>>
754        + Send;
755    fn r#request(&self, mode: SystemMode, set: bool) -> Self::RequestResponseFut;
756}
757#[derive(Debug)]
758#[cfg(target_os = "fuchsia")]
759pub struct RequesterSynchronousProxy {
760    client: fidl::client::sync::Client,
761}
762
763#[cfg(target_os = "fuchsia")]
764impl fidl::endpoints::SynchronousProxy for RequesterSynchronousProxy {
765    type Proxy = RequesterProxy;
766    type Protocol = RequesterMarker;
767
768    fn from_channel(inner: fidl::Channel) -> Self {
769        Self::new(inner)
770    }
771
772    fn into_channel(self) -> fidl::Channel {
773        self.client.into_channel()
774    }
775
776    fn as_channel(&self) -> &fidl::Channel {
777        self.client.as_channel()
778    }
779}
780
781#[cfg(target_os = "fuchsia")]
782impl RequesterSynchronousProxy {
783    pub fn new(channel: fidl::Channel) -> Self {
784        Self { client: fidl::client::sync::Client::new(channel) }
785    }
786
787    pub fn into_channel(self) -> fidl::Channel {
788        self.client.into_channel()
789    }
790
791    /// Waits until an event arrives and returns it. It is safe for other
792    /// threads to make concurrent requests while waiting for an event.
793    pub fn wait_for_event(
794        &self,
795        deadline: zx::MonotonicInstant,
796    ) -> Result<RequesterEvent, fidl::Error> {
797        RequesterEvent::decode(self.client.wait_for_event::<RequesterMarker>(deadline)?)
798    }
799
800    /// Requests to set or clear a system power mode.
801    ///
802    /// The call returns immediately after the request has been received,
803    /// validated, and accepted. Actual system changes to be applied as a result
804    /// of this request will occur after the call has returned. Therefore, any
805    /// errors that occur while updating clients according to the new system
806    /// power mode are not propagated back to the caller. Instead, client
807    /// updates are applied on a "best effort" basis.
808    ///
809    /// An error returned by this method means the request itself is not valid
810    /// and was rejected. Details of the specific rejection reason are reflected
811    /// by the error value. In the event of an error, the channel will remain
812    /// open.
813    ///
814    /// A client can use this method to set or clear system power mode variants
815    /// independently. For example:
816    ///
817    ///   // battery is below the "low" threshold
818    ///   Request(LOW_BATTERY, true);
819    ///
820    ///   // device is now plugged into the wall
821    ///   Request(ON_AC_POWER, true);
822    ///
823    ///   // battery is now above the "low" threshold
824    ///   Request(LOW_BATTERY, false);
825    ///
826    /// + `mode` is the `SystemMode` to request to be set or cleared
827    /// + `set` should be true to request to set `mode`, or false to clear it
828    /// * error a [`ModeRequestError`] value indicating why the request was
829    /// rejected.
830    pub fn r#request(
831        &self,
832        mut mode: SystemMode,
833        mut set: bool,
834        ___deadline: zx::MonotonicInstant,
835    ) -> Result<RequesterRequestResult, fidl::Error> {
836        let _response = self.client.send_query::<
837            RequesterRequestRequest,
838            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
839            RequesterMarker,
840        >(
841            (mode, set,),
842            0x5603afcd4421f425,
843            fidl::encoding::DynamicFlags::empty(),
844            ___deadline,
845        )?;
846        Ok(_response.map(|x| x))
847    }
848}
849
850#[cfg(target_os = "fuchsia")]
851impl From<RequesterSynchronousProxy> for zx::NullableHandle {
852    fn from(value: RequesterSynchronousProxy) -> Self {
853        value.into_channel().into()
854    }
855}
856
857#[cfg(target_os = "fuchsia")]
858impl From<fidl::Channel> for RequesterSynchronousProxy {
859    fn from(value: fidl::Channel) -> Self {
860        Self::new(value)
861    }
862}
863
864#[cfg(target_os = "fuchsia")]
865impl fidl::endpoints::FromClient for RequesterSynchronousProxy {
866    type Protocol = RequesterMarker;
867
868    fn from_client(value: fidl::endpoints::ClientEnd<RequesterMarker>) -> Self {
869        Self::new(value.into_channel())
870    }
871}
872
873#[derive(Debug, Clone)]
874pub struct RequesterProxy {
875    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
876}
877
878impl fidl::endpoints::Proxy for RequesterProxy {
879    type Protocol = RequesterMarker;
880
881    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
882        Self::new(inner)
883    }
884
885    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
886        self.client.into_channel().map_err(|client| Self { client })
887    }
888
889    fn as_channel(&self) -> &::fidl::AsyncChannel {
890        self.client.as_channel()
891    }
892}
893
894impl RequesterProxy {
895    /// Create a new Proxy for fuchsia.power.systemmode/Requester.
896    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
897        let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
898        Self { client: fidl::client::Client::new(channel, protocol_name) }
899    }
900
901    /// Get a Stream of events from the remote end of the protocol.
902    ///
903    /// # Panics
904    ///
905    /// Panics if the event stream was already taken.
906    pub fn take_event_stream(&self) -> RequesterEventStream {
907        RequesterEventStream { event_receiver: self.client.take_event_receiver() }
908    }
909
910    /// Requests to set or clear a system power mode.
911    ///
912    /// The call returns immediately after the request has been received,
913    /// validated, and accepted. Actual system changes to be applied as a result
914    /// of this request will occur after the call has returned. Therefore, any
915    /// errors that occur while updating clients according to the new system
916    /// power mode are not propagated back to the caller. Instead, client
917    /// updates are applied on a "best effort" basis.
918    ///
919    /// An error returned by this method means the request itself is not valid
920    /// and was rejected. Details of the specific rejection reason are reflected
921    /// by the error value. In the event of an error, the channel will remain
922    /// open.
923    ///
924    /// A client can use this method to set or clear system power mode variants
925    /// independently. For example:
926    ///
927    ///   // battery is below the "low" threshold
928    ///   Request(LOW_BATTERY, true);
929    ///
930    ///   // device is now plugged into the wall
931    ///   Request(ON_AC_POWER, true);
932    ///
933    ///   // battery is now above the "low" threshold
934    ///   Request(LOW_BATTERY, false);
935    ///
936    /// + `mode` is the `SystemMode` to request to be set or cleared
937    /// + `set` should be true to request to set `mode`, or false to clear it
938    /// * error a [`ModeRequestError`] value indicating why the request was
939    /// rejected.
940    pub fn r#request(
941        &self,
942        mut mode: SystemMode,
943        mut set: bool,
944    ) -> fidl::client::QueryResponseFut<
945        RequesterRequestResult,
946        fidl::encoding::DefaultFuchsiaResourceDialect,
947    > {
948        RequesterProxyInterface::r#request(self, mode, set)
949    }
950}
951
952impl RequesterProxyInterface for RequesterProxy {
953    type RequestResponseFut = fidl::client::QueryResponseFut<
954        RequesterRequestResult,
955        fidl::encoding::DefaultFuchsiaResourceDialect,
956    >;
957    fn r#request(&self, mut mode: SystemMode, mut set: bool) -> Self::RequestResponseFut {
958        fn _decode(
959            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
960        ) -> Result<RequesterRequestResult, fidl::Error> {
961            let _response = fidl::client::decode_transaction_body::<
962                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
963                fidl::encoding::DefaultFuchsiaResourceDialect,
964                0x5603afcd4421f425,
965            >(_buf?)?;
966            Ok(_response.map(|x| x))
967        }
968        self.client.send_query_and_decode::<RequesterRequestRequest, RequesterRequestResult>(
969            (mode, set),
970            0x5603afcd4421f425,
971            fidl::encoding::DynamicFlags::empty(),
972            _decode,
973        )
974    }
975}
976
977pub struct RequesterEventStream {
978    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
979}
980
981impl std::marker::Unpin for RequesterEventStream {}
982
983impl futures::stream::FusedStream for RequesterEventStream {
984    fn is_terminated(&self) -> bool {
985        self.event_receiver.is_terminated()
986    }
987}
988
989impl futures::Stream for RequesterEventStream {
990    type Item = Result<RequesterEvent, fidl::Error>;
991
992    fn poll_next(
993        mut self: std::pin::Pin<&mut Self>,
994        cx: &mut std::task::Context<'_>,
995    ) -> std::task::Poll<Option<Self::Item>> {
996        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
997            &mut self.event_receiver,
998            cx
999        )?) {
1000            Some(buf) => std::task::Poll::Ready(Some(RequesterEvent::decode(buf))),
1001            None => std::task::Poll::Ready(None),
1002        }
1003    }
1004}
1005
1006#[derive(Debug)]
1007pub enum RequesterEvent {}
1008
1009impl RequesterEvent {
1010    /// Decodes a message buffer as a [`RequesterEvent`].
1011    fn decode(
1012        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1013    ) -> Result<RequesterEvent, fidl::Error> {
1014        let (bytes, _handles) = buf.split_mut();
1015        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1016        debug_assert_eq!(tx_header.tx_id, 0);
1017        match tx_header.ordinal {
1018            _ => Err(fidl::Error::UnknownOrdinal {
1019                ordinal: tx_header.ordinal,
1020                protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1021            }),
1022        }
1023    }
1024}
1025
1026/// A Stream of incoming requests for fuchsia.power.systemmode/Requester.
1027pub struct RequesterRequestStream {
1028    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1029    is_terminated: bool,
1030}
1031
1032impl std::marker::Unpin for RequesterRequestStream {}
1033
1034impl futures::stream::FusedStream for RequesterRequestStream {
1035    fn is_terminated(&self) -> bool {
1036        self.is_terminated
1037    }
1038}
1039
1040impl fidl::endpoints::RequestStream for RequesterRequestStream {
1041    type Protocol = RequesterMarker;
1042    type ControlHandle = RequesterControlHandle;
1043
1044    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1045        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1046    }
1047
1048    fn control_handle(&self) -> Self::ControlHandle {
1049        RequesterControlHandle { inner: self.inner.clone() }
1050    }
1051
1052    fn into_inner(
1053        self,
1054    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1055    {
1056        (self.inner, self.is_terminated)
1057    }
1058
1059    fn from_inner(
1060        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1061        is_terminated: bool,
1062    ) -> Self {
1063        Self { inner, is_terminated }
1064    }
1065}
1066
1067impl futures::Stream for RequesterRequestStream {
1068    type Item = Result<RequesterRequest, fidl::Error>;
1069
1070    fn poll_next(
1071        mut self: std::pin::Pin<&mut Self>,
1072        cx: &mut std::task::Context<'_>,
1073    ) -> std::task::Poll<Option<Self::Item>> {
1074        let this = &mut *self;
1075        if this.inner.check_shutdown(cx) {
1076            this.is_terminated = true;
1077            return std::task::Poll::Ready(None);
1078        }
1079        if this.is_terminated {
1080            panic!("polled RequesterRequestStream after completion");
1081        }
1082        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1083            |bytes, handles| {
1084                match this.inner.channel().read_etc(cx, bytes, handles) {
1085                    std::task::Poll::Ready(Ok(())) => {}
1086                    std::task::Poll::Pending => return std::task::Poll::Pending,
1087                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1088                        this.is_terminated = true;
1089                        return std::task::Poll::Ready(None);
1090                    }
1091                    std::task::Poll::Ready(Err(e)) => {
1092                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1093                            e.into(),
1094                        ))));
1095                    }
1096                }
1097
1098                // A message has been received from the channel
1099                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1100
1101                std::task::Poll::Ready(Some(match header.ordinal {
1102                    0x5603afcd4421f425 => {
1103                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1104                        let mut req = fidl::new_empty!(
1105                            RequesterRequestRequest,
1106                            fidl::encoding::DefaultFuchsiaResourceDialect
1107                        );
1108                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RequesterRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1109                        let control_handle = RequesterControlHandle { inner: this.inner.clone() };
1110                        Ok(RequesterRequest::Request {
1111                            mode: req.mode,
1112                            set: req.set,
1113
1114                            responder: RequesterRequestResponder {
1115                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1116                                tx_id: header.tx_id,
1117                            },
1118                        })
1119                    }
1120                    _ => Err(fidl::Error::UnknownOrdinal {
1121                        ordinal: header.ordinal,
1122                        protocol_name:
1123                            <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1124                    }),
1125                }))
1126            },
1127        )
1128    }
1129}
1130
1131/// A protocol that can be used to request a change to the currently active
1132/// system power modes.
1133#[derive(Debug)]
1134pub enum RequesterRequest {
1135    /// Requests to set or clear a system power mode.
1136    ///
1137    /// The call returns immediately after the request has been received,
1138    /// validated, and accepted. Actual system changes to be applied as a result
1139    /// of this request will occur after the call has returned. Therefore, any
1140    /// errors that occur while updating clients according to the new system
1141    /// power mode are not propagated back to the caller. Instead, client
1142    /// updates are applied on a "best effort" basis.
1143    ///
1144    /// An error returned by this method means the request itself is not valid
1145    /// and was rejected. Details of the specific rejection reason are reflected
1146    /// by the error value. In the event of an error, the channel will remain
1147    /// open.
1148    ///
1149    /// A client can use this method to set or clear system power mode variants
1150    /// independently. For example:
1151    ///
1152    ///   // battery is below the "low" threshold
1153    ///   Request(LOW_BATTERY, true);
1154    ///
1155    ///   // device is now plugged into the wall
1156    ///   Request(ON_AC_POWER, true);
1157    ///
1158    ///   // battery is now above the "low" threshold
1159    ///   Request(LOW_BATTERY, false);
1160    ///
1161    /// + `mode` is the `SystemMode` to request to be set or cleared
1162    /// + `set` should be true to request to set `mode`, or false to clear it
1163    /// * error a [`ModeRequestError`] value indicating why the request was
1164    /// rejected.
1165    Request { mode: SystemMode, set: bool, responder: RequesterRequestResponder },
1166}
1167
1168impl RequesterRequest {
1169    #[allow(irrefutable_let_patterns)]
1170    pub fn into_request(self) -> Option<(SystemMode, bool, RequesterRequestResponder)> {
1171        if let RequesterRequest::Request { mode, set, responder } = self {
1172            Some((mode, set, responder))
1173        } else {
1174            None
1175        }
1176    }
1177
1178    /// Name of the method defined in FIDL
1179    pub fn method_name(&self) -> &'static str {
1180        match *self {
1181            RequesterRequest::Request { .. } => "request",
1182        }
1183    }
1184}
1185
1186#[derive(Debug, Clone)]
1187pub struct RequesterControlHandle {
1188    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1189}
1190
1191impl fidl::endpoints::ControlHandle for RequesterControlHandle {
1192    fn shutdown(&self) {
1193        self.inner.shutdown()
1194    }
1195
1196    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1197        self.inner.shutdown_with_epitaph(status)
1198    }
1199
1200    fn is_closed(&self) -> bool {
1201        self.inner.channel().is_closed()
1202    }
1203    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1204        self.inner.channel().on_closed()
1205    }
1206
1207    #[cfg(target_os = "fuchsia")]
1208    fn signal_peer(
1209        &self,
1210        clear_mask: zx::Signals,
1211        set_mask: zx::Signals,
1212    ) -> Result<(), zx_status::Status> {
1213        use fidl::Peered;
1214        self.inner.channel().signal_peer(clear_mask, set_mask)
1215    }
1216}
1217
1218impl RequesterControlHandle {}
1219
1220#[must_use = "FIDL methods require a response to be sent"]
1221#[derive(Debug)]
1222pub struct RequesterRequestResponder {
1223    control_handle: std::mem::ManuallyDrop<RequesterControlHandle>,
1224    tx_id: u32,
1225}
1226
1227/// Set the the channel to be shutdown (see [`RequesterControlHandle::shutdown`])
1228/// if the responder is dropped without sending a response, so that the client
1229/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1230impl std::ops::Drop for RequesterRequestResponder {
1231    fn drop(&mut self) {
1232        self.control_handle.shutdown();
1233        // Safety: drops once, never accessed again
1234        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1235    }
1236}
1237
1238impl fidl::endpoints::Responder for RequesterRequestResponder {
1239    type ControlHandle = RequesterControlHandle;
1240
1241    fn control_handle(&self) -> &RequesterControlHandle {
1242        &self.control_handle
1243    }
1244
1245    fn drop_without_shutdown(mut self) {
1246        // Safety: drops once, never accessed again due to mem::forget
1247        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1248        // Prevent Drop from running (which would shut down the channel)
1249        std::mem::forget(self);
1250    }
1251}
1252
1253impl RequesterRequestResponder {
1254    /// Sends a response to the FIDL transaction.
1255    ///
1256    /// Sets the channel to shutdown if an error occurs.
1257    pub fn send(self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1258        let _result = self.send_raw(result);
1259        if _result.is_err() {
1260            self.control_handle.shutdown();
1261        }
1262        self.drop_without_shutdown();
1263        _result
1264    }
1265
1266    /// Similar to "send" but does not shutdown the channel if an error occurs.
1267    pub fn send_no_shutdown_on_err(
1268        self,
1269        mut result: Result<(), ModeRequestError>,
1270    ) -> Result<(), fidl::Error> {
1271        let _result = self.send_raw(result);
1272        self.drop_without_shutdown();
1273        _result
1274    }
1275
1276    fn send_raw(&self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1277        self.control_handle.inner.send::<fidl::encoding::ResultType<
1278            fidl::encoding::EmptyStruct,
1279            ModeRequestError,
1280        >>(
1281            result,
1282            self.tx_id,
1283            0x5603afcd4421f425,
1284            fidl::encoding::DynamicFlags::empty(),
1285        )
1286    }
1287}
1288
1289mod internal {
1290    use super::*;
1291}