#![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(Clone, Debug, PartialEq)]
pub struct BatterySimulatorControllerGetBatteryInfoResponse {
pub info: fidl_fuchsia_power_battery::BatteryInfo,
}
impl fidl::Persistable for BatterySimulatorControllerGetBatteryInfoResponse {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BatterySimulatorControllerIsSimulatingResponse {
pub simulation_state: bool,
}
impl fidl::Persistable for BatterySimulatorControllerIsSimulatingResponse {}
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd)]
pub struct BatterySimulatorControllerSetBatteryPercentageRequest {
pub percent: f32,
}
impl fidl::Persistable for BatterySimulatorControllerSetBatteryPercentageRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct BatterySimulatorControllerSetBatterySpecRequest {
pub spec: fidl_fuchsia_power_battery::BatterySpec,
}
impl fidl::Persistable for BatterySimulatorControllerSetBatterySpecRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BatterySimulatorControllerSetBatteryStatusRequest {
pub battery_status: fidl_fuchsia_power_battery::BatteryStatus,
}
impl fidl::Persistable for BatterySimulatorControllerSetBatteryStatusRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BatterySimulatorControllerSetChargeSourceRequest {
pub charge_source: fidl_fuchsia_power_battery::ChargeSource,
}
impl fidl::Persistable for BatterySimulatorControllerSetChargeSourceRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BatterySimulatorControllerSetChargeStatusRequest {
pub charge_status: fidl_fuchsia_power_battery::ChargeStatus,
}
impl fidl::Persistable for BatterySimulatorControllerSetChargeStatusRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct BatterySimulatorControllerSetLevelStatusRequest {
pub level_status: fidl_fuchsia_power_battery::LevelStatus,
}
impl fidl::Persistable for BatterySimulatorControllerSetLevelStatusRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct BatterySimulatorControllerSetPresentVoltageMvRequest {
pub voltage: u32,
}
impl fidl::Persistable for BatterySimulatorControllerSetPresentVoltageMvRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct BatterySimulatorControllerSetRemainingCapacityUahRequest {
pub capacity: u32,
}
impl fidl::Persistable for BatterySimulatorControllerSetRemainingCapacityUahRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct BatterySimulatorControllerSetTimeRemainingRequest {
pub duration: i64,
}
impl fidl::Persistable for BatterySimulatorControllerSetTimeRemainingRequest {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct BatterySimulatorMarker;
impl fidl::endpoints::ProtocolMarker for BatterySimulatorMarker {
type Proxy = BatterySimulatorProxy;
type RequestStream = BatterySimulatorRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = BatterySimulatorSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.power.battery.test.BatterySimulator";
}
impl fidl::endpoints::DiscoverableProtocolMarker for BatterySimulatorMarker {}
pub trait BatterySimulatorProxyInterface: Send + Sync {
type GetBatteryInfoResponseFut: std::future::Future<Output = Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error>>
+ Send;
fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
fn r#set_battery_status(
&self,
battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error>;
fn r#set_charge_status(
&self,
charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error>;
fn r#set_charge_source(
&self,
charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error>;
fn r#set_battery_percentage(&self, percent: f32) -> Result<(), fidl::Error>;
fn r#set_level_status(
&self,
level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error>;
fn r#set_time_remaining(&self, duration: i64) -> Result<(), fidl::Error>;
fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error>;
type IsSimulatingResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut;
fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error>;
fn r#set_present_voltage_mv(&self, voltage: u32) -> Result<(), fidl::Error>;
fn r#set_remaining_capacity_uah(&self, capacity: u32) -> Result<(), fidl::Error>;
fn r#set_battery_spec(
&self,
spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error>;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct BatterySimulatorSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for BatterySimulatorSynchronousProxy {
type Proxy = BatterySimulatorProxy;
type Protocol = BatterySimulatorMarker;
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 BatterySimulatorSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <BatterySimulatorMarker 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<BatterySimulatorEvent, fidl::Error> {
BatterySimulatorEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get_battery_info(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
BatterySimulatorControllerGetBatteryInfoResponse,
>(
(),
0x4a20d3731366aaf8,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.info)
}
pub fn r#set_battery_status(
&self,
mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
(battery_status,),
0x2343eb65038c8b34,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_charge_status(
&self,
mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
(charge_status,),
0x79b2bf1a387acd85,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_charge_source(
&self,
mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
(charge_source,),
0xb40433f42c33527,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
(percent,),
0x64a9d96eb7a45a9f,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_level_status(
&self,
mut level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
(level_status,),
0x577fc3314f7a48a4,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
(duration,),
0x7427251c9d2a794e,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x75588eae6b9b67e3,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#is_simulating(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
BatterySimulatorControllerIsSimulatingResponse,
>(
(),
0x4bf85cfe3476975d,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.simulation_state)
}
pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x18306690352d9dfa,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
(voltage,),
0x5462c9e9f947b8ce,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
(capacity,),
0x38054049fe8c26ab,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_battery_spec(
&self,
mut spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
(spec,),
0x7324672546976583,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Clone)]
pub struct BatterySimulatorProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for BatterySimulatorProxy {
type Protocol = BatterySimulatorMarker;
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 BatterySimulatorProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <BatterySimulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> BatterySimulatorEventStream {
BatterySimulatorEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get_battery_info(
&self,
) -> fidl::client::QueryResponseFut<
fidl_fuchsia_power_battery::BatteryInfo,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
BatterySimulatorProxyInterface::r#get_battery_info(self)
}
pub fn r#set_battery_status(
&self,
mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_battery_status(self, battery_status)
}
pub fn r#set_charge_status(
&self,
mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_charge_status(self, charge_status)
}
pub fn r#set_charge_source(
&self,
mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_charge_source(self, charge_source)
}
pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_battery_percentage(self, percent)
}
pub fn r#set_level_status(
&self,
mut level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_level_status(self, level_status)
}
pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_time_remaining(self, duration)
}
pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#disconnect_real_battery(self)
}
pub fn r#is_simulating(
&self,
) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
BatterySimulatorProxyInterface::r#is_simulating(self)
}
pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#reconnect_real_battery(self)
}
pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_present_voltage_mv(self, voltage)
}
pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_remaining_capacity_uah(self, capacity)
}
pub fn r#set_battery_spec(
&self,
mut spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error> {
BatterySimulatorProxyInterface::r#set_battery_spec(self, spec)
}
}
impl BatterySimulatorProxyInterface for BatterySimulatorProxy {
type GetBatteryInfoResponseFut = fidl::client::QueryResponseFut<
fidl_fuchsia_power_battery::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<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
BatterySimulatorControllerGetBatteryInfoResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x4a20d3731366aaf8,
>(_buf?)?;
Ok(_response.info)
}
self.client.send_query_and_decode::<
fidl::encoding::EmptyPayload,
fidl_fuchsia_power_battery::BatteryInfo,
>(
(),
0x4a20d3731366aaf8,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#set_battery_status(
&self,
mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
(battery_status,),
0x2343eb65038c8b34,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_charge_status(
&self,
mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
(charge_status,),
0x79b2bf1a387acd85,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_charge_source(
&self,
mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
(charge_source,),
0xb40433f42c33527,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
(percent,),
0x64a9d96eb7a45a9f,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_level_status(
&self,
mut level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
(level_status,),
0x577fc3314f7a48a4,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
(duration,),
0x7427251c9d2a794e,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x75588eae6b9b67e3,
fidl::encoding::DynamicFlags::empty(),
)
}
type IsSimulatingResponseFut =
fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut {
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::<
BatterySimulatorControllerIsSimulatingResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x4bf85cfe3476975d,
>(_buf?)?;
Ok(_response.simulation_state)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
(),
0x4bf85cfe3476975d,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x18306690352d9dfa,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
(voltage,),
0x5462c9e9f947b8ce,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
(capacity,),
0x38054049fe8c26ab,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_battery_spec(
&self,
mut spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
(spec,),
0x7324672546976583,
fidl::encoding::DynamicFlags::empty(),
)
}
}
pub struct BatterySimulatorEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for BatterySimulatorEventStream {}
impl futures::stream::FusedStream for BatterySimulatorEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for BatterySimulatorEventStream {
type Item = Result<BatterySimulatorEvent, 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(BatterySimulatorEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum BatterySimulatorEvent {}
impl BatterySimulatorEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<BatterySimulatorEvent, 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:
<BatterySimulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct BatterySimulatorRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for BatterySimulatorRequestStream {}
impl futures::stream::FusedStream for BatterySimulatorRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for BatterySimulatorRequestStream {
type Protocol = BatterySimulatorMarker;
type ControlHandle = BatterySimulatorControlHandle;
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 {
BatterySimulatorControlHandle { 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 BatterySimulatorRequestStream {
type Item = Result<BatterySimulatorRequest, 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 BatterySimulatorRequestStream 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 {
0x4a20d3731366aaf8 => {
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 =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::GetBatteryInfo {
responder: BatterySimulatorGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x2343eb65038c8b34 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetBatteryStatusRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryStatusRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetBatteryStatus {
battery_status: req.battery_status,
control_handle,
})
}
0x79b2bf1a387acd85 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetChargeStatusRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeStatusRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetChargeStatus {
charge_status: req.charge_status,
control_handle,
})
}
0xb40433f42c33527 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetChargeSourceRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeSourceRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetChargeSource {
charge_source: req.charge_source,
control_handle,
})
}
0x64a9d96eb7a45a9f => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetBatteryPercentageRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryPercentageRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetBatteryPercentage {
percent: req.percent,
control_handle,
})
}
0x577fc3314f7a48a4 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetLevelStatusRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetLevelStatusRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetLevelStatus {
level_status: req.level_status,
control_handle,
})
}
0x7427251c9d2a794e => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetTimeRemainingRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetTimeRemainingRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetTimeRemaining {
duration: req.duration,
control_handle,
})
}
0x75588eae6b9b67e3 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
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 =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::DisconnectRealBattery { control_handle })
}
0x4bf85cfe3476975d => {
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 =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::IsSimulating {
responder: BatterySimulatorIsSimulatingResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x18306690352d9dfa => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
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 =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::ReconnectRealBattery { control_handle })
}
0x5462c9e9f947b8ce => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetPresentVoltageMvRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetPresentVoltageMvRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetPresentVoltageMv {
voltage: req.voltage,
control_handle,
})
}
0x38054049fe8c26ab => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetRemainingCapacityUahRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetRemainingCapacityUah {
capacity: req.capacity,
control_handle,
})
}
0x7324672546976583 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(
BatterySimulatorControllerSetBatterySpecRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatterySpecRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle =
BatterySimulatorControlHandle { inner: this.inner.clone() };
Ok(BatterySimulatorRequest::SetBatterySpec {
spec: req.spec,
control_handle,
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<BatterySimulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum BatterySimulatorRequest {
GetBatteryInfo { responder: BatterySimulatorGetBatteryInfoResponder },
SetBatteryStatus {
battery_status: fidl_fuchsia_power_battery::BatteryStatus,
control_handle: BatterySimulatorControlHandle,
},
SetChargeStatus {
charge_status: fidl_fuchsia_power_battery::ChargeStatus,
control_handle: BatterySimulatorControlHandle,
},
SetChargeSource {
charge_source: fidl_fuchsia_power_battery::ChargeSource,
control_handle: BatterySimulatorControlHandle,
},
SetBatteryPercentage { percent: f32, control_handle: BatterySimulatorControlHandle },
SetLevelStatus {
level_status: fidl_fuchsia_power_battery::LevelStatus,
control_handle: BatterySimulatorControlHandle,
},
SetTimeRemaining { duration: i64, control_handle: BatterySimulatorControlHandle },
DisconnectRealBattery { control_handle: BatterySimulatorControlHandle },
IsSimulating { responder: BatterySimulatorIsSimulatingResponder },
ReconnectRealBattery { control_handle: BatterySimulatorControlHandle },
SetPresentVoltageMv { voltage: u32, control_handle: BatterySimulatorControlHandle },
SetRemainingCapacityUah { capacity: u32, control_handle: BatterySimulatorControlHandle },
SetBatterySpec {
spec: fidl_fuchsia_power_battery::BatterySpec,
control_handle: BatterySimulatorControlHandle,
},
}
impl BatterySimulatorRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get_battery_info(self) -> Option<(BatterySimulatorGetBatteryInfoResponder)> {
if let BatterySimulatorRequest::GetBatteryInfo { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_battery_status(
self,
) -> Option<(fidl_fuchsia_power_battery::BatteryStatus, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetBatteryStatus { battery_status, control_handle } = self {
Some((battery_status, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_charge_status(
self,
) -> Option<(fidl_fuchsia_power_battery::ChargeStatus, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetChargeStatus { charge_status, control_handle } = self {
Some((charge_status, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_charge_source(
self,
) -> Option<(fidl_fuchsia_power_battery::ChargeSource, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetChargeSource { charge_source, control_handle } = self {
Some((charge_source, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_battery_percentage(self) -> Option<(f32, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetBatteryPercentage { percent, control_handle } = self {
Some((percent, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_level_status(
self,
) -> Option<(fidl_fuchsia_power_battery::LevelStatus, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetLevelStatus { level_status, control_handle } = self {
Some((level_status, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_time_remaining(self) -> Option<(i64, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetTimeRemaining { duration, control_handle } = self {
Some((duration, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_disconnect_real_battery(self) -> Option<(BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::DisconnectRealBattery { control_handle } = self {
Some((control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_is_simulating(self) -> Option<(BatterySimulatorIsSimulatingResponder)> {
if let BatterySimulatorRequest::IsSimulating { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_reconnect_real_battery(self) -> Option<(BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::ReconnectRealBattery { control_handle } = self {
Some((control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_present_voltage_mv(self) -> Option<(u32, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetPresentVoltageMv { voltage, control_handle } = self {
Some((voltage, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_remaining_capacity_uah(self) -> Option<(u32, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetRemainingCapacityUah { capacity, control_handle } = self
{
Some((capacity, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_battery_spec(
self,
) -> Option<(fidl_fuchsia_power_battery::BatterySpec, BatterySimulatorControlHandle)> {
if let BatterySimulatorRequest::SetBatterySpec { spec, control_handle } = self {
Some((spec, control_handle))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
BatterySimulatorRequest::GetBatteryInfo { .. } => "get_battery_info",
BatterySimulatorRequest::SetBatteryStatus { .. } => "set_battery_status",
BatterySimulatorRequest::SetChargeStatus { .. } => "set_charge_status",
BatterySimulatorRequest::SetChargeSource { .. } => "set_charge_source",
BatterySimulatorRequest::SetBatteryPercentage { .. } => "set_battery_percentage",
BatterySimulatorRequest::SetLevelStatus { .. } => "set_level_status",
BatterySimulatorRequest::SetTimeRemaining { .. } => "set_time_remaining",
BatterySimulatorRequest::DisconnectRealBattery { .. } => "disconnect_real_battery",
BatterySimulatorRequest::IsSimulating { .. } => "is_simulating",
BatterySimulatorRequest::ReconnectRealBattery { .. } => "reconnect_real_battery",
BatterySimulatorRequest::SetPresentVoltageMv { .. } => "set_present_voltage_mv",
BatterySimulatorRequest::SetRemainingCapacityUah { .. } => "set_remaining_capacity_uah",
BatterySimulatorRequest::SetBatterySpec { .. } => "set_battery_spec",
}
}
}
#[derive(Debug, Clone)]
pub struct BatterySimulatorControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for BatterySimulatorControlHandle {
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 BatterySimulatorControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct BatterySimulatorGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop<BatterySimulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for BatterySimulatorGetBatteryInfoResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for BatterySimulatorGetBatteryInfoResponder {
type ControlHandle = BatterySimulatorControlHandle;
fn control_handle(&self) -> &BatterySimulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl BatterySimulatorGetBatteryInfoResponder {
pub fn send(
self,
mut info: &fidl_fuchsia_power_battery::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: &fidl_fuchsia_power_battery::BatteryInfo,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(info);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut info: &fidl_fuchsia_power_battery::BatteryInfo,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<BatterySimulatorControllerGetBatteryInfoResponse>(
(info,),
self.tx_id,
0x4a20d3731366aaf8,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct BatterySimulatorIsSimulatingResponder {
control_handle: std::mem::ManuallyDrop<BatterySimulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for BatterySimulatorIsSimulatingResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for BatterySimulatorIsSimulatingResponder {
type ControlHandle = BatterySimulatorControlHandle;
fn control_handle(&self) -> &BatterySimulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl BatterySimulatorIsSimulatingResponder {
pub fn send(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
let _result = self.send_raw(simulation_state);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
let _result = self.send_raw(simulation_state);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut simulation_state: bool) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<BatterySimulatorControllerIsSimulatingResponse>(
(simulation_state,),
self.tx_id,
0x4bf85cfe3476975d,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct BatterySimulatorControllerMarker;
impl fidl::endpoints::ProtocolMarker for BatterySimulatorControllerMarker {
type Proxy = BatterySimulatorControllerProxy;
type RequestStream = BatterySimulatorControllerRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = BatterySimulatorControllerSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) BatterySimulatorController";
}
pub trait BatterySimulatorControllerProxyInterface: Send + Sync {
type GetBatteryInfoResponseFut: std::future::Future<Output = Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error>>
+ Send;
fn r#get_battery_info(&self) -> Self::GetBatteryInfoResponseFut;
fn r#set_battery_status(
&self,
battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error>;
fn r#set_charge_status(
&self,
charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error>;
fn r#set_charge_source(
&self,
charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error>;
fn r#set_battery_percentage(&self, percent: f32) -> Result<(), fidl::Error>;
fn r#set_level_status(
&self,
level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error>;
fn r#set_time_remaining(&self, duration: i64) -> Result<(), fidl::Error>;
fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error>;
type IsSimulatingResponseFut: std::future::Future<Output = Result<bool, fidl::Error>> + Send;
fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut;
fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error>;
fn r#set_present_voltage_mv(&self, voltage: u32) -> Result<(), fidl::Error>;
fn r#set_remaining_capacity_uah(&self, capacity: u32) -> Result<(), fidl::Error>;
fn r#set_battery_spec(
&self,
spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error>;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct BatterySimulatorControllerSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for BatterySimulatorControllerSynchronousProxy {
type Proxy = BatterySimulatorControllerProxy;
type Protocol = BatterySimulatorControllerMarker;
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 BatterySimulatorControllerSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name =
<BatterySimulatorControllerMarker 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<BatterySimulatorControllerEvent, fidl::Error> {
BatterySimulatorControllerEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get_battery_info(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
BatterySimulatorControllerGetBatteryInfoResponse,
>(
(),
0x4a20d3731366aaf8,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.info)
}
pub fn r#set_battery_status(
&self,
mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
(battery_status,),
0x2343eb65038c8b34,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_charge_status(
&self,
mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
(charge_status,),
0x79b2bf1a387acd85,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_charge_source(
&self,
mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
(charge_source,),
0xb40433f42c33527,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
(percent,),
0x64a9d96eb7a45a9f,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_level_status(
&self,
mut level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
(level_status,),
0x577fc3314f7a48a4,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
(duration,),
0x7427251c9d2a794e,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x75588eae6b9b67e3,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#is_simulating(&self, ___deadline: zx::MonotonicInstant) -> Result<bool, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
BatterySimulatorControllerIsSimulatingResponse,
>(
(),
0x4bf85cfe3476975d,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.simulation_state)
}
pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x18306690352d9dfa,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
(voltage,),
0x5462c9e9f947b8ce,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
(capacity,),
0x38054049fe8c26ab,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#set_battery_spec(
&self,
mut spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
(spec,),
0x7324672546976583,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Clone)]
pub struct BatterySimulatorControllerProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for BatterySimulatorControllerProxy {
type Protocol = BatterySimulatorControllerMarker;
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 BatterySimulatorControllerProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name =
<BatterySimulatorControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> BatterySimulatorControllerEventStream {
BatterySimulatorControllerEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get_battery_info(
&self,
) -> fidl::client::QueryResponseFut<
fidl_fuchsia_power_battery::BatteryInfo,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
BatterySimulatorControllerProxyInterface::r#get_battery_info(self)
}
pub fn r#set_battery_status(
&self,
mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_battery_status(self, battery_status)
}
pub fn r#set_charge_status(
&self,
mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_charge_status(self, charge_status)
}
pub fn r#set_charge_source(
&self,
mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_charge_source(self, charge_source)
}
pub fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_battery_percentage(self, percent)
}
pub fn r#set_level_status(
&self,
mut level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_level_status(self, level_status)
}
pub fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_time_remaining(self, duration)
}
pub fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#disconnect_real_battery(self)
}
pub fn r#is_simulating(
&self,
) -> fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect> {
BatterySimulatorControllerProxyInterface::r#is_simulating(self)
}
pub fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#reconnect_real_battery(self)
}
pub fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_present_voltage_mv(self, voltage)
}
pub fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_remaining_capacity_uah(self, capacity)
}
pub fn r#set_battery_spec(
&self,
mut spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error> {
BatterySimulatorControllerProxyInterface::r#set_battery_spec(self, spec)
}
}
impl BatterySimulatorControllerProxyInterface for BatterySimulatorControllerProxy {
type GetBatteryInfoResponseFut = fidl::client::QueryResponseFut<
fidl_fuchsia_power_battery::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<fidl_fuchsia_power_battery::BatteryInfo, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
BatterySimulatorControllerGetBatteryInfoResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x4a20d3731366aaf8,
>(_buf?)?;
Ok(_response.info)
}
self.client.send_query_and_decode::<
fidl::encoding::EmptyPayload,
fidl_fuchsia_power_battery::BatteryInfo,
>(
(),
0x4a20d3731366aaf8,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#set_battery_status(
&self,
mut battery_status: fidl_fuchsia_power_battery::BatteryStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryStatusRequest>(
(battery_status,),
0x2343eb65038c8b34,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_charge_status(
&self,
mut charge_status: fidl_fuchsia_power_battery::ChargeStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeStatusRequest>(
(charge_status,),
0x79b2bf1a387acd85,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_charge_source(
&self,
mut charge_source: fidl_fuchsia_power_battery::ChargeSource,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetChargeSourceRequest>(
(charge_source,),
0xb40433f42c33527,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_battery_percentage(&self, mut percent: f32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatteryPercentageRequest>(
(percent,),
0x64a9d96eb7a45a9f,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_level_status(
&self,
mut level_status: fidl_fuchsia_power_battery::LevelStatus,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetLevelStatusRequest>(
(level_status,),
0x577fc3314f7a48a4,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_time_remaining(&self, mut duration: i64) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetTimeRemainingRequest>(
(duration,),
0x7427251c9d2a794e,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#disconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x75588eae6b9b67e3,
fidl::encoding::DynamicFlags::empty(),
)
}
type IsSimulatingResponseFut =
fidl::client::QueryResponseFut<bool, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#is_simulating(&self) -> Self::IsSimulatingResponseFut {
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::<
BatterySimulatorControllerIsSimulatingResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x4bf85cfe3476975d,
>(_buf?)?;
Ok(_response.simulation_state)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, bool>(
(),
0x4bf85cfe3476975d,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#reconnect_real_battery(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x18306690352d9dfa,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_present_voltage_mv(&self, mut voltage: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetPresentVoltageMvRequest>(
(voltage,),
0x5462c9e9f947b8ce,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_remaining_capacity_uah(&self, mut capacity: u32) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
(capacity,),
0x38054049fe8c26ab,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#set_battery_spec(
&self,
mut spec: &fidl_fuchsia_power_battery::BatterySpec,
) -> Result<(), fidl::Error> {
self.client.send::<BatterySimulatorControllerSetBatterySpecRequest>(
(spec,),
0x7324672546976583,
fidl::encoding::DynamicFlags::empty(),
)
}
}
pub struct BatterySimulatorControllerEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for BatterySimulatorControllerEventStream {}
impl futures::stream::FusedStream for BatterySimulatorControllerEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for BatterySimulatorControllerEventStream {
type Item = Result<BatterySimulatorControllerEvent, 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(BatterySimulatorControllerEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum BatterySimulatorControllerEvent {}
impl BatterySimulatorControllerEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<BatterySimulatorControllerEvent, 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: <BatterySimulatorControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
})
}
}
}
pub struct BatterySimulatorControllerRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for BatterySimulatorControllerRequestStream {}
impl futures::stream::FusedStream for BatterySimulatorControllerRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for BatterySimulatorControllerRequestStream {
type Protocol = BatterySimulatorControllerMarker;
type ControlHandle = BatterySimulatorControllerControlHandle;
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 {
BatterySimulatorControllerControlHandle { 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 BatterySimulatorControllerRequestStream {
type Item = Result<BatterySimulatorControllerRequest, 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 BatterySimulatorControllerRequestStream 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 {
0x4a20d3731366aaf8 => {
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 = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::GetBatteryInfo {
responder: BatterySimulatorControllerGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x2343eb65038c8b34 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetBatteryStatusRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryStatusRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetBatteryStatus {battery_status: req.battery_status,
control_handle,
})
}
0x79b2bf1a387acd85 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetChargeStatusRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeStatusRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetChargeStatus {charge_status: req.charge_status,
control_handle,
})
}
0xb40433f42c33527 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetChargeSourceRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetChargeSourceRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetChargeSource {charge_source: req.charge_source,
control_handle,
})
}
0x64a9d96eb7a45a9f => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetBatteryPercentageRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatteryPercentageRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetBatteryPercentage {percent: req.percent,
control_handle,
})
}
0x577fc3314f7a48a4 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetLevelStatusRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetLevelStatusRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetLevelStatus {level_status: req.level_status,
control_handle,
})
}
0x7427251c9d2a794e => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetTimeRemainingRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetTimeRemainingRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetTimeRemaining {duration: req.duration,
control_handle,
})
}
0x75588eae6b9b67e3 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
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 = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::DisconnectRealBattery {
control_handle,
})
}
0x4bf85cfe3476975d => {
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 = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::IsSimulating {
responder: BatterySimulatorControllerIsSimulatingResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x18306690352d9dfa => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
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 = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::ReconnectRealBattery {
control_handle,
})
}
0x5462c9e9f947b8ce => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetPresentVoltageMvRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetPresentVoltageMvRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetPresentVoltageMv {voltage: req.voltage,
control_handle,
})
}
0x38054049fe8c26ab => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetRemainingCapacityUahRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetRemainingCapacityUah {capacity: req.capacity,
control_handle,
})
}
0x7324672546976583 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(BatterySimulatorControllerSetBatterySpecRequest, fidl::encoding::DefaultFuchsiaResourceDialect);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<BatterySimulatorControllerSetBatterySpecRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = BatterySimulatorControllerControlHandle {
inner: this.inner.clone(),
};
Ok(BatterySimulatorControllerRequest::SetBatterySpec {spec: req.spec,
control_handle,
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <BatterySimulatorControllerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum BatterySimulatorControllerRequest {
GetBatteryInfo { responder: BatterySimulatorControllerGetBatteryInfoResponder },
SetBatteryStatus {
battery_status: fidl_fuchsia_power_battery::BatteryStatus,
control_handle: BatterySimulatorControllerControlHandle,
},
SetChargeStatus {
charge_status: fidl_fuchsia_power_battery::ChargeStatus,
control_handle: BatterySimulatorControllerControlHandle,
},
SetChargeSource {
charge_source: fidl_fuchsia_power_battery::ChargeSource,
control_handle: BatterySimulatorControllerControlHandle,
},
SetBatteryPercentage { percent: f32, control_handle: BatterySimulatorControllerControlHandle },
SetLevelStatus {
level_status: fidl_fuchsia_power_battery::LevelStatus,
control_handle: BatterySimulatorControllerControlHandle,
},
SetTimeRemaining { duration: i64, control_handle: BatterySimulatorControllerControlHandle },
DisconnectRealBattery { control_handle: BatterySimulatorControllerControlHandle },
IsSimulating { responder: BatterySimulatorControllerIsSimulatingResponder },
ReconnectRealBattery { control_handle: BatterySimulatorControllerControlHandle },
SetPresentVoltageMv { voltage: u32, control_handle: BatterySimulatorControllerControlHandle },
SetRemainingCapacityUah {
capacity: u32,
control_handle: BatterySimulatorControllerControlHandle,
},
SetBatterySpec {
spec: fidl_fuchsia_power_battery::BatterySpec,
control_handle: BatterySimulatorControllerControlHandle,
},
}
impl BatterySimulatorControllerRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get_battery_info(
self,
) -> Option<(BatterySimulatorControllerGetBatteryInfoResponder)> {
if let BatterySimulatorControllerRequest::GetBatteryInfo { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_battery_status(
self,
) -> Option<(fidl_fuchsia_power_battery::BatteryStatus, BatterySimulatorControllerControlHandle)>
{
if let BatterySimulatorControllerRequest::SetBatteryStatus {
battery_status,
control_handle,
} = self
{
Some((battery_status, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_charge_status(
self,
) -> Option<(fidl_fuchsia_power_battery::ChargeStatus, BatterySimulatorControllerControlHandle)>
{
if let BatterySimulatorControllerRequest::SetChargeStatus {
charge_status,
control_handle,
} = self
{
Some((charge_status, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_charge_source(
self,
) -> Option<(fidl_fuchsia_power_battery::ChargeSource, BatterySimulatorControllerControlHandle)>
{
if let BatterySimulatorControllerRequest::SetChargeSource {
charge_source,
control_handle,
} = self
{
Some((charge_source, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_battery_percentage(
self,
) -> Option<(f32, BatterySimulatorControllerControlHandle)> {
if let BatterySimulatorControllerRequest::SetBatteryPercentage { percent, control_handle } =
self
{
Some((percent, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_level_status(
self,
) -> Option<(fidl_fuchsia_power_battery::LevelStatus, BatterySimulatorControllerControlHandle)>
{
if let BatterySimulatorControllerRequest::SetLevelStatus { level_status, control_handle } =
self
{
Some((level_status, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_time_remaining(self) -> Option<(i64, BatterySimulatorControllerControlHandle)> {
if let BatterySimulatorControllerRequest::SetTimeRemaining { duration, control_handle } =
self
{
Some((duration, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_disconnect_real_battery(self) -> Option<(BatterySimulatorControllerControlHandle)> {
if let BatterySimulatorControllerRequest::DisconnectRealBattery { control_handle } = self {
Some((control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_is_simulating(self) -> Option<(BatterySimulatorControllerIsSimulatingResponder)> {
if let BatterySimulatorControllerRequest::IsSimulating { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_reconnect_real_battery(self) -> Option<(BatterySimulatorControllerControlHandle)> {
if let BatterySimulatorControllerRequest::ReconnectRealBattery { control_handle } = self {
Some((control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_present_voltage_mv(
self,
) -> Option<(u32, BatterySimulatorControllerControlHandle)> {
if let BatterySimulatorControllerRequest::SetPresentVoltageMv { voltage, control_handle } =
self
{
Some((voltage, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_remaining_capacity_uah(
self,
) -> Option<(u32, BatterySimulatorControllerControlHandle)> {
if let BatterySimulatorControllerRequest::SetRemainingCapacityUah {
capacity,
control_handle,
} = self
{
Some((capacity, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_battery_spec(
self,
) -> Option<(fidl_fuchsia_power_battery::BatterySpec, BatterySimulatorControllerControlHandle)>
{
if let BatterySimulatorControllerRequest::SetBatterySpec { spec, control_handle } = self {
Some((spec, control_handle))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
BatterySimulatorControllerRequest::GetBatteryInfo { .. } => "get_battery_info",
BatterySimulatorControllerRequest::SetBatteryStatus { .. } => "set_battery_status",
BatterySimulatorControllerRequest::SetChargeStatus { .. } => "set_charge_status",
BatterySimulatorControllerRequest::SetChargeSource { .. } => "set_charge_source",
BatterySimulatorControllerRequest::SetBatteryPercentage { .. } => {
"set_battery_percentage"
}
BatterySimulatorControllerRequest::SetLevelStatus { .. } => "set_level_status",
BatterySimulatorControllerRequest::SetTimeRemaining { .. } => "set_time_remaining",
BatterySimulatorControllerRequest::DisconnectRealBattery { .. } => {
"disconnect_real_battery"
}
BatterySimulatorControllerRequest::IsSimulating { .. } => "is_simulating",
BatterySimulatorControllerRequest::ReconnectRealBattery { .. } => {
"reconnect_real_battery"
}
BatterySimulatorControllerRequest::SetPresentVoltageMv { .. } => {
"set_present_voltage_mv"
}
BatterySimulatorControllerRequest::SetRemainingCapacityUah { .. } => {
"set_remaining_capacity_uah"
}
BatterySimulatorControllerRequest::SetBatterySpec { .. } => "set_battery_spec",
}
}
}
#[derive(Debug, Clone)]
pub struct BatterySimulatorControllerControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for BatterySimulatorControllerControlHandle {
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 BatterySimulatorControllerControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct BatterySimulatorControllerGetBatteryInfoResponder {
control_handle: std::mem::ManuallyDrop<BatterySimulatorControllerControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for BatterySimulatorControllerGetBatteryInfoResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for BatterySimulatorControllerGetBatteryInfoResponder {
type ControlHandle = BatterySimulatorControllerControlHandle;
fn control_handle(&self) -> &BatterySimulatorControllerControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl BatterySimulatorControllerGetBatteryInfoResponder {
pub fn send(
self,
mut info: &fidl_fuchsia_power_battery::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: &fidl_fuchsia_power_battery::BatteryInfo,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(info);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut info: &fidl_fuchsia_power_battery::BatteryInfo,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<BatterySimulatorControllerGetBatteryInfoResponse>(
(info,),
self.tx_id,
0x4a20d3731366aaf8,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct BatterySimulatorControllerIsSimulatingResponder {
control_handle: std::mem::ManuallyDrop<BatterySimulatorControllerControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for BatterySimulatorControllerIsSimulatingResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for BatterySimulatorControllerIsSimulatingResponder {
type ControlHandle = BatterySimulatorControllerControlHandle;
fn control_handle(&self) -> &BatterySimulatorControllerControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl BatterySimulatorControllerIsSimulatingResponder {
pub fn send(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
let _result = self.send_raw(simulation_state);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut simulation_state: bool) -> Result<(), fidl::Error> {
let _result = self.send_raw(simulation_state);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut simulation_state: bool) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<BatterySimulatorControllerIsSimulatingResponse>(
(simulation_state,),
self.tx_id,
0x4bf85cfe3476975d,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerGetBatteryInfoResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerGetBatteryInfoResponse {
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<BatterySimulatorControllerGetBatteryInfoResponse, D>
for &BatterySimulatorControllerGetBatteryInfoResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerGetBatteryInfoResponse>(offset);
fidl::encoding::Encode::<BatterySimulatorControllerGetBatteryInfoResponse, D>::encode(
(
<fidl_fuchsia_power_battery::BatteryInfo as fidl::encoding::ValueTypeMarker>::borrow(&self.info),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_power_battery::BatteryInfo, D>,
> fidl::encoding::Encode<BatterySimulatorControllerGetBatteryInfoResponse, 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::<BatterySimulatorControllerGetBatteryInfoResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerGetBatteryInfoResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { info: fidl::new_empty!(fidl_fuchsia_power_battery::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!(
fidl_fuchsia_power_battery::BatteryInfo,
D,
&mut self.info,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerIsSimulatingResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerIsSimulatingResponse {
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<BatterySimulatorControllerIsSimulatingResponse, D>
for &BatterySimulatorControllerIsSimulatingResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerIsSimulatingResponse>(offset);
fidl::encoding::Encode::<BatterySimulatorControllerIsSimulatingResponse, D>::encode(
(<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.simulation_state),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<bool, D>>
fidl::encoding::Encode<BatterySimulatorControllerIsSimulatingResponse, 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::<BatterySimulatorControllerIsSimulatingResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerIsSimulatingResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { simulation_state: 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.simulation_state, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerSetBatteryPercentageRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetBatteryPercentageRequest {
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<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<BatterySimulatorControllerSetBatteryPercentageRequest, D>
for &BatterySimulatorControllerSetBatteryPercentageRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetBatteryPercentageRequest>(
offset,
);
fidl::encoding::Encode::<BatterySimulatorControllerSetBatteryPercentageRequest, D>::encode(
(
<f32 as fidl::encoding::ValueTypeMarker>::borrow(&self.percent),
),
encoder, offset, _depth
)
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<f32, D>>
fidl::encoding::Encode<BatterySimulatorControllerSetBatteryPercentageRequest, 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::<BatterySimulatorControllerSetBatteryPercentageRequest>(
offset,
);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetBatteryPercentageRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { percent: fidl::new_empty!(f32, 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!(f32, D, &mut self.percent, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerSetBatterySpecRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetBatterySpecRequest {
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<BatterySimulatorControllerSetBatterySpecRequest, D>
for &BatterySimulatorControllerSetBatterySpecRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetBatterySpecRequest>(offset);
fidl::encoding::Encode::<BatterySimulatorControllerSetBatterySpecRequest, D>::encode(
(
<fidl_fuchsia_power_battery::BatterySpec as fidl::encoding::ValueTypeMarker>::borrow(&self.spec),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_power_battery::BatterySpec, D>,
> fidl::encoding::Encode<BatterySimulatorControllerSetBatterySpecRequest, 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::<BatterySimulatorControllerSetBatterySpecRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetBatterySpecRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { spec: fidl::new_empty!(fidl_fuchsia_power_battery::BatterySpec, 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_fuchsia_power_battery::BatterySpec,
D,
&mut self.spec,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerSetBatteryStatusRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetBatteryStatusRequest {
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<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<BatterySimulatorControllerSetBatteryStatusRequest, D>
for &BatterySimulatorControllerSetBatteryStatusRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetBatteryStatusRequest>(offset);
fidl::encoding::Encode::<BatterySimulatorControllerSetBatteryStatusRequest, D>::encode(
(
<fidl_fuchsia_power_battery::BatteryStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.battery_status),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_power_battery::BatteryStatus, D>,
> fidl::encoding::Encode<BatterySimulatorControllerSetBatteryStatusRequest, 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::<BatterySimulatorControllerSetBatteryStatusRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetBatteryStatusRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { battery_status: fidl::new_empty!(fidl_fuchsia_power_battery::BatteryStatus, 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_fuchsia_power_battery::BatteryStatus,
D,
&mut self.battery_status,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerSetChargeSourceRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetChargeSourceRequest {
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<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<BatterySimulatorControllerSetChargeSourceRequest, D>
for &BatterySimulatorControllerSetChargeSourceRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetChargeSourceRequest>(offset);
fidl::encoding::Encode::<BatterySimulatorControllerSetChargeSourceRequest, D>::encode(
(
<fidl_fuchsia_power_battery::ChargeSource as fidl::encoding::ValueTypeMarker>::borrow(&self.charge_source),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_power_battery::ChargeSource, D>,
> fidl::encoding::Encode<BatterySimulatorControllerSetChargeSourceRequest, 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::<BatterySimulatorControllerSetChargeSourceRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetChargeSourceRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { charge_source: fidl::new_empty!(fidl_fuchsia_power_battery::ChargeSource, 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_fuchsia_power_battery::ChargeSource,
D,
&mut self.charge_source,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerSetChargeStatusRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetChargeStatusRequest {
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<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<BatterySimulatorControllerSetChargeStatusRequest, D>
for &BatterySimulatorControllerSetChargeStatusRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetChargeStatusRequest>(offset);
fidl::encoding::Encode::<BatterySimulatorControllerSetChargeStatusRequest, D>::encode(
(
<fidl_fuchsia_power_battery::ChargeStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.charge_status),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_power_battery::ChargeStatus, D>,
> fidl::encoding::Encode<BatterySimulatorControllerSetChargeStatusRequest, 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::<BatterySimulatorControllerSetChargeStatusRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetChargeStatusRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { charge_status: fidl::new_empty!(fidl_fuchsia_power_battery::ChargeStatus, 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_fuchsia_power_battery::ChargeStatus,
D,
&mut self.charge_status,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerSetLevelStatusRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetLevelStatusRequest {
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<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<BatterySimulatorControllerSetLevelStatusRequest, D>
for &BatterySimulatorControllerSetLevelStatusRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetLevelStatusRequest>(offset);
fidl::encoding::Encode::<BatterySimulatorControllerSetLevelStatusRequest, D>::encode(
(
<fidl_fuchsia_power_battery::LevelStatus as fidl::encoding::ValueTypeMarker>::borrow(&self.level_status),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_power_battery::LevelStatus, D>,
> fidl::encoding::Encode<BatterySimulatorControllerSetLevelStatusRequest, 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::<BatterySimulatorControllerSetLevelStatusRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetLevelStatusRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { level_status: fidl::new_empty!(fidl_fuchsia_power_battery::LevelStatus, 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_fuchsia_power_battery::LevelStatus,
D,
&mut self.level_status,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for BatterySimulatorControllerSetPresentVoltageMvRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetPresentVoltageMvRequest {
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<BatterySimulatorControllerSetPresentVoltageMvRequest, D>
for &BatterySimulatorControllerSetPresentVoltageMvRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder
.debug_check_bounds::<BatterySimulatorControllerSetPresentVoltageMvRequest>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut BatterySimulatorControllerSetPresentVoltageMvRequest)
.write_unaligned(
(self as *const BatterySimulatorControllerSetPresentVoltageMvRequest)
.read(),
);
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
fidl::encoding::Encode<BatterySimulatorControllerSetPresentVoltageMvRequest, 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::<BatterySimulatorControllerSetPresentVoltageMvRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetPresentVoltageMvRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { voltage: 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 BatterySimulatorControllerSetRemainingCapacityUahRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker
for BatterySimulatorControllerSetRemainingCapacityUahRequest
{
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<BatterySimulatorControllerSetRemainingCapacityUahRequest, D>
for &BatterySimulatorControllerSetRemainingCapacityUahRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
offset,
);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut BatterySimulatorControllerSetRemainingCapacityUahRequest)
.write_unaligned(
(self as *const BatterySimulatorControllerSetRemainingCapacityUahRequest)
.read(),
);
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u32, D>>
fidl::encoding::Encode<BatterySimulatorControllerSetRemainingCapacityUahRequest, 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::<BatterySimulatorControllerSetRemainingCapacityUahRequest>(
offset,
);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetRemainingCapacityUahRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { capacity: 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 BatterySimulatorControllerSetTimeRemainingRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for BatterySimulatorControllerSetTimeRemainingRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
8
}
#[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<BatterySimulatorControllerSetTimeRemainingRequest, D>
for &BatterySimulatorControllerSetTimeRemainingRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BatterySimulatorControllerSetTimeRemainingRequest>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut BatterySimulatorControllerSetTimeRemainingRequest)
.write_unaligned(
(self as *const BatterySimulatorControllerSetTimeRemainingRequest).read(),
);
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i64, D>>
fidl::encoding::Encode<BatterySimulatorControllerSetTimeRemainingRequest, 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::<BatterySimulatorControllerSetTimeRemainingRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for BatterySimulatorControllerSetTimeRemainingRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { duration: fidl::new_empty!(i64, 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, 8);
}
Ok(())
}
}
}