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