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 _};
10use futures::future::{self, MaybeDone, TryFutureExt};
11use zx_status;
12
13pub type ClientId = String;
14
15#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
19#[repr(u32)]
20pub enum RecorderError {
21 NoDrivers = 1,
23 InvalidSamplingInterval = 2,
25 AlreadyLogging = 3,
28 DuplicatedMetric = 4,
30 TooManyActiveClients = 5,
34 InvalidStatisticsInterval = 6,
37 Internal = 7,
39}
40
41impl RecorderError {
42 #[inline]
43 pub fn from_primitive(prim: u32) -> Option<Self> {
44 match prim {
45 1 => Some(Self::NoDrivers),
46 2 => Some(Self::InvalidSamplingInterval),
47 3 => Some(Self::AlreadyLogging),
48 4 => Some(Self::DuplicatedMetric),
49 5 => Some(Self::TooManyActiveClients),
50 6 => Some(Self::InvalidStatisticsInterval),
51 7 => Some(Self::Internal),
52 _ => None,
53 }
54 }
55
56 #[inline]
57 pub const fn into_primitive(self) -> u32 {
58 self as u32
59 }
60
61 #[deprecated = "Strict enums should not use `is_unknown`"]
62 #[inline]
63 pub fn is_unknown(&self) -> bool {
64 false
65 }
66}
67
68#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
70#[repr(C)]
71pub struct CpuLoad {
72 pub interval_ms: u32,
77}
78
79impl fidl::Persistable for CpuLoad {}
80
81#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
83#[repr(C)]
84pub struct GpuUsage {
85 pub interval_ms: u32,
90}
91
92impl fidl::Persistable for GpuUsage {}
93
94#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
96#[repr(C)]
97pub struct NetworkActivity {
98 pub interval_ms: u32,
103}
104
105impl fidl::Persistable for NetworkActivity {}
106
107#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
109pub struct Power {
110 pub sampling_interval_ms: u32,
115 pub statistics_args: Option<Box<StatisticsArgs>>,
117}
118
119impl fidl::Persistable for Power {}
120
121#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
122pub struct RecorderStartLoggingForeverRequest {
123 pub client_id: String,
124 pub metrics: Vec<Metric>,
125 pub output_samples_to_syslog: bool,
126 pub output_stats_to_syslog: bool,
127}
128
129impl fidl::Persistable for RecorderStartLoggingForeverRequest {}
130
131#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
132pub struct RecorderStartLoggingRequest {
133 pub client_id: String,
134 pub metrics: Vec<Metric>,
135 pub duration_ms: u32,
136 pub output_samples_to_syslog: bool,
137 pub output_stats_to_syslog: bool,
138}
139
140impl fidl::Persistable for RecorderStartLoggingRequest {}
141
142#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
143pub struct RecorderStopLoggingRequest {
144 pub client_id: String,
145}
146
147impl fidl::Persistable for RecorderStopLoggingRequest {}
148
149#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
150pub struct RecorderStopLoggingResponse {
151 pub stopped: bool,
152}
153
154impl fidl::Persistable for RecorderStopLoggingResponse {}
155
156#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
157#[repr(C)]
158pub struct StatisticsArgs {
159 pub statistics_interval_ms: u32,
166}
167
168impl fidl::Persistable for StatisticsArgs {}
169
170#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
172pub struct Temperature {
173 pub sampling_interval_ms: u32,
178 pub statistics_args: Option<Box<StatisticsArgs>>,
180}
181
182impl fidl::Persistable for Temperature {}
183
184#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
186pub enum Metric {
187 Temperature(Temperature),
188 CpuLoad(CpuLoad),
189 Power(Power),
190 GpuUsage(GpuUsage),
191 NetworkActivity(NetworkActivity),
192}
193
194impl Metric {
195 #[inline]
196 pub fn ordinal(&self) -> u64 {
197 match *self {
198 Self::Temperature(_) => 1,
199 Self::CpuLoad(_) => 2,
200 Self::Power(_) => 3,
201 Self::GpuUsage(_) => 4,
202 Self::NetworkActivity(_) => 5,
203 }
204 }
205
206 #[deprecated = "Strict unions should not use `is_unknown`"]
207 #[inline]
208 pub fn is_unknown(&self) -> bool {
209 false
210 }
211}
212
213impl fidl::Persistable for Metric {}
214
215#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
216pub struct RecorderMarker;
217
218impl fidl::endpoints::ProtocolMarker for RecorderMarker {
219 type Proxy = RecorderProxy;
220 type RequestStream = RecorderRequestStream;
221 #[cfg(target_os = "fuchsia")]
222 type SynchronousProxy = RecorderSynchronousProxy;
223
224 const DEBUG_NAME: &'static str = "fuchsia.power.metrics.Recorder";
225}
226impl fidl::endpoints::DiscoverableProtocolMarker for RecorderMarker {}
227pub type RecorderStartLoggingResult = Result<(), RecorderError>;
228pub type RecorderStartLoggingForeverResult = Result<(), RecorderError>;
229
230pub trait RecorderProxyInterface: Send + Sync {
231 type StartLoggingResponseFut: std::future::Future<Output = Result<RecorderStartLoggingResult, fidl::Error>>
232 + Send;
233 fn r#start_logging(
234 &self,
235 client_id: &str,
236 metrics: &[Metric],
237 duration_ms: u32,
238 output_samples_to_syslog: bool,
239 output_stats_to_syslog: bool,
240 ) -> Self::StartLoggingResponseFut;
241 type StartLoggingForeverResponseFut: std::future::Future<Output = Result<RecorderStartLoggingForeverResult, fidl::Error>>
242 + Send;
243 fn r#start_logging_forever(
244 &self,
245 client_id: &str,
246 metrics: &[Metric],
247 output_samples_to_syslog: bool,
248 output_stats_to_syslog: bool,
249 ) -> Self::StartLoggingForeverResponseFut;
250 type StopLoggingResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
251 fn r#stop_logging(&self, client_id: &str) -> Self::StopLoggingResponseFut;
252}
253#[derive(Debug)]
254#[cfg(target_os = "fuchsia")]
255pub struct RecorderSynchronousProxy {
256 client: fidl::client::sync::Client,
257}
258
259#[cfg(target_os = "fuchsia")]
260impl fidl::endpoints::SynchronousProxy for RecorderSynchronousProxy {
261 type Proxy = RecorderProxy;
262 type Protocol = RecorderMarker;
263
264 fn from_channel(inner: fidl::Channel) -> Self {
265 Self::new(inner)
266 }
267
268 fn into_channel(self) -> fidl::Channel {
269 self.client.into_channel()
270 }
271
272 fn as_channel(&self) -> &fidl::Channel {
273 self.client.as_channel()
274 }
275}
276
277#[cfg(target_os = "fuchsia")]
278impl RecorderSynchronousProxy {
279 pub fn new(channel: fidl::Channel) -> Self {
280 let protocol_name = <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
281 Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
282 }
283
284 pub fn into_channel(self) -> fidl::Channel {
285 self.client.into_channel()
286 }
287
288 pub fn wait_for_event(
291 &self,
292 deadline: zx::MonotonicInstant,
293 ) -> Result<RecorderEvent, fidl::Error> {
294 RecorderEvent::decode(self.client.wait_for_event(deadline)?)
295 }
296
297 pub fn r#start_logging(
318 &self,
319 mut client_id: &str,
320 mut metrics: &[Metric],
321 mut duration_ms: u32,
322 mut output_samples_to_syslog: bool,
323 mut output_stats_to_syslog: bool,
324 ___deadline: zx::MonotonicInstant,
325 ) -> Result<RecorderStartLoggingResult, fidl::Error> {
326 let _response = self.client.send_query::<
327 RecorderStartLoggingRequest,
328 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
329 >(
330 (client_id, metrics, duration_ms, output_samples_to_syslog, output_stats_to_syslog,),
331 0x40e4e1a9c6c42bd2,
332 fidl::encoding::DynamicFlags::empty(),
333 ___deadline,
334 )?;
335 Ok(_response.map(|x| x))
336 }
337
338 pub fn r#start_logging_forever(
354 &self,
355 mut client_id: &str,
356 mut metrics: &[Metric],
357 mut output_samples_to_syslog: bool,
358 mut output_stats_to_syslog: bool,
359 ___deadline: zx::MonotonicInstant,
360 ) -> Result<RecorderStartLoggingForeverResult, fidl::Error> {
361 let _response = self.client.send_query::<
362 RecorderStartLoggingForeverRequest,
363 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
364 >(
365 (client_id, metrics, output_samples_to_syslog, output_stats_to_syslog,),
366 0x37b2675fdc61ff94,
367 fidl::encoding::DynamicFlags::empty(),
368 ___deadline,
369 )?;
370 Ok(_response.map(|x| x))
371 }
372
373 pub fn r#stop_logging(
380 &self,
381 mut client_id: &str,
382 ___deadline: zx::MonotonicInstant,
383 ) -> Result<bool, fidl::Error> {
384 let _response =
385 self.client.send_query::<RecorderStopLoggingRequest, RecorderStopLoggingResponse>(
386 (client_id,),
387 0x615d67a4d94d4732,
388 fidl::encoding::DynamicFlags::empty(),
389 ___deadline,
390 )?;
391 Ok(_response.stopped)
392 }
393}
394
395#[derive(Debug, Clone)]
396pub struct RecorderProxy {
397 client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
398}
399
400impl fidl::endpoints::Proxy for RecorderProxy {
401 type Protocol = RecorderMarker;
402
403 fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
404 Self::new(inner)
405 }
406
407 fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
408 self.client.into_channel().map_err(|client| Self { client })
409 }
410
411 fn as_channel(&self) -> &::fidl::AsyncChannel {
412 self.client.as_channel()
413 }
414}
415
416impl RecorderProxy {
417 pub fn new(channel: ::fidl::AsyncChannel) -> Self {
419 let protocol_name = <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
420 Self { client: fidl::client::Client::new(channel, protocol_name) }
421 }
422
423 pub fn take_event_stream(&self) -> RecorderEventStream {
429 RecorderEventStream { event_receiver: self.client.take_event_receiver() }
430 }
431
432 pub fn r#start_logging(
453 &self,
454 mut client_id: &str,
455 mut metrics: &[Metric],
456 mut duration_ms: u32,
457 mut output_samples_to_syslog: bool,
458 mut output_stats_to_syslog: bool,
459 ) -> fidl::client::QueryResponseFut<
460 RecorderStartLoggingResult,
461 fidl::encoding::DefaultFuchsiaResourceDialect,
462 > {
463 RecorderProxyInterface::r#start_logging(
464 self,
465 client_id,
466 metrics,
467 duration_ms,
468 output_samples_to_syslog,
469 output_stats_to_syslog,
470 )
471 }
472
473 pub fn r#start_logging_forever(
489 &self,
490 mut client_id: &str,
491 mut metrics: &[Metric],
492 mut output_samples_to_syslog: bool,
493 mut output_stats_to_syslog: bool,
494 ) -> fidl::client::QueryResponseFut<
495 RecorderStartLoggingForeverResult,
496 fidl::encoding::DefaultFuchsiaResourceDialect,
497 > {
498 RecorderProxyInterface::r#start_logging_forever(
499 self,
500 client_id,
501 metrics,
502 output_samples_to_syslog,
503 output_stats_to_syslog,
504 )
505 }
506
507 pub fn r#stop_logging(
514 &self,
515 mut client_id: &str,
516 ) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
517 RecorderProxyInterface::r#stop_logging(self, client_id)
518 }
519}
520
521impl RecorderProxyInterface for RecorderProxy {
522 type StartLoggingResponseFut = fidl::client::QueryResponseFut<
523 RecorderStartLoggingResult,
524 fidl::encoding::DefaultFuchsiaResourceDialect,
525 >;
526 fn r#start_logging(
527 &self,
528 mut client_id: &str,
529 mut metrics: &[Metric],
530 mut duration_ms: u32,
531 mut output_samples_to_syslog: bool,
532 mut output_stats_to_syslog: bool,
533 ) -> Self::StartLoggingResponseFut {
534 fn _decode(
535 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
536 ) -> Result<RecorderStartLoggingResult, fidl::Error> {
537 let _response = fidl::client::decode_transaction_body::<
538 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
539 fidl::encoding::DefaultFuchsiaResourceDialect,
540 0x40e4e1a9c6c42bd2,
541 >(_buf?)?;
542 Ok(_response.map(|x| x))
543 }
544 self.client
545 .send_query_and_decode::<RecorderStartLoggingRequest, RecorderStartLoggingResult>(
546 (client_id, metrics, duration_ms, output_samples_to_syslog, output_stats_to_syslog),
547 0x40e4e1a9c6c42bd2,
548 fidl::encoding::DynamicFlags::empty(),
549 _decode,
550 )
551 }
552
553 type StartLoggingForeverResponseFut = fidl::client::QueryResponseFut<
554 RecorderStartLoggingForeverResult,
555 fidl::encoding::DefaultFuchsiaResourceDialect,
556 >;
557 fn r#start_logging_forever(
558 &self,
559 mut client_id: &str,
560 mut metrics: &[Metric],
561 mut output_samples_to_syslog: bool,
562 mut output_stats_to_syslog: bool,
563 ) -> Self::StartLoggingForeverResponseFut {
564 fn _decode(
565 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
566 ) -> Result<RecorderStartLoggingForeverResult, fidl::Error> {
567 let _response = fidl::client::decode_transaction_body::<
568 fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
569 fidl::encoding::DefaultFuchsiaResourceDialect,
570 0x37b2675fdc61ff94,
571 >(_buf?)?;
572 Ok(_response.map(|x| x))
573 }
574 self.client.send_query_and_decode::<
575 RecorderStartLoggingForeverRequest,
576 RecorderStartLoggingForeverResult,
577 >(
578 (client_id, metrics, output_samples_to_syslog, output_stats_to_syslog,),
579 0x37b2675fdc61ff94,
580 fidl::encoding::DynamicFlags::empty(),
581 _decode,
582 )
583 }
584
585 type StopLoggingResponseFut =
586 fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
587 fn r#stop_logging(&self, mut client_id: &str) -> Self::StopLoggingResponseFut {
588 fn _decode(
589 mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
590 ) -> Result<bool, fidl::Error> {
591 let _response = fidl::client::decode_transaction_body::<
592 RecorderStopLoggingResponse,
593 fidl::encoding::DefaultFuchsiaResourceDialect,
594 0x615d67a4d94d4732,
595 >(_buf?)?;
596 Ok(_response.stopped)
597 }
598 self.client.send_query_and_decode::<RecorderStopLoggingRequest, bool>(
599 (client_id,),
600 0x615d67a4d94d4732,
601 fidl::encoding::DynamicFlags::empty(),
602 _decode,
603 )
604 }
605}
606
607pub struct RecorderEventStream {
608 event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
609}
610
611impl std::marker::Unpin for RecorderEventStream {}
612
613impl futures::stream::FusedStream for RecorderEventStream {
614 fn is_terminated(&self) -> bool {
615 self.event_receiver.is_terminated()
616 }
617}
618
619impl futures::Stream for RecorderEventStream {
620 type Item = Result<RecorderEvent, fidl::Error>;
621
622 fn poll_next(
623 mut self: std::pin::Pin<&mut Self>,
624 cx: &mut std::task::Context<'_>,
625 ) -> std::task::Poll<Option<Self::Item>> {
626 match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
627 &mut self.event_receiver,
628 cx
629 )?) {
630 Some(buf) => std::task::Poll::Ready(Some(RecorderEvent::decode(buf))),
631 None => std::task::Poll::Ready(None),
632 }
633 }
634}
635
636#[derive(Debug)]
637pub enum RecorderEvent {}
638
639impl RecorderEvent {
640 fn decode(
642 mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
643 ) -> Result<RecorderEvent, fidl::Error> {
644 let (bytes, _handles) = buf.split_mut();
645 let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
646 debug_assert_eq!(tx_header.tx_id, 0);
647 match tx_header.ordinal {
648 _ => Err(fidl::Error::UnknownOrdinal {
649 ordinal: tx_header.ordinal,
650 protocol_name: <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
651 }),
652 }
653 }
654}
655
656pub struct RecorderRequestStream {
658 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
659 is_terminated: bool,
660}
661
662impl std::marker::Unpin for RecorderRequestStream {}
663
664impl futures::stream::FusedStream for RecorderRequestStream {
665 fn is_terminated(&self) -> bool {
666 self.is_terminated
667 }
668}
669
670impl fidl::endpoints::RequestStream for RecorderRequestStream {
671 type Protocol = RecorderMarker;
672 type ControlHandle = RecorderControlHandle;
673
674 fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
675 Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
676 }
677
678 fn control_handle(&self) -> Self::ControlHandle {
679 RecorderControlHandle { inner: self.inner.clone() }
680 }
681
682 fn into_inner(
683 self,
684 ) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
685 {
686 (self.inner, self.is_terminated)
687 }
688
689 fn from_inner(
690 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
691 is_terminated: bool,
692 ) -> Self {
693 Self { inner, is_terminated }
694 }
695}
696
697impl futures::Stream for RecorderRequestStream {
698 type Item = Result<RecorderRequest, fidl::Error>;
699
700 fn poll_next(
701 mut self: std::pin::Pin<&mut Self>,
702 cx: &mut std::task::Context<'_>,
703 ) -> std::task::Poll<Option<Self::Item>> {
704 let this = &mut *self;
705 if this.inner.check_shutdown(cx) {
706 this.is_terminated = true;
707 return std::task::Poll::Ready(None);
708 }
709 if this.is_terminated {
710 panic!("polled RecorderRequestStream after completion");
711 }
712 fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
713 |bytes, handles| {
714 match this.inner.channel().read_etc(cx, bytes, handles) {
715 std::task::Poll::Ready(Ok(())) => {}
716 std::task::Poll::Pending => return std::task::Poll::Pending,
717 std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
718 this.is_terminated = true;
719 return std::task::Poll::Ready(None);
720 }
721 std::task::Poll::Ready(Err(e)) => {
722 return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
723 e.into(),
724 ))))
725 }
726 }
727
728 let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
730
731 std::task::Poll::Ready(Some(match header.ordinal {
732 0x40e4e1a9c6c42bd2 => {
733 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
734 let mut req = fidl::new_empty!(
735 RecorderStartLoggingRequest,
736 fidl::encoding::DefaultFuchsiaResourceDialect
737 );
738 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecorderStartLoggingRequest>(&header, _body_bytes, handles, &mut req)?;
739 let control_handle = RecorderControlHandle { inner: this.inner.clone() };
740 Ok(RecorderRequest::StartLogging {
741 client_id: req.client_id,
742 metrics: req.metrics,
743 duration_ms: req.duration_ms,
744 output_samples_to_syslog: req.output_samples_to_syslog,
745 output_stats_to_syslog: req.output_stats_to_syslog,
746
747 responder: RecorderStartLoggingResponder {
748 control_handle: std::mem::ManuallyDrop::new(control_handle),
749 tx_id: header.tx_id,
750 },
751 })
752 }
753 0x37b2675fdc61ff94 => {
754 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
755 let mut req = fidl::new_empty!(
756 RecorderStartLoggingForeverRequest,
757 fidl::encoding::DefaultFuchsiaResourceDialect
758 );
759 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecorderStartLoggingForeverRequest>(&header, _body_bytes, handles, &mut req)?;
760 let control_handle = RecorderControlHandle { inner: this.inner.clone() };
761 Ok(RecorderRequest::StartLoggingForever {
762 client_id: req.client_id,
763 metrics: req.metrics,
764 output_samples_to_syslog: req.output_samples_to_syslog,
765 output_stats_to_syslog: req.output_stats_to_syslog,
766
767 responder: RecorderStartLoggingForeverResponder {
768 control_handle: std::mem::ManuallyDrop::new(control_handle),
769 tx_id: header.tx_id,
770 },
771 })
772 }
773 0x615d67a4d94d4732 => {
774 header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
775 let mut req = fidl::new_empty!(
776 RecorderStopLoggingRequest,
777 fidl::encoding::DefaultFuchsiaResourceDialect
778 );
779 fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecorderStopLoggingRequest>(&header, _body_bytes, handles, &mut req)?;
780 let control_handle = RecorderControlHandle { inner: this.inner.clone() };
781 Ok(RecorderRequest::StopLogging {
782 client_id: req.client_id,
783
784 responder: RecorderStopLoggingResponder {
785 control_handle: std::mem::ManuallyDrop::new(control_handle),
786 tx_id: header.tx_id,
787 },
788 })
789 }
790 _ => Err(fidl::Error::UnknownOrdinal {
791 ordinal: header.ordinal,
792 protocol_name:
793 <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
794 }),
795 }))
796 },
797 )
798 }
799}
800
801#[derive(Debug)]
803pub enum RecorderRequest {
804 StartLogging {
825 client_id: String,
826 metrics: Vec<Metric>,
827 duration_ms: u32,
828 output_samples_to_syslog: bool,
829 output_stats_to_syslog: bool,
830 responder: RecorderStartLoggingResponder,
831 },
832 StartLoggingForever {
848 client_id: String,
849 metrics: Vec<Metric>,
850 output_samples_to_syslog: bool,
851 output_stats_to_syslog: bool,
852 responder: RecorderStartLoggingForeverResponder,
853 },
854 StopLogging { client_id: String, responder: RecorderStopLoggingResponder },
861}
862
863impl RecorderRequest {
864 #[allow(irrefutable_let_patterns)]
865 pub fn into_start_logging(
866 self,
867 ) -> Option<(String, Vec<Metric>, u32, bool, bool, RecorderStartLoggingResponder)> {
868 if let RecorderRequest::StartLogging {
869 client_id,
870 metrics,
871 duration_ms,
872 output_samples_to_syslog,
873 output_stats_to_syslog,
874 responder,
875 } = self
876 {
877 Some((
878 client_id,
879 metrics,
880 duration_ms,
881 output_samples_to_syslog,
882 output_stats_to_syslog,
883 responder,
884 ))
885 } else {
886 None
887 }
888 }
889
890 #[allow(irrefutable_let_patterns)]
891 pub fn into_start_logging_forever(
892 self,
893 ) -> Option<(String, Vec<Metric>, bool, bool, RecorderStartLoggingForeverResponder)> {
894 if let RecorderRequest::StartLoggingForever {
895 client_id,
896 metrics,
897 output_samples_to_syslog,
898 output_stats_to_syslog,
899 responder,
900 } = self
901 {
902 Some((client_id, metrics, output_samples_to_syslog, output_stats_to_syslog, responder))
903 } else {
904 None
905 }
906 }
907
908 #[allow(irrefutable_let_patterns)]
909 pub fn into_stop_logging(self) -> Option<(String, RecorderStopLoggingResponder)> {
910 if let RecorderRequest::StopLogging { client_id, responder } = self {
911 Some((client_id, responder))
912 } else {
913 None
914 }
915 }
916
917 pub fn method_name(&self) -> &'static str {
919 match *self {
920 RecorderRequest::StartLogging { .. } => "start_logging",
921 RecorderRequest::StartLoggingForever { .. } => "start_logging_forever",
922 RecorderRequest::StopLogging { .. } => "stop_logging",
923 }
924 }
925}
926
927#[derive(Debug, Clone)]
928pub struct RecorderControlHandle {
929 inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
930}
931
932impl fidl::endpoints::ControlHandle for RecorderControlHandle {
933 fn shutdown(&self) {
934 self.inner.shutdown()
935 }
936 fn shutdown_with_epitaph(&self, status: zx_status::Status) {
937 self.inner.shutdown_with_epitaph(status)
938 }
939
940 fn is_closed(&self) -> bool {
941 self.inner.channel().is_closed()
942 }
943 fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
944 self.inner.channel().on_closed()
945 }
946
947 #[cfg(target_os = "fuchsia")]
948 fn signal_peer(
949 &self,
950 clear_mask: zx::Signals,
951 set_mask: zx::Signals,
952 ) -> Result<(), zx_status::Status> {
953 use fidl::Peered;
954 self.inner.channel().signal_peer(clear_mask, set_mask)
955 }
956}
957
958impl RecorderControlHandle {}
959
960#[must_use = "FIDL methods require a response to be sent"]
961#[derive(Debug)]
962pub struct RecorderStartLoggingResponder {
963 control_handle: std::mem::ManuallyDrop<RecorderControlHandle>,
964 tx_id: u32,
965}
966
967impl std::ops::Drop for RecorderStartLoggingResponder {
971 fn drop(&mut self) {
972 self.control_handle.shutdown();
973 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
975 }
976}
977
978impl fidl::endpoints::Responder for RecorderStartLoggingResponder {
979 type ControlHandle = RecorderControlHandle;
980
981 fn control_handle(&self) -> &RecorderControlHandle {
982 &self.control_handle
983 }
984
985 fn drop_without_shutdown(mut self) {
986 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
988 std::mem::forget(self);
990 }
991}
992
993impl RecorderStartLoggingResponder {
994 pub fn send(self, mut result: Result<(), RecorderError>) -> Result<(), fidl::Error> {
998 let _result = self.send_raw(result);
999 if _result.is_err() {
1000 self.control_handle.shutdown();
1001 }
1002 self.drop_without_shutdown();
1003 _result
1004 }
1005
1006 pub fn send_no_shutdown_on_err(
1008 self,
1009 mut result: Result<(), RecorderError>,
1010 ) -> 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<(), RecorderError>) -> Result<(), fidl::Error> {
1017 self.control_handle.inner.send::<fidl::encoding::ResultType<
1018 fidl::encoding::EmptyStruct,
1019 RecorderError,
1020 >>(
1021 result,
1022 self.tx_id,
1023 0x40e4e1a9c6c42bd2,
1024 fidl::encoding::DynamicFlags::empty(),
1025 )
1026 }
1027}
1028
1029#[must_use = "FIDL methods require a response to be sent"]
1030#[derive(Debug)]
1031pub struct RecorderStartLoggingForeverResponder {
1032 control_handle: std::mem::ManuallyDrop<RecorderControlHandle>,
1033 tx_id: u32,
1034}
1035
1036impl std::ops::Drop for RecorderStartLoggingForeverResponder {
1040 fn drop(&mut self) {
1041 self.control_handle.shutdown();
1042 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1044 }
1045}
1046
1047impl fidl::endpoints::Responder for RecorderStartLoggingForeverResponder {
1048 type ControlHandle = RecorderControlHandle;
1049
1050 fn control_handle(&self) -> &RecorderControlHandle {
1051 &self.control_handle
1052 }
1053
1054 fn drop_without_shutdown(mut self) {
1055 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1057 std::mem::forget(self);
1059 }
1060}
1061
1062impl RecorderStartLoggingForeverResponder {
1063 pub fn send(self, mut result: Result<(), RecorderError>) -> Result<(), fidl::Error> {
1067 let _result = self.send_raw(result);
1068 if _result.is_err() {
1069 self.control_handle.shutdown();
1070 }
1071 self.drop_without_shutdown();
1072 _result
1073 }
1074
1075 pub fn send_no_shutdown_on_err(
1077 self,
1078 mut result: Result<(), RecorderError>,
1079 ) -> Result<(), fidl::Error> {
1080 let _result = self.send_raw(result);
1081 self.drop_without_shutdown();
1082 _result
1083 }
1084
1085 fn send_raw(&self, mut result: Result<(), RecorderError>) -> Result<(), fidl::Error> {
1086 self.control_handle.inner.send::<fidl::encoding::ResultType<
1087 fidl::encoding::EmptyStruct,
1088 RecorderError,
1089 >>(
1090 result,
1091 self.tx_id,
1092 0x37b2675fdc61ff94,
1093 fidl::encoding::DynamicFlags::empty(),
1094 )
1095 }
1096}
1097
1098#[must_use = "FIDL methods require a response to be sent"]
1099#[derive(Debug)]
1100pub struct RecorderStopLoggingResponder {
1101 control_handle: std::mem::ManuallyDrop<RecorderControlHandle>,
1102 tx_id: u32,
1103}
1104
1105impl std::ops::Drop for RecorderStopLoggingResponder {
1109 fn drop(&mut self) {
1110 self.control_handle.shutdown();
1111 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1113 }
1114}
1115
1116impl fidl::endpoints::Responder for RecorderStopLoggingResponder {
1117 type ControlHandle = RecorderControlHandle;
1118
1119 fn control_handle(&self) -> &RecorderControlHandle {
1120 &self.control_handle
1121 }
1122
1123 fn drop_without_shutdown(mut self) {
1124 unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
1126 std::mem::forget(self);
1128 }
1129}
1130
1131impl RecorderStopLoggingResponder {
1132 pub fn send(self, mut stopped: bool) -> Result<(), fidl::Error> {
1136 let _result = self.send_raw(stopped);
1137 if _result.is_err() {
1138 self.control_handle.shutdown();
1139 }
1140 self.drop_without_shutdown();
1141 _result
1142 }
1143
1144 pub fn send_no_shutdown_on_err(self, mut stopped: bool) -> Result<(), fidl::Error> {
1146 let _result = self.send_raw(stopped);
1147 self.drop_without_shutdown();
1148 _result
1149 }
1150
1151 fn send_raw(&self, mut stopped: bool) -> Result<(), fidl::Error> {
1152 self.control_handle.inner.send::<RecorderStopLoggingResponse>(
1153 (stopped,),
1154 self.tx_id,
1155 0x615d67a4d94d4732,
1156 fidl::encoding::DynamicFlags::empty(),
1157 )
1158 }
1159}
1160
1161mod internal {
1162 use super::*;
1163 unsafe impl fidl::encoding::TypeMarker for RecorderError {
1164 type Owned = Self;
1165
1166 #[inline(always)]
1167 fn inline_align(_context: fidl::encoding::Context) -> usize {
1168 std::mem::align_of::<u32>()
1169 }
1170
1171 #[inline(always)]
1172 fn inline_size(_context: fidl::encoding::Context) -> usize {
1173 std::mem::size_of::<u32>()
1174 }
1175
1176 #[inline(always)]
1177 fn encode_is_copy() -> bool {
1178 true
1179 }
1180
1181 #[inline(always)]
1182 fn decode_is_copy() -> bool {
1183 false
1184 }
1185 }
1186
1187 impl fidl::encoding::ValueTypeMarker for RecorderError {
1188 type Borrowed<'a> = Self;
1189 #[inline(always)]
1190 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1191 *value
1192 }
1193 }
1194
1195 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RecorderError {
1196 #[inline]
1197 unsafe fn encode(
1198 self,
1199 encoder: &mut fidl::encoding::Encoder<'_, D>,
1200 offset: usize,
1201 _depth: fidl::encoding::Depth,
1202 ) -> fidl::Result<()> {
1203 encoder.debug_check_bounds::<Self>(offset);
1204 encoder.write_num(self.into_primitive(), offset);
1205 Ok(())
1206 }
1207 }
1208
1209 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RecorderError {
1210 #[inline(always)]
1211 fn new_empty() -> Self {
1212 Self::NoDrivers
1213 }
1214
1215 #[inline]
1216 unsafe fn decode(
1217 &mut self,
1218 decoder: &mut fidl::encoding::Decoder<'_, D>,
1219 offset: usize,
1220 _depth: fidl::encoding::Depth,
1221 ) -> fidl::Result<()> {
1222 decoder.debug_check_bounds::<Self>(offset);
1223 let prim = decoder.read_num::<u32>(offset);
1224
1225 *self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
1226 Ok(())
1227 }
1228 }
1229
1230 impl fidl::encoding::ValueTypeMarker for CpuLoad {
1231 type Borrowed<'a> = &'a Self;
1232 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1233 value
1234 }
1235 }
1236
1237 unsafe impl fidl::encoding::TypeMarker for CpuLoad {
1238 type Owned = Self;
1239
1240 #[inline(always)]
1241 fn inline_align(_context: fidl::encoding::Context) -> usize {
1242 4
1243 }
1244
1245 #[inline(always)]
1246 fn inline_size(_context: fidl::encoding::Context) -> usize {
1247 4
1248 }
1249 #[inline(always)]
1250 fn encode_is_copy() -> bool {
1251 true
1252 }
1253
1254 #[inline(always)]
1255 fn decode_is_copy() -> bool {
1256 true
1257 }
1258 }
1259
1260 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CpuLoad, D> for &CpuLoad {
1261 #[inline]
1262 unsafe fn encode(
1263 self,
1264 encoder: &mut fidl::encoding::Encoder<'_, D>,
1265 offset: usize,
1266 _depth: fidl::encoding::Depth,
1267 ) -> fidl::Result<()> {
1268 encoder.debug_check_bounds::<CpuLoad>(offset);
1269 unsafe {
1270 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1272 (buf_ptr as *mut CpuLoad).write_unaligned((self as *const CpuLoad).read());
1273 }
1276 Ok(())
1277 }
1278 }
1279 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1280 fidl::encoding::Encode<CpuLoad, D> for (T0,)
1281 {
1282 #[inline]
1283 unsafe fn encode(
1284 self,
1285 encoder: &mut fidl::encoding::Encoder<'_, D>,
1286 offset: usize,
1287 depth: fidl::encoding::Depth,
1288 ) -> fidl::Result<()> {
1289 encoder.debug_check_bounds::<CpuLoad>(offset);
1290 self.0.encode(encoder, offset + 0, depth)?;
1294 Ok(())
1295 }
1296 }
1297
1298 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CpuLoad {
1299 #[inline(always)]
1300 fn new_empty() -> Self {
1301 Self { interval_ms: fidl::new_empty!(u32, D) }
1302 }
1303
1304 #[inline]
1305 unsafe fn decode(
1306 &mut self,
1307 decoder: &mut fidl::encoding::Decoder<'_, D>,
1308 offset: usize,
1309 _depth: fidl::encoding::Depth,
1310 ) -> fidl::Result<()> {
1311 decoder.debug_check_bounds::<Self>(offset);
1312 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1313 unsafe {
1316 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1317 }
1318 Ok(())
1319 }
1320 }
1321
1322 impl fidl::encoding::ValueTypeMarker for GpuUsage {
1323 type Borrowed<'a> = &'a Self;
1324 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1325 value
1326 }
1327 }
1328
1329 unsafe impl fidl::encoding::TypeMarker for GpuUsage {
1330 type Owned = Self;
1331
1332 #[inline(always)]
1333 fn inline_align(_context: fidl::encoding::Context) -> usize {
1334 4
1335 }
1336
1337 #[inline(always)]
1338 fn inline_size(_context: fidl::encoding::Context) -> usize {
1339 4
1340 }
1341 #[inline(always)]
1342 fn encode_is_copy() -> bool {
1343 true
1344 }
1345
1346 #[inline(always)]
1347 fn decode_is_copy() -> bool {
1348 true
1349 }
1350 }
1351
1352 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GpuUsage, D> for &GpuUsage {
1353 #[inline]
1354 unsafe fn encode(
1355 self,
1356 encoder: &mut fidl::encoding::Encoder<'_, D>,
1357 offset: usize,
1358 _depth: fidl::encoding::Depth,
1359 ) -> fidl::Result<()> {
1360 encoder.debug_check_bounds::<GpuUsage>(offset);
1361 unsafe {
1362 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1364 (buf_ptr as *mut GpuUsage).write_unaligned((self as *const GpuUsage).read());
1365 }
1368 Ok(())
1369 }
1370 }
1371 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1372 fidl::encoding::Encode<GpuUsage, D> for (T0,)
1373 {
1374 #[inline]
1375 unsafe fn encode(
1376 self,
1377 encoder: &mut fidl::encoding::Encoder<'_, D>,
1378 offset: usize,
1379 depth: fidl::encoding::Depth,
1380 ) -> fidl::Result<()> {
1381 encoder.debug_check_bounds::<GpuUsage>(offset);
1382 self.0.encode(encoder, offset + 0, depth)?;
1386 Ok(())
1387 }
1388 }
1389
1390 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GpuUsage {
1391 #[inline(always)]
1392 fn new_empty() -> Self {
1393 Self { interval_ms: fidl::new_empty!(u32, D) }
1394 }
1395
1396 #[inline]
1397 unsafe fn decode(
1398 &mut self,
1399 decoder: &mut fidl::encoding::Decoder<'_, D>,
1400 offset: usize,
1401 _depth: fidl::encoding::Depth,
1402 ) -> fidl::Result<()> {
1403 decoder.debug_check_bounds::<Self>(offset);
1404 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1405 unsafe {
1408 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1409 }
1410 Ok(())
1411 }
1412 }
1413
1414 impl fidl::encoding::ValueTypeMarker for NetworkActivity {
1415 type Borrowed<'a> = &'a Self;
1416 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1417 value
1418 }
1419 }
1420
1421 unsafe impl fidl::encoding::TypeMarker for NetworkActivity {
1422 type Owned = Self;
1423
1424 #[inline(always)]
1425 fn inline_align(_context: fidl::encoding::Context) -> usize {
1426 4
1427 }
1428
1429 #[inline(always)]
1430 fn inline_size(_context: fidl::encoding::Context) -> usize {
1431 4
1432 }
1433 #[inline(always)]
1434 fn encode_is_copy() -> bool {
1435 true
1436 }
1437
1438 #[inline(always)]
1439 fn decode_is_copy() -> bool {
1440 true
1441 }
1442 }
1443
1444 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NetworkActivity, D>
1445 for &NetworkActivity
1446 {
1447 #[inline]
1448 unsafe fn encode(
1449 self,
1450 encoder: &mut fidl::encoding::Encoder<'_, D>,
1451 offset: usize,
1452 _depth: fidl::encoding::Depth,
1453 ) -> fidl::Result<()> {
1454 encoder.debug_check_bounds::<NetworkActivity>(offset);
1455 unsafe {
1456 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
1458 (buf_ptr as *mut NetworkActivity)
1459 .write_unaligned((self as *const NetworkActivity).read());
1460 }
1463 Ok(())
1464 }
1465 }
1466 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
1467 fidl::encoding::Encode<NetworkActivity, D> for (T0,)
1468 {
1469 #[inline]
1470 unsafe fn encode(
1471 self,
1472 encoder: &mut fidl::encoding::Encoder<'_, D>,
1473 offset: usize,
1474 depth: fidl::encoding::Depth,
1475 ) -> fidl::Result<()> {
1476 encoder.debug_check_bounds::<NetworkActivity>(offset);
1477 self.0.encode(encoder, offset + 0, depth)?;
1481 Ok(())
1482 }
1483 }
1484
1485 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NetworkActivity {
1486 #[inline(always)]
1487 fn new_empty() -> Self {
1488 Self { interval_ms: fidl::new_empty!(u32, D) }
1489 }
1490
1491 #[inline]
1492 unsafe fn decode(
1493 &mut self,
1494 decoder: &mut fidl::encoding::Decoder<'_, D>,
1495 offset: usize,
1496 _depth: fidl::encoding::Depth,
1497 ) -> fidl::Result<()> {
1498 decoder.debug_check_bounds::<Self>(offset);
1499 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
1500 unsafe {
1503 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
1504 }
1505 Ok(())
1506 }
1507 }
1508
1509 impl fidl::encoding::ValueTypeMarker for Power {
1510 type Borrowed<'a> = &'a Self;
1511 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1512 value
1513 }
1514 }
1515
1516 unsafe impl fidl::encoding::TypeMarker for Power {
1517 type Owned = Self;
1518
1519 #[inline(always)]
1520 fn inline_align(_context: fidl::encoding::Context) -> usize {
1521 8
1522 }
1523
1524 #[inline(always)]
1525 fn inline_size(_context: fidl::encoding::Context) -> usize {
1526 16
1527 }
1528 }
1529
1530 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Power, D> for &Power {
1531 #[inline]
1532 unsafe fn encode(
1533 self,
1534 encoder: &mut fidl::encoding::Encoder<'_, D>,
1535 offset: usize,
1536 _depth: fidl::encoding::Depth,
1537 ) -> fidl::Result<()> {
1538 encoder.debug_check_bounds::<Power>(offset);
1539 fidl::encoding::Encode::<Power, D>::encode(
1541 (
1542 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.sampling_interval_ms),
1543 <fidl::encoding::Boxed<StatisticsArgs> as fidl::encoding::ValueTypeMarker>::borrow(&self.statistics_args),
1544 ),
1545 encoder, offset, _depth
1546 )
1547 }
1548 }
1549 unsafe impl<
1550 D: fidl::encoding::ResourceDialect,
1551 T0: fidl::encoding::Encode<u32, D>,
1552 T1: fidl::encoding::Encode<fidl::encoding::Boxed<StatisticsArgs>, D>,
1553 > fidl::encoding::Encode<Power, D> for (T0, T1)
1554 {
1555 #[inline]
1556 unsafe fn encode(
1557 self,
1558 encoder: &mut fidl::encoding::Encoder<'_, D>,
1559 offset: usize,
1560 depth: fidl::encoding::Depth,
1561 ) -> fidl::Result<()> {
1562 encoder.debug_check_bounds::<Power>(offset);
1563 unsafe {
1566 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
1567 (ptr as *mut u64).write_unaligned(0);
1568 }
1569 self.0.encode(encoder, offset + 0, depth)?;
1571 self.1.encode(encoder, offset + 8, depth)?;
1572 Ok(())
1573 }
1574 }
1575
1576 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Power {
1577 #[inline(always)]
1578 fn new_empty() -> Self {
1579 Self {
1580 sampling_interval_ms: fidl::new_empty!(u32, D),
1581 statistics_args: fidl::new_empty!(fidl::encoding::Boxed<StatisticsArgs>, D),
1582 }
1583 }
1584
1585 #[inline]
1586 unsafe fn decode(
1587 &mut self,
1588 decoder: &mut fidl::encoding::Decoder<'_, D>,
1589 offset: usize,
1590 _depth: fidl::encoding::Depth,
1591 ) -> fidl::Result<()> {
1592 decoder.debug_check_bounds::<Self>(offset);
1593 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
1595 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1596 let mask = 0xffffffff00000000u64;
1597 let maskedval = padval & mask;
1598 if maskedval != 0 {
1599 return Err(fidl::Error::NonZeroPadding {
1600 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
1601 });
1602 }
1603 fidl::decode!(u32, D, &mut self.sampling_interval_ms, decoder, offset + 0, _depth)?;
1604 fidl::decode!(
1605 fidl::encoding::Boxed<StatisticsArgs>,
1606 D,
1607 &mut self.statistics_args,
1608 decoder,
1609 offset + 8,
1610 _depth
1611 )?;
1612 Ok(())
1613 }
1614 }
1615
1616 impl fidl::encoding::ValueTypeMarker for RecorderStartLoggingForeverRequest {
1617 type Borrowed<'a> = &'a Self;
1618 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1619 value
1620 }
1621 }
1622
1623 unsafe impl fidl::encoding::TypeMarker for RecorderStartLoggingForeverRequest {
1624 type Owned = Self;
1625
1626 #[inline(always)]
1627 fn inline_align(_context: fidl::encoding::Context) -> usize {
1628 8
1629 }
1630
1631 #[inline(always)]
1632 fn inline_size(_context: fidl::encoding::Context) -> usize {
1633 40
1634 }
1635 }
1636
1637 unsafe impl<D: fidl::encoding::ResourceDialect>
1638 fidl::encoding::Encode<RecorderStartLoggingForeverRequest, D>
1639 for &RecorderStartLoggingForeverRequest
1640 {
1641 #[inline]
1642 unsafe fn encode(
1643 self,
1644 encoder: &mut fidl::encoding::Encoder<'_, D>,
1645 offset: usize,
1646 _depth: fidl::encoding::Depth,
1647 ) -> fidl::Result<()> {
1648 encoder.debug_check_bounds::<RecorderStartLoggingForeverRequest>(offset);
1649 fidl::encoding::Encode::<RecorderStartLoggingForeverRequest, D>::encode(
1651 (
1652 <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(&self.client_id),
1653 <fidl::encoding::UnboundedVector<Metric> as fidl::encoding::ValueTypeMarker>::borrow(&self.metrics),
1654 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_samples_to_syslog),
1655 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_stats_to_syslog),
1656 ),
1657 encoder, offset, _depth
1658 )
1659 }
1660 }
1661 unsafe impl<
1662 D: fidl::encoding::ResourceDialect,
1663 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>, D>,
1664 T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Metric>, D>,
1665 T2: fidl::encoding::Encode<bool, D>,
1666 T3: fidl::encoding::Encode<bool, D>,
1667 > fidl::encoding::Encode<RecorderStartLoggingForeverRequest, D> for (T0, T1, T2, T3)
1668 {
1669 #[inline]
1670 unsafe fn encode(
1671 self,
1672 encoder: &mut fidl::encoding::Encoder<'_, D>,
1673 offset: usize,
1674 depth: fidl::encoding::Depth,
1675 ) -> fidl::Result<()> {
1676 encoder.debug_check_bounds::<RecorderStartLoggingForeverRequest>(offset);
1677 unsafe {
1680 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1681 (ptr as *mut u64).write_unaligned(0);
1682 }
1683 self.0.encode(encoder, offset + 0, depth)?;
1685 self.1.encode(encoder, offset + 16, depth)?;
1686 self.2.encode(encoder, offset + 32, depth)?;
1687 self.3.encode(encoder, offset + 33, depth)?;
1688 Ok(())
1689 }
1690 }
1691
1692 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1693 for RecorderStartLoggingForeverRequest
1694 {
1695 #[inline(always)]
1696 fn new_empty() -> Self {
1697 Self {
1698 client_id: fidl::new_empty!(fidl::encoding::BoundedString<16>, D),
1699 metrics: fidl::new_empty!(fidl::encoding::UnboundedVector<Metric>, D),
1700 output_samples_to_syslog: fidl::new_empty!(bool, D),
1701 output_stats_to_syslog: fidl::new_empty!(bool, D),
1702 }
1703 }
1704
1705 #[inline]
1706 unsafe fn decode(
1707 &mut self,
1708 decoder: &mut fidl::encoding::Decoder<'_, D>,
1709 offset: usize,
1710 _depth: fidl::encoding::Depth,
1711 ) -> fidl::Result<()> {
1712 decoder.debug_check_bounds::<Self>(offset);
1713 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1715 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1716 let mask = 0xffffffffffff0000u64;
1717 let maskedval = padval & mask;
1718 if maskedval != 0 {
1719 return Err(fidl::Error::NonZeroPadding {
1720 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1721 });
1722 }
1723 fidl::decode!(
1724 fidl::encoding::BoundedString<16>,
1725 D,
1726 &mut self.client_id,
1727 decoder,
1728 offset + 0,
1729 _depth
1730 )?;
1731 fidl::decode!(
1732 fidl::encoding::UnboundedVector<Metric>,
1733 D,
1734 &mut self.metrics,
1735 decoder,
1736 offset + 16,
1737 _depth
1738 )?;
1739 fidl::decode!(
1740 bool,
1741 D,
1742 &mut self.output_samples_to_syslog,
1743 decoder,
1744 offset + 32,
1745 _depth
1746 )?;
1747 fidl::decode!(bool, D, &mut self.output_stats_to_syslog, decoder, offset + 33, _depth)?;
1748 Ok(())
1749 }
1750 }
1751
1752 impl fidl::encoding::ValueTypeMarker for RecorderStartLoggingRequest {
1753 type Borrowed<'a> = &'a Self;
1754 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1755 value
1756 }
1757 }
1758
1759 unsafe impl fidl::encoding::TypeMarker for RecorderStartLoggingRequest {
1760 type Owned = Self;
1761
1762 #[inline(always)]
1763 fn inline_align(_context: fidl::encoding::Context) -> usize {
1764 8
1765 }
1766
1767 #[inline(always)]
1768 fn inline_size(_context: fidl::encoding::Context) -> usize {
1769 40
1770 }
1771 }
1772
1773 unsafe impl<D: fidl::encoding::ResourceDialect>
1774 fidl::encoding::Encode<RecorderStartLoggingRequest, D> for &RecorderStartLoggingRequest
1775 {
1776 #[inline]
1777 unsafe fn encode(
1778 self,
1779 encoder: &mut fidl::encoding::Encoder<'_, D>,
1780 offset: usize,
1781 _depth: fidl::encoding::Depth,
1782 ) -> fidl::Result<()> {
1783 encoder.debug_check_bounds::<RecorderStartLoggingRequest>(offset);
1784 fidl::encoding::Encode::<RecorderStartLoggingRequest, D>::encode(
1786 (
1787 <fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(&self.client_id),
1788 <fidl::encoding::UnboundedVector<Metric> as fidl::encoding::ValueTypeMarker>::borrow(&self.metrics),
1789 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.duration_ms),
1790 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_samples_to_syslog),
1791 <bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_stats_to_syslog),
1792 ),
1793 encoder, offset, _depth
1794 )
1795 }
1796 }
1797 unsafe impl<
1798 D: fidl::encoding::ResourceDialect,
1799 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>, D>,
1800 T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Metric>, D>,
1801 T2: fidl::encoding::Encode<u32, D>,
1802 T3: fidl::encoding::Encode<bool, D>,
1803 T4: fidl::encoding::Encode<bool, D>,
1804 > fidl::encoding::Encode<RecorderStartLoggingRequest, D> for (T0, T1, T2, T3, T4)
1805 {
1806 #[inline]
1807 unsafe fn encode(
1808 self,
1809 encoder: &mut fidl::encoding::Encoder<'_, D>,
1810 offset: usize,
1811 depth: fidl::encoding::Depth,
1812 ) -> fidl::Result<()> {
1813 encoder.debug_check_bounds::<RecorderStartLoggingRequest>(offset);
1814 unsafe {
1817 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
1818 (ptr as *mut u64).write_unaligned(0);
1819 }
1820 self.0.encode(encoder, offset + 0, depth)?;
1822 self.1.encode(encoder, offset + 16, depth)?;
1823 self.2.encode(encoder, offset + 32, depth)?;
1824 self.3.encode(encoder, offset + 36, depth)?;
1825 self.4.encode(encoder, offset + 37, depth)?;
1826 Ok(())
1827 }
1828 }
1829
1830 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1831 for RecorderStartLoggingRequest
1832 {
1833 #[inline(always)]
1834 fn new_empty() -> Self {
1835 Self {
1836 client_id: fidl::new_empty!(fidl::encoding::BoundedString<16>, D),
1837 metrics: fidl::new_empty!(fidl::encoding::UnboundedVector<Metric>, D),
1838 duration_ms: fidl::new_empty!(u32, D),
1839 output_samples_to_syslog: fidl::new_empty!(bool, D),
1840 output_stats_to_syslog: fidl::new_empty!(bool, D),
1841 }
1842 }
1843
1844 #[inline]
1845 unsafe fn decode(
1846 &mut self,
1847 decoder: &mut fidl::encoding::Decoder<'_, D>,
1848 offset: usize,
1849 _depth: fidl::encoding::Depth,
1850 ) -> fidl::Result<()> {
1851 decoder.debug_check_bounds::<Self>(offset);
1852 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
1854 let padval = unsafe { (ptr as *const u64).read_unaligned() };
1855 let mask = 0xffff000000000000u64;
1856 let maskedval = padval & mask;
1857 if maskedval != 0 {
1858 return Err(fidl::Error::NonZeroPadding {
1859 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
1860 });
1861 }
1862 fidl::decode!(
1863 fidl::encoding::BoundedString<16>,
1864 D,
1865 &mut self.client_id,
1866 decoder,
1867 offset + 0,
1868 _depth
1869 )?;
1870 fidl::decode!(
1871 fidl::encoding::UnboundedVector<Metric>,
1872 D,
1873 &mut self.metrics,
1874 decoder,
1875 offset + 16,
1876 _depth
1877 )?;
1878 fidl::decode!(u32, D, &mut self.duration_ms, decoder, offset + 32, _depth)?;
1879 fidl::decode!(
1880 bool,
1881 D,
1882 &mut self.output_samples_to_syslog,
1883 decoder,
1884 offset + 36,
1885 _depth
1886 )?;
1887 fidl::decode!(bool, D, &mut self.output_stats_to_syslog, decoder, offset + 37, _depth)?;
1888 Ok(())
1889 }
1890 }
1891
1892 impl fidl::encoding::ValueTypeMarker for RecorderStopLoggingRequest {
1893 type Borrowed<'a> = &'a Self;
1894 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1895 value
1896 }
1897 }
1898
1899 unsafe impl fidl::encoding::TypeMarker for RecorderStopLoggingRequest {
1900 type Owned = Self;
1901
1902 #[inline(always)]
1903 fn inline_align(_context: fidl::encoding::Context) -> usize {
1904 8
1905 }
1906
1907 #[inline(always)]
1908 fn inline_size(_context: fidl::encoding::Context) -> usize {
1909 16
1910 }
1911 }
1912
1913 unsafe impl<D: fidl::encoding::ResourceDialect>
1914 fidl::encoding::Encode<RecorderStopLoggingRequest, D> for &RecorderStopLoggingRequest
1915 {
1916 #[inline]
1917 unsafe fn encode(
1918 self,
1919 encoder: &mut fidl::encoding::Encoder<'_, D>,
1920 offset: usize,
1921 _depth: fidl::encoding::Depth,
1922 ) -> fidl::Result<()> {
1923 encoder.debug_check_bounds::<RecorderStopLoggingRequest>(offset);
1924 fidl::encoding::Encode::<RecorderStopLoggingRequest, D>::encode(
1926 (<fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
1927 &self.client_id,
1928 ),),
1929 encoder,
1930 offset,
1931 _depth,
1932 )
1933 }
1934 }
1935 unsafe impl<
1936 D: fidl::encoding::ResourceDialect,
1937 T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>, D>,
1938 > fidl::encoding::Encode<RecorderStopLoggingRequest, D> for (T0,)
1939 {
1940 #[inline]
1941 unsafe fn encode(
1942 self,
1943 encoder: &mut fidl::encoding::Encoder<'_, D>,
1944 offset: usize,
1945 depth: fidl::encoding::Depth,
1946 ) -> fidl::Result<()> {
1947 encoder.debug_check_bounds::<RecorderStopLoggingRequest>(offset);
1948 self.0.encode(encoder, offset + 0, depth)?;
1952 Ok(())
1953 }
1954 }
1955
1956 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
1957 for RecorderStopLoggingRequest
1958 {
1959 #[inline(always)]
1960 fn new_empty() -> Self {
1961 Self { client_id: fidl::new_empty!(fidl::encoding::BoundedString<16>, D) }
1962 }
1963
1964 #[inline]
1965 unsafe fn decode(
1966 &mut self,
1967 decoder: &mut fidl::encoding::Decoder<'_, D>,
1968 offset: usize,
1969 _depth: fidl::encoding::Depth,
1970 ) -> fidl::Result<()> {
1971 decoder.debug_check_bounds::<Self>(offset);
1972 fidl::decode!(
1974 fidl::encoding::BoundedString<16>,
1975 D,
1976 &mut self.client_id,
1977 decoder,
1978 offset + 0,
1979 _depth
1980 )?;
1981 Ok(())
1982 }
1983 }
1984
1985 impl fidl::encoding::ValueTypeMarker for RecorderStopLoggingResponse {
1986 type Borrowed<'a> = &'a Self;
1987 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
1988 value
1989 }
1990 }
1991
1992 unsafe impl fidl::encoding::TypeMarker for RecorderStopLoggingResponse {
1993 type Owned = Self;
1994
1995 #[inline(always)]
1996 fn inline_align(_context: fidl::encoding::Context) -> usize {
1997 1
1998 }
1999
2000 #[inline(always)]
2001 fn inline_size(_context: fidl::encoding::Context) -> usize {
2002 1
2003 }
2004 }
2005
2006 unsafe impl<D: fidl::encoding::ResourceDialect>
2007 fidl::encoding::Encode<RecorderStopLoggingResponse, D> for &RecorderStopLoggingResponse
2008 {
2009 #[inline]
2010 unsafe fn encode(
2011 self,
2012 encoder: &mut fidl::encoding::Encoder<'_, D>,
2013 offset: usize,
2014 _depth: fidl::encoding::Depth,
2015 ) -> fidl::Result<()> {
2016 encoder.debug_check_bounds::<RecorderStopLoggingResponse>(offset);
2017 fidl::encoding::Encode::<RecorderStopLoggingResponse, D>::encode(
2019 (<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.stopped),),
2020 encoder,
2021 offset,
2022 _depth,
2023 )
2024 }
2025 }
2026 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
2027 fidl::encoding::Encode<RecorderStopLoggingResponse, D> for (T0,)
2028 {
2029 #[inline]
2030 unsafe fn encode(
2031 self,
2032 encoder: &mut fidl::encoding::Encoder<'_, D>,
2033 offset: usize,
2034 depth: fidl::encoding::Depth,
2035 ) -> fidl::Result<()> {
2036 encoder.debug_check_bounds::<RecorderStopLoggingResponse>(offset);
2037 self.0.encode(encoder, offset + 0, depth)?;
2041 Ok(())
2042 }
2043 }
2044
2045 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
2046 for RecorderStopLoggingResponse
2047 {
2048 #[inline(always)]
2049 fn new_empty() -> Self {
2050 Self { stopped: fidl::new_empty!(bool, D) }
2051 }
2052
2053 #[inline]
2054 unsafe fn decode(
2055 &mut self,
2056 decoder: &mut fidl::encoding::Decoder<'_, D>,
2057 offset: usize,
2058 _depth: fidl::encoding::Depth,
2059 ) -> fidl::Result<()> {
2060 decoder.debug_check_bounds::<Self>(offset);
2061 fidl::decode!(bool, D, &mut self.stopped, decoder, offset + 0, _depth)?;
2063 Ok(())
2064 }
2065 }
2066
2067 impl fidl::encoding::ValueTypeMarker for StatisticsArgs {
2068 type Borrowed<'a> = &'a Self;
2069 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2070 value
2071 }
2072 }
2073
2074 unsafe impl fidl::encoding::TypeMarker for StatisticsArgs {
2075 type Owned = Self;
2076
2077 #[inline(always)]
2078 fn inline_align(_context: fidl::encoding::Context) -> usize {
2079 4
2080 }
2081
2082 #[inline(always)]
2083 fn inline_size(_context: fidl::encoding::Context) -> usize {
2084 4
2085 }
2086 #[inline(always)]
2087 fn encode_is_copy() -> bool {
2088 true
2089 }
2090
2091 #[inline(always)]
2092 fn decode_is_copy() -> bool {
2093 true
2094 }
2095 }
2096
2097 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StatisticsArgs, D>
2098 for &StatisticsArgs
2099 {
2100 #[inline]
2101 unsafe fn encode(
2102 self,
2103 encoder: &mut fidl::encoding::Encoder<'_, D>,
2104 offset: usize,
2105 _depth: fidl::encoding::Depth,
2106 ) -> fidl::Result<()> {
2107 encoder.debug_check_bounds::<StatisticsArgs>(offset);
2108 unsafe {
2109 let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
2111 (buf_ptr as *mut StatisticsArgs)
2112 .write_unaligned((self as *const StatisticsArgs).read());
2113 }
2116 Ok(())
2117 }
2118 }
2119 unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
2120 fidl::encoding::Encode<StatisticsArgs, D> for (T0,)
2121 {
2122 #[inline]
2123 unsafe fn encode(
2124 self,
2125 encoder: &mut fidl::encoding::Encoder<'_, D>,
2126 offset: usize,
2127 depth: fidl::encoding::Depth,
2128 ) -> fidl::Result<()> {
2129 encoder.debug_check_bounds::<StatisticsArgs>(offset);
2130 self.0.encode(encoder, offset + 0, depth)?;
2134 Ok(())
2135 }
2136 }
2137
2138 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StatisticsArgs {
2139 #[inline(always)]
2140 fn new_empty() -> Self {
2141 Self { statistics_interval_ms: fidl::new_empty!(u32, D) }
2142 }
2143
2144 #[inline]
2145 unsafe fn decode(
2146 &mut self,
2147 decoder: &mut fidl::encoding::Decoder<'_, D>,
2148 offset: usize,
2149 _depth: fidl::encoding::Depth,
2150 ) -> fidl::Result<()> {
2151 decoder.debug_check_bounds::<Self>(offset);
2152 let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
2153 unsafe {
2156 std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
2157 }
2158 Ok(())
2159 }
2160 }
2161
2162 impl fidl::encoding::ValueTypeMarker for Temperature {
2163 type Borrowed<'a> = &'a Self;
2164 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2165 value
2166 }
2167 }
2168
2169 unsafe impl fidl::encoding::TypeMarker for Temperature {
2170 type Owned = Self;
2171
2172 #[inline(always)]
2173 fn inline_align(_context: fidl::encoding::Context) -> usize {
2174 8
2175 }
2176
2177 #[inline(always)]
2178 fn inline_size(_context: fidl::encoding::Context) -> usize {
2179 16
2180 }
2181 }
2182
2183 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Temperature, D>
2184 for &Temperature
2185 {
2186 #[inline]
2187 unsafe fn encode(
2188 self,
2189 encoder: &mut fidl::encoding::Encoder<'_, D>,
2190 offset: usize,
2191 _depth: fidl::encoding::Depth,
2192 ) -> fidl::Result<()> {
2193 encoder.debug_check_bounds::<Temperature>(offset);
2194 fidl::encoding::Encode::<Temperature, D>::encode(
2196 (
2197 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.sampling_interval_ms),
2198 <fidl::encoding::Boxed<StatisticsArgs> as fidl::encoding::ValueTypeMarker>::borrow(&self.statistics_args),
2199 ),
2200 encoder, offset, _depth
2201 )
2202 }
2203 }
2204 unsafe impl<
2205 D: fidl::encoding::ResourceDialect,
2206 T0: fidl::encoding::Encode<u32, D>,
2207 T1: fidl::encoding::Encode<fidl::encoding::Boxed<StatisticsArgs>, D>,
2208 > fidl::encoding::Encode<Temperature, D> for (T0, T1)
2209 {
2210 #[inline]
2211 unsafe fn encode(
2212 self,
2213 encoder: &mut fidl::encoding::Encoder<'_, D>,
2214 offset: usize,
2215 depth: fidl::encoding::Depth,
2216 ) -> fidl::Result<()> {
2217 encoder.debug_check_bounds::<Temperature>(offset);
2218 unsafe {
2221 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
2222 (ptr as *mut u64).write_unaligned(0);
2223 }
2224 self.0.encode(encoder, offset + 0, depth)?;
2226 self.1.encode(encoder, offset + 8, depth)?;
2227 Ok(())
2228 }
2229 }
2230
2231 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Temperature {
2232 #[inline(always)]
2233 fn new_empty() -> Self {
2234 Self {
2235 sampling_interval_ms: fidl::new_empty!(u32, D),
2236 statistics_args: fidl::new_empty!(fidl::encoding::Boxed<StatisticsArgs>, D),
2237 }
2238 }
2239
2240 #[inline]
2241 unsafe fn decode(
2242 &mut self,
2243 decoder: &mut fidl::encoding::Decoder<'_, D>,
2244 offset: usize,
2245 _depth: fidl::encoding::Depth,
2246 ) -> fidl::Result<()> {
2247 decoder.debug_check_bounds::<Self>(offset);
2248 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
2250 let padval = unsafe { (ptr as *const u64).read_unaligned() };
2251 let mask = 0xffffffff00000000u64;
2252 let maskedval = padval & mask;
2253 if maskedval != 0 {
2254 return Err(fidl::Error::NonZeroPadding {
2255 padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
2256 });
2257 }
2258 fidl::decode!(u32, D, &mut self.sampling_interval_ms, decoder, offset + 0, _depth)?;
2259 fidl::decode!(
2260 fidl::encoding::Boxed<StatisticsArgs>,
2261 D,
2262 &mut self.statistics_args,
2263 decoder,
2264 offset + 8,
2265 _depth
2266 )?;
2267 Ok(())
2268 }
2269 }
2270
2271 impl fidl::encoding::ValueTypeMarker for Metric {
2272 type Borrowed<'a> = &'a Self;
2273 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
2274 value
2275 }
2276 }
2277
2278 unsafe impl fidl::encoding::TypeMarker for Metric {
2279 type Owned = Self;
2280
2281 #[inline(always)]
2282 fn inline_align(_context: fidl::encoding::Context) -> usize {
2283 8
2284 }
2285
2286 #[inline(always)]
2287 fn inline_size(_context: fidl::encoding::Context) -> usize {
2288 16
2289 }
2290 }
2291
2292 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Metric, D> for &Metric {
2293 #[inline]
2294 unsafe fn encode(
2295 self,
2296 encoder: &mut fidl::encoding::Encoder<'_, D>,
2297 offset: usize,
2298 _depth: fidl::encoding::Depth,
2299 ) -> fidl::Result<()> {
2300 encoder.debug_check_bounds::<Metric>(offset);
2301 encoder.write_num::<u64>(self.ordinal(), offset);
2302 match self {
2303 Metric::Temperature(ref val) => {
2304 fidl::encoding::encode_in_envelope::<Temperature, D>(
2305 <Temperature as fidl::encoding::ValueTypeMarker>::borrow(val),
2306 encoder,
2307 offset + 8,
2308 _depth,
2309 )
2310 }
2311 Metric::CpuLoad(ref val) => fidl::encoding::encode_in_envelope::<CpuLoad, D>(
2312 <CpuLoad as fidl::encoding::ValueTypeMarker>::borrow(val),
2313 encoder,
2314 offset + 8,
2315 _depth,
2316 ),
2317 Metric::Power(ref val) => fidl::encoding::encode_in_envelope::<Power, D>(
2318 <Power as fidl::encoding::ValueTypeMarker>::borrow(val),
2319 encoder,
2320 offset + 8,
2321 _depth,
2322 ),
2323 Metric::GpuUsage(ref val) => fidl::encoding::encode_in_envelope::<GpuUsage, D>(
2324 <GpuUsage as fidl::encoding::ValueTypeMarker>::borrow(val),
2325 encoder,
2326 offset + 8,
2327 _depth,
2328 ),
2329 Metric::NetworkActivity(ref val) => {
2330 fidl::encoding::encode_in_envelope::<NetworkActivity, D>(
2331 <NetworkActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
2332 encoder,
2333 offset + 8,
2334 _depth,
2335 )
2336 }
2337 }
2338 }
2339 }
2340
2341 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Metric {
2342 #[inline(always)]
2343 fn new_empty() -> Self {
2344 Self::Temperature(fidl::new_empty!(Temperature, D))
2345 }
2346
2347 #[inline]
2348 unsafe fn decode(
2349 &mut self,
2350 decoder: &mut fidl::encoding::Decoder<'_, D>,
2351 offset: usize,
2352 mut depth: fidl::encoding::Depth,
2353 ) -> fidl::Result<()> {
2354 decoder.debug_check_bounds::<Self>(offset);
2355 #[allow(unused_variables)]
2356 let next_out_of_line = decoder.next_out_of_line();
2357 let handles_before = decoder.remaining_handles();
2358 let (ordinal, inlined, num_bytes, num_handles) =
2359 fidl::encoding::decode_union_inline_portion(decoder, offset)?;
2360
2361 let member_inline_size = match ordinal {
2362 1 => <Temperature as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2363 2 => <CpuLoad as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2364 3 => <Power as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2365 4 => <GpuUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2366 5 => <NetworkActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2367 _ => return Err(fidl::Error::UnknownUnionTag),
2368 };
2369
2370 if inlined != (member_inline_size <= 4) {
2371 return Err(fidl::Error::InvalidInlineBitInEnvelope);
2372 }
2373 let _inner_offset;
2374 if inlined {
2375 decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
2376 _inner_offset = offset + 8;
2377 } else {
2378 depth.increment()?;
2379 _inner_offset = decoder.out_of_line_offset(member_inline_size)?;
2380 }
2381 match ordinal {
2382 1 => {
2383 #[allow(irrefutable_let_patterns)]
2384 if let Metric::Temperature(_) = self {
2385 } else {
2387 *self = Metric::Temperature(fidl::new_empty!(Temperature, D));
2389 }
2390 #[allow(irrefutable_let_patterns)]
2391 if let Metric::Temperature(ref mut val) = self {
2392 fidl::decode!(Temperature, D, val, decoder, _inner_offset, depth)?;
2393 } else {
2394 unreachable!()
2395 }
2396 }
2397 2 => {
2398 #[allow(irrefutable_let_patterns)]
2399 if let Metric::CpuLoad(_) = self {
2400 } else {
2402 *self = Metric::CpuLoad(fidl::new_empty!(CpuLoad, D));
2404 }
2405 #[allow(irrefutable_let_patterns)]
2406 if let Metric::CpuLoad(ref mut val) = self {
2407 fidl::decode!(CpuLoad, D, val, decoder, _inner_offset, depth)?;
2408 } else {
2409 unreachable!()
2410 }
2411 }
2412 3 => {
2413 #[allow(irrefutable_let_patterns)]
2414 if let Metric::Power(_) = self {
2415 } else {
2417 *self = Metric::Power(fidl::new_empty!(Power, D));
2419 }
2420 #[allow(irrefutable_let_patterns)]
2421 if let Metric::Power(ref mut val) = self {
2422 fidl::decode!(Power, D, val, decoder, _inner_offset, depth)?;
2423 } else {
2424 unreachable!()
2425 }
2426 }
2427 4 => {
2428 #[allow(irrefutable_let_patterns)]
2429 if let Metric::GpuUsage(_) = self {
2430 } else {
2432 *self = Metric::GpuUsage(fidl::new_empty!(GpuUsage, D));
2434 }
2435 #[allow(irrefutable_let_patterns)]
2436 if let Metric::GpuUsage(ref mut val) = self {
2437 fidl::decode!(GpuUsage, D, val, decoder, _inner_offset, depth)?;
2438 } else {
2439 unreachable!()
2440 }
2441 }
2442 5 => {
2443 #[allow(irrefutable_let_patterns)]
2444 if let Metric::NetworkActivity(_) = self {
2445 } else {
2447 *self = Metric::NetworkActivity(fidl::new_empty!(NetworkActivity, D));
2449 }
2450 #[allow(irrefutable_let_patterns)]
2451 if let Metric::NetworkActivity(ref mut val) = self {
2452 fidl::decode!(NetworkActivity, D, val, decoder, _inner_offset, depth)?;
2453 } else {
2454 unreachable!()
2455 }
2456 }
2457 ordinal => panic!("unexpected ordinal {:?}", ordinal),
2458 }
2459 if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
2460 return Err(fidl::Error::InvalidNumBytesInEnvelope);
2461 }
2462 if handles_before != decoder.remaining_handles() + (num_handles as usize) {
2463 return Err(fidl::Error::InvalidNumHandlesInEnvelope);
2464 }
2465 Ok(())
2466 }
2467 }
2468}