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