Skip to main content

fidl_fuchsia_ui_display_color/
fidl_fuchsia_ui_display_color.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_ui_display_color__common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, PartialEq)]
15pub struct ConverterSetValuesRequest {
16    pub properties: ConversionProperties,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for ConverterSetValuesRequest {}
20
21#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
22pub struct ConverterMarker;
23
24impl fidl::endpoints::ProtocolMarker for ConverterMarker {
25    type Proxy = ConverterProxy;
26    type RequestStream = ConverterRequestStream;
27    #[cfg(target_os = "fuchsia")]
28    type SynchronousProxy = ConverterSynchronousProxy;
29
30    const DEBUG_NAME: &'static str = "fuchsia.ui.display.color.Converter";
31}
32impl fidl::endpoints::DiscoverableProtocolMarker for ConverterMarker {}
33
34pub trait ConverterProxyInterface: Send + Sync {
35    type SetValuesResponseFut: std::future::Future<Output = Result<i32, fidl::Error>> + Send;
36    fn r#set_values(&self, properties: &ConversionProperties) -> Self::SetValuesResponseFut;
37    type SetMinimumRgbResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
38    fn r#set_minimum_rgb(&self, minimum_rgb: u8) -> Self::SetMinimumRgbResponseFut;
39}
40#[derive(Debug)]
41#[cfg(target_os = "fuchsia")]
42pub struct ConverterSynchronousProxy {
43    client: fidl::client::sync::Client,
44}
45
46#[cfg(target_os = "fuchsia")]
47impl fidl::endpoints::SynchronousProxy for ConverterSynchronousProxy {
48    type Proxy = ConverterProxy;
49    type Protocol = ConverterMarker;
50
51    fn from_channel(inner: fidl::Channel) -> Self {
52        Self::new(inner)
53    }
54
55    fn into_channel(self) -> fidl::Channel {
56        self.client.into_channel()
57    }
58
59    fn as_channel(&self) -> &fidl::Channel {
60        self.client.as_channel()
61    }
62}
63
64#[cfg(target_os = "fuchsia")]
65impl ConverterSynchronousProxy {
66    pub fn new(channel: fidl::Channel) -> Self {
67        Self { client: fidl::client::sync::Client::new(channel) }
68    }
69
70    pub fn into_channel(self) -> fidl::Channel {
71        self.client.into_channel()
72    }
73
74    /// Waits until an event arrives and returns it. It is safe for other
75    /// threads to make concurrent requests while waiting for an event.
76    pub fn wait_for_event(
77        &self,
78        deadline: zx::MonotonicInstant,
79    ) -> Result<ConverterEvent, fidl::Error> {
80        ConverterEvent::decode(self.client.wait_for_event::<ConverterMarker>(deadline)?)
81    }
82
83    /// Modifies the color of final display output of rendered content. The sole parameter is a
84    /// table of |ConversionProperties|, which contains the parameters required to apply the
85    /// color conversion formula to the display. Please see |ConversionProperties| defined
86    /// above for more information.
87    ///
88    /// All parameters in the properties table must be normal 32-bit floating point values.
89    /// If any of the values do not meet this specification, the new color conversion values
90    /// will not be applied and a value of ZX_ERR_INVALID_ARGS will be returned. Otherwise,
91    /// the return value will be ZX_OK: https://en.wikipedia.org/wiki/Normal_number_%28computing%29.
92    /// Once a value of ZX_OK has been returned to the client, the color conversion values are ready
93    /// to be used in future render calls, including screenshots.
94    ///
95    /// Values in |ConversionProperties| may also be left blank. The default values for each member,
96    /// if left blank, are as follows:
97    ///     coefficients =
98    ///             [1, 0, 0,
99    ///              0, 1, 0,
100    ///              0, 0, 1]  (i.e. the identity matrix)
101    ///     preoffsets = [0,0,0]
102    ///     postoffsets = [0,0,0]
103    /// Thus, ColorConversion can be reset by passing in an empty table to this function.
104    ///
105    /// Hardware that support color conversion generally accept a limited range of coefficient
106    /// values. Coefficients in the range of [-2, 2] inclusive will be accepted by most
107    /// hardware. The hardware driver will clamp values that are outside its acceptable range.
108    ///
109    /// `preoffsets`, `postoffsets`: Clients are encouraged to produce color conversion values that
110    /// do not depend on pre and post offsets since some hardware do not have support for that.
111    /// For cases where pre and post offset values need to be used, the range should be limited to
112    /// (-1, 1).
113    pub fn r#set_values(
114        &self,
115        mut properties: &ConversionProperties,
116        ___deadline: zx::MonotonicInstant,
117    ) -> Result<i32, fidl::Error> {
118        let _response = self
119            .client
120            .send_query::<ConverterSetValuesRequest, ConverterSetValuesResponse, ConverterMarker>(
121                (properties,),
122                0x64131a672b34af8d,
123                fidl::encoding::DynamicFlags::empty(),
124                ___deadline,
125            )?;
126        Ok(_response.res)
127    }
128
129    /// Submits a minimum value that all channels of all pixels rendered to the display
130    /// are clamped to. This can be used to mitigate the apparent effects of backlight
131    /// bleeding on certain devices in low-light environments.
132    ///
133    /// The valid range for a minimum value is [0, 255] (inclusive).  For a new
134    /// minimum value M, each color channel's range will be limited to [M, 255].
135    ///
136    /// Callers should wait for the acknowledgement to return before submitting another
137    /// call to this function. The minimum_rgb clamping can be removed simply by submitting
138    /// a value of 0.
139    ///
140    /// Not all hardware supports this feature. So this function returns |true|
141    /// if successfully applied and |false| if unsupported.
142    pub fn r#set_minimum_rgb(
143        &self,
144        mut minimum_rgb: u8,
145        ___deadline: zx::MonotonicInstant,
146    ) -> Result<bool, fidl::Error> {
147        let _response = self.client.send_query::<
148            ConverterSetMinimumRgbRequest,
149            ConverterSetMinimumRgbResponse,
150            ConverterMarker,
151        >(
152            (minimum_rgb,),
153            0x45dd02bf82f653d1,
154            fidl::encoding::DynamicFlags::empty(),
155            ___deadline,
156        )?;
157        Ok(_response.supported)
158    }
159}
160
161#[cfg(target_os = "fuchsia")]
162impl From<ConverterSynchronousProxy> for zx::NullableHandle {
163    fn from(value: ConverterSynchronousProxy) -> Self {
164        value.into_channel().into()
165    }
166}
167
168#[cfg(target_os = "fuchsia")]
169impl From<fidl::Channel> for ConverterSynchronousProxy {
170    fn from(value: fidl::Channel) -> Self {
171        Self::new(value)
172    }
173}
174
175#[cfg(target_os = "fuchsia")]
176impl fidl::endpoints::FromClient for ConverterSynchronousProxy {
177    type Protocol = ConverterMarker;
178
179    fn from_client(value: fidl::endpoints::ClientEnd<ConverterMarker>) -> Self {
180        Self::new(value.into_channel())
181    }
182}
183
184#[derive(Debug, Clone)]
185pub struct ConverterProxy {
186    client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
187}
188
189impl fidl::endpoints::Proxy for ConverterProxy {
190    type Protocol = ConverterMarker;
191
192    fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
193        Self::new(inner)
194    }
195
196    fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
197        self.client.into_channel().map_err(|client| Self { client })
198    }
199
200    fn as_channel(&self) -> &::fidl::AsyncChannel {
201        self.client.as_channel()
202    }
203}
204
205impl ConverterProxy {
206    /// Create a new Proxy for fuchsia.ui.display.color/Converter.
207    pub fn new(channel: ::fidl::AsyncChannel) -> Self {
208        let protocol_name = <ConverterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
209        Self { client: fidl::client::Client::new(channel, protocol_name) }
210    }
211
212    /// Get a Stream of events from the remote end of the protocol.
213    ///
214    /// # Panics
215    ///
216    /// Panics if the event stream was already taken.
217    pub fn take_event_stream(&self) -> ConverterEventStream {
218        ConverterEventStream { event_receiver: self.client.take_event_receiver() }
219    }
220
221    /// Modifies the color of final display output of rendered content. The sole parameter is a
222    /// table of |ConversionProperties|, which contains the parameters required to apply the
223    /// color conversion formula to the display. Please see |ConversionProperties| defined
224    /// above for more information.
225    ///
226    /// All parameters in the properties table must be normal 32-bit floating point values.
227    /// If any of the values do not meet this specification, the new color conversion values
228    /// will not be applied and a value of ZX_ERR_INVALID_ARGS will be returned. Otherwise,
229    /// the return value will be ZX_OK: https://en.wikipedia.org/wiki/Normal_number_%28computing%29.
230    /// Once a value of ZX_OK has been returned to the client, the color conversion values are ready
231    /// to be used in future render calls, including screenshots.
232    ///
233    /// Values in |ConversionProperties| may also be left blank. The default values for each member,
234    /// if left blank, are as follows:
235    ///     coefficients =
236    ///             [1, 0, 0,
237    ///              0, 1, 0,
238    ///              0, 0, 1]  (i.e. the identity matrix)
239    ///     preoffsets = [0,0,0]
240    ///     postoffsets = [0,0,0]
241    /// Thus, ColorConversion can be reset by passing in an empty table to this function.
242    ///
243    /// Hardware that support color conversion generally accept a limited range of coefficient
244    /// values. Coefficients in the range of [-2, 2] inclusive will be accepted by most
245    /// hardware. The hardware driver will clamp values that are outside its acceptable range.
246    ///
247    /// `preoffsets`, `postoffsets`: Clients are encouraged to produce color conversion values that
248    /// do not depend on pre and post offsets since some hardware do not have support for that.
249    /// For cases where pre and post offset values need to be used, the range should be limited to
250    /// (-1, 1).
251    pub fn r#set_values(
252        &self,
253        mut properties: &ConversionProperties,
254    ) -> fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect> {
255        ConverterProxyInterface::r#set_values(self, properties)
256    }
257
258    /// Submits a minimum value that all channels of all pixels rendered to the display
259    /// are clamped to. This can be used to mitigate the apparent effects of backlight
260    /// bleeding on certain devices in low-light environments.
261    ///
262    /// The valid range for a minimum value is [0, 255] (inclusive).  For a new
263    /// minimum value M, each color channel's range will be limited to [M, 255].
264    ///
265    /// Callers should wait for the acknowledgement to return before submitting another
266    /// call to this function. The minimum_rgb clamping can be removed simply by submitting
267    /// a value of 0.
268    ///
269    /// Not all hardware supports this feature. So this function returns |true|
270    /// if successfully applied and |false| if unsupported.
271    pub fn r#set_minimum_rgb(
272        &self,
273        mut minimum_rgb: u8,
274    ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
275        ConverterProxyInterface::r#set_minimum_rgb(self, minimum_rgb)
276    }
277}
278
279impl ConverterProxyInterface for ConverterProxy {
280    type SetValuesResponseFut =
281        fidl::client::QueryResponseFut<i32, fidl::encoding::DefaultFuchsiaResourceDialect>;
282    fn r#set_values(&self, mut properties: &ConversionProperties) -> Self::SetValuesResponseFut {
283        fn _decode(
284            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
285        ) -> Result<i32, fidl::Error> {
286            let _response = fidl::client::decode_transaction_body::<
287                ConverterSetValuesResponse,
288                fidl::encoding::DefaultFuchsiaResourceDialect,
289                0x64131a672b34af8d,
290            >(_buf?)?;
291            Ok(_response.res)
292        }
293        self.client.send_query_and_decode::<ConverterSetValuesRequest, i32>(
294            (properties,),
295            0x64131a672b34af8d,
296            fidl::encoding::DynamicFlags::empty(),
297            _decode,
298        )
299    }
300
301    type SetMinimumRgbResponseFut =
302        fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
303    fn r#set_minimum_rgb(&self, mut minimum_rgb: u8) -> Self::SetMinimumRgbResponseFut {
304        fn _decode(
305            mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
306        ) -> Result<bool, fidl::Error> {
307            let _response = fidl::client::decode_transaction_body::<
308                ConverterSetMinimumRgbResponse,
309                fidl::encoding::DefaultFuchsiaResourceDialect,
310                0x45dd02bf82f653d1,
311            >(_buf?)?;
312            Ok(_response.supported)
313        }
314        self.client.send_query_and_decode::<ConverterSetMinimumRgbRequest, bool>(
315            (minimum_rgb,),
316            0x45dd02bf82f653d1,
317            fidl::encoding::DynamicFlags::empty(),
318            _decode,
319        )
320    }
321}
322
323pub struct ConverterEventStream {
324    event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
325}
326
327impl std::marker::Unpin for ConverterEventStream {}
328
329impl futures::stream::FusedStream for ConverterEventStream {
330    fn is_terminated(&self) -> bool {
331        self.event_receiver.is_terminated()
332    }
333}
334
335impl futures::Stream for ConverterEventStream {
336    type Item = Result<ConverterEvent, fidl::Error>;
337
338    fn poll_next(
339        mut self: std::pin::Pin<&mut Self>,
340        cx: &mut std::task::Context<'_>,
341    ) -> std::task::Poll<Option<Self::Item>> {
342        match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
343            &mut self.event_receiver,
344            cx
345        )?) {
346            Some(buf) => std::task::Poll::Ready(Some(ConverterEvent::decode(buf))),
347            None => std::task::Poll::Ready(None),
348        }
349    }
350}
351
352#[derive(Debug)]
353pub enum ConverterEvent {}
354
355impl ConverterEvent {
356    /// Decodes a message buffer as a [`ConverterEvent`].
357    fn decode(
358        mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
359    ) -> Result<ConverterEvent, fidl::Error> {
360        let (bytes, _handles) = buf.split_mut();
361        let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
362        debug_assert_eq!(tx_header.tx_id, 0);
363        match tx_header.ordinal {
364            _ => Err(fidl::Error::UnknownOrdinal {
365                ordinal: tx_header.ordinal,
366                protocol_name: <ConverterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
367            }),
368        }
369    }
370}
371
372/// A Stream of incoming requests for fuchsia.ui.display.color/Converter.
373pub struct ConverterRequestStream {
374    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
375    is_terminated: bool,
376}
377
378impl std::marker::Unpin for ConverterRequestStream {}
379
380impl futures::stream::FusedStream for ConverterRequestStream {
381    fn is_terminated(&self) -> bool {
382        self.is_terminated
383    }
384}
385
386impl fidl::endpoints::RequestStream for ConverterRequestStream {
387    type Protocol = ConverterMarker;
388    type ControlHandle = ConverterControlHandle;
389
390    fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
391        Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
392    }
393
394    fn control_handle(&self) -> Self::ControlHandle {
395        ConverterControlHandle { inner: self.inner.clone() }
396    }
397
398    fn into_inner(
399        self,
400    ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
401    {
402        (self.inner, self.is_terminated)
403    }
404
405    fn from_inner(
406        inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
407        is_terminated: bool,
408    ) -> Self {
409        Self { inner, is_terminated }
410    }
411}
412
413impl futures::Stream for ConverterRequestStream {
414    type Item = Result<ConverterRequest, fidl::Error>;
415
416    fn poll_next(
417        mut self: std::pin::Pin<&mut Self>,
418        cx: &mut std::task::Context<'_>,
419    ) -> std::task::Poll<Option<Self::Item>> {
420        let this = &mut *self;
421        if this.inner.check_shutdown(cx) {
422            this.is_terminated = true;
423            return std::task::Poll::Ready(None);
424        }
425        if this.is_terminated {
426            panic!("polled ConverterRequestStream after completion");
427        }
428        fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
429            |bytes, handles| {
430                match this.inner.channel().read_etc(cx, bytes, handles) {
431                    std::task::Poll::Ready(Ok(())) => {}
432                    std::task::Poll::Pending => return std::task::Poll::Pending,
433                    std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
434                        this.is_terminated = true;
435                        return std::task::Poll::Ready(None);
436                    }
437                    std::task::Poll::Ready(Err(e)) => {
438                        return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
439                            e.into(),
440                        ))));
441                    }
442                }
443
444                // A message has been received from the channel
445                let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
446
447                std::task::Poll::Ready(Some(match header.ordinal {
448                    0x64131a672b34af8d => {
449                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
450                        let mut req = fidl::new_empty!(
451                            ConverterSetValuesRequest,
452                            fidl::encoding::DefaultFuchsiaResourceDialect
453                        );
454                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConverterSetValuesRequest>(&header, _body_bytes, handles, &mut req)?;
455                        let control_handle = ConverterControlHandle { inner: this.inner.clone() };
456                        Ok(ConverterRequest::SetValues {
457                            properties: req.properties,
458
459                            responder: ConverterSetValuesResponder {
460                                control_handle: std::mem::ManuallyDrop::new(control_handle),
461                                tx_id: header.tx_id,
462                            },
463                        })
464                    }
465                    0x45dd02bf82f653d1 => {
466                        header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
467                        let mut req = fidl::new_empty!(
468                            ConverterSetMinimumRgbRequest,
469                            fidl::encoding::DefaultFuchsiaResourceDialect
470                        );
471                        fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<ConverterSetMinimumRgbRequest>(&header, _body_bytes, handles, &mut req)?;
472                        let control_handle = ConverterControlHandle { inner: this.inner.clone() };
473                        Ok(ConverterRequest::SetMinimumRgb {
474                            minimum_rgb: req.minimum_rgb,
475
476                            responder: ConverterSetMinimumRgbResponder {
477                                control_handle: std::mem::ManuallyDrop::new(control_handle),
478                                tx_id: header.tx_id,
479                            },
480                        })
481                    }
482                    _ => Err(fidl::Error::UnknownOrdinal {
483                        ordinal: header.ordinal,
484                        protocol_name:
485                            <ConverterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
486                    }),
487                }))
488            },
489        )
490    }
491}
492
493#[derive(Debug)]
494pub enum ConverterRequest {
495    /// Modifies the color of final display output of rendered content. The sole parameter is a
496    /// table of |ConversionProperties|, which contains the parameters required to apply the
497    /// color conversion formula to the display. Please see |ConversionProperties| defined
498    /// above for more information.
499    ///
500    /// All parameters in the properties table must be normal 32-bit floating point values.
501    /// If any of the values do not meet this specification, the new color conversion values
502    /// will not be applied and a value of ZX_ERR_INVALID_ARGS will be returned. Otherwise,
503    /// the return value will be ZX_OK: https://en.wikipedia.org/wiki/Normal_number_%28computing%29.
504    /// Once a value of ZX_OK has been returned to the client, the color conversion values are ready
505    /// to be used in future render calls, including screenshots.
506    ///
507    /// Values in |ConversionProperties| may also be left blank. The default values for each member,
508    /// if left blank, are as follows:
509    ///     coefficients =
510    ///             [1, 0, 0,
511    ///              0, 1, 0,
512    ///              0, 0, 1]  (i.e. the identity matrix)
513    ///     preoffsets = [0,0,0]
514    ///     postoffsets = [0,0,0]
515    /// Thus, ColorConversion can be reset by passing in an empty table to this function.
516    ///
517    /// Hardware that support color conversion generally accept a limited range of coefficient
518    /// values. Coefficients in the range of [-2, 2] inclusive will be accepted by most
519    /// hardware. The hardware driver will clamp values that are outside its acceptable range.
520    ///
521    /// `preoffsets`, `postoffsets`: Clients are encouraged to produce color conversion values that
522    /// do not depend on pre and post offsets since some hardware do not have support for that.
523    /// For cases where pre and post offset values need to be used, the range should be limited to
524    /// (-1, 1).
525    SetValues { properties: ConversionProperties, responder: ConverterSetValuesResponder },
526    /// Submits a minimum value that all channels of all pixels rendered to the display
527    /// are clamped to. This can be used to mitigate the apparent effects of backlight
528    /// bleeding on certain devices in low-light environments.
529    ///
530    /// The valid range for a minimum value is [0, 255] (inclusive).  For a new
531    /// minimum value M, each color channel's range will be limited to [M, 255].
532    ///
533    /// Callers should wait for the acknowledgement to return before submitting another
534    /// call to this function. The minimum_rgb clamping can be removed simply by submitting
535    /// a value of 0.
536    ///
537    /// Not all hardware supports this feature. So this function returns |true|
538    /// if successfully applied and |false| if unsupported.
539    SetMinimumRgb { minimum_rgb: u8, responder: ConverterSetMinimumRgbResponder },
540}
541
542impl ConverterRequest {
543    #[allow(irrefutable_let_patterns)]
544    pub fn into_set_values(self) -> Option<(ConversionProperties, ConverterSetValuesResponder)> {
545        if let ConverterRequest::SetValues { properties, responder } = self {
546            Some((properties, responder))
547        } else {
548            None
549        }
550    }
551
552    #[allow(irrefutable_let_patterns)]
553    pub fn into_set_minimum_rgb(self) -> Option<(u8, ConverterSetMinimumRgbResponder)> {
554        if let ConverterRequest::SetMinimumRgb { minimum_rgb, responder } = self {
555            Some((minimum_rgb, responder))
556        } else {
557            None
558        }
559    }
560
561    /// Name of the method defined in FIDL
562    pub fn method_name(&self) -> &'static str {
563        match *self {
564            ConverterRequest::SetValues { .. } => "set_values",
565            ConverterRequest::SetMinimumRgb { .. } => "set_minimum_rgb",
566        }
567    }
568}
569
570#[derive(Debug, Clone)]
571pub struct ConverterControlHandle {
572    inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
573}
574
575impl fidl::endpoints::ControlHandle for ConverterControlHandle {
576    fn shutdown(&self) {
577        self.inner.shutdown()
578    }
579
580    fn shutdown_with_epitaph(&self, status: zx_status::Status) {
581        self.inner.shutdown_with_epitaph(status)
582    }
583
584    fn is_closed(&self) -> bool {
585        self.inner.channel().is_closed()
586    }
587    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
588        self.inner.channel().on_closed()
589    }
590
591    #[cfg(target_os = "fuchsia")]
592    fn signal_peer(
593        &self,
594        clear_mask: zx::Signals,
595        set_mask: zx::Signals,
596    ) -> Result<(), zx_status::Status> {
597        use fidl::Peered;
598        self.inner.channel().signal_peer(clear_mask, set_mask)
599    }
600}
601
602impl ConverterControlHandle {}
603
604#[must_use = "FIDL methods require a response to be sent"]
605#[derive(Debug)]
606pub struct ConverterSetValuesResponder {
607    control_handle: std::mem::ManuallyDrop<ConverterControlHandle>,
608    tx_id: u32,
609}
610
611/// Set the the channel to be shutdown (see [`ConverterControlHandle::shutdown`])
612/// if the responder is dropped without sending a response, so that the client
613/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
614impl std::ops::Drop for ConverterSetValuesResponder {
615    fn drop(&mut self) {
616        self.control_handle.shutdown();
617        // Safety: drops once, never accessed again
618        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
619    }
620}
621
622impl fidl::endpoints::Responder for ConverterSetValuesResponder {
623    type ControlHandle = ConverterControlHandle;
624
625    fn control_handle(&self) -> &ConverterControlHandle {
626        &self.control_handle
627    }
628
629    fn drop_without_shutdown(mut self) {
630        // Safety: drops once, never accessed again due to mem::forget
631        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
632        // Prevent Drop from running (which would shut down the channel)
633        std::mem::forget(self);
634    }
635}
636
637impl ConverterSetValuesResponder {
638    /// Sends a response to the FIDL transaction.
639    ///
640    /// Sets the channel to shutdown if an error occurs.
641    pub fn send(self, mut res: i32) -> Result<(), fidl::Error> {
642        let _result = self.send_raw(res);
643        if _result.is_err() {
644            self.control_handle.shutdown();
645        }
646        self.drop_without_shutdown();
647        _result
648    }
649
650    /// Similar to "send" but does not shutdown the channel if an error occurs.
651    pub fn send_no_shutdown_on_err(self, mut res: i32) -> Result<(), fidl::Error> {
652        let _result = self.send_raw(res);
653        self.drop_without_shutdown();
654        _result
655    }
656
657    fn send_raw(&self, mut res: i32) -> Result<(), fidl::Error> {
658        self.control_handle.inner.send::<ConverterSetValuesResponse>(
659            (res,),
660            self.tx_id,
661            0x64131a672b34af8d,
662            fidl::encoding::DynamicFlags::empty(),
663        )
664    }
665}
666
667#[must_use = "FIDL methods require a response to be sent"]
668#[derive(Debug)]
669pub struct ConverterSetMinimumRgbResponder {
670    control_handle: std::mem::ManuallyDrop<ConverterControlHandle>,
671    tx_id: u32,
672}
673
674/// Set the the channel to be shutdown (see [`ConverterControlHandle::shutdown`])
675/// if the responder is dropped without sending a response, so that the client
676/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
677impl std::ops::Drop for ConverterSetMinimumRgbResponder {
678    fn drop(&mut self) {
679        self.control_handle.shutdown();
680        // Safety: drops once, never accessed again
681        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
682    }
683}
684
685impl fidl::endpoints::Responder for ConverterSetMinimumRgbResponder {
686    type ControlHandle = ConverterControlHandle;
687
688    fn control_handle(&self) -> &ConverterControlHandle {
689        &self.control_handle
690    }
691
692    fn drop_without_shutdown(mut self) {
693        // Safety: drops once, never accessed again due to mem::forget
694        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
695        // Prevent Drop from running (which would shut down the channel)
696        std::mem::forget(self);
697    }
698}
699
700impl ConverterSetMinimumRgbResponder {
701    /// Sends a response to the FIDL transaction.
702    ///
703    /// Sets the channel to shutdown if an error occurs.
704    pub fn send(self, mut supported: bool) -> Result<(), fidl::Error> {
705        let _result = self.send_raw(supported);
706        if _result.is_err() {
707            self.control_handle.shutdown();
708        }
709        self.drop_without_shutdown();
710        _result
711    }
712
713    /// Similar to "send" but does not shutdown the channel if an error occurs.
714    pub fn send_no_shutdown_on_err(self, mut supported: bool) -> Result<(), fidl::Error> {
715        let _result = self.send_raw(supported);
716        self.drop_without_shutdown();
717        _result
718    }
719
720    fn send_raw(&self, mut supported: bool) -> Result<(), fidl::Error> {
721        self.control_handle.inner.send::<ConverterSetMinimumRgbResponse>(
722            (supported,),
723            self.tx_id,
724            0x45dd02bf82f653d1,
725            fidl::encoding::DynamicFlags::empty(),
726        )
727    }
728}
729
730mod internal {
731    use super::*;
732
733    impl fidl::encoding::ResourceTypeMarker for ConverterSetValuesRequest {
734        type Borrowed<'a> = &'a mut Self;
735        fn take_or_borrow<'a>(
736            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
737        ) -> Self::Borrowed<'a> {
738            value
739        }
740    }
741
742    unsafe impl fidl::encoding::TypeMarker for ConverterSetValuesRequest {
743        type Owned = Self;
744
745        #[inline(always)]
746        fn inline_align(_context: fidl::encoding::Context) -> usize {
747            8
748        }
749
750        #[inline(always)]
751        fn inline_size(_context: fidl::encoding::Context) -> usize {
752            16
753        }
754    }
755
756    unsafe impl
757        fidl::encoding::Encode<
758            ConverterSetValuesRequest,
759            fidl::encoding::DefaultFuchsiaResourceDialect,
760        > for &mut ConverterSetValuesRequest
761    {
762        #[inline]
763        unsafe fn encode(
764            self,
765            encoder: &mut fidl::encoding::Encoder<
766                '_,
767                fidl::encoding::DefaultFuchsiaResourceDialect,
768            >,
769            offset: usize,
770            _depth: fidl::encoding::Depth,
771        ) -> fidl::Result<()> {
772            encoder.debug_check_bounds::<ConverterSetValuesRequest>(offset);
773            // Delegate to tuple encoding.
774            fidl::encoding::Encode::<
775                ConverterSetValuesRequest,
776                fidl::encoding::DefaultFuchsiaResourceDialect,
777            >::encode(
778                (<ConversionProperties as fidl::encoding::ValueTypeMarker>::borrow(
779                    &self.properties,
780                ),),
781                encoder,
782                offset,
783                _depth,
784            )
785        }
786    }
787    unsafe impl<
788        T0: fidl::encoding::Encode<ConversionProperties, fidl::encoding::DefaultFuchsiaResourceDialect>,
789    >
790        fidl::encoding::Encode<
791            ConverterSetValuesRequest,
792            fidl::encoding::DefaultFuchsiaResourceDialect,
793        > for (T0,)
794    {
795        #[inline]
796        unsafe fn encode(
797            self,
798            encoder: &mut fidl::encoding::Encoder<
799                '_,
800                fidl::encoding::DefaultFuchsiaResourceDialect,
801            >,
802            offset: usize,
803            depth: fidl::encoding::Depth,
804        ) -> fidl::Result<()> {
805            encoder.debug_check_bounds::<ConverterSetValuesRequest>(offset);
806            // Zero out padding regions. There's no need to apply masks
807            // because the unmasked parts will be overwritten by fields.
808            // Write the fields.
809            self.0.encode(encoder, offset + 0, depth)?;
810            Ok(())
811        }
812    }
813
814    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
815        for ConverterSetValuesRequest
816    {
817        #[inline(always)]
818        fn new_empty() -> Self {
819            Self {
820                properties: fidl::new_empty!(
821                    ConversionProperties,
822                    fidl::encoding::DefaultFuchsiaResourceDialect
823                ),
824            }
825        }
826
827        #[inline]
828        unsafe fn decode(
829            &mut self,
830            decoder: &mut fidl::encoding::Decoder<
831                '_,
832                fidl::encoding::DefaultFuchsiaResourceDialect,
833            >,
834            offset: usize,
835            _depth: fidl::encoding::Depth,
836        ) -> fidl::Result<()> {
837            decoder.debug_check_bounds::<Self>(offset);
838            // Verify that padding bytes are zero.
839            fidl::decode!(
840                ConversionProperties,
841                fidl::encoding::DefaultFuchsiaResourceDialect,
842                &mut self.properties,
843                decoder,
844                offset + 0,
845                _depth
846            )?;
847            Ok(())
848        }
849    }
850}