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 ConverterControlHandle {
576    pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
577        self.inner.shutdown_with_epitaph(status.into())
578    }
579}
580
581impl fidl::endpoints::ControlHandle for ConverterControlHandle {
582    fn shutdown(&self) {
583        self.inner.shutdown()
584    }
585
586    fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
587        self.inner.shutdown_with_epitaph(status)
588    }
589
590    fn is_closed(&self) -> bool {
591        self.inner.channel().is_closed()
592    }
593    fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
594        self.inner.channel().on_closed()
595    }
596
597    #[cfg(target_os = "fuchsia")]
598    fn signal_peer(
599        &self,
600        clear_mask: zx::Signals,
601        set_mask: zx::Signals,
602    ) -> Result<(), zx_status::Status> {
603        use fidl::Peered;
604        self.inner.channel().signal_peer(clear_mask, set_mask)
605    }
606}
607
608impl ConverterControlHandle {}
609
610#[must_use = "FIDL methods require a response to be sent"]
611#[derive(Debug)]
612pub struct ConverterSetValuesResponder {
613    control_handle: std::mem::ManuallyDrop<ConverterControlHandle>,
614    tx_id: u32,
615}
616
617/// Set the the channel to be shutdown (see [`ConverterControlHandle::shutdown`])
618/// if the responder is dropped without sending a response, so that the client
619/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
620impl std::ops::Drop for ConverterSetValuesResponder {
621    fn drop(&mut self) {
622        self.control_handle.shutdown();
623        // Safety: drops once, never accessed again
624        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
625    }
626}
627
628impl fidl::endpoints::Responder for ConverterSetValuesResponder {
629    type ControlHandle = ConverterControlHandle;
630
631    fn control_handle(&self) -> &ConverterControlHandle {
632        &self.control_handle
633    }
634
635    fn drop_without_shutdown(mut self) {
636        // Safety: drops once, never accessed again due to mem::forget
637        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
638        // Prevent Drop from running (which would shut down the channel)
639        std::mem::forget(self);
640    }
641}
642
643impl ConverterSetValuesResponder {
644    /// Sends a response to the FIDL transaction.
645    ///
646    /// Sets the channel to shutdown if an error occurs.
647    pub fn send(self, mut res: i32) -> Result<(), fidl::Error> {
648        let _result = self.send_raw(res);
649        if _result.is_err() {
650            self.control_handle.shutdown();
651        }
652        self.drop_without_shutdown();
653        _result
654    }
655
656    /// Similar to "send" but does not shutdown the channel if an error occurs.
657    pub fn send_no_shutdown_on_err(self, mut res: i32) -> Result<(), fidl::Error> {
658        let _result = self.send_raw(res);
659        self.drop_without_shutdown();
660        _result
661    }
662
663    fn send_raw(&self, mut res: i32) -> Result<(), fidl::Error> {
664        self.control_handle.inner.send::<ConverterSetValuesResponse>(
665            (res,),
666            self.tx_id,
667            0x64131a672b34af8d,
668            fidl::encoding::DynamicFlags::empty(),
669        )
670    }
671}
672
673#[must_use = "FIDL methods require a response to be sent"]
674#[derive(Debug)]
675pub struct ConverterSetMinimumRgbResponder {
676    control_handle: std::mem::ManuallyDrop<ConverterControlHandle>,
677    tx_id: u32,
678}
679
680/// Set the the channel to be shutdown (see [`ConverterControlHandle::shutdown`])
681/// if the responder is dropped without sending a response, so that the client
682/// doesn't hang. To prevent this behavior, call `drop_without_shutdown`.
683impl std::ops::Drop for ConverterSetMinimumRgbResponder {
684    fn drop(&mut self) {
685        self.control_handle.shutdown();
686        // Safety: drops once, never accessed again
687        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
688    }
689}
690
691impl fidl::endpoints::Responder for ConverterSetMinimumRgbResponder {
692    type ControlHandle = ConverterControlHandle;
693
694    fn control_handle(&self) -> &ConverterControlHandle {
695        &self.control_handle
696    }
697
698    fn drop_without_shutdown(mut self) {
699        // Safety: drops once, never accessed again due to mem::forget
700        unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
701        // Prevent Drop from running (which would shut down the channel)
702        std::mem::forget(self);
703    }
704}
705
706impl ConverterSetMinimumRgbResponder {
707    /// Sends a response to the FIDL transaction.
708    ///
709    /// Sets the channel to shutdown if an error occurs.
710    pub fn send(self, mut supported: bool) -> Result<(), fidl::Error> {
711        let _result = self.send_raw(supported);
712        if _result.is_err() {
713            self.control_handle.shutdown();
714        }
715        self.drop_without_shutdown();
716        _result
717    }
718
719    /// Similar to "send" but does not shutdown the channel if an error occurs.
720    pub fn send_no_shutdown_on_err(self, mut supported: bool) -> Result<(), fidl::Error> {
721        let _result = self.send_raw(supported);
722        self.drop_without_shutdown();
723        _result
724    }
725
726    fn send_raw(&self, mut supported: bool) -> Result<(), fidl::Error> {
727        self.control_handle.inner.send::<ConverterSetMinimumRgbResponse>(
728            (supported,),
729            self.tx_id,
730            0x45dd02bf82f653d1,
731            fidl::encoding::DynamicFlags::empty(),
732        )
733    }
734}
735
736mod internal {
737    use super::*;
738
739    impl fidl::encoding::ResourceTypeMarker for ConverterSetValuesRequest {
740        type Borrowed<'a> = &'a mut Self;
741        fn take_or_borrow<'a>(
742            value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
743        ) -> Self::Borrowed<'a> {
744            value
745        }
746    }
747
748    unsafe impl fidl::encoding::TypeMarker for ConverterSetValuesRequest {
749        type Owned = Self;
750
751        #[inline(always)]
752        fn inline_align(_context: fidl::encoding::Context) -> usize {
753            8
754        }
755
756        #[inline(always)]
757        fn inline_size(_context: fidl::encoding::Context) -> usize {
758            16
759        }
760    }
761
762    unsafe impl
763        fidl::encoding::Encode<
764            ConverterSetValuesRequest,
765            fidl::encoding::DefaultFuchsiaResourceDialect,
766        > for &mut ConverterSetValuesRequest
767    {
768        #[inline]
769        unsafe fn encode(
770            self,
771            encoder: &mut fidl::encoding::Encoder<
772                '_,
773                fidl::encoding::DefaultFuchsiaResourceDialect,
774            >,
775            offset: usize,
776            _depth: fidl::encoding::Depth,
777        ) -> fidl::Result<()> {
778            encoder.debug_check_bounds::<ConverterSetValuesRequest>(offset);
779            // Delegate to tuple encoding.
780            fidl::encoding::Encode::<
781                ConverterSetValuesRequest,
782                fidl::encoding::DefaultFuchsiaResourceDialect,
783            >::encode(
784                (<ConversionProperties as fidl::encoding::ValueTypeMarker>::borrow(
785                    &self.properties,
786                ),),
787                encoder,
788                offset,
789                _depth,
790            )
791        }
792    }
793    unsafe impl<
794        T0: fidl::encoding::Encode<ConversionProperties, fidl::encoding::DefaultFuchsiaResourceDialect>,
795    >
796        fidl::encoding::Encode<
797            ConverterSetValuesRequest,
798            fidl::encoding::DefaultFuchsiaResourceDialect,
799        > for (T0,)
800    {
801        #[inline]
802        unsafe fn encode(
803            self,
804            encoder: &mut fidl::encoding::Encoder<
805                '_,
806                fidl::encoding::DefaultFuchsiaResourceDialect,
807            >,
808            offset: usize,
809            depth: fidl::encoding::Depth,
810        ) -> fidl::Result<()> {
811            encoder.debug_check_bounds::<ConverterSetValuesRequest>(offset);
812            // Zero out padding regions. There's no need to apply masks
813            // because the unmasked parts will be overwritten by fields.
814            // Write the fields.
815            self.0.encode(encoder, offset + 0, depth)?;
816            Ok(())
817        }
818    }
819
820    impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
821        for ConverterSetValuesRequest
822    {
823        #[inline(always)]
824        fn new_empty() -> Self {
825            Self {
826                properties: fidl::new_empty!(
827                    ConversionProperties,
828                    fidl::encoding::DefaultFuchsiaResourceDialect
829                ),
830            }
831        }
832
833        #[inline]
834        unsafe fn decode(
835            &mut self,
836            decoder: &mut fidl::encoding::Decoder<
837                '_,
838                fidl::encoding::DefaultFuchsiaResourceDialect,
839            >,
840            offset: usize,
841            _depth: fidl::encoding::Depth,
842        ) -> fidl::Result<()> {
843            decoder.debug_check_bounds::<Self>(offset);
844            // Verify that padding bytes are zero.
845            fidl::decode!(
846                ConversionProperties,
847                fidl::encoding::DefaultFuchsiaResourceDialect,
848                &mut self.properties,
849                decoder,
850                offset + 0,
851                _depth
852            )?;
853            Ok(())
854        }
855    }
856}