#![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;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum BatteryStatus {
Unknown = 0,
Ok = 1,
NotAvailable = 2,
NotPresent = 3,
}
impl BatteryStatus {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
0 => Some(Self::Unknown),
1 => Some(Self::Ok),
2 => Some(Self::NotAvailable),
3 => Some(Self::NotPresent),
_ => 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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum ChargeSource {
Unknown = 0,
None = 1,
AcAdapter = 2,
Usb = 3,
Wireless = 4,
}
impl ChargeSource {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
0 => Some(Self::Unknown),
1 => Some(Self::None),
2 => Some(Self::AcAdapter),
3 => Some(Self::Usb),
4 => Some(Self::Wireless),
_ => 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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum ChargeStatus {
Unknown = 0,
NotCharging = 1,
Charging = 2,
Discharging = 3,
Full = 4,
}
impl ChargeStatus {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
0 => Some(Self::Unknown),
1 => Some(Self::NotCharging),
2 => Some(Self::Charging),
3 => Some(Self::Discharging),
4 => Some(Self::Full),
_ => 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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum HealthStatus {
Unknown = 0,
Good = 1,
Cold = 2,
Hot = 3,
Dead = 4,
OverVoltage = 5,
UnspecifiedFailure = 6,
}
impl HealthStatus {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
0 => Some(Self::Unknown),
1 => Some(Self::Good),
2 => Some(Self::Cold),
3 => Some(Self::Hot),
4 => Some(Self::Dead),
5 => Some(Self::OverVoltage),
6 => Some(Self::UnspecifiedFailure),
_ => 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(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum LevelStatus {
Unknown = 0,
Ok = 1,
Warning = 2,
Low = 3,
Critical = 4,
}
impl LevelStatus {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
0 => Some(Self::Unknown),
1 => Some(Self::Ok),
2 => Some(Self::Warning),
3 => Some(Self::Low),
4 => Some(Self::Critical),
_ => 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, Debug, PartialEq)]
pub struct BatteryInfoProviderGetBatteryInfoResponse {
pub info: BatteryInfo,
}
impl fidl::Persistable for BatteryInfoProviderGetBatteryInfoResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BatteryInfoProviderWatchRequest {
pub watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
for BatteryInfoProviderWatchRequest
{
}
#[derive(Clone, Debug, PartialEq)]
pub struct BatteryInfoWatcherOnChangeBatteryInfoRequest {
pub info: BatteryInfo,
}
impl fidl::Persistable for BatteryInfoWatcherOnChangeBatteryInfoRequest {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct BatteryInfo {
pub status: Option<BatteryStatus>,
pub charge_status: Option<ChargeStatus>,
pub charge_source: Option<ChargeSource>,
pub level_percent: Option<f32>,
pub level_status: Option<LevelStatus>,
pub health: Option<HealthStatus>,
pub time_remaining: Option<TimeRemaining>,
pub timestamp: Option<i64>,
pub present_voltage_mv: Option<u32>,
pub remaining_capacity_uah: Option<u32>,
pub battery_spec: Option<BatterySpec>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for BatteryInfo {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct BatterySpec {
pub max_charging_current_ua: Option<i32>,
pub max_charnging_voltage_uv: Option<i32>,
pub design_capacity_uah: Option<i32>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for BatterySpec {}
#[derive(Clone, Debug)]
pub enum TimeRemaining {
Indeterminate(i64),
BatteryLife(i64),
FullCharge(i64),
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u64 },
}
#[macro_export]
macro_rules! TimeRemainingUnknown {
() => {
_
};
}
impl PartialEq for TimeRemaining {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Indeterminate(x), Self::Indeterminate(y)) => *x == *y,
(Self::BatteryLife(x), Self::BatteryLife(y)) => *x == *y,
(Self::FullCharge(x), Self::FullCharge(y)) => *x == *y,
_ => false,
}
}
}
impl TimeRemaining {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Indeterminate(_) => 1,
Self::BatteryLife(_) => 2,
Self::FullCharge(_) => 3,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Persistable for TimeRemaining {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct BatteryInfoProviderMarker;
impl fidl::endpoints::ProtocolMarker for BatteryInfoProviderMarker {
type Proxy = BatteryInfoProviderProxy;
type RequestStream = BatteryInfoProviderRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = BatteryInfoProviderSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) BatteryInfoProvider";
}
pub trait BatteryInfoProviderProxyInterface: Send + Sync {
type GetBatteryInfoResponseFut: std::future::Future<Output = Result<BatteryInfo, fidl::Error>>
+ Send;
fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
fn r#watch(
&self,
watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error>;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct BatteryInfoProviderSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for BatteryInfoProviderSynchronousProxy {
type Proxy = BatteryInfoProviderProxy;
type Protocol = BatteryInfoProviderMarker;
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 BatteryInfoProviderSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name =
<BatteryInfoProviderMarker 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<BatteryInfoProviderEvent, fidl::Error> {
BatteryInfoProviderEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get_battery_info(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<BatteryInfo, fidl::Error> {
let _response = self
.client
.send_query::<fidl::encoding::EmptyPayload, BatteryInfoProviderGetBatteryInfoResponse>(
(),
0x51ea101e4fe7a192,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.info)
}
pub fn r#watch(
&self,
mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error> {
self.client.send::<BatteryInfoProviderWatchRequest>(
(watcher,),
0x4d44a314cd3f5191,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Clone)]
pub struct BatteryInfoProviderProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for BatteryInfoProviderProxy {
type Protocol = BatteryInfoProviderMarker;
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 BatteryInfoProviderProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name =
<BatteryInfoProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> BatteryInfoProviderEventStream {
BatteryInfoProviderEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get_battery_info(
&self,
) -> fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
{
BatteryInfoProviderProxyInterface::r#get_battery_info(self)
}
pub fn r#watch(
&self,
mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error> {
BatteryInfoProviderProxyInterface::r#watch(self, watcher)
}
}
impl BatteryInfoProviderProxyInterface for BatteryInfoProviderProxy {
type GetBatteryInfoResponseFut =
fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<BatteryInfo, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
BatteryInfoProviderGetBatteryInfoResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x51ea101e4fe7a192,
>(_buf?)?;
Ok(_response.info)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BatteryInfo>(
(),
0x51ea101e4fe7a192,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#watch(
&self,
mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error> {
self.client.send::<BatteryInfoProviderWatchRequest>(
(watcher,),
0x4d44a314cd3f5191,
fidl::encoding::DynamicFlags::empty(),
)
}
}
pub struct BatteryInfoProviderEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for BatteryInfoProviderEventStream {}
impl futures::stream::FusedStream for BatteryInfoProviderEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for BatteryInfoProviderEventStream {
type Item = Result<BatteryInfoProviderEvent, 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(BatteryInfoProviderEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum BatteryInfoProviderEvent {}
impl BatteryInfoProviderEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<BatteryInfoProviderEvent, 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:
<BatteryInfoProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct BatteryInfoProviderRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for BatteryInfoProviderRequestStream {}
impl futures::stream::FusedStream for BatteryInfoProviderRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for BatteryInfoProviderRequestStream {
type Protocol = BatteryInfoProviderMarker;
type ControlHandle = BatteryInfoProviderControlHandle;
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 {
BatteryInfoProviderControlHandle { 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 BatteryInfoProviderRequestStream {
type Item = Result<BatteryInfoProviderRequest, 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 BatteryInfoProviderRequestStream 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 {
0x51ea101e4fe7a192 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatteryInfoProviderControlHandle {
inner: this.inner.clone(),
};
Ok(BatteryInfoProviderRequest::GetBatteryInfo {
responder: BatteryInfoProviderGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x4d44a314cd3f5191 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatteryInfoProviderWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatteryInfoProviderWatchRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatteryInfoProviderControlHandle {
inner: this.inner.clone(),
};
Ok(BatteryInfoProviderRequest::Watch {watcher: req.watcher,
control_handle,
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <BatteryInfoProviderMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum BatteryInfoProviderRequest {
GetBatteryInfo { responder: BatteryInfoProviderGetBatteryInfoResponder },
Watch {
watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
control_handle: BatteryInfoProviderControlHandle,
},
}
impl BatteryInfoProviderRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get_battery_info(self) -> Option<(BatteryInfoProviderGetBatteryInfoResponder)> {
if let BatteryInfoProviderRequest::GetBatteryInfo { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_watch(
self,
) -> Option<(
fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
BatteryInfoProviderControlHandle,
)> {
if let BatteryInfoProviderRequest::Watch { watcher, control_handle } = self {
Some((watcher, control_handle))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
BatteryInfoProviderRequest::GetBatteryInfo { .. } => "get_battery_info",
BatteryInfoProviderRequest::Watch { .. } => "watch",
}
}
}
#[derive(Debug, Clone)]
pub struct BatteryInfoProviderControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for BatteryInfoProviderControlHandle {
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 BatteryInfoProviderControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct BatteryInfoProviderGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop<BatteryInfoProviderControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for BatteryInfoProviderGetBatteryInfoResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for BatteryInfoProviderGetBatteryInfoResponder {
type ControlHandle = BatteryInfoProviderControlHandle;
fn control_handle(&self) -> &BatteryInfoProviderControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl BatteryInfoProviderGetBatteryInfoResponder {
pub fn send(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
let _result = self.send_raw(info);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
let _result = self.send_raw(info);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<BatteryInfoProviderGetBatteryInfoResponse>(
(info,),
self.tx_id,
0x51ea101e4fe7a192,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct BatteryInfoWatcherMarker;
impl fidl::endpoints::ProtocolMarker for BatteryInfoWatcherMarker {
type Proxy = BatteryInfoWatcherProxy;
type RequestStream = BatteryInfoWatcherRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = BatteryInfoWatcherSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) BatteryInfoWatcher";
}
pub trait BatteryInfoWatcherProxyInterface: Send + Sync {
type OnChangeBatteryInfoResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
+ Send;
fn r#on_change_battery_info(&self, info: &BatteryInfo) -> Self::OnChangeBatteryInfoResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct BatteryInfoWatcherSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for BatteryInfoWatcherSynchronousProxy {
type Proxy = BatteryInfoWatcherProxy;
type Protocol = BatteryInfoWatcherMarker;
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 BatteryInfoWatcherSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name =
<BatteryInfoWatcherMarker 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<BatteryInfoWatcherEvent, fidl::Error> {
BatteryInfoWatcherEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#on_change_battery_info(
&self,
mut info: &BatteryInfo,
___deadline: zx::MonotonicInstant,
) -> Result<(), fidl::Error> {
let _response = self.client.send_query::<
BatteryInfoWatcherOnChangeBatteryInfoRequest,
fidl::encoding::EmptyPayload,
>(
(info,),
0x2d1eb8ed2b619a7d,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct BatteryInfoWatcherProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for BatteryInfoWatcherProxy {
type Protocol = BatteryInfoWatcherMarker;
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 BatteryInfoWatcherProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name =
<BatteryInfoWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> BatteryInfoWatcherEventStream {
BatteryInfoWatcherEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#on_change_battery_info(
&self,
mut info: &BatteryInfo,
) -> fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect> {
BatteryInfoWatcherProxyInterface::r#on_change_battery_info(self, info)
}
}
impl BatteryInfoWatcherProxyInterface for BatteryInfoWatcherProxy {
type OnChangeBatteryInfoResponseFut =
fidl::client::QueryResponseFut<(), fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#on_change_battery_info(
&self,
mut info: &BatteryInfo,
) -> Self::OnChangeBatteryInfoResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x2d1eb8ed2b619a7d,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<BatteryInfoWatcherOnChangeBatteryInfoRequest, ()>(
(info,),
0x2d1eb8ed2b619a7d,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct BatteryInfoWatcherEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for BatteryInfoWatcherEventStream {}
impl futures::stream::FusedStream for BatteryInfoWatcherEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for BatteryInfoWatcherEventStream {
type Item = Result<BatteryInfoWatcherEvent, 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(BatteryInfoWatcherEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum BatteryInfoWatcherEvent {}
impl BatteryInfoWatcherEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<BatteryInfoWatcherEvent, 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:
<BatteryInfoWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct BatteryInfoWatcherRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for BatteryInfoWatcherRequestStream {}
impl futures::stream::FusedStream for BatteryInfoWatcherRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for BatteryInfoWatcherRequestStream {
type Protocol = BatteryInfoWatcherMarker;
type ControlHandle = BatteryInfoWatcherControlHandle;
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 {
BatteryInfoWatcherControlHandle { 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 BatteryInfoWatcherRequestStream {
type Item = Result<BatteryInfoWatcherRequest, 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 BatteryInfoWatcherRequestStream 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 {
0x2d1eb8ed2b619a7d => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(BatteryInfoWatcherOnChangeBatteryInfoRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatteryInfoWatcherControlHandle {
inner: this.inner.clone(),
};
Ok(BatteryInfoWatcherRequest::OnChangeBatteryInfo {info: req.info,
responder: BatteryInfoWatcherOnChangeBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <BatteryInfoWatcherMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum BatteryInfoWatcherRequest {
OnChangeBatteryInfo {
info: BatteryInfo,
responder: BatteryInfoWatcherOnChangeBatteryInfoResponder,
},
}
impl BatteryInfoWatcherRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_on_change_battery_info(
self,
) -> Option<(BatteryInfo, BatteryInfoWatcherOnChangeBatteryInfoResponder)> {
if let BatteryInfoWatcherRequest::OnChangeBatteryInfo { info, responder } = self {
Some((info, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
BatteryInfoWatcherRequest::OnChangeBatteryInfo { .. } => "on_change_battery_info",
}
}
}
#[derive(Debug, Clone)]
pub struct BatteryInfoWatcherControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for BatteryInfoWatcherControlHandle {
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 BatteryInfoWatcherControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct BatteryInfoWatcherOnChangeBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop<BatteryInfoWatcherControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for BatteryInfoWatcherOnChangeBatteryInfoResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for BatteryInfoWatcherOnChangeBatteryInfoResponder {
type ControlHandle = BatteryInfoWatcherControlHandle;
fn control_handle(&self) -> &BatteryInfoWatcherControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl BatteryInfoWatcherOnChangeBatteryInfoResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x2d1eb8ed2b619a7d,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct BatteryManagerMarker;
impl fidl::endpoints::ProtocolMarker for BatteryManagerMarker {
type Proxy = BatteryManagerProxy;
type RequestStream = BatteryManagerRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = BatteryManagerSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.power.battery.BatteryManager";
}
impl fidl::endpoints::DiscoverableProtocolMarker for BatteryManagerMarker {}
pub trait BatteryManagerProxyInterface: Send + Sync {
type GetBatteryInfoResponseFut: std::future::Future<Output = Result<BatteryInfo, fidl::Error>>
+ Send;
fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
fn r#watch(
&self,
watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error>;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct BatteryManagerSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for BatteryManagerSynchronousProxy {
type Proxy = BatteryManagerProxy;
type Protocol = BatteryManagerMarker;
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 BatteryManagerSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <BatteryManagerMarker 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<BatteryManagerEvent, fidl::Error> {
BatteryManagerEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get_battery_info(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<BatteryInfo, fidl::Error> {
let _response = self
.client
.send_query::<fidl::encoding::EmptyPayload, BatteryInfoProviderGetBatteryInfoResponse>(
(),
0x51ea101e4fe7a192,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.info)
}
pub fn r#watch(
&self,
mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error> {
self.client.send::<BatteryInfoProviderWatchRequest>(
(watcher,),
0x4d44a314cd3f5191,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Clone)]
pub struct BatteryManagerProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for BatteryManagerProxy {
type Protocol = BatteryManagerMarker;
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 BatteryManagerProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <BatteryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> BatteryManagerEventStream {
BatteryManagerEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get_battery_info(
&self,
) -> fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>
{
BatteryManagerProxyInterface::r#get_battery_info(self)
}
pub fn r#watch(
&self,
mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error> {
BatteryManagerProxyInterface::r#watch(self, watcher)
}
}
impl BatteryManagerProxyInterface for BatteryManagerProxy {
type GetBatteryInfoResponseFut =
fidl::client::QueryResponseFut<BatteryInfo, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<BatteryInfo, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
BatteryInfoProviderGetBatteryInfoResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x51ea101e4fe7a192,
>(_buf?)?;
Ok(_response.info)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, BatteryInfo>(
(),
0x51ea101e4fe7a192,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#watch(
&self,
mut watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
) -> Result<(), fidl::Error> {
self.client.send::<BatteryInfoProviderWatchRequest>(
(watcher,),
0x4d44a314cd3f5191,
fidl::encoding::DynamicFlags::empty(),
)
}
}
pub struct BatteryManagerEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for BatteryManagerEventStream {}
impl futures::stream::FusedStream for BatteryManagerEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for BatteryManagerEventStream {
type Item = Result<BatteryManagerEvent, 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(BatteryManagerEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum BatteryManagerEvent {}
impl BatteryManagerEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<BatteryManagerEvent, 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:
<BatteryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct BatteryManagerRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for BatteryManagerRequestStream {}
impl futures::stream::FusedStream for BatteryManagerRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for BatteryManagerRequestStream {
type Protocol = BatteryManagerMarker;
type ControlHandle = BatteryManagerControlHandle;
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 {
BatteryManagerControlHandle { 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 BatteryManagerRequestStream {
type Item = Result<BatteryManagerRequest, 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 BatteryManagerRequestStream 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 {
0x51ea101e4fe7a192 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
fidl::encoding::EmptyPayload,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<fidl::encoding::EmptyPayload>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatteryManagerControlHandle { inner: this.inner.clone() };
Ok(BatteryManagerRequest::GetBatteryInfo {
responder: BatteryManagerGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x4d44a314cd3f5191 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatteryInfoProviderWatchRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatteryInfoProviderWatchRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatteryManagerControlHandle { inner: this.inner.clone() };
Ok(BatteryManagerRequest::Watch { watcher: req.watcher, control_handle })
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<BatteryManagerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum BatteryManagerRequest {
GetBatteryInfo { responder: BatteryManagerGetBatteryInfoResponder },
Watch {
watcher: fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>,
control_handle: BatteryManagerControlHandle,
},
}
impl BatteryManagerRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get_battery_info(self) -> Option<(BatteryManagerGetBatteryInfoResponder)> {
if let BatteryManagerRequest::GetBatteryInfo { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_watch(
self,
) -> Option<(fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>, BatteryManagerControlHandle)>
{
if let BatteryManagerRequest::Watch { watcher, control_handle } = self {
Some((watcher, control_handle))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
BatteryManagerRequest::GetBatteryInfo { .. } => "get_battery_info",
BatteryManagerRequest::Watch { .. } => "watch",
}
}
}
#[derive(Debug, Clone)]
pub struct BatteryManagerControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for BatteryManagerControlHandle {
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 BatteryManagerControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct BatteryManagerGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop<BatteryManagerControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for BatteryManagerGetBatteryInfoResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for BatteryManagerGetBatteryInfoResponder {
type ControlHandle = BatteryManagerControlHandle;
fn control_handle(&self) -> &BatteryManagerControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl BatteryManagerGetBatteryInfoResponder {
pub fn send(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
let _result = self.send_raw(info);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
let _result = self.send_raw(info);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut info: &BatteryInfo) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<BatteryInfoProviderGetBatteryInfoResponse>(
(info,),
self.tx_id,
0x51ea101e4fe7a192,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for BatteryStatus {
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 BatteryStatus {
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 BatteryStatus {
#[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 BatteryStatus {
#[inline(always)]
fn new_empty() -> Self {
Self::Unknown
}
#[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(())
}
}
unsafe impl fidl::encoding::TypeMarker for ChargeSource {
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 ChargeSource {
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 ChargeSource {
#[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 ChargeSource {
#[inline(always)]
fn new_empty() -> Self {
Self::Unknown
}
#[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(())
}
}
unsafe impl fidl::encoding::TypeMarker for ChargeStatus {
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 ChargeStatus {
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 ChargeStatus {
#[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 ChargeStatus {
#[inline(always)]
fn new_empty() -> Self {
Self::Unknown
}
#[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(())
}
}
unsafe impl fidl::encoding::TypeMarker for HealthStatus {
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 HealthStatus {
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 HealthStatus {
#[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 HealthStatus {
#[inline(always)]
fn new_empty() -> Self {
Self::Unknown
}
#[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(())
}
}
unsafe impl fidl::encoding::TypeMarker for LevelStatus {
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 LevelStatus {
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 LevelStatus {
#[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 LevelStatus {
#[inline(always)]
fn new_empty() -> Self {
Self::Unknown
}
#[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 BatteryInfoProviderGetBatteryInfoResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatteryInfoProviderGetBatteryInfoResponse {
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<BatteryInfoProviderGetBatteryInfoResponse, D>
for &BatteryInfoProviderGetBatteryInfoResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatteryInfoProviderGetBatteryInfoResponse>(offset);
fidl::encoding::Encode::<BatteryInfoProviderGetBatteryInfoResponse, D>::encode(
(<BatteryInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BatteryInfo, D>>
fidl::encoding::Encode<BatteryInfoProviderGetBatteryInfoResponse, 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::<BatteryInfoProviderGetBatteryInfoResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatteryInfoProviderGetBatteryInfoResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { info: fidl::new_empty!(BatteryInfo, 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!(BatteryInfo, D, &mut self.info, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for BatteryInfoProviderWatchRequest {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatteryInfoProviderWatchRequest {
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
}
}
unsafe impl
fidl::encoding::Encode<
BatteryInfoProviderWatchRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut BatteryInfoProviderWatchRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatteryInfoProviderWatchRequest>(offset);
fidl::encoding::Encode::<BatteryInfoProviderWatchRequest, fidl::encoding::DefaultFuchsiaResourceDialect>::encode(
(
<fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.watcher),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
BatteryInfoProviderWatchRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatteryInfoProviderWatchRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for BatteryInfoProviderWatchRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self {
watcher: fidl::new_empty!(
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>>,
fidl::encoding::DefaultFuchsiaResourceDialect
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::Endpoint<fidl::endpoints::ClientEnd<BatteryInfoWatcherMarker>>,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.watcher,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatteryInfoWatcherOnChangeBatteryInfoRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatteryInfoWatcherOnChangeBatteryInfoRequest {
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<BatteryInfoWatcherOnChangeBatteryInfoRequest, D>
for &BatteryInfoWatcherOnChangeBatteryInfoRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(offset);
fidl::encoding::Encode::<BatteryInfoWatcherOnChangeBatteryInfoRequest, D>::encode(
(<BatteryInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<BatteryInfo, D>>
fidl::encoding::Encode<BatteryInfoWatcherOnChangeBatteryInfoRequest, 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::<BatteryInfoWatcherOnChangeBatteryInfoRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatteryInfoWatcherOnChangeBatteryInfoRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { info: fidl::new_empty!(BatteryInfo, 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!(BatteryInfo, D, &mut self.info, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl BatteryInfo {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.battery_spec {
return 11;
}
if let Some(_) = self.remaining_capacity_uah {
return 10;
}
if let Some(_) = self.present_voltage_mv {
return 9;
}
if let Some(_) = self.timestamp {
return 8;
}
if let Some(_) = self.time_remaining {
return 7;
}
if let Some(_) = self.health {
return 6;
}
if let Some(_) = self.level_status {
return 5;
}
if let Some(_) = self.level_percent {
return 4;
}
if let Some(_) = self.charge_source {
return 3;
}
if let Some(_) = self.charge_status {
return 2;
}
if let Some(_) = self.status {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for BatteryInfo {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatteryInfo {
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<BatteryInfo, D>
for &BatteryInfo
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatteryInfo>(offset);
let max_ordinal: u64 = self.max_ordinal_present();
encoder.write_num(max_ordinal, offset);
encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
if max_ordinal == 0 {
return Ok(());
}
depth.increment()?;
let envelope_size = 8;
let bytes_len = max_ordinal as usize * envelope_size;
#[allow(unused_variables)]
let offset = encoder.out_of_line_offset(bytes_len);
let mut _prev_end_offset: usize = 0;
if 1 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (1 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<BatteryStatus, D>(
self.status
.as_ref()
.map(<BatteryStatus as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 2 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (2 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<ChargeStatus, D>(
self.charge_status
.as_ref()
.map(<ChargeStatus as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 3 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (3 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<ChargeSource, D>(
self.charge_source
.as_ref()
.map(<ChargeSource as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 4 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (4 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<f32, D>(
self.level_percent.as_ref().map(<f32 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 5 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (5 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<LevelStatus, D>(
self.level_status
.as_ref()
.map(<LevelStatus as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 6 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (6 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<HealthStatus, D>(
self.health.as_ref().map(<HealthStatus as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 7 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (7 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<TimeRemaining, D>(
self.time_remaining
.as_ref()
.map(<TimeRemaining as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 8 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (8 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<i64, D>(
self.timestamp.as_ref().map(<i64 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 9 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (9 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<u32, D>(
self.present_voltage_mv
.as_ref()
.map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 10 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (10 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<u32, D>(
self.remaining_capacity_uah
.as_ref()
.map(<u32 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 11 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (11 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<BatterySpec, D>(
self.battery_spec
.as_ref()
.map(<BatterySpec as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BatteryInfo {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
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);
let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
None => return Err(fidl::Error::NotNullable),
Some(len) => len,
};
if len == 0 {
return Ok(());
};
depth.increment()?;
let envelope_size = 8;
let bytes_len = len * envelope_size;
let offset = decoder.out_of_line_offset(bytes_len)?;
let mut _next_ordinal_to_read = 0;
let mut next_offset = offset;
let end_offset = offset + bytes_len;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 1 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<BatteryStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.status.get_or_insert_with(|| fidl::new_empty!(BatteryStatus, D));
fidl::decode!(BatteryStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 2 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<ChargeStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.charge_status.get_or_insert_with(|| fidl::new_empty!(ChargeStatus, D));
fidl::decode!(ChargeStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 3 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<ChargeSource as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.charge_source.get_or_insert_with(|| fidl::new_empty!(ChargeSource, D));
fidl::decode!(ChargeSource, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 4 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<f32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.level_percent.get_or_insert_with(|| fidl::new_empty!(f32, D));
fidl::decode!(f32, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 5 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<LevelStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.level_status.get_or_insert_with(|| fidl::new_empty!(LevelStatus, D));
fidl::decode!(LevelStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 6 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<HealthStatus as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.health.get_or_insert_with(|| fidl::new_empty!(HealthStatus, D));
fidl::decode!(HealthStatus, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 7 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<TimeRemaining as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.time_remaining.get_or_insert_with(|| fidl::new_empty!(TimeRemaining, D));
fidl::decode!(TimeRemaining, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 8 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.timestamp.get_or_insert_with(|| fidl::new_empty!(i64, D));
fidl::decode!(i64, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 9 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.present_voltage_mv.get_or_insert_with(|| fidl::new_empty!(u32, D));
fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 10 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<u32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.remaining_capacity_uah.get_or_insert_with(|| fidl::new_empty!(u32, D));
fidl::decode!(u32, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 11 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<BatterySpec as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.battery_spec.get_or_insert_with(|| fidl::new_empty!(BatterySpec, D));
fidl::decode!(BatterySpec, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
while next_offset < end_offset {
_next_ordinal_to_read += 1;
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
next_offset += envelope_size;
}
Ok(())
}
}
impl BatterySpec {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.design_capacity_uah {
return 3;
}
if let Some(_) = self.max_charnging_voltage_uv {
return 2;
}
if let Some(_) = self.max_charging_current_ua {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for BatterySpec {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySpec {
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<BatterySpec, D>
for &BatterySpec
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySpec>(offset);
let max_ordinal: u64 = self.max_ordinal_present();
encoder.write_num(max_ordinal, offset);
encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
if max_ordinal == 0 {
return Ok(());
}
depth.increment()?;
let envelope_size = 8;
let bytes_len = max_ordinal as usize * envelope_size;
#[allow(unused_variables)]
let offset = encoder.out_of_line_offset(bytes_len);
let mut _prev_end_offset: usize = 0;
if 1 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (1 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<i32, D>(
self.max_charging_current_ua
.as_ref()
.map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 2 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (2 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<i32, D>(
self.max_charnging_voltage_uv
.as_ref()
.map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 3 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (3 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<i32, D>(
self.design_capacity_uah
.as_ref()
.map(<i32 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for BatterySpec {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
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);
let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
None => return Err(fidl::Error::NotNullable),
Some(len) => len,
};
if len == 0 {
return Ok(());
};
depth.increment()?;
let envelope_size = 8;
let bytes_len = len * envelope_size;
let offset = decoder.out_of_line_offset(bytes_len)?;
let mut _next_ordinal_to_read = 0;
let mut next_offset = offset;
let end_offset = offset + bytes_len;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 1 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.max_charging_current_ua.get_or_insert_with(|| fidl::new_empty!(i32, D));
fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 2 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.max_charnging_voltage_uv.get_or_insert_with(|| fidl::new_empty!(i32, D));
fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 3 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<i32 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.design_capacity_uah.get_or_insert_with(|| fidl::new_empty!(i32, D));
fidl::decode!(i32, D, val_ref, decoder, inner_offset, inner_depth)?;
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);
}
}
next_offset += envelope_size;
while next_offset < end_offset {
_next_ordinal_to_read += 1;
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
next_offset += envelope_size;
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for TimeRemaining {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for TimeRemaining {
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<TimeRemaining, D>
for &TimeRemaining
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<TimeRemaining>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
TimeRemaining::Indeterminate(ref val) => {
fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
TimeRemaining::BatteryLife(ref val) => {
fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
TimeRemaining::FullCharge(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
TimeRemaining::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TimeRemaining {
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[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 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
2 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
3 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
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 TimeRemaining::Indeterminate(_) = self {
} else {
*self = TimeRemaining::Indeterminate(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let TimeRemaining::Indeterminate(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let TimeRemaining::BatteryLife(_) = self {
} else {
*self = TimeRemaining::BatteryLife(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let TimeRemaining::BatteryLife(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
3 => {
#[allow(irrefutable_let_patterns)]
if let TimeRemaining::FullCharge(_) = self {
} else {
*self = TimeRemaining::FullCharge(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let TimeRemaining::FullCharge(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = TimeRemaining::__SourceBreaking { unknown_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(())
}
}
}