#![allow(
unused_parens, unused_mut, nonstandard_style, )]
#![recursion_limit = "512"]
#[cfg(target_os = "fuchsia")]
#[allow(unused_imports)]
use fuchsia_zircon as zx;
#[allow(unused_imports)]
use {
bitflags::bitflags,
fidl::{
client::QueryResponseFut,
encoding::zerocopy,
endpoints::{ControlHandle as _, Responder as _},
fidl_bits, fidl_enum, fidl_struct, fidl_table, fidl_union,
},
fuchsia_zircon_status as zx_status,
futures::future::{self, MaybeDone, TryFutureExt},
};
const _FIDL_TRACE_BINDINGS_RUST: u32 = 6;
pub const MAX_MODE_MATCHES_PER_CLIENT: u32 = 0;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[non_exhaustive]
pub enum ModeRequestError {
Generic,
#[deprecated = "Use `ModeRequestError::unknown()` to construct and `ModeRequestErrorUnknown!()` to exhaustively match."]
#[doc(hidden)]
__Unknown(u32),
}
#[macro_export]
macro_rules! ModeRequestErrorUnknown {
() => {
_
};
}
impl ModeRequestError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::Generic),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::Generic,
#[allow(deprecated)]
x => Self::__Unknown(x),
}
}
#[inline]
pub fn unknown() -> Self {
#[allow(deprecated)]
Self::__Unknown(0xffffffff)
}
#[inline]
pub const fn into_primitive(self) -> u32 {
match self {
Self::Generic => 1,
#[allow(deprecated)]
Self::__Unknown(x) => x,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
#[allow(deprecated)]
Self::__Unknown(_) => true,
_ => false,
}
}
}
fidl_enum! {
name: ModeRequestError,
prim_ty: u32,
flexible: true,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[non_exhaustive]
pub enum SystemMode {
#[deprecated = "Use `SystemMode::unknown()` to construct and `SystemModeUnknown!()` to exhaustively match."]
#[doc(hidden)]
__Unknown(u32),
}
#[macro_export]
macro_rules! SystemModeUnknown {
() => {
_
};
}
impl SystemMode {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
#[allow(deprecated)]
x => Self::__Unknown(x),
}
}
#[inline]
pub fn unknown() -> Self {
#[allow(deprecated)]
Self::__Unknown(0xffffffff)
}
#[inline]
pub const fn into_primitive(self) -> u32 {
match self {
#[allow(deprecated)]
Self::__Unknown(x) => x,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
#[allow(deprecated)]
Self::__Unknown(_) => true,
}
}
}
fidl_enum! {
name: SystemMode,
prim_ty: u32,
flexible: true,
}
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ClientConfig {
pub mode_matches: Vec<ModeMatch>,
pub default_level: u64,
}
impl fidl::Persistable for ClientConfig {}
fidl_struct! {
name: ClientConfig,
members: [
mode_matches {
ty: fidl::encoding::Vector<ModeMatch, 0>,
index: 0,
typevar: T0,
offset_v1: 0,
offset_v2: 0,
},
default_level {
ty: u64,
index: 1,
typevar: T1,
offset_v1: 16,
offset_v2: 16,
},
],
padding_v1: [
],
padding_v2: [
],
size_v1: 24,
size_v2: 24,
align_v1: 8,
align_v2: 8,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ClientConfiguratorGetRequest {
pub client_type: fidl_fuchsia_power_clientlevel::ClientType,
}
impl fidl::Persistable for ClientConfiguratorGetRequest {}
fidl_struct! {
name: ClientConfiguratorGetRequest,
members: [
client_type {
ty: fidl_fuchsia_power_clientlevel::ClientType,
index: 0,
typevar: T0,
offset_v1: 0,
offset_v2: 0,
},
],
padding_v1: [
],
padding_v2: [
],
size_v1: 4,
size_v2: 4,
align_v1: 4,
align_v2: 4,
}
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ClientConfiguratorGetResponse {
pub config: Option<Box<ClientConfig>>,
}
impl fidl::Persistable for ClientConfiguratorGetResponse {}
fidl_struct! {
name: ClientConfiguratorGetResponse,
members: [
config {
ty: fidl::encoding::Boxed<ClientConfig>,
index: 0,
typevar: T0,
offset_v1: 0,
offset_v2: 0,
},
],
padding_v1: [
],
padding_v2: [
],
size_v1: 8,
size_v2: 8,
align_v1: 8,
align_v2: 8,
}
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ClientConfiguratorSetRequest {
pub client_type: fidl_fuchsia_power_clientlevel::ClientType,
pub config: ClientConfig,
}
impl fidl::Persistable for ClientConfiguratorSetRequest {}
fidl_struct! {
name: ClientConfiguratorSetRequest,
members: [
client_type {
ty: fidl_fuchsia_power_clientlevel::ClientType,
index: 0,
typevar: T0,
offset_v1: 0,
offset_v2: 0,
},
config {
ty: ClientConfig,
index: 1,
typevar: T1,
offset_v1: 8,
offset_v2: 8,
},
],
padding_v1: [
{
ty: u64,
offset: 0,
mask: 0xffffffff00000000u64,
},
],
padding_v2: [
{
ty: u64,
offset: 0,
mask: 0xffffffff00000000u64,
},
],
size_v1: 32,
size_v2: 32,
align_v1: 8,
align_v2: 8,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ModeMatch {
pub mode: SystemMode,
pub power_level: u64,
}
impl fidl::Persistable for ModeMatch {}
fidl_struct! {
name: ModeMatch,
members: [
mode {
ty: SystemMode,
index: 0,
typevar: T0,
offset_v1: 0,
offset_v2: 0,
},
power_level {
ty: u64,
index: 1,
typevar: T1,
offset_v1: 8,
offset_v2: 8,
},
],
padding_v1: [
{
ty: u64,
offset: 0,
mask: 0xffffffff00000000u64,
},
],
padding_v2: [
{
ty: u64,
offset: 0,
mask: 0xffffffff00000000u64,
},
],
size_v1: 16,
size_v2: 16,
align_v1: 8,
align_v2: 8,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct RequesterRequestRequest {
pub mode: SystemMode,
pub set: bool,
}
impl fidl::Persistable for RequesterRequestRequest {}
fidl_struct! {
name: RequesterRequestRequest,
members: [
mode {
ty: SystemMode,
index: 0,
typevar: T0,
offset_v1: 0,
offset_v2: 0,
},
set {
ty: bool,
index: 1,
typevar: T1,
offset_v1: 4,
offset_v2: 4,
},
],
padding_v1: [
{
ty: u32,
offset: 4,
mask: 0xffffff00u32,
},
],
padding_v2: [
{
ty: u32,
offset: 4,
mask: 0xffffff00u32,
},
],
size_v1: 8,
size_v2: 8,
align_v1: 4,
align_v2: 4,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ClientConfiguratorMarker;
impl fidl::endpoints::ProtocolMarker for ClientConfiguratorMarker {
type Proxy = ClientConfiguratorProxy;
type RequestStream = ClientConfiguratorRequestStream;
const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.ClientConfigurator";
}
impl fidl::endpoints::DiscoverableProtocolMarker for ClientConfiguratorMarker {}
pub trait ClientConfiguratorProxyInterface: Send + Sync {
type GetResponseFut: std::future::Future<Output = Result<Option<Box<ClientConfig>>, fidl::Error>>
+ Send;
fn r#get(
&self,
client_type: fidl_fuchsia_power_clientlevel::ClientType,
) -> Self::GetResponseFut;
type SetResponseFut: std::future::Future<Output = Result<(), fidl::Error>> + Send;
fn r#set(
&self,
client_type: fidl_fuchsia_power_clientlevel::ClientType,
config: &ClientConfig,
) -> Self::SetResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct ClientConfiguratorSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl ClientConfiguratorSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name =
<ClientConfiguratorMarker 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::Time,
) -> Result<ClientConfiguratorEvent, fidl::Error> {
ClientConfiguratorEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get(
&self,
mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
___deadline: zx::Time,
) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
let _response = self.client.send_query::<
ClientConfiguratorGetRequest,
ClientConfiguratorGetResponse,false,false>(
(client_type,),
0x1e37597b4d247d7b,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?
;
Ok(_response.config)
}
pub fn r#set(
&self,
mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
mut config: &ClientConfig,
___deadline: zx::Time,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<ClientConfiguratorSetRequest, fidl::encoding::EmptyPayload, false, false>(
(client_type, config),
0x2204fb91b32f6435,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
}
#[derive(Debug, Clone)]
pub struct ClientConfiguratorProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for ClientConfiguratorProxy {
type Protocol = ClientConfiguratorMarker;
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 ClientConfiguratorProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name =
<ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> ClientConfiguratorEventStream {
ClientConfiguratorEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get(
&self,
mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
) -> fidl::client::QueryResponseFut<Option<Box<ClientConfig>>> {
ClientConfiguratorProxyInterface::r#get(self, client_type)
}
pub fn r#set(
&self,
mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
mut config: &ClientConfig,
) -> fidl::client::QueryResponseFut<()> {
ClientConfiguratorProxyInterface::r#set(self, client_type, config)
}
}
impl ClientConfiguratorProxyInterface for ClientConfiguratorProxy {
type GetResponseFut = fidl::client::QueryResponseFut<Option<Box<ClientConfig>>>;
fn r#get(
&self,
mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
) -> Self::GetResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<Option<Box<ClientConfig>>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
ClientConfiguratorGetResponse,
false,
>(_buf?)?;
Ok(_response.config)
}
self.client.send_query_and_decode::<
ClientConfiguratorGetRequest,
Option<Box<ClientConfig>>,
false,
>(
(client_type,),
0x1e37597b4d247d7b,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type SetResponseFut = fidl::client::QueryResponseFut<()>;
fn r#set(
&self,
mut client_type: fidl_fuchsia_power_clientlevel::ClientType,
mut config: &ClientConfig,
) -> Self::SetResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
false,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<ClientConfiguratorSetRequest, (), false>(
(client_type, config),
0x2204fb91b32f6435,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct ClientConfiguratorEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for ClientConfiguratorEventStream {}
impl futures::stream::FusedStream for ClientConfiguratorEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for ClientConfiguratorEventStream {
type Item = Result<ClientConfiguratorEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let buf = match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => buf,
None => return std::task::Poll::Ready(None),
};
std::task::Poll::Ready(Some(ClientConfiguratorEvent::decode(buf)))
}
}
#[derive(Debug)]
pub enum ClientConfiguratorEvent {}
impl ClientConfiguratorEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<ClientConfiguratorEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
match tx_header.ordinal() {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal(),
protocol_name:
<ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct ClientConfiguratorRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for ClientConfiguratorRequestStream {}
impl futures::stream::FusedStream for ClientConfiguratorRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for ClientConfiguratorRequestStream {
type Protocol = ClientConfiguratorMarker;
type ControlHandle = ClientConfiguratorControlHandle;
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 {
ClientConfiguratorControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for ClientConfiguratorRequestStream {
type Item = Result<ClientConfiguratorRequest, 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.poll_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled ClientConfiguratorRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|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))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
if !header.is_compatible() {
return std::task::Poll::Ready(Some(Err(fidl::Error::IncompatibleMagicNumber(
header.magic_number(),
))));
}
std::task::Poll::Ready(Some(match header.ordinal() {
0x1e37597b4d247d7b => {
let mut req = fidl::new_empty!(ClientConfiguratorGetRequest);
fidl::duration_begin!("fidl", "decode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "name" => "fuchsia.power.systemmode/ClientConfiguratorGetRequest");
fidl::trace_blob!("fidl:blob", "decode", bytes);
if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::BYTE_OVERFLOW)
{
Err(fidl::Error::LargeMessageImpossible)?;
}
fidl::encoding::Decoder::decode_into::<ClientConfiguratorGetRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
fidl::duration_end!("fidl", "decode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "size" => bytes.len() as u32, "handle_count" => handles.len() as u32);
let control_handle =
ClientConfiguratorControlHandle { inner: this.inner.clone() };
Ok(ClientConfiguratorRequest::Get {
client_type: req.client_type,
responder: ClientConfiguratorGetResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id(),
ordinal: header.ordinal(),
},
})
}
0x2204fb91b32f6435 => {
let mut req = fidl::new_empty!(ClientConfiguratorSetRequest);
fidl::duration_begin!("fidl", "decode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "name" => "fuchsia.power.systemmode/ClientConfiguratorSetRequest");
fidl::trace_blob!("fidl:blob", "decode", bytes);
if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::BYTE_OVERFLOW)
{
Err(fidl::Error::LargeMessageImpossible)?;
}
fidl::encoding::Decoder::decode_into::<ClientConfiguratorSetRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
fidl::duration_end!("fidl", "decode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "size" => bytes.len() as u32, "handle_count" => handles.len() as u32);
let control_handle =
ClientConfiguratorControlHandle { inner: this.inner.clone() };
Ok(ClientConfiguratorRequest::Set {
client_type: req.client_type,
config: req.config,
responder: ClientConfiguratorSetResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id(),
ordinal: header.ordinal(),
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal(),
protocol_name:
<ClientConfiguratorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum ClientConfiguratorRequest {
Get {
client_type: fidl_fuchsia_power_clientlevel::ClientType,
responder: ClientConfiguratorGetResponder,
},
Set {
client_type: fidl_fuchsia_power_clientlevel::ClientType,
config: ClientConfig,
responder: ClientConfiguratorSetResponder,
},
}
impl ClientConfiguratorRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get(
self,
) -> Option<(fidl_fuchsia_power_clientlevel::ClientType, ClientConfiguratorGetResponder)> {
if let ClientConfiguratorRequest::Get { client_type, responder } = self {
Some((client_type, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set(
self,
) -> Option<(
fidl_fuchsia_power_clientlevel::ClientType,
ClientConfig,
ClientConfiguratorSetResponder,
)> {
if let ClientConfiguratorRequest::Set { client_type, config, responder } = self {
Some((client_type, config, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
ClientConfiguratorRequest::Get { .. } => "get",
ClientConfiguratorRequest::Set { .. } => "set",
}
}
}
#[derive(Debug, Clone)]
pub struct ClientConfiguratorControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for ClientConfiguratorControlHandle {
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<'a>(&'a self) -> fidl::OnSignals<'a> {
self.inner.channel().on_closed()
}
}
impl ClientConfiguratorControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ClientConfiguratorGetResponder {
control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
tx_id: u32,
ordinal: u64,
}
impl std::ops::Drop for ClientConfiguratorGetResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ClientConfiguratorGetResponder {
type ControlHandle = ClientConfiguratorControlHandle;
fn control_handle(&self) -> &ClientConfiguratorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ClientConfiguratorGetResponder {
pub fn send(self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
let r = self.send_raw(config);
if r.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
r
}
pub fn send_no_shutdown_on_err(
self,
mut config: Option<&ClientConfig>,
) -> Result<(), fidl::Error> {
let r = self.send_raw(config);
self.drop_without_shutdown();
r
}
fn send_raw(&self, mut config: Option<&ClientConfig>) -> Result<(), fidl::Error> {
let msg = fidl::encoding::TransactionMessage {
header: fidl::encoding::TransactionHeader::new(
self.tx_id,
self.ordinal,
fidl::encoding::DynamicFlags::empty(),
),
body: (config,),
};
fidl::encoding::with_tls_encode_buf(|bytes, handles| {
fidl::duration_begin!("fidl", "encode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "name" => "fuchsia.power.systemmode/ClientConfiguratorGetResponse");
fidl::encoding::Encoder::encode::<
fidl::encoding::TransactionMessageType<ClientConfiguratorGetResponse>,
>(bytes, handles, msg)?;
fidl::trace_blob!("fidl:blob", "encode", bytes.as_slice());
fidl::duration_end!("fidl", "encode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "size" => bytes.len() as u32, "handle_count" => handles.len() as u32);
self.control_handle.inner.send_raw_msg(&*bytes, &mut *handles)
})
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct ClientConfiguratorSetResponder {
control_handle: std::mem::ManuallyDrop<ClientConfiguratorControlHandle>,
tx_id: u32,
ordinal: u64,
}
impl std::ops::Drop for ClientConfiguratorSetResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for ClientConfiguratorSetResponder {
type ControlHandle = ClientConfiguratorControlHandle;
fn control_handle(&self) -> &ClientConfiguratorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl ClientConfiguratorSetResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let r = self.send_raw();
if r.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
r
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let r = self.send_raw();
self.drop_without_shutdown();
r
}
fn send_raw(&self) -> Result<(), fidl::Error> {
let msg = fidl::encoding::TransactionMessage {
header: fidl::encoding::TransactionHeader::new(
self.tx_id,
self.ordinal,
fidl::encoding::DynamicFlags::empty(),
),
body: (),
};
fidl::encoding::with_tls_encode_buf(|bytes, handles| {
fidl::duration_begin!("fidl", "encode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "name" => "fuchsia.power.systemmode/ClientConfiguratorSetResponse");
fidl::encoding::Encoder::encode::<
fidl::encoding::TransactionMessageType<fidl::encoding::EmptyPayload>,
>(bytes, handles, msg)?;
fidl::trace_blob!("fidl:blob", "encode", bytes.as_slice());
fidl::duration_end!("fidl", "encode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "size" => bytes.len() as u32, "handle_count" => handles.len() as u32);
self.control_handle.inner.send_raw_msg(&*bytes, &mut *handles)
})
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct RequesterMarker;
impl fidl::endpoints::ProtocolMarker for RequesterMarker {
type Proxy = RequesterProxy;
type RequestStream = RequesterRequestStream;
const DEBUG_NAME: &'static str = "fuchsia.power.systemmode.Requester";
}
impl fidl::endpoints::DiscoverableProtocolMarker for RequesterMarker {}
pub type RequesterRequestResult = Result<(), ModeRequestError>;
pub trait RequesterProxyInterface: Send + Sync {
type RequestResponseFut: std::future::Future<Output = Result<RequesterRequestResult, fidl::Error>>
+ Send;
fn r#request(&self, mode: SystemMode, set: bool) -> Self::RequestResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct RequesterSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl RequesterSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <RequesterMarker 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::Time) -> Result<RequesterEvent, fidl::Error> {
RequesterEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#request(
&self,
mut mode: SystemMode,
mut set: bool,
___deadline: zx::Time,
) -> Result<RequesterRequestResult, fidl::Error> {
let _response = self.client.send_query::<
RequesterRequestRequest,
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,false,false>(
(mode, set,),
0x5603afcd4421f425,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?
;
Ok(_response.map(|x| x))
}
}
#[derive(Debug, Clone)]
pub struct RequesterProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for RequesterProxy {
type Protocol = RequesterMarker;
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 RequesterProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> RequesterEventStream {
RequesterEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#request(
&self,
mut mode: SystemMode,
mut set: bool,
) -> fidl::client::QueryResponseFut<RequesterRequestResult> {
RequesterProxyInterface::r#request(self, mode, set)
}
}
impl RequesterProxyInterface for RequesterProxy {
type RequestResponseFut = fidl::client::QueryResponseFut<RequesterRequestResult>;
fn r#request(&self, mut mode: SystemMode, mut set: bool) -> Self::RequestResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<RequesterRequestResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
false,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<RequesterRequestRequest, RequesterRequestResult, false>(
(mode, set),
0x5603afcd4421f425,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct RequesterEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for RequesterEventStream {}
impl futures::stream::FusedStream for RequesterEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for RequesterEventStream {
type Item = Result<RequesterEvent, fidl::Error>;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let buf = match futures::ready!(futures::stream::StreamExt::poll_next_unpin(
&mut self.event_receiver,
cx
)?) {
Some(buf) => buf,
None => return std::task::Poll::Ready(None),
};
std::task::Poll::Ready(Some(RequesterEvent::decode(buf)))
}
}
#[derive(Debug)]
pub enum RequesterEvent {}
impl RequesterEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<RequesterEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
match tx_header.ordinal() {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal(),
protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct RequesterRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for RequesterRequestStream {}
impl futures::stream::FusedStream for RequesterRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for RequesterRequestStream {
type Protocol = RequesterMarker;
type ControlHandle = RequesterControlHandle;
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 {
RequesterControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for RequesterRequestStream {
type Item = Result<RequesterRequest, 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.poll_shutdown(cx) {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
if this.is_terminated {
panic!("polled RequesterRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|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))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
if !header.is_compatible() {
return std::task::Poll::Ready(Some(Err(fidl::Error::IncompatibleMagicNumber(
header.magic_number(),
))));
}
std::task::Poll::Ready(Some(match header.ordinal() {
0x5603afcd4421f425 => {
let mut req = fidl::new_empty!(RequesterRequestRequest);
fidl::duration_begin!("fidl", "decode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "name" => "fuchsia.power.systemmode/RequesterRequestRequest");
fidl::trace_blob!("fidl:blob", "decode", bytes);
if header.dynamic_flags().contains(fidl::encoding::DynamicFlags::BYTE_OVERFLOW)
{
Err(fidl::Error::LargeMessageImpossible)?;
}
fidl::encoding::Decoder::decode_into::<RequesterRequestRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
fidl::duration_end!("fidl", "decode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "size" => bytes.len() as u32, "handle_count" => handles.len() as u32);
let control_handle = RequesterControlHandle { inner: this.inner.clone() };
Ok(RequesterRequest::Request {
mode: req.mode,
set: req.set,
responder: RequesterRequestResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id(),
ordinal: header.ordinal(),
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal(),
protocol_name: <RequesterMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum RequesterRequest {
Request { mode: SystemMode, set: bool, responder: RequesterRequestResponder },
}
impl RequesterRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_request(self) -> Option<(SystemMode, bool, RequesterRequestResponder)> {
if let RequesterRequest::Request { mode, set, responder } = self {
Some((mode, set, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
RequesterRequest::Request { .. } => "request",
}
}
}
#[derive(Debug, Clone)]
pub struct RequesterControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for RequesterControlHandle {
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<'a>(&'a self) -> fidl::OnSignals<'a> {
self.inner.channel().on_closed()
}
}
impl RequesterControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct RequesterRequestResponder {
control_handle: std::mem::ManuallyDrop<RequesterControlHandle>,
tx_id: u32,
ordinal: u64,
}
impl std::ops::Drop for RequesterRequestResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for RequesterRequestResponder {
type ControlHandle = RequesterControlHandle;
fn control_handle(&self) -> &RequesterControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl RequesterRequestResponder {
pub fn send(self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
let r = self.send_raw(result);
if r.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
r
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<(), ModeRequestError>,
) -> Result<(), fidl::Error> {
let r = self.send_raw(result);
self.drop_without_shutdown();
r
}
fn send_raw(&self, mut result: Result<(), ModeRequestError>) -> Result<(), fidl::Error> {
let msg = fidl::encoding::TransactionMessage {
header: fidl::encoding::TransactionHeader::new(
self.tx_id,
self.ordinal,
fidl::encoding::DynamicFlags::empty(),
),
body: result,
};
fidl::encoding::with_tls_encode_buf(|bytes, handles| {
fidl::duration_begin!("fidl", "encode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "name" => "fuchsia.power.systemmode/RequesterRequestResponse");
fidl::encoding::Encoder::encode::<
fidl::encoding::TransactionMessageType<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, ModeRequestError>,
>,
>(bytes, handles, msg)?;
fidl::trace_blob!("fidl:blob", "encode", bytes.as_slice());
fidl::duration_end!("fidl", "encode", "bindings" => _FIDL_TRACE_BINDINGS_RUST, "size" => bytes.len() as u32, "handle_count" => handles.len() as u32);
self.control_handle.inner.send_raw_msg(&*bytes, &mut *handles)
})
}
}