1#![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_hardware_backlight_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
15pub struct DeviceMarker;
16
17impl fidl::endpoints::ProtocolMarker for DeviceMarker {
18 type Proxy = DeviceProxy;
19 type RequestStream = DeviceRequestStream;
20 #[cfg(target_os = "fuchsia")]
21 type SynchronousProxy = DeviceSynchronousProxy;
22
23 const DEBUG_NAME: &'static str = "fuchsia.hardware.backlight.Device";
24}
25impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
26pub type DeviceGetStateNormalizedResult = Result<State, i32>;
27pub type DeviceSetStateNormalizedResult = Result<(), i32>;
28pub type DeviceGetStateAbsoluteResult = Result<State, i32>;
29pub type DeviceSetStateAbsoluteResult = Result<(), i32>;
30pub type DeviceGetMaxAbsoluteBrightnessResult = Result<f64, i32>;
31
32pub trait DeviceProxyInterface: Send + Sync {
33 type GetStateNormalizedResponseFut: std::future::Future<Output = Result<DeviceGetStateNormalizedResult, fidl::Error>>
34 + Send;
35 fn r#get_state_normalized(&self) -> Self::GetStateNormalizedResponseFut;
36 type SetStateNormalizedResponseFut: std::future::Future<Output = Result<DeviceSetStateNormalizedResult, fidl::Error>>
37 + Send;
38 fn r#set_state_normalized(&self, state: &State) -> Self::SetStateNormalizedResponseFut;
39 type GetStateAbsoluteResponseFut: std::future::Future<Output = Result<DeviceGetStateAbsoluteResult, fidl::Error>>
40 + Send;
41 fn r#get_state_absolute(&self) -> Self::GetStateAbsoluteResponseFut;
42 type SetStateAbsoluteResponseFut: std::future::Future<Output = Result<DeviceSetStateAbsoluteResult, fidl::Error>>
43 + Send;
44 fn r#set_state_absolute(&self, state: &State) -> Self::SetStateAbsoluteResponseFut;
45 type GetMaxAbsoluteBrightnessResponseFut: std::future::Future<Output = Result<DeviceGetMaxAbsoluteBrightnessResult, fidl::Error>>
46 + Send;
47 fn r#get_max_absolute_brightness(&self) -> Self::GetMaxAbsoluteBrightnessResponseFut;
48}
49#[derive(Debug)]
50#[cfg(target_os = "fuchsia")]
51pub struct DeviceSynchronousProxy {
52 client: fidl::client::sync::Client,
53}
54
55#[cfg(target_os = "fuchsia")]
56impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
57 type Proxy = DeviceProxy;
58 type Protocol = DeviceMarker;
59
60 fn from_channel(inner: fidl::Channel) -> Self {
61 Self::new(inner)
62 }
63
64 fn into_channel(self) -> fidl::Channel {
65 self.client.into_channel()
66 }
67
68 fn as_channel(&self) -> &fidl::Channel {
69 self.client.as_channel()
70 }
71}
72
73#[cfg(target_os = "fuchsia")]
74impl DeviceSynchronousProxy {
75 pub fn new(channel: fidl::Channel) -> Self {
76 Self { client: fidl::client::sync::Client::new(channel) }
77 }
78
79 pub fn into_channel(self) -> fidl::Channel {
80 self.client.into_channel()
81 }
82
83 pub fn wait_for_event(
86 &self,
87 deadline: zx::MonotonicInstant,
88 ) -> Result<DeviceEvent, fidl::Error> {
89 DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
90 }
91
92 pub fn r#get_state_normalized(
95 &self,
96 ___deadline: zx::MonotonicInstant,
97 ) -> Result<DeviceGetStateNormalizedResult, fidl::Error> {
98 let _response = self.client.send_query::<
99 fidl::encoding::EmptyPayload,
100 fidl::encoding::ResultType<DeviceGetStateNormalizedResponse, i32>,
101 DeviceMarker,
102 >(
103 (),
104 0x2506201b5999b9b7,
105 fidl::encoding::DynamicFlags::empty(),
106 ___deadline,
107 )?;
108 Ok(_response.map(|x| x.state))
109 }
110
111 pub fn r#set_state_normalized(
114 &self,
115 mut state: &State,
116 ___deadline: zx::MonotonicInstant,
117 ) -> Result<DeviceSetStateNormalizedResult, fidl::Error> {
118 let _response = self.client.send_query::<
119 DeviceSetStateNormalizedRequest,
120 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
121 DeviceMarker,
122 >(
123 (state,),
124 0x554ac5cb4f9f5b62,
125 fidl::encoding::DynamicFlags::empty(),
126 ___deadline,
127 )?;
128 Ok(_response.map(|x| x))
129 }
130
131 pub fn r#get_state_absolute(
133 &self,
134 ___deadline: zx::MonotonicInstant,
135 ) -> Result<DeviceGetStateAbsoluteResult, fidl::Error> {
136 let _response = self.client.send_query::<
137 fidl::encoding::EmptyPayload,
138 fidl::encoding::ResultType<DeviceGetStateAbsoluteResponse, i32>,
139 DeviceMarker,
140 >(
141 (),
142 0x1f8ccf01cf526a2b,
143 fidl::encoding::DynamicFlags::empty(),
144 ___deadline,
145 )?;
146 Ok(_response.map(|x| x.state))
147 }
148
149 pub fn r#set_state_absolute(
151 &self,
152 mut state: &State,
153 ___deadline: zx::MonotonicInstant,
154 ) -> Result<DeviceSetStateAbsoluteResult, fidl::Error> {
155 let _response = self.client.send_query::<
156 DeviceSetStateAbsoluteRequest,
157 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
158 DeviceMarker,
159 >(
160 (state,),
161 0x19c100c43faaa178,
162 fidl::encoding::DynamicFlags::empty(),
163 ___deadline,
164 )?;
165 Ok(_response.map(|x| x))
166 }
167
168 pub fn r#get_max_absolute_brightness(
171 &self,
172 ___deadline: zx::MonotonicInstant,
173 ) -> Result<DeviceGetMaxAbsoluteBrightnessResult, fidl::Error> {
174 let _response = self.client.send_query::<
175 fidl::encoding::EmptyPayload,
176 fidl::encoding::ResultType<DeviceGetMaxAbsoluteBrightnessResponse, i32>,
177 DeviceMarker,
178 >(
179 (),
180 0x2aa0699313d4160d,
181 fidl::encoding::DynamicFlags::empty(),
182 ___deadline,
183 )?;
184 Ok(_response.map(|x| x.max_brightness))
185 }
186}
187
188#[cfg(target_os = "fuchsia")]
189impl From<DeviceSynchronousProxy> for zx::NullableHandle {
190 fn from(value: DeviceSynchronousProxy) -> Self {
191 value.into_channel().into()
192 }
193}
194
195#[cfg(target_os = "fuchsia")]
196impl From<fidl::Channel> for DeviceSynchronousProxy {
197 fn from(value: fidl::Channel) -> Self {
198 Self::new(value)
199 }
200}
201
202#[cfg(target_os = "fuchsia")]
203impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
204 type Protocol = DeviceMarker;
205
206 fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
207 Self::new(value.into_channel())
208 }
209}
210
211#[derive(Debug, Clone)]
212pub struct DeviceProxy {
213 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
214}
215
216impl fidl::endpoints::Proxy for DeviceProxy {
217 type Protocol = DeviceMarker;
218
219 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
220 Self::new(inner)
221 }
222
223 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
224 self.client.into_channel().map_err(|client| Self { client })
225 }
226
227 fn as_channel(&self) -> &::fidl::AsyncChannel {
228 self.client.as_channel()
229 }
230}
231
232impl DeviceProxy {
233 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
235 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
236 Self { client: fidl::client::Client::new(channel, protocol_name) }
237 }
238
239 pub fn take_event_stream(&self) -> DeviceEventStream {
245 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
246 }
247
248 pub fn r#get_state_normalized(
251 &self,
252 ) -> fidl::client::QueryResponseFut<
253 DeviceGetStateNormalizedResult,
254 fidl::encoding::DefaultFuchsiaResourceDialect,
255 > {
256 DeviceProxyInterface::r#get_state_normalized(self)
257 }
258
259 pub fn r#set_state_normalized(
262 &self,
263 mut state: &State,
264 ) -> fidl::client::QueryResponseFut<
265 DeviceSetStateNormalizedResult,
266 fidl::encoding::DefaultFuchsiaResourceDialect,
267 > {
268 DeviceProxyInterface::r#set_state_normalized(self, state)
269 }
270
271 pub fn r#get_state_absolute(
273 &self,
274 ) -> fidl::client::QueryResponseFut<
275 DeviceGetStateAbsoluteResult,
276 fidl::encoding::DefaultFuchsiaResourceDialect,
277 > {
278 DeviceProxyInterface::r#get_state_absolute(self)
279 }
280
281 pub fn r#set_state_absolute(
283 &self,
284 mut state: &State,
285 ) -> fidl::client::QueryResponseFut<
286 DeviceSetStateAbsoluteResult,
287 fidl::encoding::DefaultFuchsiaResourceDialect,
288 > {
289 DeviceProxyInterface::r#set_state_absolute(self, state)
290 }
291
292 pub fn r#get_max_absolute_brightness(
295 &self,
296 ) -> fidl::client::QueryResponseFut<
297 DeviceGetMaxAbsoluteBrightnessResult,
298 fidl::encoding::DefaultFuchsiaResourceDialect,
299 > {
300 DeviceProxyInterface::r#get_max_absolute_brightness(self)
301 }
302}
303
304impl DeviceProxyInterface for DeviceProxy {
305 type GetStateNormalizedResponseFut = fidl::client::QueryResponseFut<
306 DeviceGetStateNormalizedResult,
307 fidl::encoding::DefaultFuchsiaResourceDialect,
308 >;
309 fn r#get_state_normalized(&self) -> Self::GetStateNormalizedResponseFut {
310 fn _decode(
311 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
312 ) -> Result<DeviceGetStateNormalizedResult, fidl::Error> {
313 let _response = fidl::client::decode_transaction_body::<
314 fidl::encoding::ResultType<DeviceGetStateNormalizedResponse, i32>,
315 fidl::encoding::DefaultFuchsiaResourceDialect,
316 0x2506201b5999b9b7,
317 >(_buf?)?;
318 Ok(_response.map(|x| x.state))
319 }
320 self.client
321 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetStateNormalizedResult>(
322 (),
323 0x2506201b5999b9b7,
324 fidl::encoding::DynamicFlags::empty(),
325 _decode,
326 )
327 }
328
329 type SetStateNormalizedResponseFut = fidl::client::QueryResponseFut<
330 DeviceSetStateNormalizedResult,
331 fidl::encoding::DefaultFuchsiaResourceDialect,
332 >;
333 fn r#set_state_normalized(&self, mut state: &State) -> Self::SetStateNormalizedResponseFut {
334 fn _decode(
335 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
336 ) -> Result<DeviceSetStateNormalizedResult, fidl::Error> {
337 let _response = fidl::client::decode_transaction_body::<
338 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
339 fidl::encoding::DefaultFuchsiaResourceDialect,
340 0x554ac5cb4f9f5b62,
341 >(_buf?)?;
342 Ok(_response.map(|x| x))
343 }
344 self.client.send_query_and_decode::<
345 DeviceSetStateNormalizedRequest,
346 DeviceSetStateNormalizedResult,
347 >(
348 (state,),
349 0x554ac5cb4f9f5b62,
350 fidl::encoding::DynamicFlags::empty(),
351 _decode,
352 )
353 }
354
355 type GetStateAbsoluteResponseFut = fidl::client::QueryResponseFut<
356 DeviceGetStateAbsoluteResult,
357 fidl::encoding::DefaultFuchsiaResourceDialect,
358 >;
359 fn r#get_state_absolute(&self) -> Self::GetStateAbsoluteResponseFut {
360 fn _decode(
361 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
362 ) -> Result<DeviceGetStateAbsoluteResult, fidl::Error> {
363 let _response = fidl::client::decode_transaction_body::<
364 fidl::encoding::ResultType<DeviceGetStateAbsoluteResponse, i32>,
365 fidl::encoding::DefaultFuchsiaResourceDialect,
366 0x1f8ccf01cf526a2b,
367 >(_buf?)?;
368 Ok(_response.map(|x| x.state))
369 }
370 self.client
371 .send_query_and_decode::<fidl::encoding::EmptyPayload, DeviceGetStateAbsoluteResult>(
372 (),
373 0x1f8ccf01cf526a2b,
374 fidl::encoding::DynamicFlags::empty(),
375 _decode,
376 )
377 }
378
379 type SetStateAbsoluteResponseFut = fidl::client::QueryResponseFut<
380 DeviceSetStateAbsoluteResult,
381 fidl::encoding::DefaultFuchsiaResourceDialect,
382 >;
383 fn r#set_state_absolute(&self, mut state: &State) -> Self::SetStateAbsoluteResponseFut {
384 fn _decode(
385 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
386 ) -> Result<DeviceSetStateAbsoluteResult, fidl::Error> {
387 let _response = fidl::client::decode_transaction_body::<
388 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>,
389 fidl::encoding::DefaultFuchsiaResourceDialect,
390 0x19c100c43faaa178,
391 >(_buf?)?;
392 Ok(_response.map(|x| x))
393 }
394 self.client
395 .send_query_and_decode::<DeviceSetStateAbsoluteRequest, DeviceSetStateAbsoluteResult>(
396 (state,),
397 0x19c100c43faaa178,
398 fidl::encoding::DynamicFlags::empty(),
399 _decode,
400 )
401 }
402
403 type GetMaxAbsoluteBrightnessResponseFut = fidl::client::QueryResponseFut<
404 DeviceGetMaxAbsoluteBrightnessResult,
405 fidl::encoding::DefaultFuchsiaResourceDialect,
406 >;
407 fn r#get_max_absolute_brightness(&self) -> Self::GetMaxAbsoluteBrightnessResponseFut {
408 fn _decode(
409 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
410 ) -> Result<DeviceGetMaxAbsoluteBrightnessResult, fidl::Error> {
411 let _response = fidl::client::decode_transaction_body::<
412 fidl::encoding::ResultType<DeviceGetMaxAbsoluteBrightnessResponse, i32>,
413 fidl::encoding::DefaultFuchsiaResourceDialect,
414 0x2aa0699313d4160d,
415 >(_buf?)?;
416 Ok(_response.map(|x| x.max_brightness))
417 }
418 self.client.send_query_and_decode::<
419 fidl::encoding::EmptyPayload,
420 DeviceGetMaxAbsoluteBrightnessResult,
421 >(
422 (),
423 0x2aa0699313d4160d,
424 fidl::encoding::DynamicFlags::empty(),
425 _decode,
426 )
427 }
428}
429
430pub struct DeviceEventStream {
431 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
432}
433
434impl std::marker::Unpin for DeviceEventStream {}
435
436impl futures::stream::FusedStream for DeviceEventStream {
437 fn is_terminated(&self) -> bool {
438 self.event_receiver.is_terminated()
439 }
440}
441
442impl futures::Stream for DeviceEventStream {
443 type Item = Result<DeviceEvent, fidl::Error>;
444
445 fn poll_next(
446 mut self: std::pin::Pin<&mut Self>,
447 cx: &mut std::task::Context<'_>,
448 ) -> std::task::Poll<Option<Self::Item>> {
449 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
450 &mut self.event_receiver,
451 cx
452 )?) {
453 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
454 None => std::task::Poll::Ready(None),
455 }
456 }
457}
458
459#[derive(Debug)]
460pub enum DeviceEvent {}
461
462impl DeviceEvent {
463 fn decode(
465 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
466 ) -> Result<DeviceEvent, fidl::Error> {
467 let (bytes, _handles) = buf.split_mut();
468 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
469 debug_assert_eq!(tx_header.tx_id, 0);
470 match tx_header.ordinal {
471 _ => Err(fidl::Error::UnknownOrdinal {
472 ordinal: tx_header.ordinal,
473 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
474 }),
475 }
476 }
477}
478
479pub struct DeviceRequestStream {
481 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
482 is_terminated: bool,
483}
484
485impl std::marker::Unpin for DeviceRequestStream {}
486
487impl futures::stream::FusedStream for DeviceRequestStream {
488 fn is_terminated(&self) -> bool {
489 self.is_terminated
490 }
491}
492
493impl fidl::endpoints::RequestStream for DeviceRequestStream {
494 type Protocol = DeviceMarker;
495 type ControlHandle = DeviceControlHandle;
496
497 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
498 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
499 }
500
501 fn control_handle(&self) -> Self::ControlHandle {
502 DeviceControlHandle { inner: self.inner.clone() }
503 }
504
505 fn into_inner(
506 self,
507 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
508 {
509 (self.inner, self.is_terminated)
510 }
511
512 fn from_inner(
513 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
514 is_terminated: bool,
515 ) -> Self {
516 Self { inner, is_terminated }
517 }
518}
519
520impl futures::Stream for DeviceRequestStream {
521 type Item = Result<DeviceRequest, fidl::Error>;
522
523 fn poll_next(
524 mut self: std::pin::Pin<&mut Self>,
525 cx: &mut std::task::Context<'_>,
526 ) -> std::task::Poll<Option<Self::Item>> {
527 let this = &mut *self;
528 if this.inner.check_shutdown(cx) {
529 this.is_terminated = true;
530 return std::task::Poll::Ready(None);
531 }
532 if this.is_terminated {
533 panic!("polled DeviceRequestStream after completion");
534 }
535 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
536 |bytes, handles| {
537 match this.inner.channel().read_etc(cx, bytes, handles) {
538 std::task::Poll::Ready(Ok(())) => {}
539 std::task::Poll::Pending => return std::task::Poll::Pending,
540 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
541 this.is_terminated = true;
542 return std::task::Poll::Ready(None);
543 }
544 std::task::Poll::Ready(Err(e)) => {
545 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
546 e.into(),
547 ))));
548 }
549 }
550
551 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
553
554 std::task::Poll::Ready(Some(match header.ordinal {
555 0x2506201b5999b9b7 => {
556 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
557 let mut req = fidl::new_empty!(
558 fidl::encoding::EmptyPayload,
559 fidl::encoding::DefaultFuchsiaResourceDialect
560 );
561 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
562 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
563 Ok(DeviceRequest::GetStateNormalized {
564 responder: DeviceGetStateNormalizedResponder {
565 control_handle: std::mem::ManuallyDrop::new(control_handle),
566 tx_id: header.tx_id,
567 },
568 })
569 }
570 0x554ac5cb4f9f5b62 => {
571 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
572 let mut req = fidl::new_empty!(
573 DeviceSetStateNormalizedRequest,
574 fidl::encoding::DefaultFuchsiaResourceDialect
575 );
576 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetStateNormalizedRequest>(&header, _body_bytes, handles, &mut req)?;
577 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
578 Ok(DeviceRequest::SetStateNormalized {
579 state: req.state,
580
581 responder: DeviceSetStateNormalizedResponder {
582 control_handle: std::mem::ManuallyDrop::new(control_handle),
583 tx_id: header.tx_id,
584 },
585 })
586 }
587 0x1f8ccf01cf526a2b => {
588 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
589 let mut req = fidl::new_empty!(
590 fidl::encoding::EmptyPayload,
591 fidl::encoding::DefaultFuchsiaResourceDialect
592 );
593 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
594 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
595 Ok(DeviceRequest::GetStateAbsolute {
596 responder: DeviceGetStateAbsoluteResponder {
597 control_handle: std::mem::ManuallyDrop::new(control_handle),
598 tx_id: header.tx_id,
599 },
600 })
601 }
602 0x19c100c43faaa178 => {
603 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
604 let mut req = fidl::new_empty!(
605 DeviceSetStateAbsoluteRequest,
606 fidl::encoding::DefaultFuchsiaResourceDialect
607 );
608 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetStateAbsoluteRequest>(&header, _body_bytes, handles, &mut req)?;
609 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
610 Ok(DeviceRequest::SetStateAbsolute {
611 state: req.state,
612
613 responder: DeviceSetStateAbsoluteResponder {
614 control_handle: std::mem::ManuallyDrop::new(control_handle),
615 tx_id: header.tx_id,
616 },
617 })
618 }
619 0x2aa0699313d4160d => {
620 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
621 let mut req = fidl::new_empty!(
622 fidl::encoding::EmptyPayload,
623 fidl::encoding::DefaultFuchsiaResourceDialect
624 );
625 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
626 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
627 Ok(DeviceRequest::GetMaxAbsoluteBrightness {
628 responder: DeviceGetMaxAbsoluteBrightnessResponder {
629 control_handle: std::mem::ManuallyDrop::new(control_handle),
630 tx_id: header.tx_id,
631 },
632 })
633 }
634 _ => Err(fidl::Error::UnknownOrdinal {
635 ordinal: header.ordinal,
636 protocol_name:
637 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
638 }),
639 }))
640 },
641 )
642 }
643}
644
645#[derive(Debug)]
646pub enum DeviceRequest {
647 GetStateNormalized { responder: DeviceGetStateNormalizedResponder },
650 SetStateNormalized { state: State, responder: DeviceSetStateNormalizedResponder },
653 GetStateAbsolute { responder: DeviceGetStateAbsoluteResponder },
655 SetStateAbsolute { state: State, responder: DeviceSetStateAbsoluteResponder },
657 GetMaxAbsoluteBrightness { responder: DeviceGetMaxAbsoluteBrightnessResponder },
660}
661
662impl DeviceRequest {
663 #[allow(irrefutable_let_patterns)]
664 pub fn into_get_state_normalized(self) -> Option<(DeviceGetStateNormalizedResponder)> {
665 if let DeviceRequest::GetStateNormalized { responder } = self {
666 Some((responder))
667 } else {
668 None
669 }
670 }
671
672 #[allow(irrefutable_let_patterns)]
673 pub fn into_set_state_normalized(self) -> Option<(State, DeviceSetStateNormalizedResponder)> {
674 if let DeviceRequest::SetStateNormalized { state, responder } = self {
675 Some((state, responder))
676 } else {
677 None
678 }
679 }
680
681 #[allow(irrefutable_let_patterns)]
682 pub fn into_get_state_absolute(self) -> Option<(DeviceGetStateAbsoluteResponder)> {
683 if let DeviceRequest::GetStateAbsolute { responder } = self {
684 Some((responder))
685 } else {
686 None
687 }
688 }
689
690 #[allow(irrefutable_let_patterns)]
691 pub fn into_set_state_absolute(self) -> Option<(State, DeviceSetStateAbsoluteResponder)> {
692 if let DeviceRequest::SetStateAbsolute { state, responder } = self {
693 Some((state, responder))
694 } else {
695 None
696 }
697 }
698
699 #[allow(irrefutable_let_patterns)]
700 pub fn into_get_max_absolute_brightness(
701 self,
702 ) -> Option<(DeviceGetMaxAbsoluteBrightnessResponder)> {
703 if let DeviceRequest::GetMaxAbsoluteBrightness { responder } = self {
704 Some((responder))
705 } else {
706 None
707 }
708 }
709
710 pub fn method_name(&self) -> &'static str {
712 match *self {
713 DeviceRequest::GetStateNormalized { .. } => "get_state_normalized",
714 DeviceRequest::SetStateNormalized { .. } => "set_state_normalized",
715 DeviceRequest::GetStateAbsolute { .. } => "get_state_absolute",
716 DeviceRequest::SetStateAbsolute { .. } => "set_state_absolute",
717 DeviceRequest::GetMaxAbsoluteBrightness { .. } => "get_max_absolute_brightness",
718 }
719 }
720}
721
722#[derive(Debug, Clone)]
723pub struct DeviceControlHandle {
724 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
725}
726
727impl DeviceControlHandle {
728 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
729 self.inner.shutdown_with_epitaph(status.into())
730 }
731}
732
733impl fidl::endpoints::ControlHandle for DeviceControlHandle {
734 fn shutdown(&self) {
735 self.inner.shutdown()
736 }
737
738 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
739 self.inner.shutdown_with_epitaph(status)
740 }
741
742 fn is_closed(&self) -> bool {
743 self.inner.channel().is_closed()
744 }
745 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
746 self.inner.channel().on_closed()
747 }
748
749 #[cfg(target_os = "fuchsia")]
750 fn signal_peer(
751 &self,
752 clear_mask: zx::Signals,
753 set_mask: zx::Signals,
754 ) -> Result<(), zx_status::Status> {
755 use fidl::Peered;
756 self.inner.channel().signal_peer(clear_mask, set_mask)
757 }
758}
759
760impl DeviceControlHandle {}
761
762#[must_use = "FIDL methods require a response to be sent"]
763#[derive(Debug)]
764pub struct DeviceGetStateNormalizedResponder {
765 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
766 tx_id: u32,
767}
768
769impl std::ops::Drop for DeviceGetStateNormalizedResponder {
773 fn drop(&mut self) {
774 self.control_handle.shutdown();
775 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
777 }
778}
779
780impl fidl::endpoints::Responder for DeviceGetStateNormalizedResponder {
781 type ControlHandle = DeviceControlHandle;
782
783 fn control_handle(&self) -> &DeviceControlHandle {
784 &self.control_handle
785 }
786
787 fn drop_without_shutdown(mut self) {
788 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
790 std::mem::forget(self);
792 }
793}
794
795impl DeviceGetStateNormalizedResponder {
796 pub fn send(self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
800 let _result = self.send_raw(result);
801 if _result.is_err() {
802 self.control_handle.shutdown();
803 }
804 self.drop_without_shutdown();
805 _result
806 }
807
808 pub fn send_no_shutdown_on_err(
810 self,
811 mut result: Result<&State, i32>,
812 ) -> Result<(), fidl::Error> {
813 let _result = self.send_raw(result);
814 self.drop_without_shutdown();
815 _result
816 }
817
818 fn send_raw(&self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
819 self.control_handle
820 .inner
821 .send::<fidl::encoding::ResultType<DeviceGetStateNormalizedResponse, i32>>(
822 result.map(|state| (state,)),
823 self.tx_id,
824 0x2506201b5999b9b7,
825 fidl::encoding::DynamicFlags::empty(),
826 )
827 }
828}
829
830#[must_use = "FIDL methods require a response to be sent"]
831#[derive(Debug)]
832pub struct DeviceSetStateNormalizedResponder {
833 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
834 tx_id: u32,
835}
836
837impl std::ops::Drop for DeviceSetStateNormalizedResponder {
841 fn drop(&mut self) {
842 self.control_handle.shutdown();
843 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
845 }
846}
847
848impl fidl::endpoints::Responder for DeviceSetStateNormalizedResponder {
849 type ControlHandle = DeviceControlHandle;
850
851 fn control_handle(&self) -> &DeviceControlHandle {
852 &self.control_handle
853 }
854
855 fn drop_without_shutdown(mut self) {
856 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
858 std::mem::forget(self);
860 }
861}
862
863impl DeviceSetStateNormalizedResponder {
864 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
868 let _result = self.send_raw(result);
869 if _result.is_err() {
870 self.control_handle.shutdown();
871 }
872 self.drop_without_shutdown();
873 _result
874 }
875
876 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
878 let _result = self.send_raw(result);
879 self.drop_without_shutdown();
880 _result
881 }
882
883 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
884 self.control_handle
885 .inner
886 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
887 result,
888 self.tx_id,
889 0x554ac5cb4f9f5b62,
890 fidl::encoding::DynamicFlags::empty(),
891 )
892 }
893}
894
895#[must_use = "FIDL methods require a response to be sent"]
896#[derive(Debug)]
897pub struct DeviceGetStateAbsoluteResponder {
898 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
899 tx_id: u32,
900}
901
902impl std::ops::Drop for DeviceGetStateAbsoluteResponder {
906 fn drop(&mut self) {
907 self.control_handle.shutdown();
908 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
910 }
911}
912
913impl fidl::endpoints::Responder for DeviceGetStateAbsoluteResponder {
914 type ControlHandle = DeviceControlHandle;
915
916 fn control_handle(&self) -> &DeviceControlHandle {
917 &self.control_handle
918 }
919
920 fn drop_without_shutdown(mut self) {
921 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
923 std::mem::forget(self);
925 }
926}
927
928impl DeviceGetStateAbsoluteResponder {
929 pub fn send(self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
933 let _result = self.send_raw(result);
934 if _result.is_err() {
935 self.control_handle.shutdown();
936 }
937 self.drop_without_shutdown();
938 _result
939 }
940
941 pub fn send_no_shutdown_on_err(
943 self,
944 mut result: Result<&State, i32>,
945 ) -> Result<(), fidl::Error> {
946 let _result = self.send_raw(result);
947 self.drop_without_shutdown();
948 _result
949 }
950
951 fn send_raw(&self, mut result: Result<&State, i32>) -> Result<(), fidl::Error> {
952 self.control_handle
953 .inner
954 .send::<fidl::encoding::ResultType<DeviceGetStateAbsoluteResponse, i32>>(
955 result.map(|state| (state,)),
956 self.tx_id,
957 0x1f8ccf01cf526a2b,
958 fidl::encoding::DynamicFlags::empty(),
959 )
960 }
961}
962
963#[must_use = "FIDL methods require a response to be sent"]
964#[derive(Debug)]
965pub struct DeviceSetStateAbsoluteResponder {
966 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
967 tx_id: u32,
968}
969
970impl std::ops::Drop for DeviceSetStateAbsoluteResponder {
974 fn drop(&mut self) {
975 self.control_handle.shutdown();
976 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
978 }
979}
980
981impl fidl::endpoints::Responder for DeviceSetStateAbsoluteResponder {
982 type ControlHandle = DeviceControlHandle;
983
984 fn control_handle(&self) -> &DeviceControlHandle {
985 &self.control_handle
986 }
987
988 fn drop_without_shutdown(mut self) {
989 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
991 std::mem::forget(self);
993 }
994}
995
996impl DeviceSetStateAbsoluteResponder {
997 pub fn send(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1001 let _result = self.send_raw(result);
1002 if _result.is_err() {
1003 self.control_handle.shutdown();
1004 }
1005 self.drop_without_shutdown();
1006 _result
1007 }
1008
1009 pub fn send_no_shutdown_on_err(self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1011 let _result = self.send_raw(result);
1012 self.drop_without_shutdown();
1013 _result
1014 }
1015
1016 fn send_raw(&self, mut result: Result<(), i32>) -> Result<(), fidl::Error> {
1017 self.control_handle
1018 .inner
1019 .send::<fidl::encoding::ResultType<fidl::encoding::EmptyStruct, i32>>(
1020 result,
1021 self.tx_id,
1022 0x19c100c43faaa178,
1023 fidl::encoding::DynamicFlags::empty(),
1024 )
1025 }
1026}
1027
1028#[must_use = "FIDL methods require a response to be sent"]
1029#[derive(Debug)]
1030pub struct DeviceGetMaxAbsoluteBrightnessResponder {
1031 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
1032 tx_id: u32,
1033}
1034
1035impl std::ops::Drop for DeviceGetMaxAbsoluteBrightnessResponder {
1039 fn drop(&mut self) {
1040 self.control_handle.shutdown();
1041 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1043 }
1044}
1045
1046impl fidl::endpoints::Responder for DeviceGetMaxAbsoluteBrightnessResponder {
1047 type ControlHandle = DeviceControlHandle;
1048
1049 fn control_handle(&self) -> &DeviceControlHandle {
1050 &self.control_handle
1051 }
1052
1053 fn drop_without_shutdown(mut self) {
1054 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1056 std::mem::forget(self);
1058 }
1059}
1060
1061impl DeviceGetMaxAbsoluteBrightnessResponder {
1062 pub fn send(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1066 let _result = self.send_raw(result);
1067 if _result.is_err() {
1068 self.control_handle.shutdown();
1069 }
1070 self.drop_without_shutdown();
1071 _result
1072 }
1073
1074 pub fn send_no_shutdown_on_err(self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1076 let _result = self.send_raw(result);
1077 self.drop_without_shutdown();
1078 _result
1079 }
1080
1081 fn send_raw(&self, mut result: Result<f64, i32>) -> Result<(), fidl::Error> {
1082 self.control_handle.inner.send::<fidl::encoding::ResultType<
1083 DeviceGetMaxAbsoluteBrightnessResponse,
1084 i32,
1085 >>(
1086 result.map(|max_brightness| (max_brightness,)),
1087 self.tx_id,
1088 0x2aa0699313d4160d,
1089 fidl::encoding::DynamicFlags::empty(),
1090 )
1091 }
1092}
1093
1094#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1095pub struct ServiceMarker;
1096
1097#[cfg(target_os = "fuchsia")]
1098impl fidl::endpoints::ServiceMarker for ServiceMarker {
1099 type Proxy = ServiceProxy;
1100 type Request = ServiceRequest;
1101 const SERVICE_NAME: &'static str = "fuchsia.hardware.backlight.Service";
1102}
1103
1104#[cfg(target_os = "fuchsia")]
1107pub enum ServiceRequest {
1108 Backlight(DeviceRequestStream),
1109}
1110
1111#[cfg(target_os = "fuchsia")]
1112impl fidl::endpoints::ServiceRequest for ServiceRequest {
1113 type Service = ServiceMarker;
1114
1115 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
1116 match name {
1117 "backlight" => Self::Backlight(
1118 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
1119 ),
1120 _ => panic!("no such member protocol name for service Service"),
1121 }
1122 }
1123
1124 fn member_names() -> &'static [&'static str] {
1125 &["backlight"]
1126 }
1127}
1128#[cfg(target_os = "fuchsia")]
1129pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
1130
1131#[cfg(target_os = "fuchsia")]
1132impl fidl::endpoints::ServiceProxy for ServiceProxy {
1133 type Service = ServiceMarker;
1134
1135 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
1136 Self(opener)
1137 }
1138}
1139
1140#[cfg(target_os = "fuchsia")]
1141impl ServiceProxy {
1142 pub fn connect_to_backlight(&self) -> Result<DeviceProxy, fidl::Error> {
1143 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
1144 self.connect_channel_to_backlight(server_end)?;
1145 Ok(proxy)
1146 }
1147
1148 pub fn connect_to_backlight_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
1151 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
1152 self.connect_channel_to_backlight(server_end)?;
1153 Ok(proxy)
1154 }
1155
1156 pub fn connect_channel_to_backlight(
1159 &self,
1160 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
1161 ) -> Result<(), fidl::Error> {
1162 self.0.open_member("backlight", server_end.into_channel())
1163 }
1164
1165 pub fn instance_name(&self) -> &str {
1166 self.0.instance_name()
1167 }
1168}
1169
1170mod internal {
1171 use super::*;
1172}