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::NullableHandle {
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
579    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
580        self.inner.shutdown_with_epitaph(status)
581    }
582
583    fn is_closed(&self) -> bool {
584        self.inner.channel().is_closed()
585    }
586    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
587        self.inner.channel().on_closed()
588    }
589
590    #[cfg(target_os = "fuchsia")]
591    fn signal_peer(
592        &self,
593        clear_mask: zx::Signals,
594        set_mask: zx::Signals,
595    ) -> Result<(), zx_status::Status> {
596        use fidl::Peered;
597        self.inner.channel().signal_peer(clear_mask, set_mask)
598    }
599}
600
601impl ClientConfiguratorControlHandle {}
602
603#[must_use = "FIDL methods require a response to be sent"]
604#[derive(Debug)]
605pub struct ClientConfiguratorGetResponder {
606    control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
607    tx_id: u32,
608}
609
610/// Set the the channel to be shutdown (see [`ClientConfiguratorControlHandle::shutdown`])
611/// if the responder is dropped without sending a response, so that the client
612/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
613impl std::ops::Drop for ClientConfiguratorGetResponder {
614    fn drop(&mut self) {
615        self.control_handle.shutdown();
616        // Safety: drops once, never accessed again
617        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
618    }
619}
620
621impl fidl::endpoints::Responder for ClientConfiguratorGetResponder {
622    type ControlHandle = ClientConfiguratorControlHandle;
623
624    fn control_handle(&self) -> &ClientConfiguratorControlHandle {
625        &self.control_handle
626    }
627
628    fn drop_without_shutdown(mut self) {
629        // Safety: drops once, never accessed again due to mem::forget
630        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
631        // Prevent Drop from running (which would shut down the channel)
632        std::mem::forget(self);
633    }
634}
635
636impl ClientConfiguratorGetResponder {
637    /// Sends a response to the FIDL transaction.
638    ///
639    /// Sets the channel to shutdown if an error occurs.
640    pub fn send(self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
641        let _result = self.send_raw(config);
642        if _result.is_err() {
643            self.control_handle.shutdown();
644        }
645        self.drop_without_shutdown();
646        _result
647    }
648
649    /// Similar to "send" but does not shutdown the channel if an error occurs.
650    pub fn send_no_shutdown_on_err(
651        self,
652        mut config: Option<&ClientConfig>,
653    ) -> Result<(), fidl::Error> {
654        let _result = self.send_raw(config);
655        self.drop_without_shutdown();
656        _result
657    }
658
659    fn send_raw(&self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
660        self.control_handle.inner.send::<ClientConfiguratorGetResponse>(
661            (config,),
662            self.tx_id,
663            0x1e37597b4d247d7b,
664            fidl::encoding::DynamicFlags::empty(),
665        )
666    }
667}
668
669#[must_use = "FIDL methods require a response to be sent"]
670#[derive(Debug)]
671pub struct ClientConfiguratorSetResponder {
672    control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
673    tx_id: u32,
674}
675
676/// Set the the channel to be shutdown (see [`ClientConfiguratorControlHandle::shutdown`])
677/// if the responder is dropped without sending a response, so that the client
678/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
679impl std::ops::Drop for ClientConfiguratorSetResponder {
680    fn drop(&mut self) {
681        self.control_handle.shutdown();
682        // Safety: drops once, never accessed again
683        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
684    }
685}
686
687impl fidl::endpoints::Responder for ClientConfiguratorSetResponder {
688    type ControlHandle = ClientConfiguratorControlHandle;
689
690    fn control_handle(&self) -> &ClientConfiguratorControlHandle {
691        &self.control_handle
692    }
693
694    fn drop_without_shutdown(mut self) {
695        // Safety: drops once, never accessed again due to mem::forget
696        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
697        // Prevent Drop from running (which would shut down the channel)
698        std::mem::forget(self);
699    }
700}
701
702impl ClientConfiguratorSetResponder {
703    /// Sends a response to the FIDL transaction.
704    ///
705    /// Sets the channel to shutdown if an error occurs.
706    pub fn send(self) -> Result<(), fidl::Error> {
707        let _result = self.send_raw();
708        if _result.is_err() {
709            self.control_handle.shutdown();
710        }
711        self.drop_without_shutdown();
712        _result
713    }
714
715    /// Similar to "send" but does not shutdown the channel if an error occurs.
716    pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
717        let _result = self.send_raw();
718        self.drop_without_shutdown();
719        _result
720    }
721
722    fn send_raw(&self) -> Result<(), fidl::Error> {
723        self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
724            (),
725            self.tx_id,
726            0x2204fb91b32f6435,
727            fidl::encoding::DynamicFlags::empty(),
728        )
729    }
730}
731
732#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
733pub struct RequesterMarker;
734
735impl fidl::endpoints::ProtocolMarker for RequesterMarker {
736    type Proxy = RequesterProxy;
737    type RequestStream = RequesterRequestStream;
738    #[cfg(target_os = "fuchsia")]
739    type SynchronousProxy = RequesterSynchronousProxy;
740
741    const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.Requester";
742}
743impl fidl::endpoints::DiscoverableProtocolMarker for RequesterMarker {}
744pub type RequesterRequestResult = Result<(), ModeRequestError>;
745
746pub trait RequesterProxyInterface: Send + Sync {
747    type RequestResponseFut: std::future::Future<Output = Result<RequesterRequestResult, fidl::Error>>
748        + Send;
749    fn r#request(&self, mode: SystemMode, set: bool) -> Self::RequestResponseFut;
750}
751#[derive(Debug)]
752#[cfg(target_os = "fuchsia")]
753pub struct RequesterSynchronousProxy {
754    client: fidl::client::sync::Client,
755}
756
757#[cfg(target_os = "fuchsia")]
758impl fidl::endpoints::SynchronousProxy for RequesterSynchronousProxy {
759    type Proxy = RequesterProxy;
760    type Protocol = RequesterMarker;
761
762    fn from_channel(inner: fidl::Channel) -> Self {
763        Self::new(inner)
764    }
765
766    fn into_channel(self) -> fidl::Channel {
767        self.client.into_channel()
768    }
769
770    fn as_channel(&self) -> &fidl::Channel {
771        self.client.as_channel()
772    }
773}
774
775#[cfg(target_os = "fuchsia")]
776impl RequesterSynchronousProxy {
777    pub fn new(channel: fidl::Channel) -> Self {
778        let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
779        Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
780    }
781
782    pub fn into_channel(self) -> fidl::Channel {
783        self.client.into_channel()
784    }
785
786    /// Waits until an event arrives and returns it. It is safe for other
787    /// threads to make concurrent requests while waiting for an event.
788    pub fn wait_for_event(
789        &self,
790        deadline: zx::MonotonicInstant,
791    ) -> Result<RequesterEvent, fidl::Error> {
792        RequesterEvent::decode(self.client.wait_for_event(deadline)?)
793    }
794
795    /// Requests to set or clear a system power mode.
796    ///
797    /// The call returns immediately after the request has been received,
798    /// validated, and accepted. Actual system changes to be applied as a result
799    /// of this request will occur after the call has returned. Therefore, any
800    /// errors that occur while updating clients according to the new system
801    /// power mode are not propagated back to the caller. Instead, client
802    /// updates are applied on a "best effort" basis.
803    ///
804    /// An error returned by this method means the request itself is not valid
805    /// and was rejected. Details of the specific rejection reason are reflected
806    /// by the error value. In the event of an error, the channel will remain
807    /// open.
808    ///
809    /// A client can use this method to set or clear system power mode variants
810    /// independently. For example:
811    ///
812    ///   // battery is below the "low" threshold
813    ///   Request(LOW_BATTERY, true);
814    ///
815    ///   // device is now plugged into the wall
816    ///   Request(ON_AC_POWER, true);
817    ///
818    ///   // battery is now above the "low" threshold
819    ///   Request(LOW_BATTERY, false);
820    ///
821    /// + `mode` is the `SystemMode` to request to be set or cleared
822    /// + `set` should be true to request to set `mode`, or false to clear it
823    /// * error a [`ModeRequestError`] value indicating why the request was
824    /// rejected.
825    pub fn r#request(
826        &self,
827        mut mode: SystemMode,
828        mut set: bool,
829        ___deadline: zx::MonotonicInstant,
830    ) -> Result<RequesterRequestResult, fidl::Error> {
831        let _response = self.client.send_query::<
832            RequesterRequestRequest,
833            fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
834        >(
835            (mode, set,),
836            0x5603afcd4421f425,
837            fidl::encoding::DynamicFlags::empty(),
838            ___deadline,
839        )?;
840        Ok(_response.map(|x| x))
841    }
842}
843
844#[cfg(target_os = "fuchsia")]
845impl From<RequesterSynchronousProxy> for zx::NullableHandle {
846    fn from(value: RequesterSynchronousProxy) -> Self {
847        value.into_channel().into()
848    }
849}
850
851#[cfg(target_os = "fuchsia")]
852impl From<fidl::Channel> for RequesterSynchronousProxy {
853    fn from(value: fidl::Channel) -> Self {
854        Self::new(value)
855    }
856}
857
858#[cfg(target_os = "fuchsia")]
859impl fidl::endpoints::FromClient for RequesterSynchronousProxy {
860    type Protocol = RequesterMarker;
861
862    fn from_client(value: fidl::endpoints::ClientEnd<RequesterMarker>) -> Self {
863        Self::new(value.into_channel())
864    }
865}
866
867#[derive(Debug, Clone)]
868pub struct RequesterProxy {
869    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
870}
871
872impl fidl::endpoints::Proxy for RequesterProxy {
873    type Protocol = RequesterMarker;
874
875    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
876        Self::new(inner)
877    }
878
879    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
880        self.client.into_channel().map_err(|client| Self { client })
881    }
882
883    fn as_channel(&self) -> &::fidl::AsyncChannel {
884        self.client.as_channel()
885    }
886}
887
888impl RequesterProxy {
889    /// Create a new Proxy for fuchsia.power.systemmode/Requester.
890    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
891        let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
892        Self { client: fidl::client::Client::new(channel, protocol_name) }
893    }
894
895    /// Get a Stream of events from the remote end of the protocol.
896    ///
897    /// # Panics
898    ///
899    /// Panics if the event stream was already taken.
900    pub fn take_event_stream(&self) -> RequesterEventStream {
901        RequesterEventStream { event_receiver: self.client.take_event_receiver() }
902    }
903
904    /// Requests to set or clear a system power mode.
905    ///
906    /// The call returns immediately after the request has been received,
907    /// validated, and accepted. Actual system changes to be applied as a result
908    /// of this request will occur after the call has returned. Therefore, any
909    /// errors that occur while updating clients according to the new system
910    /// power mode are not propagated back to the caller. Instead, client
911    /// updates are applied on a "best effort" basis.
912    ///
913    /// An error returned by this method means the request itself is not valid
914    /// and was rejected. Details of the specific rejection reason are reflected
915    /// by the error value. In the event of an error, the channel will remain
916    /// open.
917    ///
918    /// A client can use this method to set or clear system power mode variants
919    /// independently. For example:
920    ///
921    ///   // battery is below the "low" threshold
922    ///   Request(LOW_BATTERY, true);
923    ///
924    ///   // device is now plugged into the wall
925    ///   Request(ON_AC_POWER, true);
926    ///
927    ///   // battery is now above the "low" threshold
928    ///   Request(LOW_BATTERY, false);
929    ///
930    /// + `mode` is the `SystemMode` to request to be set or cleared
931    /// + `set` should be true to request to set `mode`, or false to clear it
932    /// * error a [`ModeRequestError`] value indicating why the request was
933    /// rejected.
934    pub fn r#request(
935        &self,
936        mut mode: SystemMode,
937        mut set: bool,
938    ) -> fidl::client::QueryResponseFut<
939        RequesterRequestResult,
940        fidl::encoding::DefaultFuchsiaResourceDialect,
941    > {
942        RequesterProxyInterface::r#request(self, mode, set)
943    }
944}
945
946impl RequesterProxyInterface for RequesterProxy {
947    type RequestResponseFut = fidl::client::QueryResponseFut<
948        RequesterRequestResult,
949        fidl::encoding::DefaultFuchsiaResourceDialect,
950    >;
951    fn r#request(&self, mut mode: SystemMode, mut set: bool) -> Self::RequestResponseFut {
952        fn _decode(
953            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
954        ) -> Result<RequesterRequestResult, fidl::Error> {
955            let _response = fidl::client::decode_transaction_body::<
956                fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
957                fidl::encoding::DefaultFuchsiaResourceDialect,
958                0x5603afcd4421f425,
959            >(_buf?)?;
960            Ok(_response.map(|x| x))
961        }
962        self.client.send_query_and_decode::<RequesterRequestRequest, RequesterRequestResult>(
963            (mode, set),
964            0x5603afcd4421f425,
965            fidl::encoding::DynamicFlags::empty(),
966            _decode,
967        )
968    }
969}
970
971pub struct RequesterEventStream {
972    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
973}
974
975impl std::marker::Unpin for RequesterEventStream {}
976
977impl futures::stream::FusedStream for RequesterEventStream {
978    fn is_terminated(&self) -> bool {
979        self.event_receiver.is_terminated()
980    }
981}
982
983impl futures::Stream for RequesterEventStream {
984    type Item = Result<RequesterEvent, fidl::Error>;
985
986    fn poll_next(
987        mut self: std::pin::Pin<&mut Self>,
988        cx: &mut std::task::Context<'_>,
989    ) -> std::task::Poll<Option<Self::Item>> {
990        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
991            &mut self.event_receiver,
992            cx
993        )?) {
994            Some(buf) => std::task::Poll::Ready(Some(RequesterEvent::decode(buf))),
995            None => std::task::Poll::Ready(None),
996        }
997    }
998}
999
1000#[derive(Debug)]
1001pub enum RequesterEvent {}
1002
1003impl RequesterEvent {
1004    /// Decodes a message buffer as a [`RequesterEvent`].
1005    fn decode(
1006        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
1007    ) -> Result<RequesterEvent, fidl::Error> {
1008        let (bytes, _handles) = buf.split_mut();
1009        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1010        debug_assert_eq!(tx_header.tx_id, 0);
1011        match tx_header.ordinal {
1012            _ => Err(fidl::Error::UnknownOrdinal {
1013                ordinal: tx_header.ordinal,
1014                protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1015            }),
1016        }
1017    }
1018}
1019
1020/// A Stream of incoming requests for fuchsia.power.systemmode/Requester.
1021pub struct RequesterRequestStream {
1022    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1023    is_terminated: bool,
1024}
1025
1026impl std::marker::Unpin for RequesterRequestStream {}
1027
1028impl futures::stream::FusedStream for RequesterRequestStream {
1029    fn is_terminated(&self) -> bool {
1030        self.is_terminated
1031    }
1032}
1033
1034impl fidl::endpoints::RequestStream for RequesterRequestStream {
1035    type Protocol = RequesterMarker;
1036    type ControlHandle = RequesterControlHandle;
1037
1038    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
1039        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
1040    }
1041
1042    fn control_handle(&self) -> Self::ControlHandle {
1043        RequesterControlHandle { inner: self.inner.clone() }
1044    }
1045
1046    fn into_inner(
1047        self,
1048    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
1049    {
1050        (self.inner, self.is_terminated)
1051    }
1052
1053    fn from_inner(
1054        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1055        is_terminated: bool,
1056    ) -> Self {
1057        Self { inner, is_terminated }
1058    }
1059}
1060
1061impl futures::Stream for RequesterRequestStream {
1062    type Item = Result<RequesterRequest, fidl::Error>;
1063
1064    fn poll_next(
1065        mut self: std::pin::Pin<&mut Self>,
1066        cx: &mut std::task::Context<'_>,
1067    ) -> std::task::Poll<Option<Self::Item>> {
1068        let this = &mut *self;
1069        if this.inner.check_shutdown(cx) {
1070            this.is_terminated = true;
1071            return std::task::Poll::Ready(None);
1072        }
1073        if this.is_terminated {
1074            panic!("polled RequesterRequestStream after completion");
1075        }
1076        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
1077            |bytes, handles| {
1078                match this.inner.channel().read_etc(cx, bytes, handles) {
1079                    std::task::Poll::Ready(Ok(())) => {}
1080                    std::task::Poll::Pending => return std::task::Poll::Pending,
1081                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
1082                        this.is_terminated = true;
1083                        return std::task::Poll::Ready(None);
1084                    }
1085                    std::task::Poll::Ready(Err(e)) => {
1086                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
1087                            e.into(),
1088                        ))));
1089                    }
1090                }
1091
1092                // A message has been received from the channel
1093                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
1094
1095                std::task::Poll::Ready(Some(match header.ordinal {
1096                    0x5603afcd4421f425 => {
1097                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
1098                        let mut req = fidl::new_empty!(
1099                            RequesterRequestRequest,
1100                            fidl::encoding::DefaultFuchsiaResourceDialect
1101                        );
1102                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RequesterRequestRequest>(&header, _body_bytes, handles, &mut req)?;
1103                        let control_handle = RequesterControlHandle { inner: this.inner.clone() };
1104                        Ok(RequesterRequest::Request {
1105                            mode: req.mode,
1106                            set: req.set,
1107
1108                            responder: RequesterRequestResponder {
1109                                control_handle: std::mem::ManuallyDrop::new(control_handle),
1110                                tx_id: header.tx_id,
1111                            },
1112                        })
1113                    }
1114                    _ => Err(fidl::Error::UnknownOrdinal {
1115                        ordinal: header.ordinal,
1116                        protocol_name:
1117                            <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
1118                    }),
1119                }))
1120            },
1121        )
1122    }
1123}
1124
1125/// A protocol that can be used to request a change to the currently active
1126/// system power modes.
1127#[derive(Debug)]
1128pub enum RequesterRequest {
1129    /// Requests to set or clear a system power mode.
1130    ///
1131    /// The call returns immediately after the request has been received,
1132    /// validated, and accepted. Actual system changes to be applied as a result
1133    /// of this request will occur after the call has returned. Therefore, any
1134    /// errors that occur while updating clients according to the new system
1135    /// power mode are not propagated back to the caller. Instead, client
1136    /// updates are applied on a "best effort" basis.
1137    ///
1138    /// An error returned by this method means the request itself is not valid
1139    /// and was rejected. Details of the specific rejection reason are reflected
1140    /// by the error value. In the event of an error, the channel will remain
1141    /// open.
1142    ///
1143    /// A client can use this method to set or clear system power mode variants
1144    /// independently. For example:
1145    ///
1146    ///   // battery is below the "low" threshold
1147    ///   Request(LOW_BATTERY, true);
1148    ///
1149    ///   // device is now plugged into the wall
1150    ///   Request(ON_AC_POWER, true);
1151    ///
1152    ///   // battery is now above the "low" threshold
1153    ///   Request(LOW_BATTERY, false);
1154    ///
1155    /// + `mode` is the `SystemMode` to request to be set or cleared
1156    /// + `set` should be true to request to set `mode`, or false to clear it
1157    /// * error a [`ModeRequestError`] value indicating why the request was
1158    /// rejected.
1159    Request { mode: SystemMode, set: bool, responder: RequesterRequestResponder },
1160}
1161
1162impl RequesterRequest {
1163    #[allow(irrefutable_let_patterns)]
1164    pub fn into_request(self) -> Option<(SystemMode, bool, RequesterRequestResponder)> {
1165        if let RequesterRequest::Request { mode, set, responder } = self {
1166            Some((mode, set, responder))
1167        } else {
1168            None
1169        }
1170    }
1171
1172    /// Name of the method defined in FIDL
1173    pub fn method_name(&self) -> &'static str {
1174        match *self {
1175            RequesterRequest::Request { .. } => "request",
1176        }
1177    }
1178}
1179
1180#[derive(Debug, Clone)]
1181pub struct RequesterControlHandle {
1182    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
1183}
1184
1185impl fidl::endpoints::ControlHandle for RequesterControlHandle {
1186    fn shutdown(&self) {
1187        self.inner.shutdown()
1188    }
1189
1190    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
1191        self.inner.shutdown_with_epitaph(status)
1192    }
1193
1194    fn is_closed(&self) -> bool {
1195        self.inner.channel().is_closed()
1196    }
1197    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
1198        self.inner.channel().on_closed()
1199    }
1200
1201    #[cfg(target_os = "fuchsia")]
1202    fn signal_peer(
1203        &self,
1204        clear_mask: zx::Signals,
1205        set_mask: zx::Signals,
1206    ) -> Result<(), zx_status::Status> {
1207        use fidl::Peered;
1208        self.inner.channel().signal_peer(clear_mask, set_mask)
1209    }
1210}
1211
1212impl RequesterControlHandle {}
1213
1214#[must_use = "FIDL methods require a response to be sent"]
1215#[derive(Debug)]
1216pub struct RequesterRequestResponder {
1217    control_handle: std::mem::ManuallyDrop<RequesterControlHandle>,
1218    tx_id: u32,
1219}
1220
1221/// Set the the channel to be shutdown (see [`RequesterControlHandle::shutdown`])
1222/// if the responder is dropped without sending a response, so that the client
1223/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
1224impl std::ops::Drop for RequesterRequestResponder {
1225    fn drop(&mut self) {
1226        self.control_handle.shutdown();
1227        // Safety: drops once, never accessed again
1228        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1229    }
1230}
1231
1232impl fidl::endpoints::Responder for RequesterRequestResponder {
1233    type ControlHandle = RequesterControlHandle;
1234
1235    fn control_handle(&self) -> &RequesterControlHandle {
1236        &self.control_handle
1237    }
1238
1239    fn drop_without_shutdown(mut self) {
1240        // Safety: drops once, never accessed again due to mem::forget
1241        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1242        // Prevent Drop from running (which would shut down the channel)
1243        std::mem::forget(self);
1244    }
1245}
1246
1247impl RequesterRequestResponder {
1248    /// Sends a response to the FIDL transaction.
1249    ///
1250    /// Sets the channel to shutdown if an error occurs.
1251    pub fn send(self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1252        let _result = self.send_raw(result);
1253        if _result.is_err() {
1254            self.control_handle.shutdown();
1255        }
1256        self.drop_without_shutdown();
1257        _result
1258    }
1259
1260    /// Similar to "send" but does not shutdown the channel if an error occurs.
1261    pub fn send_no_shutdown_on_err(
1262        self,
1263        mut result: Result<(), ModeRequestError>,
1264    ) -> Result<(), fidl::Error> {
1265        let _result = self.send_raw(result);
1266        self.drop_without_shutdown();
1267        _result
1268    }
1269
1270    fn send_raw(&self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
1271        self.control_handle.inner.send::<fidl::encoding::ResultType<
1272            fidl::encoding::EmptyStruct,
1273            ModeRequestError,
1274        >>(
1275            result,
1276            self.tx_id,
1277            0x5603afcd4421f425,
1278            fidl::encoding::DynamicFlags::empty(),
1279        )
1280    }
1281}
1282
1283mod internal {
1284    use super::*;
1285}