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_power_stats_common::*;
11use futures::future::{self, MaybeDone, TryFutureExt};
12use zx_status;
13
14#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
15pub struct DeviceGetEntitiesResponse {
16 pub entities: Vec<Entity>,
17}
18
19impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetEntitiesResponse {}
20
21#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
22pub struct DeviceGetStatsResponse {
23 pub reports: Vec<Stats>,
24}
25
26impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceGetStatsResponse {}
27
28#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
29pub struct DeviceMarker;
30
31impl fidl::endpoints::ProtocolMarker for DeviceMarker {
32 type Proxy = DeviceProxy;
33 type RequestStream = DeviceRequestStream;
34 #[cfg(target_os = "fuchsia")]
35 type SynchronousProxy = DeviceSynchronousProxy;
36
37 const DEBUG_NAME: &'static str = "(anonymous) Device";
38}
39
40pub trait DeviceProxyInterface: Send + Sync {
41 type GetStatsResponseFut: std::future::Future<Output = Result<Vec<Stats>, fidl::Error>> + Send;
42 fn r#get_stats(&self) -> Self::GetStatsResponseFut;
43 type GetEntitiesResponseFut: std::future::Future<Output = Result<Vec<Entity>, fidl::Error>>
44 + Send;
45 fn r#get_entities(&self) -> Self::GetEntitiesResponseFut;
46}
47#[derive(Debug)]
48#[cfg(target_os = "fuchsia")]
49pub struct DeviceSynchronousProxy {
50 client: fidl::client::sync::Client,
51}
52
53#[cfg(target_os = "fuchsia")]
54impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
55 type Proxy = DeviceProxy;
56 type Protocol = DeviceMarker;
57
58 fn from_channel(inner: fidl::Channel) -> Self {
59 Self::new(inner)
60 }
61
62 fn into_channel(self) -> fidl::Channel {
63 self.client.into_channel()
64 }
65
66 fn as_channel(&self) -> &fidl::Channel {
67 self.client.as_channel()
68 }
69}
70
71#[cfg(target_os = "fuchsia")]
72impl DeviceSynchronousProxy {
73 pub fn new(channel: fidl::Channel) -> Self {
74 Self { client: fidl::client::sync::Client::new(channel) }
75 }
76
77 pub fn into_channel(self) -> fidl::Channel {
78 self.client.into_channel()
79 }
80
81 pub fn wait_for_event(
84 &self,
85 deadline: zx::MonotonicInstant,
86 ) -> Result<DeviceEvent, fidl::Error> {
87 DeviceEvent::decode(self.client.wait_for_event::<DeviceMarker>(deadline)?)
88 }
89
90 pub fn r#get_stats(
92 &self,
93 ___deadline: zx::MonotonicInstant,
94 ) -> Result<Vec<Stats>, fidl::Error> {
95 let _response = self.client.send_query::<
96 fidl::encoding::EmptyPayload,
97 fidl::encoding::FlexibleType<DeviceGetStatsResponse>,
98 DeviceMarker,
99 >(
100 (),
101 0x57fe9346ac73f056,
102 fidl::encoding::DynamicFlags::FLEXIBLE,
103 ___deadline,
104 )?
105 .into_result::<DeviceMarker>("get_stats")?;
106 Ok(_response.reports)
107 }
108
109 pub fn r#get_entities(
111 &self,
112 ___deadline: zx::MonotonicInstant,
113 ) -> Result<Vec<Entity>, fidl::Error> {
114 let _response = self.client.send_query::<
115 fidl::encoding::EmptyPayload,
116 fidl::encoding::FlexibleType<DeviceGetEntitiesResponse>,
117 DeviceMarker,
118 >(
119 (),
120 0xc34340e0675de11,
121 fidl::encoding::DynamicFlags::FLEXIBLE,
122 ___deadline,
123 )?
124 .into_result::<DeviceMarker>("get_entities")?;
125 Ok(_response.entities)
126 }
127}
128
129#[cfg(target_os = "fuchsia")]
130impl From<DeviceSynchronousProxy> for zx::NullableHandle {
131 fn from(value: DeviceSynchronousProxy) -> Self {
132 value.into_channel().into()
133 }
134}
135
136#[cfg(target_os = "fuchsia")]
137impl From<fidl::Channel> for DeviceSynchronousProxy {
138 fn from(value: fidl::Channel) -> Self {
139 Self::new(value)
140 }
141}
142
143#[cfg(target_os = "fuchsia")]
144impl fidl::endpoints::FromClient for DeviceSynchronousProxy {
145 type Protocol = DeviceMarker;
146
147 fn from_client(value: fidl::endpoints::ClientEnd<DeviceMarker>) -> Self {
148 Self::new(value.into_channel())
149 }
150}
151
152#[derive(Debug, Clone)]
153pub struct DeviceProxy {
154 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
155}
156
157impl fidl::endpoints::Proxy for DeviceProxy {
158 type Protocol = DeviceMarker;
159
160 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
161 Self::new(inner)
162 }
163
164 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
165 self.client.into_channel().map_err(|client| Self { client })
166 }
167
168 fn as_channel(&self) -> &::fidl::AsyncChannel {
169 self.client.as_channel()
170 }
171}
172
173impl DeviceProxy {
174 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
176 let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
177 Self { client: fidl::client::Client::new(channel, protocol_name) }
178 }
179
180 pub fn take_event_stream(&self) -> DeviceEventStream {
186 DeviceEventStream { event_receiver: self.client.take_event_receiver() }
187 }
188
189 pub fn r#get_stats(
191 &self,
192 ) -> fidl::client::QueryResponseFut<Vec<Stats>, fidl::encoding::DefaultFuchsiaResourceDialect>
193 {
194 DeviceProxyInterface::r#get_stats(self)
195 }
196
197 pub fn r#get_entities(
199 &self,
200 ) -> fidl::client::QueryResponseFut<Vec<Entity>, fidl::encoding::DefaultFuchsiaResourceDialect>
201 {
202 DeviceProxyInterface::r#get_entities(self)
203 }
204}
205
206impl DeviceProxyInterface for DeviceProxy {
207 type GetStatsResponseFut =
208 fidl::client::QueryResponseFut<Vec<Stats>, fidl::encoding::DefaultFuchsiaResourceDialect>;
209 fn r#get_stats(&self) -> Self::GetStatsResponseFut {
210 fn _decode(
211 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
212 ) -> Result<Vec<Stats>, fidl::Error> {
213 let _response = fidl::client::decode_transaction_body::<
214 fidl::encoding::FlexibleType<DeviceGetStatsResponse>,
215 fidl::encoding::DefaultFuchsiaResourceDialect,
216 0x57fe9346ac73f056,
217 >(_buf?)?
218 .into_result::<DeviceMarker>("get_stats")?;
219 Ok(_response.reports)
220 }
221 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Stats>>(
222 (),
223 0x57fe9346ac73f056,
224 fidl::encoding::DynamicFlags::FLEXIBLE,
225 _decode,
226 )
227 }
228
229 type GetEntitiesResponseFut =
230 fidl::client::QueryResponseFut<Vec<Entity>, fidl::encoding::DefaultFuchsiaResourceDialect>;
231 fn r#get_entities(&self) -> Self::GetEntitiesResponseFut {
232 fn _decode(
233 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
234 ) -> Result<Vec<Entity>, fidl::Error> {
235 let _response = fidl::client::decode_transaction_body::<
236 fidl::encoding::FlexibleType<DeviceGetEntitiesResponse>,
237 fidl::encoding::DefaultFuchsiaResourceDialect,
238 0xc34340e0675de11,
239 >(_buf?)?
240 .into_result::<DeviceMarker>("get_entities")?;
241 Ok(_response.entities)
242 }
243 self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<Entity>>(
244 (),
245 0xc34340e0675de11,
246 fidl::encoding::DynamicFlags::FLEXIBLE,
247 _decode,
248 )
249 }
250}
251
252pub struct DeviceEventStream {
253 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
254}
255
256impl std::marker::Unpin for DeviceEventStream {}
257
258impl futures::stream::FusedStream for DeviceEventStream {
259 fn is_terminated(&self) -> bool {
260 self.event_receiver.is_terminated()
261 }
262}
263
264impl futures::Stream for DeviceEventStream {
265 type Item = Result<DeviceEvent, fidl::Error>;
266
267 fn poll_next(
268 mut self: std::pin::Pin<&mut Self>,
269 cx: &mut std::task::Context<'_>,
270 ) -> std::task::Poll<Option<Self::Item>> {
271 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
272 &mut self.event_receiver,
273 cx
274 )?) {
275 Some(buf) => std::task::Poll::Ready(Some(DeviceEvent::decode(buf))),
276 None => std::task::Poll::Ready(None),
277 }
278 }
279}
280
281#[derive(Debug)]
282pub enum DeviceEvent {
283 #[non_exhaustive]
284 _UnknownEvent {
285 ordinal: u64,
287 },
288}
289
290impl DeviceEvent {
291 fn decode(
293 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
294 ) -> Result<DeviceEvent, fidl::Error> {
295 let (bytes, _handles) = buf.split_mut();
296 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
297 debug_assert_eq!(tx_header.tx_id, 0);
298 match tx_header.ordinal {
299 _ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
300 Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
301 }
302 _ => Err(fidl::Error::UnknownOrdinal {
303 ordinal: tx_header.ordinal,
304 protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
305 }),
306 }
307 }
308}
309
310pub struct DeviceRequestStream {
312 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
313 is_terminated: bool,
314}
315
316impl std::marker::Unpin for DeviceRequestStream {}
317
318impl futures::stream::FusedStream for DeviceRequestStream {
319 fn is_terminated(&self) -> bool {
320 self.is_terminated
321 }
322}
323
324impl fidl::endpoints::RequestStream for DeviceRequestStream {
325 type Protocol = DeviceMarker;
326 type ControlHandle = DeviceControlHandle;
327
328 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
329 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
330 }
331
332 fn control_handle(&self) -> Self::ControlHandle {
333 DeviceControlHandle { inner: self.inner.clone() }
334 }
335
336 fn into_inner(
337 self,
338 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
339 {
340 (self.inner, self.is_terminated)
341 }
342
343 fn from_inner(
344 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
345 is_terminated: bool,
346 ) -> Self {
347 Self { inner, is_terminated }
348 }
349}
350
351impl futures::Stream for DeviceRequestStream {
352 type Item = Result<DeviceRequest, fidl::Error>;
353
354 fn poll_next(
355 mut self: std::pin::Pin<&mut Self>,
356 cx: &mut std::task::Context<'_>,
357 ) -> std::task::Poll<Option<Self::Item>> {
358 let this = &mut *self;
359 if this.inner.check_shutdown(cx) {
360 this.is_terminated = true;
361 return std::task::Poll::Ready(None);
362 }
363 if this.is_terminated {
364 panic!("polled DeviceRequestStream after completion");
365 }
366 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
367 |bytes, handles| {
368 match this.inner.channel().read_etc(cx, bytes, handles) {
369 std::task::Poll::Ready(Ok(())) => {}
370 std::task::Poll::Pending => return std::task::Poll::Pending,
371 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
372 this.is_terminated = true;
373 return std::task::Poll::Ready(None);
374 }
375 std::task::Poll::Ready(Err(e)) => {
376 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
377 e.into(),
378 ))));
379 }
380 }
381
382 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
384
385 std::task::Poll::Ready(Some(match header.ordinal {
386 0x57fe9346ac73f056 => {
387 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
388 let mut req = fidl::new_empty!(
389 fidl::encoding::EmptyPayload,
390 fidl::encoding::DefaultFuchsiaResourceDialect
391 );
392 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
393 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
394 Ok(DeviceRequest::GetStats {
395 responder: DeviceGetStatsResponder {
396 control_handle: std::mem::ManuallyDrop::new(control_handle),
397 tx_id: header.tx_id,
398 },
399 })
400 }
401 0xc34340e0675de11 => {
402 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
403 let mut req = fidl::new_empty!(
404 fidl::encoding::EmptyPayload,
405 fidl::encoding::DefaultFuchsiaResourceDialect
406 );
407 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
408 let control_handle = DeviceControlHandle { inner: this.inner.clone() };
409 Ok(DeviceRequest::GetEntities {
410 responder: DeviceGetEntitiesResponder {
411 control_handle: std::mem::ManuallyDrop::new(control_handle),
412 tx_id: header.tx_id,
413 },
414 })
415 }
416 _ if header.tx_id == 0
417 && header
418 .dynamic_flags()
419 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
420 {
421 Ok(DeviceRequest::_UnknownMethod {
422 ordinal: header.ordinal,
423 control_handle: DeviceControlHandle { inner: this.inner.clone() },
424 method_type: fidl::MethodType::OneWay,
425 })
426 }
427 _ if header
428 .dynamic_flags()
429 .contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
430 {
431 this.inner.send_framework_err(
432 fidl::encoding::FrameworkErr::UnknownMethod,
433 header.tx_id,
434 header.ordinal,
435 header.dynamic_flags(),
436 (bytes, handles),
437 )?;
438 Ok(DeviceRequest::_UnknownMethod {
439 ordinal: header.ordinal,
440 control_handle: DeviceControlHandle { inner: this.inner.clone() },
441 method_type: fidl::MethodType::TwoWay,
442 })
443 }
444 _ => Err(fidl::Error::UnknownOrdinal {
445 ordinal: header.ordinal,
446 protocol_name:
447 <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
448 }),
449 }))
450 },
451 )
452 }
453}
454
455#[derive(Debug)]
456pub enum DeviceRequest {
457 GetStats { responder: DeviceGetStatsResponder },
459 GetEntities { responder: DeviceGetEntitiesResponder },
461 #[non_exhaustive]
463 _UnknownMethod {
464 ordinal: u64,
466 control_handle: DeviceControlHandle,
467 method_type: fidl::MethodType,
468 },
469}
470
471impl DeviceRequest {
472 #[allow(irrefutable_let_patterns)]
473 pub fn into_get_stats(self) -> Option<(DeviceGetStatsResponder)> {
474 if let DeviceRequest::GetStats { responder } = self { Some((responder)) } else { None }
475 }
476
477 #[allow(irrefutable_let_patterns)]
478 pub fn into_get_entities(self) -> Option<(DeviceGetEntitiesResponder)> {
479 if let DeviceRequest::GetEntities { responder } = self { Some((responder)) } else { None }
480 }
481
482 pub fn method_name(&self) -> &'static str {
484 match *self {
485 DeviceRequest::GetStats { .. } => "get_stats",
486 DeviceRequest::GetEntities { .. } => "get_entities",
487 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
488 "unknown one-way method"
489 }
490 DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
491 "unknown two-way method"
492 }
493 }
494 }
495}
496
497#[derive(Debug, Clone)]
498pub struct DeviceControlHandle {
499 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
500}
501
502impl DeviceControlHandle {
503 pub fn shutdown_with_epitaph(&self, status: impl Into<fidl::Epitaph>) {
504 self.inner.shutdown_with_epitaph(status.into())
505 }
506}
507
508impl fidl::endpoints::ControlHandle for DeviceControlHandle {
509 fn shutdown(&self) {
510 self.inner.shutdown()
511 }
512
513 fn shutdown_with_epitaph(&self, status: fidl::Epitaph) {
514 self.inner.shutdown_with_epitaph(status)
515 }
516
517 fn is_closed(&self) -> bool {
518 self.inner.channel().is_closed()
519 }
520 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
521 self.inner.channel().on_closed()
522 }
523
524 #[cfg(target_os = "fuchsia")]
525 fn signal_peer(
526 &self,
527 clear_mask: zx::Signals,
528 set_mask: zx::Signals,
529 ) -> Result<(), zx_status::Status> {
530 use fidl::Peered;
531 self.inner.channel().signal_peer(clear_mask, set_mask)
532 }
533}
534
535impl DeviceControlHandle {}
536
537#[must_use = "FIDL methods require a response to be sent"]
538#[derive(Debug)]
539pub struct DeviceGetStatsResponder {
540 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
541 tx_id: u32,
542}
543
544impl std::ops::Drop for DeviceGetStatsResponder {
548 fn drop(&mut self) {
549 self.control_handle.shutdown();
550 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
552 }
553}
554
555impl fidl::endpoints::Responder for DeviceGetStatsResponder {
556 type ControlHandle = DeviceControlHandle;
557
558 fn control_handle(&self) -> &DeviceControlHandle {
559 &self.control_handle
560 }
561
562 fn drop_without_shutdown(mut self) {
563 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
565 std::mem::forget(self);
567 }
568}
569
570impl DeviceGetStatsResponder {
571 pub fn send(self, mut reports: &[Stats]) -> Result<(), fidl::Error> {
575 let _result = self.send_raw(reports);
576 if _result.is_err() {
577 self.control_handle.shutdown();
578 }
579 self.drop_without_shutdown();
580 _result
581 }
582
583 pub fn send_no_shutdown_on_err(self, mut reports: &[Stats]) -> Result<(), fidl::Error> {
585 let _result = self.send_raw(reports);
586 self.drop_without_shutdown();
587 _result
588 }
589
590 fn send_raw(&self, mut reports: &[Stats]) -> Result<(), fidl::Error> {
591 self.control_handle.inner.send::<fidl::encoding::FlexibleType<DeviceGetStatsResponse>>(
592 fidl::encoding::Flexible::new((reports,)),
593 self.tx_id,
594 0x57fe9346ac73f056,
595 fidl::encoding::DynamicFlags::FLEXIBLE,
596 )
597 }
598}
599
600#[must_use = "FIDL methods require a response to be sent"]
601#[derive(Debug)]
602pub struct DeviceGetEntitiesResponder {
603 control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
604 tx_id: u32,
605}
606
607impl std::ops::Drop for DeviceGetEntitiesResponder {
611 fn drop(&mut self) {
612 self.control_handle.shutdown();
613 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
615 }
616}
617
618impl fidl::endpoints::Responder for DeviceGetEntitiesResponder {
619 type ControlHandle = DeviceControlHandle;
620
621 fn control_handle(&self) -> &DeviceControlHandle {
622 &self.control_handle
623 }
624
625 fn drop_without_shutdown(mut self) {
626 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
628 std::mem::forget(self);
630 }
631}
632
633impl DeviceGetEntitiesResponder {
634 pub fn send(self, mut entities: &[Entity]) -> Result<(), fidl::Error> {
638 let _result = self.send_raw(entities);
639 if _result.is_err() {
640 self.control_handle.shutdown();
641 }
642 self.drop_without_shutdown();
643 _result
644 }
645
646 pub fn send_no_shutdown_on_err(self, mut entities: &[Entity]) -> Result<(), fidl::Error> {
648 let _result = self.send_raw(entities);
649 self.drop_without_shutdown();
650 _result
651 }
652
653 fn send_raw(&self, mut entities: &[Entity]) -> Result<(), fidl::Error> {
654 self.control_handle.inner.send::<fidl::encoding::FlexibleType<DeviceGetEntitiesResponse>>(
655 fidl::encoding::Flexible::new((entities,)),
656 self.tx_id,
657 0xc34340e0675de11,
658 fidl::encoding::DynamicFlags::FLEXIBLE,
659 )
660 }
661}
662
663#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
664pub struct ServiceMarker;
665
666#[cfg(target_os = "fuchsia")]
667impl fidl::endpoints::ServiceMarker for ServiceMarker {
668 type Proxy = ServiceProxy;
669 type Request = ServiceRequest;
670 const SERVICE_NAME: &'static str = "fuchsia.hardware.power.stats.Service";
671}
672
673#[cfg(target_os = "fuchsia")]
676pub enum ServiceRequest {
677 Device(DeviceRequestStream),
678}
679
680#[cfg(target_os = "fuchsia")]
681impl fidl::endpoints::ServiceRequest for ServiceRequest {
682 type Service = ServiceMarker;
683
684 fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
685 match name {
686 "device" => Self::Device(
687 <DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
688 ),
689 _ => panic!("no such member protocol name for service Service"),
690 }
691 }
692
693 fn member_names() -> &'static [&'static str] {
694 &["device"]
695 }
696}
697#[cfg(target_os = "fuchsia")]
698pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
699
700#[cfg(target_os = "fuchsia")]
701impl fidl::endpoints::ServiceProxy for ServiceProxy {
702 type Service = ServiceMarker;
703
704 fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
705 Self(opener)
706 }
707}
708
709#[cfg(target_os = "fuchsia")]
710impl ServiceProxy {
711 pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
712 let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
713 self.connect_channel_to_device(server_end)?;
714 Ok(proxy)
715 }
716
717 pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
720 let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
721 self.connect_channel_to_device(server_end)?;
722 Ok(proxy)
723 }
724
725 pub fn connect_channel_to_device(
728 &self,
729 server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
730 ) -> Result<(), fidl::Error> {
731 self.0.open_member("device", server_end.into_channel())
732 }
733
734 pub fn instance_name(&self) -> &str {
735 self.0.instance_name()
736 }
737}
738
739mod internal {
740 use super::*;
741
742 impl fidl::encoding::ResourceTypeMarker for DeviceGetEntitiesResponse {
743 type Borrowed<'a> = &'a mut Self;
744 fn take_or_borrow<'a>(
745 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
746 ) -> Self::Borrowed<'a> {
747 value
748 }
749 }
750
751 unsafe impl fidl::encoding::TypeMarker for DeviceGetEntitiesResponse {
752 type Owned = Self;
753
754 #[inline(always)]
755 fn inline_align(_context: fidl::encoding::Context) -> usize {
756 8
757 }
758
759 #[inline(always)]
760 fn inline_size(_context: fidl::encoding::Context) -> usize {
761 16
762 }
763 }
764
765 unsafe impl
766 fidl::encoding::Encode<
767 DeviceGetEntitiesResponse,
768 fidl::encoding::DefaultFuchsiaResourceDialect,
769 > for &mut DeviceGetEntitiesResponse
770 {
771 #[inline]
772 unsafe fn encode(
773 self,
774 encoder: &mut fidl::encoding::Encoder<
775 '_,
776 fidl::encoding::DefaultFuchsiaResourceDialect,
777 >,
778 offset: usize,
779 _depth: fidl::encoding::Depth,
780 ) -> fidl::Result<()> {
781 encoder.debug_check_bounds::<DeviceGetEntitiesResponse>(offset);
782 fidl::encoding::Encode::<DeviceGetEntitiesResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
784 (
785 <fidl::encoding::UnboundedVector<Entity> as fidl::encoding::ValueTypeMarker>::borrow(&self.entities),
786 ),
787 encoder, offset, _depth
788 )
789 }
790 }
791 unsafe impl<
792 T0: fidl::encoding::Encode<
793 fidl::encoding::UnboundedVector<Entity>,
794 fidl::encoding::DefaultFuchsiaResourceDialect,
795 >,
796 >
797 fidl::encoding::Encode<
798 DeviceGetEntitiesResponse,
799 fidl::encoding::DefaultFuchsiaResourceDialect,
800 > for (T0,)
801 {
802 #[inline]
803 unsafe fn encode(
804 self,
805 encoder: &mut fidl::encoding::Encoder<
806 '_,
807 fidl::encoding::DefaultFuchsiaResourceDialect,
808 >,
809 offset: usize,
810 depth: fidl::encoding::Depth,
811 ) -> fidl::Result<()> {
812 encoder.debug_check_bounds::<DeviceGetEntitiesResponse>(offset);
813 self.0.encode(encoder, offset + 0, depth)?;
817 Ok(())
818 }
819 }
820
821 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
822 for DeviceGetEntitiesResponse
823 {
824 #[inline(always)]
825 fn new_empty() -> Self {
826 Self {
827 entities: fidl::new_empty!(
828 fidl::encoding::UnboundedVector<Entity>,
829 fidl::encoding::DefaultFuchsiaResourceDialect
830 ),
831 }
832 }
833
834 #[inline]
835 unsafe fn decode(
836 &mut self,
837 decoder: &mut fidl::encoding::Decoder<
838 '_,
839 fidl::encoding::DefaultFuchsiaResourceDialect,
840 >,
841 offset: usize,
842 _depth: fidl::encoding::Depth,
843 ) -> fidl::Result<()> {
844 decoder.debug_check_bounds::<Self>(offset);
845 fidl::decode!(
847 fidl::encoding::UnboundedVector<Entity>,
848 fidl::encoding::DefaultFuchsiaResourceDialect,
849 &mut self.entities,
850 decoder,
851 offset + 0,
852 _depth
853 )?;
854 Ok(())
855 }
856 }
857
858 impl fidl::encoding::ResourceTypeMarker for DeviceGetStatsResponse {
859 type Borrowed<'a> = &'a mut Self;
860 fn take_or_borrow<'a>(
861 value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
862 ) -> Self::Borrowed<'a> {
863 value
864 }
865 }
866
867 unsafe impl fidl::encoding::TypeMarker for DeviceGetStatsResponse {
868 type Owned = Self;
869
870 #[inline(always)]
871 fn inline_align(_context: fidl::encoding::Context) -> usize {
872 8
873 }
874
875 #[inline(always)]
876 fn inline_size(_context: fidl::encoding::Context) -> usize {
877 16
878 }
879 }
880
881 unsafe impl
882 fidl::encoding::Encode<
883 DeviceGetStatsResponse,
884 fidl::encoding::DefaultFuchsiaResourceDialect,
885 > for &mut DeviceGetStatsResponse
886 {
887 #[inline]
888 unsafe fn encode(
889 self,
890 encoder: &mut fidl::encoding::Encoder<
891 '_,
892 fidl::encoding::DefaultFuchsiaResourceDialect,
893 >,
894 offset: usize,
895 _depth: fidl::encoding::Depth,
896 ) -> fidl::Result<()> {
897 encoder.debug_check_bounds::<DeviceGetStatsResponse>(offset);
898 fidl::encoding::Encode::<DeviceGetStatsResponse, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
900 (
901 <fidl::encoding::UnboundedVector<Stats> as fidl::encoding::ValueTypeMarker>::borrow(&self.reports),
902 ),
903 encoder, offset, _depth
904 )
905 }
906 }
907 unsafe impl<
908 T0: fidl::encoding::Encode<
909 fidl::encoding::UnboundedVector<Stats>,
910 fidl::encoding::DefaultFuchsiaResourceDialect,
911 >,
912 >
913 fidl::encoding::Encode<
914 DeviceGetStatsResponse,
915 fidl::encoding::DefaultFuchsiaResourceDialect,
916 > for (T0,)
917 {
918 #[inline]
919 unsafe fn encode(
920 self,
921 encoder: &mut fidl::encoding::Encoder<
922 '_,
923 fidl::encoding::DefaultFuchsiaResourceDialect,
924 >,
925 offset: usize,
926 depth: fidl::encoding::Depth,
927 ) -> fidl::Result<()> {
928 encoder.debug_check_bounds::<DeviceGetStatsResponse>(offset);
929 self.0.encode(encoder, offset + 0, depth)?;
933 Ok(())
934 }
935 }
936
937 impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
938 for DeviceGetStatsResponse
939 {
940 #[inline(always)]
941 fn new_empty() -> Self {
942 Self {
943 reports: fidl::new_empty!(
944 fidl::encoding::UnboundedVector<Stats>,
945 fidl::encoding::DefaultFuchsiaResourceDialect
946 ),
947 }
948 }
949
950 #[inline]
951 unsafe fn decode(
952 &mut self,
953 decoder: &mut fidl::encoding::Decoder<
954 '_,
955 fidl::encoding::DefaultFuchsiaResourceDialect,
956 >,
957 offset: usize,
958 _depth: fidl::encoding::Depth,
959 ) -> fidl::Result<()> {
960 decoder.debug_check_bounds::<Self>(offset);
961 fidl::decode!(
963 fidl::encoding::UnboundedVector<Stats>,
964 fidl::encoding::DefaultFuchsiaResourceDialect,
965 &mut self.reports,
966 decoder,
967 offset + 0,
968 _depth
969 )?;
970 Ok(())
971 }
972 }
973}