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