#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use bitflags::bitflags;
use fidl::client::QueryResponseFut;
use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
use fidl::endpoints::{ControlHandle as _, Responder as _};
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
pub type ClientId = String;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum RecorderError {
NoDrivers = 1,
InvalidSamplingInterval = 2,
AlreadyLogging = 3,
DuplicatedMetric = 4,
TooManyActiveClients = 5,
InvalidStatisticsInterval = 6,
Internal = 7,
}
impl RecorderError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::NoDrivers),
2 => Some(Self::InvalidSamplingInterval),
3 => Some(Self::AlreadyLogging),
4 => Some(Self::DuplicatedMetric),
5 => Some(Self::TooManyActiveClients),
6 => Some(Self::InvalidStatisticsInterval),
7 => Some(Self::Internal),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u32 {
self as u32
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct CpuLoad {
pub interval_ms: u32,
}
impl fidl::Persistable for CpuLoad {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct GpuUsage {
pub interval_ms: u32,
}
impl fidl::Persistable for GpuUsage {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct NetworkActivity {
pub interval_ms: u32,
}
impl fidl::Persistable for NetworkActivity {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Power {
pub sampling_interval_ms: u32,
pub statistics_args: Option<Box<StatisticsArgs>>,
}
impl fidl::Persistable for Power {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct RecorderStartLoggingForeverRequest {
pub client_id: String,
pub metrics: Vec<Metric>,
pub output_samples_to_syslog: bool,
pub output_stats_to_syslog: bool,
}
impl fidl::Persistable for RecorderStartLoggingForeverRequest {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct RecorderStartLoggingRequest {
pub client_id: String,
pub metrics: Vec<Metric>,
pub duration_ms: u32,
pub output_samples_to_syslog: bool,
pub output_stats_to_syslog: bool,
}
impl fidl::Persistable for RecorderStartLoggingRequest {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct RecorderStopLoggingRequest {
pub client_id: String,
}
impl fidl::Persistable for RecorderStopLoggingRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct RecorderStopLoggingResponse {
pub stopped: bool,
}
impl fidl::Persistable for RecorderStopLoggingResponse {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct StatisticsArgs {
pub statistics_interval_ms: u32,
}
impl fidl::Persistable for StatisticsArgs {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Temperature {
pub sampling_interval_ms: u32,
pub statistics_args: Option<Box<StatisticsArgs>>,
}
impl fidl::Persistable for Temperature {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum Metric {
Temperature(Temperature),
CpuLoad(CpuLoad),
Power(Power),
GpuUsage(GpuUsage),
NetworkActivity(NetworkActivity),
}
impl Metric {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Temperature(_) => 1,
Self::CpuLoad(_) => 2,
Self::Power(_) => 3,
Self::GpuUsage(_) => 4,
Self::NetworkActivity(_) => 5,
}
}
#[deprecated = "Strict unions should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
impl fidl::Persistable for Metric {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct RecorderMarker;
impl fidl::endpoints::ProtocolMarker for RecorderMarker {
type Proxy = RecorderProxy;
type RequestStream = RecorderRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = RecorderSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.power.metrics.Recorder";
}
impl fidl::endpoints::DiscoverableProtocolMarker for RecorderMarker {}
pub type RecorderStartLoggingResult = Result<(), RecorderError>;
pub type RecorderStartLoggingForeverResult = Result<(), RecorderError>;
pub trait RecorderProxyInterface: Send + Sync {
type StartLoggingResponseFut: std::future::Future<Output = Result<RecorderStartLoggingResult, fidl::Error>>
+ Send;
fn r#start_logging(
&self,
client_id: &str,
metrics: &[Metric],
duration_ms: u32,
output_samples_to_syslog: bool,
output_stats_to_syslog: bool,
) -> Self::StartLoggingResponseFut;
type StartLoggingForeverResponseFut: std::future::Future<Output = Result<RecorderStartLoggingForeverResult, fidl::Error>>
+ Send;
fn r#start_logging_forever(
&self,
client_id: &str,
metrics: &[Metric],
output_samples_to_syslog: bool,
output_stats_to_syslog: bool,
) -> Self::StartLoggingForeverResponseFut;
type StopLoggingResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
fn r#stop_logging(&self, client_id: &str) -> Self::StopLoggingResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct RecorderSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for RecorderSynchronousProxy {
type Proxy = RecorderProxy;
type Protocol = RecorderMarker;
fn from_channel(inner: fidl::Channel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
fn as_channel(&self) -> &fidl::Channel {
self.client.as_channel()
}
}
#[cfg(target_os = "fuchsia")]
impl RecorderSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(
&self,
deadline: zx::MonotonicInstant,
) -> Result<RecorderEvent, fidl::Error> {
RecorderEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#start_logging(
&self,
mut client_id: &str,
mut metrics: &[Metric],
mut duration_ms: u32,
mut output_samples_to_syslog: bool,
mut output_stats_to_syslog: bool,
___deadline: zx::MonotonicInstant,
) -> Result<RecorderStartLoggingResult, fidl::Error> {
let _response = self.client.send_query::<
RecorderStartLoggingRequest,
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
>(
(client_id, metrics, duration_ms, output_samples_to_syslog, output_stats_to_syslog,),
0x40e4e1a9c6c42bd2,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x))
}
pub fn r#start_logging_forever(
&self,
mut client_id: &str,
mut metrics: &[Metric],
mut output_samples_to_syslog: bool,
mut output_stats_to_syslog: bool,
___deadline: zx::MonotonicInstant,
) -> Result<RecorderStartLoggingForeverResult, fidl::Error> {
let _response = self.client.send_query::<
RecorderStartLoggingForeverRequest,
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
>(
(client_id, metrics, output_samples_to_syslog, output_stats_to_syslog,),
0x37b2675fdc61ff94,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x))
}
pub fn r#stop_logging(
&self,
mut client_id: &str,
___deadline: zx::MonotonicInstant,
) -> Result<bool, fidl::Error> {
let _response =
self.client.send_query::<RecorderStopLoggingRequest, RecorderStopLoggingResponse>(
(client_id,),
0x615d67a4d94d4732,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.stopped)
}
}
#[derive(Debug, Clone)]
pub struct RecorderProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for RecorderProxy {
type Protocol = RecorderMarker;
fn from_channel(inner: ::fidl::AsyncChannel) -> Self {
Self::new(inner)
}
fn into_channel(self) -> Result<::fidl::AsyncChannel, Self> {
self.client.into_channel().map_err(|client| Self { client })
}
fn as_channel(&self) -> &::fidl::AsyncChannel {
self.client.as_channel()
}
}
impl RecorderProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> RecorderEventStream {
RecorderEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#start_logging(
&self,
mut client_id: &str,
mut metrics: &[Metric],
mut duration_ms: u32,
mut output_samples_to_syslog: bool,
mut output_stats_to_syslog: bool,
) -> fidl::client::QueryResponseFut<
RecorderStartLoggingResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
RecorderProxyInterface::r#start_logging(
self,
client_id,
metrics,
duration_ms,
output_samples_to_syslog,
output_stats_to_syslog,
)
}
pub fn r#start_logging_forever(
&self,
mut client_id: &str,
mut metrics: &[Metric],
mut output_samples_to_syslog: bool,
mut output_stats_to_syslog: bool,
) -> fidl::client::QueryResponseFut<
RecorderStartLoggingForeverResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
RecorderProxyInterface::r#start_logging_forever(
self,
client_id,
metrics,
output_samples_to_syslog,
output_stats_to_syslog,
)
}
pub fn r#stop_logging(
&self,
mut client_id: &str,
) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
RecorderProxyInterface::r#stop_logging(self, client_id)
}
}
impl RecorderProxyInterface for RecorderProxy {
type StartLoggingResponseFut = fidl::client::QueryResponseFut<
RecorderStartLoggingResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#start_logging(
&self,
mut client_id: &str,
mut metrics: &[Metric],
mut duration_ms: u32,
mut output_samples_to_syslog: bool,
mut output_stats_to_syslog: bool,
) -> Self::StartLoggingResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<RecorderStartLoggingResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x40e4e1a9c6c42bd2,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client
.send_query_and_decode::<RecorderStartLoggingRequest, RecorderStartLoggingResult>(
(client_id, metrics, duration_ms, output_samples_to_syslog, output_stats_to_syslog),
0x40e4e1a9c6c42bd2,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StartLoggingForeverResponseFut = fidl::client::QueryResponseFut<
RecorderStartLoggingForeverResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#start_logging_forever(
&self,
mut client_id: &str,
mut metrics: &[Metric],
mut output_samples_to_syslog: bool,
mut output_stats_to_syslog: bool,
) -> Self::StartLoggingForeverResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<RecorderStartLoggingForeverResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, RecorderError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x37b2675fdc61ff94,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<
RecorderStartLoggingForeverRequest,
RecorderStartLoggingForeverResult,
>(
(client_id, metrics, output_samples_to_syslog, output_stats_to_syslog,),
0x37b2675fdc61ff94,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type StopLoggingResponseFut =
fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#stop_logging(&self, mut client_id: &str) -> Self::StopLoggingResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<bool, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
RecorderStopLoggingResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x615d67a4d94d4732,
>(_buf?)?;
Ok(_response.stopped)
}
self.client.send_query_and_decode::<RecorderStopLoggingRequest, bool>(
(client_id,),
0x615d67a4d94d4732,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct RecorderEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for RecorderEventStream {}
impl futures::stream::FusedStream for RecorderEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for RecorderEventStream {
type Item = Result<RecorderEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => std::task::Poll::Ready(Some(RecorderEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum RecorderEvent {}
impl RecorderEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<RecorderEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct RecorderRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for RecorderRequestStream {}
impl futures::stream::FusedStream for RecorderRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for RecorderRequestStream {
type Protocol = RecorderMarker;
type ControlHandle = RecorderControlHandle;
fn from_channel(channel: ::fidl::AsyncChannel) -> Self {
Self { inner: std::sync::Arc::new(fidl::ServeInner::new(channel)), is_terminated: false }
}
fn control_handle(&self) -> Self::ControlHandle {
RecorderControlHandle { inner: self.inner.clone() }
}
fn into_inner(
self,
) -> (::std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>, bool)
{
(self.inner, self.is_terminated)
}
fn from_inner(
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for RecorderRequestStream {
type Item = Result<RecorderRequest, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = &mut *self;
if this.inner.check_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled RecorderRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf::<_, fidl::encoding::DefaultFuchsiaResourceDialect>(
|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(
e.into(),
))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x40e4e1a9c6c42bd2 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
RecorderStartLoggingRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecorderStartLoggingRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = RecorderControlHandle { inner: this.inner.clone() };
Ok(RecorderRequest::StartLogging {
client_id: req.client_id,
metrics: req.metrics,
duration_ms: req.duration_ms,
output_samples_to_syslog: req.output_samples_to_syslog,
output_stats_to_syslog: req.output_stats_to_syslog,
responder: RecorderStartLoggingResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x37b2675fdc61ff94 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
RecorderStartLoggingForeverRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecorderStartLoggingForeverRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = RecorderControlHandle { inner: this.inner.clone() };
Ok(RecorderRequest::StartLoggingForever {
client_id: req.client_id,
metrics: req.metrics,
output_samples_to_syslog: req.output_samples_to_syslog,
output_stats_to_syslog: req.output_stats_to_syslog,
responder: RecorderStartLoggingForeverResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x615d67a4d94d4732 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
RecorderStopLoggingRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<RecorderStopLoggingRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = RecorderControlHandle { inner: this.inner.clone() };
Ok(RecorderRequest::StopLogging {
client_id: req.client_id,
responder: RecorderStopLoggingResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<RecorderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum RecorderRequest {
StartLogging {
client_id: String,
metrics: Vec<Metric>,
duration_ms: u32,
output_samples_to_syslog: bool,
output_stats_to_syslog: bool,
responder: RecorderStartLoggingResponder,
},
StartLoggingForever {
client_id: String,
metrics: Vec<Metric>,
output_samples_to_syslog: bool,
output_stats_to_syslog: bool,
responder: RecorderStartLoggingForeverResponder,
},
StopLogging { client_id: String, responder: RecorderStopLoggingResponder },
}
impl RecorderRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_start_logging(
self,
) -> Option<(String, Vec<Metric>, u32, bool, bool, RecorderStartLoggingResponder)> {
if let RecorderRequest::StartLogging {
client_id,
metrics,
duration_ms,
output_samples_to_syslog,
output_stats_to_syslog,
responder,
} = self
{
Some((
client_id,
metrics,
duration_ms,
output_samples_to_syslog,
output_stats_to_syslog,
responder,
))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start_logging_forever(
self,
) -> Option<(String, Vec<Metric>, bool, bool, RecorderStartLoggingForeverResponder)> {
if let RecorderRequest::StartLoggingForever {
client_id,
metrics,
output_samples_to_syslog,
output_stats_to_syslog,
responder,
} = self
{
Some((client_id, metrics, output_samples_to_syslog, output_stats_to_syslog, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_stop_logging(self) -> Option<(String, RecorderStopLoggingResponder)> {
if let RecorderRequest::StopLogging { client_id, responder } = self {
Some((client_id, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
RecorderRequest::StartLogging { .. } => "start_logging",
RecorderRequest::StartLoggingForever { .. } => "start_logging_forever",
RecorderRequest::StopLogging { .. } => "stop_logging",
}
}
}
#[derive(Debug, Clone)]
pub struct RecorderControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for RecorderControlHandle {
fn shutdown(&self) {
self.inner.shutdown()
}
fn shutdown_with_epitaph(&self, status: zx_status::Status) {
self.inner.shutdown_with_epitaph(status)
}
fn is_closed(&self) -> bool {
self.inner.channel().is_closed()
}
fn on_closed(&self) -> fidl::OnSignalsRef<'_> {
self.inner.channel().on_closed()
}
#[cfg(target_os = "fuchsia")]
fn signal_peer(
&self,
clear_mask: zx::Signals,
set_mask: zx::Signals,
) -> Result<(), zx_status::Status> {
use fidl::Peered;
self.inner.channel().signal_peer(clear_mask, set_mask)
}
}
impl RecorderControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct RecorderStartLoggingResponder {
control_handle: std::mem::ManuallyDrop<RecorderControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for RecorderStartLoggingResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for RecorderStartLoggingResponder {
type ControlHandle = RecorderControlHandle;
fn control_handle(&self) -> &RecorderControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl RecorderStartLoggingResponder {
pub fn send(self, mut result: Result<(), RecorderError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<(), RecorderError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), RecorderError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::ResultType<
fidl::encoding::EmptyStruct,
RecorderError,
>>(
result,
self.tx_id,
0x40e4e1a9c6c42bd2,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct RecorderStartLoggingForeverResponder {
control_handle: std::mem::ManuallyDrop<RecorderControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for RecorderStartLoggingForeverResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for RecorderStartLoggingForeverResponder {
type ControlHandle = RecorderControlHandle;
fn control_handle(&self) -> &RecorderControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl RecorderStartLoggingForeverResponder {
pub fn send(self, mut result: Result<(), RecorderError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<(), RecorderError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), RecorderError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::ResultType<
fidl::encoding::EmptyStruct,
RecorderError,
>>(
result,
self.tx_id,
0x37b2675fdc61ff94,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct RecorderStopLoggingResponder {
control_handle: std::mem::ManuallyDrop<RecorderControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for RecorderStopLoggingResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for RecorderStopLoggingResponder {
type ControlHandle = RecorderControlHandle;
fn control_handle(&self) -> &RecorderControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl RecorderStopLoggingResponder {
pub fn send(self, mut stopped: bool) -> Result<(), fidl::Error> {
let _result = self.send_raw(stopped);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut stopped: bool) -> Result<(), fidl::Error> {
let _result = self.send_raw(stopped);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut stopped: bool) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<RecorderStopLoggingResponse>(
(stopped,),
self.tx_id,
0x615d67a4d94d4732,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for RecorderError {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u32>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u32>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for RecorderError {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
*value
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for RecorderError {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for RecorderError {
#[inline(always)]
fn new_empty() -> Self {
Self::NoDrivers
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for CpuLoad {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for CpuLoad {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<CpuLoad, D> for &CpuLoad {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CpuLoad>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut CpuLoad).write_unaligned((self as *const CpuLoad).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
fidl::encoding::Encode<CpuLoad, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CpuLoad>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for CpuLoad {
#[inline(always)]
fn new_empty() -> Self {
Self { interval_ms: fidl::new_empty!(u32, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for GpuUsage {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for GpuUsage {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<GpuUsage, D> for &GpuUsage {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<GpuUsage>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut GpuUsage).write_unaligned((self as *const GpuUsage).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
fidl::encoding::Encode<GpuUsage, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<GpuUsage>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for GpuUsage {
#[inline(always)]
fn new_empty() -> Self {
Self { interval_ms: fidl::new_empty!(u32, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for NetworkActivity {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for NetworkActivity {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<NetworkActivity, D>
for &NetworkActivity
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<NetworkActivity>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut NetworkActivity)
.write_unaligned((self as *const NetworkActivity).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
fidl::encoding::Encode<NetworkActivity, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<NetworkActivity>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for NetworkActivity {
#[inline(always)]
fn new_empty() -> Self {
Self { interval_ms: fidl::new_empty!(u32, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for Power {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Power {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Power, D> for &Power {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Power>(offset);
fidl::encoding::Encode::<Power, D>::encode(
(
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.sampling_interval_ms),
<fidl::encoding::Boxed<StatisticsArgs> as fidl::encoding::ValueTypeMarker>::borrow(&self.statistics_args),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<u32, D>,
T1: fidl::encoding::Encode<fidl::encoding::Boxed<StatisticsArgs>, D>,
> fidl::encoding::Encode<Power, D> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Power>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Power {
#[inline(always)]
fn new_empty() -> Self {
Self {
sampling_interval_ms: fidl::new_empty!(u32, D),
statistics_args: fidl::new_empty!(fidl::encoding::Boxed<StatisticsArgs>, D),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(u32, D, &mut self.sampling_interval_ms, decoder, offset + 0, _depth)?;
fidl::decode!(
fidl::encoding::Boxed<StatisticsArgs>,
D,
&mut self.statistics_args,
decoder,
offset + 8,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for RecorderStartLoggingForeverRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for RecorderStartLoggingForeverRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
40
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<RecorderStartLoggingForeverRequest, D>
for &RecorderStartLoggingForeverRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStartLoggingForeverRequest>(offset);
fidl::encoding::Encode::<RecorderStartLoggingForeverRequest, D>::encode(
(
<fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(&self.client_id),
<fidl::encoding::UnboundedVector<Metric> as fidl::encoding::ValueTypeMarker>::borrow(&self.metrics),
<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_samples_to_syslog),
<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_stats_to_syslog),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>, D>,
T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Metric>, D>,
T2: fidl::encoding::Encode<bool, D>,
T3: fidl::encoding::Encode<bool, D>,
> fidl::encoding::Encode<RecorderStartLoggingForeverRequest, D> for (T0, T1, T2, T3)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStartLoggingForeverRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 16, depth)?;
self.2.encode(encoder, offset + 32, depth)?;
self.3.encode(encoder, offset + 33, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for RecorderStartLoggingForeverRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self {
client_id: fidl::new_empty!(fidl::encoding::BoundedString<16>, D),
metrics: fidl::new_empty!(fidl::encoding::UnboundedVector<Metric>, D),
output_samples_to_syslog: fidl::new_empty!(bool, D),
output_stats_to_syslog: fidl::new_empty!(bool, D),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffffffff0000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
fidl::encoding::BoundedString<16>,
D,
&mut self.client_id,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
fidl::encoding::UnboundedVector<Metric>,
D,
&mut self.metrics,
decoder,
offset + 16,
_depth
)?;
fidl::decode!(
bool,
D,
&mut self.output_samples_to_syslog,
decoder,
offset + 32,
_depth
)?;
fidl::decode!(bool, D, &mut self.output_stats_to_syslog, decoder, offset + 33, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for RecorderStartLoggingRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for RecorderStartLoggingRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
40
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<RecorderStartLoggingRequest, D> for &RecorderStartLoggingRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStartLoggingRequest>(offset);
fidl::encoding::Encode::<RecorderStartLoggingRequest, D>::encode(
(
<fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(&self.client_id),
<fidl::encoding::UnboundedVector<Metric> as fidl::encoding::ValueTypeMarker>::borrow(&self.metrics),
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.duration_ms),
<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_samples_to_syslog),
<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.output_stats_to_syslog),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>, D>,
T1: fidl::encoding::Encode<fidl::encoding::UnboundedVector<Metric>, D>,
T2: fidl::encoding::Encode<u32, D>,
T3: fidl::encoding::Encode<bool, D>,
T4: fidl::encoding::Encode<bool, D>,
> fidl::encoding::Encode<RecorderStartLoggingRequest, D> for (T0, T1, T2, T3, T4)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStartLoggingRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 16, depth)?;
self.2.encode(encoder, offset + 32, depth)?;
self.3.encode(encoder, offset + 36, depth)?;
self.4.encode(encoder, offset + 37, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for RecorderStartLoggingRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self {
client_id: fidl::new_empty!(fidl::encoding::BoundedString<16>, D),
metrics: fidl::new_empty!(fidl::encoding::UnboundedVector<Metric>, D),
duration_ms: fidl::new_empty!(u32, D),
output_samples_to_syslog: fidl::new_empty!(bool, D),
output_stats_to_syslog: fidl::new_empty!(bool, D),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffff000000000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
fidl::encoding::BoundedString<16>,
D,
&mut self.client_id,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
fidl::encoding::UnboundedVector<Metric>,
D,
&mut self.metrics,
decoder,
offset + 16,
_depth
)?;
fidl::decode!(u32, D, &mut self.duration_ms, decoder, offset + 32, _depth)?;
fidl::decode!(
bool,
D,
&mut self.output_samples_to_syslog,
decoder,
offset + 36,
_depth
)?;
fidl::decode!(bool, D, &mut self.output_stats_to_syslog, decoder, offset + 37, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for RecorderStopLoggingRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for RecorderStopLoggingRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<RecorderStopLoggingRequest, D> for &RecorderStopLoggingRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStopLoggingRequest>(offset);
fidl::encoding::Encode::<RecorderStopLoggingRequest, D>::encode(
(<fidl::encoding::BoundedString<16> as fidl::encoding::ValueTypeMarker>::borrow(
&self.client_id,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl::encoding::BoundedString<16>, D>,
> fidl::encoding::Encode<RecorderStopLoggingRequest, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStopLoggingRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for RecorderStopLoggingRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { client_id: fidl::new_empty!(fidl::encoding::BoundedString<16>, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::BoundedString<16>,
D,
&mut self.client_id,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for RecorderStopLoggingResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for RecorderStopLoggingResponse {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
1
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
1
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<RecorderStopLoggingResponse, D> for &RecorderStopLoggingResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStopLoggingResponse>(offset);
fidl::encoding::Encode::<RecorderStopLoggingResponse, D>::encode(
(<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.stopped),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
fidl::encoding::Encode<RecorderStopLoggingResponse, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<RecorderStopLoggingResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for RecorderStopLoggingResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { stopped: fidl::new_empty!(bool, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(bool, D, &mut self.stopped, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for StatisticsArgs {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for StatisticsArgs {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<StatisticsArgs, D>
for &StatisticsArgs
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StatisticsArgs>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut StatisticsArgs)
.write_unaligned((self as *const StatisticsArgs).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
fidl::encoding::Encode<StatisticsArgs, D> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<StatisticsArgs>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for StatisticsArgs {
#[inline(always)]
fn new_empty() -> Self {
Self { statistics_interval_ms: fidl::new_empty!(u32, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for Temperature {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Temperature {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Temperature, D>
for &Temperature
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Temperature>(offset);
fidl::encoding::Encode::<Temperature, D>::encode(
(
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.sampling_interval_ms),
<fidl::encoding::Boxed<StatisticsArgs> as fidl::encoding::ValueTypeMarker>::borrow(&self.statistics_args),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<u32, D>,
T1: fidl::encoding::Encode<fidl::encoding::Boxed<StatisticsArgs>, D>,
> fidl::encoding::Encode<Temperature, D> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Temperature>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Temperature {
#[inline(always)]
fn new_empty() -> Self {
Self {
sampling_interval_ms: fidl::new_empty!(u32, D),
statistics_args: fidl::new_empty!(fidl::encoding::Boxed<StatisticsArgs>, D),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(u32, D, &mut self.sampling_interval_ms, decoder, offset + 0, _depth)?;
fidl::decode!(
fidl::encoding::Boxed<StatisticsArgs>,
D,
&mut self.statistics_args,
decoder,
offset + 8,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for Metric {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Metric {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Metric, D> for &Metric {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Metric>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
Metric::Temperature(ref val) => {
fidl::encoding::encode_in_envelope::<Temperature, D>(
<Temperature as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
Metric::CpuLoad(ref val) => fidl::encoding::encode_in_envelope::<CpuLoad, D>(
<CpuLoad as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
Metric::Power(ref val) => fidl::encoding::encode_in_envelope::<Power, D>(
<Power as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
Metric::GpuUsage(ref val) => fidl::encoding::encode_in_envelope::<GpuUsage, D>(
<GpuUsage as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
Metric::NetworkActivity(ref val) => {
fidl::encoding::encode_in_envelope::<NetworkActivity, D>(
<NetworkActivity as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Metric {
#[inline(always)]
fn new_empty() -> Self {
Self::Temperature(fidl::new_empty!(Temperature, D))
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
#[allow(unused_variables)]
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
let (ordinal, inlined, num_bytes, num_handles) =
fidl::encoding::decode_union_inline_portion(decoder, offset)?;
let member_inline_size = match ordinal {
1 => <Temperature as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <CpuLoad as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <Power as fidl::encoding::TypeMarker>::inline_size(decoder.context),
4 => <GpuUsage as fidl::encoding::TypeMarker>::inline_size(decoder.context),
5 => <NetworkActivity as fidl::encoding::TypeMarker>::inline_size(decoder.context),
_ => return Err(fidl::Error::UnknownUnionTag),
};
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let _inner_offset;
if inlined {
decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
_inner_offset = offset + 8;
} else {
depth.increment()?;
_inner_offset = decoder.out_of_line_offset(member_inline_size)?;
}
match ordinal {
1 => {
#[allow(irrefutable_let_patterns)]
if let Metric::Temperature(_) = self {
} else {
*self = Metric::Temperature(fidl::new_empty!(Temperature, D));
}
#[allow(irrefutable_let_patterns)]
if let Metric::Temperature(ref mut val) = self {
fidl::decode!(Temperature, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let Metric::CpuLoad(_) = self {
} else {
*self = Metric::CpuLoad(fidl::new_empty!(CpuLoad, D));
}
#[allow(irrefutable_let_patterns)]
if let Metric::CpuLoad(ref mut val) = self {
fidl::decode!(CpuLoad, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let Metric::Power(_) = self {
} else {
*self = Metric::Power(fidl::new_empty!(Power, D));
}
#[allow(irrefutable_let_patterns)]
if let Metric::Power(ref mut val) = self {
fidl::decode!(Power, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
4 => {
#[allow(irrefutable_let_patterns)]
if let Metric::GpuUsage(_) = self {
} else {
*self = Metric::GpuUsage(fidl::new_empty!(GpuUsage, D));
}
#[allow(irrefutable_let_patterns)]
if let Metric::GpuUsage(ref mut val) = self {
fidl::decode!(GpuUsage, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
5 => {
#[allow(irrefutable_let_patterns)]
if let Metric::NetworkActivity(_) = self {
} else {
*self = Metric::NetworkActivity(fidl::new_empty!(NetworkActivity, D));
}
#[allow(irrefutable_let_patterns)]
if let Metric::NetworkActivity(ref mut val) = self {
fidl::decode!(NetworkActivity, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
ordinal => panic!("unexpected ordinal {:?}", ordinal),
}
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
Ok(())
}
}
}