#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use bitflags::bitflags;
use fidl::client::QueryResponseFut;
use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
use fidl::endpoints::{ControlHandle as _, Responder as _};
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
pub const MAX_COUNT_RESOLUTIONS: u32 = 64;
pub const MAX_COUNT_TIMERS: u32 = 64;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum DriverError {
InternalError,
NotSupported,
InvalidArgs,
BadState,
Canceled,
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u32 },
}
#[macro_export]
macro_rules! DriverErrorUnknown {
() => {
_
};
}
impl DriverError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::InternalError),
2 => Some(Self::NotSupported),
3 => Some(Self::InvalidArgs),
4 => Some(Self::BadState),
5 => Some(Self::Canceled),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::InternalError,
2 => Self::NotSupported,
3 => Self::InvalidArgs,
4 => Self::BadState,
5 => Self::Canceled,
unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
}
}
#[inline]
pub fn unknown() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0xffffffff }
}
#[inline]
pub const fn into_primitive(self) -> u32 {
match self {
Self::InternalError => 1,
Self::NotSupported => 2,
Self::InvalidArgs => 3,
Self::BadState => 4,
Self::Canceled => 5,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { unknown_ordinal: _ } => true,
_ => false,
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct DeviceGetTicksLeftRequest {
pub id: u64,
}
impl fidl::Persistable for DeviceGetTicksLeftRequest {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct DeviceSetEventRequest {
pub id: u64,
pub event: fidl::Event,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceSetEventRequest {}
#[derive(Debug, PartialEq)]
pub struct DeviceStartAndWait2Request {
pub id: u64,
pub resolution: Resolution,
pub ticks: u64,
pub setup_keep_alive: fidl::EventPair,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceStartAndWait2Request
{
}
#[derive(Debug, PartialEq)]
pub struct DeviceStartAndWaitRequest {
pub id: u64,
pub resolution: Resolution,
pub ticks: u64,
pub setup_event: fidl::Event,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for DeviceStartAndWaitRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct DeviceStartRequest {
pub id: u64,
pub resolution: Resolution,
pub ticks: u64,
}
impl fidl::Persistable for DeviceStartRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct DeviceStopRequest {
pub id: u64,
}
impl fidl::Persistable for DeviceStopRequest {}
#[derive(Debug, PartialEq)]
pub struct DeviceGetPropertiesResponse {
pub properties: Properties,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceGetPropertiesResponse
{
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct DeviceGetTicksLeftResponse {
pub ticks: u64,
}
impl fidl::Persistable for DeviceGetTicksLeftResponse {}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct DeviceStartAndWait2Response {
pub expiration_keep_alive: fidl::EventPair,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceStartAndWait2Response
{
}
#[derive(Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct DeviceStartAndWaitResponse {
pub keep_alive: fidl::EventPair,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceStartAndWaitResponse
{
}
#[derive(Debug, Default, PartialEq)]
pub struct Properties {
pub timers_properties: Option<Vec<TimerProperties>>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Standalone<fidl::encoding::DefaultFuchsiaResourceDialect> for Properties {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct TimerProperties {
pub id: Option<u64>,
pub supported_resolutions: Option<Vec<Resolution>>,
pub max_ticks: Option<u64>,
pub supports_event: Option<bool>,
pub supports_wait: Option<bool>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for TimerProperties {}
#[derive(Clone, Debug)]
pub enum Resolution {
Duration(i64),
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u64 },
}
#[macro_export]
macro_rules! ResolutionUnknown {
() => {
_
};
}
impl PartialEq for Resolution {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Duration(x), Self::Duration(y)) => *x == *y,
_ => false,
}
}
}
impl Resolution {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::Duration(_) => 1,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Persistable for Resolution {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct DeviceMarker;
impl fidl::endpoints::ProtocolMarker for DeviceMarker {
type Proxy = DeviceProxy;
type RequestStream = DeviceRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = DeviceSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.hardware.hrtimer.Device";
}
impl fidl::endpoints::DiscoverableProtocolMarker for DeviceMarker {}
pub type DeviceStartResult = Result<(), DriverError>;
pub type DeviceStopResult = Result<(), DriverError>;
pub type DeviceGetTicksLeftResult = Result<u64, DriverError>;
pub type DeviceSetEventResult = Result<(), DriverError>;
pub type DeviceStartAndWaitResult = Result<fidl::EventPair, DriverError>;
pub type DeviceStartAndWait2Result = Result<fidl::EventPair, DriverError>;
pub trait DeviceProxyInterface: Send + Sync {
type StartResponseFut: std::future::Future<Output = Result<DeviceStartResult, fidl::Error>>
+ Send;
fn r#start(&self, id: u64, resolution: &Resolution, ticks: u64) -> Self::StartResponseFut;
type StopResponseFut: std::future::Future<Output = Result<DeviceStopResult, fidl::Error>> + Send;
fn r#stop(&self, id: u64) -> Self::StopResponseFut;
type GetTicksLeftResponseFut: std::future::Future<Output = Result<DeviceGetTicksLeftResult, fidl::Error>>
+ Send;
fn r#get_ticks_left(&self, id: u64) -> Self::GetTicksLeftResponseFut;
type SetEventResponseFut: std::future::Future<Output = Result<DeviceSetEventResult, fidl::Error>>
+ Send;
fn r#set_event(&self, id: u64, event: fidl::Event) -> Self::SetEventResponseFut;
type StartAndWaitResponseFut: std::future::Future<Output = Result<DeviceStartAndWaitResult, fidl::Error>>
+ Send;
fn r#start_and_wait(
&self,
id: u64,
resolution: &Resolution,
ticks: u64,
setup_event: fidl::Event,
) -> Self::StartAndWaitResponseFut;
type StartAndWait2ResponseFut: std::future::Future<Output = Result<DeviceStartAndWait2Result, fidl::Error>>
+ Send;
fn r#start_and_wait2(
&self,
id: u64,
resolution: &Resolution,
ticks: u64,
setup_keep_alive: fidl::EventPair,
) -> Self::StartAndWait2ResponseFut;
type GetPropertiesResponseFut: std::future::Future<Output = Result<Properties, fidl::Error>>
+ Send;
fn r#get_properties(&self) -> Self::GetPropertiesResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct DeviceSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for DeviceSynchronousProxy {
type Proxy = DeviceProxy;
type Protocol = DeviceMarker;
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 DeviceSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <DeviceMarker 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<DeviceEvent, fidl::Error> {
DeviceEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#start(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
___deadline: zx::MonotonicInstant,
) -> Result<DeviceStartResult, fidl::Error> {
let _response = self.client.send_query::<
DeviceStartRequest,
fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
>(
(id, resolution, ticks,),
0x5a0a193b0467cc8a,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DeviceMarker>("start")?;
Ok(_response.map(|x| x))
}
pub fn r#stop(
&self,
mut id: u64,
___deadline: zx::MonotonicInstant,
) -> Result<DeviceStopResult, fidl::Error> {
let _response = self.client.send_query::<
DeviceStopRequest,
fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
>(
(id,),
0x77e4cd1c3841a0e2,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DeviceMarker>("stop")?;
Ok(_response.map(|x| x))
}
pub fn r#get_ticks_left(
&self,
mut id: u64,
___deadline: zx::MonotonicInstant,
) -> Result<DeviceGetTicksLeftResult, fidl::Error> {
let _response = self.client.send_query::<
DeviceGetTicksLeftRequest,
fidl::encoding::FlexibleResultType<DeviceGetTicksLeftResponse, DriverError>,
>(
(id,),
0xde2a48ae7d4b4ea,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DeviceMarker>("get_ticks_left")?;
Ok(_response.map(|x| x.ticks))
}
pub fn r#set_event(
&self,
mut id: u64,
mut event: fidl::Event,
___deadline: zx::MonotonicInstant,
) -> Result<DeviceSetEventResult, fidl::Error> {
let _response = self.client.send_query::<
DeviceSetEventRequest,
fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
>(
(id, event,),
0x1027024d25ffa820,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DeviceMarker>("set_event")?;
Ok(_response.map(|x| x))
}
pub fn r#start_and_wait(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
mut setup_event: fidl::Event,
___deadline: zx::MonotonicInstant,
) -> Result<DeviceStartAndWaitResult, fidl::Error> {
let _response = self.client.send_query::<
DeviceStartAndWaitRequest,
fidl::encoding::FlexibleResultType<DeviceStartAndWaitResponse, DriverError>,
>(
(id, resolution, ticks, setup_event,),
0x716f415cdf234e0f,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DeviceMarker>("start_and_wait")?;
Ok(_response.map(|x| x.keep_alive))
}
pub fn r#start_and_wait2(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
mut setup_keep_alive: fidl::EventPair,
___deadline: zx::MonotonicInstant,
) -> Result<DeviceStartAndWait2Result, fidl::Error> {
let _response = self.client.send_query::<
DeviceStartAndWait2Request,
fidl::encoding::FlexibleResultType<DeviceStartAndWait2Response, DriverError>,
>(
(id, resolution, ticks, setup_keep_alive,),
0x5f2aaf21254d3238,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DeviceMarker>("start_and_wait2")?;
Ok(_response.map(|x| x.expiration_keep_alive))
}
pub fn r#get_properties(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<Properties, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
fidl::encoding::FlexibleType<DeviceGetPropertiesResponse>,
>(
(),
0x6bc22ab4c9396cbb,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DeviceMarker>("get_properties")?;
Ok(_response.properties)
}
}
#[derive(Debug, Clone)]
pub struct DeviceProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for DeviceProxy {
type Protocol = DeviceMarker;
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 DeviceProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> DeviceEventStream {
DeviceEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#start(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
) -> fidl::client::QueryResponseFut<
DeviceStartResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DeviceProxyInterface::r#start(self, id, resolution, ticks)
}
pub fn r#stop(
&self,
mut id: u64,
) -> fidl::client::QueryResponseFut<
DeviceStopResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DeviceProxyInterface::r#stop(self, id)
}
pub fn r#get_ticks_left(
&self,
mut id: u64,
) -> fidl::client::QueryResponseFut<
DeviceGetTicksLeftResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DeviceProxyInterface::r#get_ticks_left(self, id)
}
pub fn r#set_event(
&self,
mut id: u64,
mut event: fidl::Event,
) -> fidl::client::QueryResponseFut<
DeviceSetEventResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DeviceProxyInterface::r#set_event(self, id, event)
}
pub fn r#start_and_wait(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
mut setup_event: fidl::Event,
) -> fidl::client::QueryResponseFut<
DeviceStartAndWaitResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DeviceProxyInterface::r#start_and_wait(self, id, resolution, ticks, setup_event)
}
pub fn r#start_and_wait2(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
mut setup_keep_alive: fidl::EventPair,
) -> fidl::client::QueryResponseFut<
DeviceStartAndWait2Result,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DeviceProxyInterface::r#start_and_wait2(self, id, resolution, ticks, setup_keep_alive)
}
pub fn r#get_properties(
&self,
) -> fidl::client::QueryResponseFut<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>
{
DeviceProxyInterface::r#get_properties(self)
}
}
impl DeviceProxyInterface for DeviceProxy {
type StartResponseFut = fidl::client::QueryResponseFut<
DeviceStartResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#start(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
) -> Self::StartResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DeviceStartResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x5a0a193b0467cc8a,
>(_buf?)?
.into_result::<DeviceMarker>("start")?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<DeviceStartRequest, DeviceStartResult>(
(id, resolution, ticks),
0x5a0a193b0467cc8a,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type StopResponseFut = fidl::client::QueryResponseFut<
DeviceStopResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#stop(&self, mut id: u64) -> Self::StopResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DeviceStopResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x77e4cd1c3841a0e2,
>(_buf?)?
.into_result::<DeviceMarker>("stop")?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<DeviceStopRequest, DeviceStopResult>(
(id,),
0x77e4cd1c3841a0e2,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type GetTicksLeftResponseFut = fidl::client::QueryResponseFut<
DeviceGetTicksLeftResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#get_ticks_left(&self, mut id: u64) -> Self::GetTicksLeftResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DeviceGetTicksLeftResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<DeviceGetTicksLeftResponse, DriverError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0xde2a48ae7d4b4ea,
>(_buf?)?
.into_result::<DeviceMarker>("get_ticks_left")?;
Ok(_response.map(|x| x.ticks))
}
self.client.send_query_and_decode::<DeviceGetTicksLeftRequest, DeviceGetTicksLeftResult>(
(id,),
0xde2a48ae7d4b4ea,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type SetEventResponseFut = fidl::client::QueryResponseFut<
DeviceSetEventResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#set_event(&self, mut id: u64, mut event: fidl::Event) -> Self::SetEventResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DeviceSetEventResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<fidl::encoding::EmptyStruct, DriverError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x1027024d25ffa820,
>(_buf?)?
.into_result::<DeviceMarker>("set_event")?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<DeviceSetEventRequest, DeviceSetEventResult>(
(id, event),
0x1027024d25ffa820,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type StartAndWaitResponseFut = fidl::client::QueryResponseFut<
DeviceStartAndWaitResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#start_and_wait(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
mut setup_event: fidl::Event,
) -> Self::StartAndWaitResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DeviceStartAndWaitResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<DeviceStartAndWaitResponse, DriverError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x716f415cdf234e0f,
>(_buf?)?
.into_result::<DeviceMarker>("start_and_wait")?;
Ok(_response.map(|x| x.keep_alive))
}
self.client.send_query_and_decode::<DeviceStartAndWaitRequest, DeviceStartAndWaitResult>(
(id, resolution, ticks, setup_event),
0x716f415cdf234e0f,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type StartAndWait2ResponseFut = fidl::client::QueryResponseFut<
DeviceStartAndWait2Result,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#start_and_wait2(
&self,
mut id: u64,
mut resolution: &Resolution,
mut ticks: u64,
mut setup_keep_alive: fidl::EventPair,
) -> Self::StartAndWait2ResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DeviceStartAndWait2Result, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<DeviceStartAndWait2Response, DriverError>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x5f2aaf21254d3238,
>(_buf?)?
.into_result::<DeviceMarker>("start_and_wait2")?;
Ok(_response.map(|x| x.expiration_keep_alive))
}
self.client.send_query_and_decode::<DeviceStartAndWait2Request, DeviceStartAndWait2Result>(
(id, resolution, ticks, setup_keep_alive),
0x5f2aaf21254d3238,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type GetPropertiesResponseFut =
fidl::client::QueryResponseFut<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>;
fn r#get_properties(&self) -> Self::GetPropertiesResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<Properties, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleType<DeviceGetPropertiesResponse>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x6bc22ab4c9396cbb,
>(_buf?)?
.into_result::<DeviceMarker>("get_properties")?;
Ok(_response.properties)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Properties>(
(),
0x6bc22ab4c9396cbb,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
}
pub struct DeviceEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for DeviceEventStream {}
impl futures::stream::FusedStream for DeviceEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for DeviceEventStream {
type Item = Result<DeviceEvent, 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(DeviceEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum DeviceEvent {
#[non_exhaustive]
_UnknownEvent {
ordinal: u64,
},
}
impl DeviceEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<DeviceEvent, 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 {
_ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
Ok(DeviceEvent::_UnknownEvent { ordinal: tx_header.ordinal })
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct DeviceRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for DeviceRequestStream {}
impl futures::stream::FusedStream for DeviceRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for DeviceRequestStream {
type Protocol = DeviceMarker;
type ControlHandle = DeviceControlHandle;
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 {
DeviceControlHandle { 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 DeviceRequestStream {
type Item = Result<DeviceRequest, 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 DeviceRequestStream 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 {
0x5a0a193b0467cc8a => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DeviceStartRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DeviceControlHandle { inner: this.inner.clone() };
Ok(DeviceRequest::Start {
id: req.id,
resolution: req.resolution,
ticks: req.ticks,
responder: DeviceStartResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x77e4cd1c3841a0e2 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DeviceStopRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStopRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DeviceControlHandle { inner: this.inner.clone() };
Ok(DeviceRequest::Stop {
id: req.id,
responder: DeviceStopResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0xde2a48ae7d4b4ea => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DeviceGetTicksLeftRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceGetTicksLeftRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DeviceControlHandle { inner: this.inner.clone() };
Ok(DeviceRequest::GetTicksLeft {
id: req.id,
responder: DeviceGetTicksLeftResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x1027024d25ffa820 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DeviceSetEventRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceSetEventRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DeviceControlHandle { inner: this.inner.clone() };
Ok(DeviceRequest::SetEvent {
id: req.id,
event: req.event,
responder: DeviceSetEventResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x716f415cdf234e0f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DeviceStartAndWaitRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartAndWaitRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DeviceControlHandle { inner: this.inner.clone() };
Ok(DeviceRequest::StartAndWait {
id: req.id,
resolution: req.resolution,
ticks: req.ticks,
setup_event: req.setup_event,
responder: DeviceStartAndWaitResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x5f2aaf21254d3238 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DeviceStartAndWait2Request,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DeviceStartAndWait2Request>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DeviceControlHandle { inner: this.inner.clone() };
Ok(DeviceRequest::StartAndWait2 {
id: req.id,
resolution: req.resolution,
ticks: req.ticks,
setup_keep_alive: req.setup_keep_alive,
responder: DeviceStartAndWait2Responder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6bc22ab4c9396cbb => {
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 = DeviceControlHandle { inner: this.inner.clone() };
Ok(DeviceRequest::GetProperties {
responder: DeviceGetPropertiesResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ if header.tx_id == 0
&& header
.dynamic_flags()
.contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
{
Ok(DeviceRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: DeviceControlHandle { inner: this.inner.clone() },
method_type: fidl::MethodType::OneWay,
})
}
_ if header
.dynamic_flags()
.contains(fidl::encoding::DynamicFlags::FLEXIBLE) =>
{
this.inner.send_framework_err(
fidl::encoding::FrameworkErr::UnknownMethod,
header.tx_id,
header.ordinal,
header.dynamic_flags(),
(bytes, handles),
)?;
Ok(DeviceRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: DeviceControlHandle { inner: this.inner.clone() },
method_type: fidl::MethodType::TwoWay,
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<DeviceMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum DeviceRequest {
Start { id: u64, resolution: Resolution, ticks: u64, responder: DeviceStartResponder },
Stop { id: u64, responder: DeviceStopResponder },
GetTicksLeft { id: u64, responder: DeviceGetTicksLeftResponder },
SetEvent { id: u64, event: fidl::Event, responder: DeviceSetEventResponder },
StartAndWait {
id: u64,
resolution: Resolution,
ticks: u64,
setup_event: fidl::Event,
responder: DeviceStartAndWaitResponder,
},
StartAndWait2 {
id: u64,
resolution: Resolution,
ticks: u64,
setup_keep_alive: fidl::EventPair,
responder: DeviceStartAndWait2Responder,
},
GetProperties { responder: DeviceGetPropertiesResponder },
#[non_exhaustive]
_UnknownMethod {
ordinal: u64,
control_handle: DeviceControlHandle,
method_type: fidl::MethodType,
},
}
impl DeviceRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_start(self) -> Option<(u64, Resolution, u64, DeviceStartResponder)> {
if let DeviceRequest::Start { id, resolution, ticks, responder } = self {
Some((id, resolution, ticks, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_stop(self) -> Option<(u64, DeviceStopResponder)> {
if let DeviceRequest::Stop { id, responder } = self {
Some((id, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_get_ticks_left(self) -> Option<(u64, DeviceGetTicksLeftResponder)> {
if let DeviceRequest::GetTicksLeft { id, responder } = self {
Some((id, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_set_event(self) -> Option<(u64, fidl::Event, DeviceSetEventResponder)> {
if let DeviceRequest::SetEvent { id, event, responder } = self {
Some((id, event, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start_and_wait(
self,
) -> Option<(u64, Resolution, u64, fidl::Event, DeviceStartAndWaitResponder)> {
if let DeviceRequest::StartAndWait { id, resolution, ticks, setup_event, responder } = self
{
Some((id, resolution, ticks, setup_event, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_start_and_wait2(
self,
) -> Option<(u64, Resolution, u64, fidl::EventPair, DeviceStartAndWait2Responder)> {
if let DeviceRequest::StartAndWait2 { id, resolution, ticks, setup_keep_alive, responder } =
self
{
Some((id, resolution, ticks, setup_keep_alive, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_get_properties(self) -> Option<(DeviceGetPropertiesResponder)> {
if let DeviceRequest::GetProperties { responder } = self {
Some((responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
DeviceRequest::Start { .. } => "start",
DeviceRequest::Stop { .. } => "stop",
DeviceRequest::GetTicksLeft { .. } => "get_ticks_left",
DeviceRequest::SetEvent { .. } => "set_event",
DeviceRequest::StartAndWait { .. } => "start_and_wait",
DeviceRequest::StartAndWait2 { .. } => "start_and_wait2",
DeviceRequest::GetProperties { .. } => "get_properties",
DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
"unknown one-way method"
}
DeviceRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
"unknown two-way method"
}
}
}
}
#[derive(Debug, Clone)]
pub struct DeviceControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for DeviceControlHandle {
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 DeviceControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DeviceStartResponder {
control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DeviceStartResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DeviceStartResponder {
type ControlHandle = DeviceControlHandle;
fn control_handle(&self) -> &DeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DeviceStartResponder {
pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<(), DriverError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
DriverError,
>>(
fidl::encoding::FlexibleResult::new(result),
self.tx_id,
0x5a0a193b0467cc8a,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DeviceStopResponder {
control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DeviceStopResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DeviceStopResponder {
type ControlHandle = DeviceControlHandle;
fn control_handle(&self) -> &DeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DeviceStopResponder {
pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<(), DriverError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
DriverError,
>>(
fidl::encoding::FlexibleResult::new(result),
self.tx_id,
0x77e4cd1c3841a0e2,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DeviceGetTicksLeftResponder {
control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DeviceGetTicksLeftResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DeviceGetTicksLeftResponder {
type ControlHandle = DeviceControlHandle;
fn control_handle(&self) -> &DeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DeviceGetTicksLeftResponder {
pub fn send(self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<u64, DriverError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<u64, DriverError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
DeviceGetTicksLeftResponse,
DriverError,
>>(
fidl::encoding::FlexibleResult::new(result.map(|ticks| (ticks,))),
self.tx_id,
0xde2a48ae7d4b4ea,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DeviceSetEventResponder {
control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DeviceSetEventResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DeviceSetEventResponder {
type ControlHandle = DeviceControlHandle;
fn control_handle(&self) -> &DeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DeviceSetEventResponder {
pub fn send(self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<(), DriverError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), DriverError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
DriverError,
>>(
fidl::encoding::FlexibleResult::new(result),
self.tx_id,
0x1027024d25ffa820,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DeviceStartAndWaitResponder {
control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DeviceStartAndWaitResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DeviceStartAndWaitResponder {
type ControlHandle = DeviceControlHandle;
fn control_handle(&self) -> &DeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DeviceStartAndWaitResponder {
pub fn send(self, mut result: Result<fidl::EventPair, DriverError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<fidl::EventPair, DriverError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut result: Result<fidl::EventPair, DriverError>,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
DeviceStartAndWaitResponse,
DriverError,
>>(
fidl::encoding::FlexibleResult::new(result.map(|keep_alive| (keep_alive,))),
self.tx_id,
0x716f415cdf234e0f,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DeviceStartAndWait2Responder {
control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DeviceStartAndWait2Responder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DeviceStartAndWait2Responder {
type ControlHandle = DeviceControlHandle;
fn control_handle(&self) -> &DeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DeviceStartAndWait2Responder {
pub fn send(self, mut result: Result<fidl::EventPair, DriverError>) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut result: Result<fidl::EventPair, DriverError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut result: Result<fidl::EventPair, DriverError>,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
DeviceStartAndWait2Response,
DriverError,
>>(
fidl::encoding::FlexibleResult::new(
result.map(|expiration_keep_alive| (expiration_keep_alive,)),
),
self.tx_id,
0x5f2aaf21254d3238,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DeviceGetPropertiesResponder {
control_handle: std::mem::ManuallyDrop<DeviceControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DeviceGetPropertiesResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DeviceGetPropertiesResponder {
type ControlHandle = DeviceControlHandle;
fn control_handle(&self) -> &DeviceControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DeviceGetPropertiesResponder {
pub fn send(self, mut properties: Properties) -> Result<(), fidl::Error> {
let _result = self.send_raw(properties);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut properties: Properties) -> Result<(), fidl::Error> {
let _result = self.send_raw(properties);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut properties: Properties) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleType<DeviceGetPropertiesResponse>>(
fidl::encoding::Flexible::new((&mut properties,)),
self.tx_id,
0x6bc22ab4c9396cbb,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct ServiceMarker;
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceMarker for ServiceMarker {
type Proxy = ServiceProxy;
type Request = ServiceRequest;
const SERVICE_NAME: &'static str = "fuchsia.hardware.hrtimer.Service";
}
#[cfg(target_os = "fuchsia")]
pub enum ServiceRequest {
Device(DeviceRequestStream),
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceRequest for ServiceRequest {
type Service = ServiceMarker;
fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
match name {
"device" => Self::Device(
<DeviceRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
),
_ => panic!("no such member protocol name for service Service"),
}
}
fn member_names() -> &'static [&'static str] {
&["device"]
}
}
#[cfg(target_os = "fuchsia")]
pub struct ServiceProxy(#[allow(dead_code)] Box<dyn fidl::endpoints::MemberOpener>);
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceProxy for ServiceProxy {
type Service = ServiceMarker;
fn from_member_opener(opener: Box<dyn fidl::endpoints::MemberOpener>) -> Self {
Self(opener)
}
}
#[cfg(target_os = "fuchsia")]
impl ServiceProxy {
pub fn connect_to_device(&self) -> Result<DeviceProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_proxy::<DeviceMarker>();
self.connect_channel_to_device(server_end)?;
Ok(proxy)
}
pub fn connect_to_device_sync(&self) -> Result<DeviceSynchronousProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DeviceMarker>();
self.connect_channel_to_device(server_end)?;
Ok(proxy)
}
pub fn connect_channel_to_device(
&self,
server_end: fidl::endpoints::ServerEnd<DeviceMarker>,
) -> Result<(), fidl::Error> {
self.0.open_member("device", server_end.into_channel())
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for DriverError {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u32>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u32>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
false
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for DriverError {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
*value
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<Self, D> for DriverError {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DriverError {
#[inline(always)]
fn new_empty() -> Self {
Self::unknown()
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive_allow_unknown(prim);
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DeviceGetTicksLeftRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceGetTicksLeftRequest {
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<DeviceGetTicksLeftRequest, D> for &DeviceGetTicksLeftRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceGetTicksLeftRequest>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut DeviceGetTicksLeftRequest)
.write_unaligned((self as *const DeviceGetTicksLeftRequest).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
fidl::encoding::Encode<DeviceGetTicksLeftRequest, 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::<DeviceGetTicksLeftRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for DeviceGetTicksLeftRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { id: fidl::new_empty!(u64, 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(())
}
}
impl fidl::encoding::ResourceTypeMarker for DeviceSetEventRequest {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceSetEventRequest {
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
fidl::encoding::Encode<DeviceSetEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut DeviceSetEventRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceSetEventRequest>(offset);
fidl::encoding::Encode::<
DeviceSetEventRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
<fidl::encoding::HandleType<
fidl::Event,
{ fidl::ObjectType::EVENT.into_raw() },
2147483648,
> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
&mut self.event
),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
T1: fidl::encoding::Encode<
fidl::encoding::HandleType<
fidl::Event,
{ fidl::ObjectType::EVENT.into_raw() },
2147483648,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<DeviceSetEventRequest, fidl::encoding::DefaultFuchsiaResourceDialect>
for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceSetEventRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(8);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceSetEventRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self {
id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(8) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 8 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
u64,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.id,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.event, decoder, offset + 8, _depth)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWait2Request {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWait2Request {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
40
}
}
unsafe impl
fidl::encoding::Encode<
DeviceStartAndWait2Request,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut DeviceStartAndWait2Request
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWait2Request>(offset);
fidl::encoding::Encode::<
DeviceStartAndWait2Request,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
<Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
<fidl::encoding::HandleType<
fidl::EventPair,
{ fidl::ObjectType::EVENTPAIR.into_raw() },
2147483648,
> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
&mut self.setup_keep_alive,
),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
T1: fidl::encoding::Encode<Resolution, fidl::encoding::DefaultFuchsiaResourceDialect>,
T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
T3: fidl::encoding::Encode<
fidl::encoding::HandleType<
fidl::EventPair,
{ fidl::ObjectType::EVENTPAIR.into_raw() },
2147483648,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
DeviceStartAndWait2Request,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for (T0, T1, T2, T3)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWait2Request>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
self.2.encode(encoder, offset + 24, depth)?;
self.3.encode(encoder, offset + 32, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceStartAndWait2Request
{
#[inline(always)]
fn new_empty() -> Self {
Self {
id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
resolution: fidl::new_empty!(
Resolution,
fidl::encoding::DefaultFuchsiaResourceDialect
),
ticks: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
setup_keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
u64,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.id,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
Resolution,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.resolution,
decoder,
offset + 8,
_depth
)?;
fidl::decode!(
u64,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.ticks,
decoder,
offset + 24,
_depth
)?;
fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.setup_keep_alive, decoder, offset + 32, _depth)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWaitRequest {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWaitRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
40
}
}
unsafe impl
fidl::encoding::Encode<
DeviceStartAndWaitRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut DeviceStartAndWaitRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWaitRequest>(offset);
fidl::encoding::Encode::<
DeviceStartAndWaitRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
<Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
<fidl::encoding::HandleType<
fidl::Event,
{ fidl::ObjectType::EVENT.into_raw() },
2147483648,
> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
&mut self.setup_event
),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
T1: fidl::encoding::Encode<Resolution, fidl::encoding::DefaultFuchsiaResourceDialect>,
T2: fidl::encoding::Encode<u64, fidl::encoding::DefaultFuchsiaResourceDialect>,
T3: fidl::encoding::Encode<
fidl::encoding::HandleType<
fidl::Event,
{ fidl::ObjectType::EVENT.into_raw() },
2147483648,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
DeviceStartAndWaitRequest,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for (T0, T1, T2, T3)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWaitRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
self.2.encode(encoder, offset + 24, depth)?;
self.3.encode(encoder, offset + 32, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceStartAndWaitRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self {
id: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
resolution: fidl::new_empty!(
Resolution,
fidl::encoding::DefaultFuchsiaResourceDialect
),
ticks: fidl::new_empty!(u64, fidl::encoding::DefaultFuchsiaResourceDialect),
setup_event: fidl::new_empty!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
u64,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.id,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
Resolution,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.resolution,
decoder,
offset + 8,
_depth
)?;
fidl::decode!(
u64,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.ticks,
decoder,
offset + 24,
_depth
)?;
fidl::decode!(fidl::encoding::HandleType<fidl::Event, { fidl::ObjectType::EVENT.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.setup_event, decoder, offset + 32, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DeviceStartRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceStartRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
32
}
}
unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DeviceStartRequest, D>
for &DeviceStartRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartRequest>(offset);
fidl::encoding::Encode::<DeviceStartRequest, D>::encode(
(
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.id),
<Resolution as fidl::encoding::ValueTypeMarker>::borrow(&self.resolution),
<u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.ticks),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<u64, D>,
T1: fidl::encoding::Encode<Resolution, D>,
T2: fidl::encoding::Encode<u64, D>,
> fidl::encoding::Encode<DeviceStartRequest, D> for (T0, T1, T2)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
self.2.encode(encoder, offset + 24, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceStartRequest {
#[inline(always)]
fn new_empty() -> Self {
Self {
id: fidl::new_empty!(u64, D),
resolution: fidl::new_empty!(Resolution, D),
ticks: fidl::new_empty!(u64, 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!(u64, D, &mut self.id, decoder, offset + 0, _depth)?;
fidl::decode!(Resolution, D, &mut self.resolution, decoder, offset + 8, _depth)?;
fidl::decode!(u64, D, &mut self.ticks, decoder, offset + 24, _depth)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DeviceStopRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceStopRequest {
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<DeviceStopRequest, D>
for &DeviceStopRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStopRequest>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut DeviceStopRequest)
.write_unaligned((self as *const DeviceStopRequest).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
fidl::encoding::Encode<DeviceStopRequest, 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::<DeviceStopRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DeviceStopRequest {
#[inline(always)]
fn new_empty() -> Self {
Self { id: fidl::new_empty!(u64, 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(())
}
}
impl fidl::encoding::ResourceTypeMarker for DeviceGetPropertiesResponse {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceGetPropertiesResponse {
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
fidl::encoding::Encode<
DeviceGetPropertiesResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut DeviceGetPropertiesResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceGetPropertiesResponse>(offset);
fidl::encoding::Encode::<
DeviceGetPropertiesResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(<Properties as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
&mut self.properties,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>>
fidl::encoding::Encode<
DeviceGetPropertiesResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceGetPropertiesResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceGetPropertiesResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self {
properties: fidl::new_empty!(
Properties,
fidl::encoding::DefaultFuchsiaResourceDialect
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
Properties,
fidl::encoding::DefaultFuchsiaResourceDialect,
&mut self.properties,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DeviceGetTicksLeftResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceGetTicksLeftResponse {
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<DeviceGetTicksLeftResponse, D> for &DeviceGetTicksLeftResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceGetTicksLeftResponse>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut DeviceGetTicksLeftResponse)
.write_unaligned((self as *const DeviceGetTicksLeftResponse).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<u64, D>>
fidl::encoding::Encode<DeviceGetTicksLeftResponse, 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::<DeviceGetTicksLeftResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for DeviceGetTicksLeftResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self { ticks: fidl::new_empty!(u64, 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(())
}
}
impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWait2Response {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWait2Response {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
}
unsafe impl
fidl::encoding::Encode<
DeviceStartAndWait2Response,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut DeviceStartAndWait2Response
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWait2Response>(offset);
fidl::encoding::Encode::<
DeviceStartAndWait2Response,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(<fidl::encoding::HandleType<
fidl::EventPair,
{ fidl::ObjectType::EVENTPAIR.into_raw() },
2147483648,
> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
&mut self.expiration_keep_alive,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::HandleType<
fidl::EventPair,
{ fidl::ObjectType::EVENTPAIR.into_raw() },
2147483648,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
DeviceStartAndWait2Response,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWait2Response>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceStartAndWait2Response
{
#[inline(always)]
fn new_empty() -> Self {
Self {
expiration_keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.expiration_keep_alive, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl fidl::encoding::ResourceTypeMarker for DeviceStartAndWaitResponse {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceStartAndWaitResponse {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
}
unsafe impl
fidl::encoding::Encode<
DeviceStartAndWaitResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for &mut DeviceStartAndWaitResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWaitResponse>(offset);
fidl::encoding::Encode::<
DeviceStartAndWaitResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
>::encode(
(<fidl::encoding::HandleType<
fidl::EventPair,
{ fidl::ObjectType::EVENTPAIR.into_raw() },
2147483648,
> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(
&mut self.keep_alive
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<
fidl::encoding::HandleType<
fidl::EventPair,
{ fidl::ObjectType::EVENTPAIR.into_raw() },
2147483648,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
>
fidl::encoding::Encode<
DeviceStartAndWaitResponse,
fidl::encoding::DefaultFuchsiaResourceDialect,
> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceStartAndWaitResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect>
for DeviceStartAndWaitResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self {
keep_alive: fidl::new_empty!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(fidl::encoding::HandleType<fidl::EventPair, { fidl::ObjectType::EVENTPAIR.into_raw() }, 2147483648>, fidl::encoding::DefaultFuchsiaResourceDialect, &mut self.keep_alive, decoder, offset + 0, _depth)?;
Ok(())
}
}
impl Properties {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.timers_properties {
return 1;
}
0
}
}
impl fidl::encoding::ResourceTypeMarker for Properties {
type Borrowed<'a> = &'a mut Self;
fn take_or_borrow<'a>(
value: &'a mut <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Properties {
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 fidl::encoding::Encode<Properties, fidl::encoding::DefaultFuchsiaResourceDialect>
for &mut Properties
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Properties>(offset);
let max_ordinal: u64 = self.max_ordinal_present();
encoder.write_num(max_ordinal, offset);
encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
if max_ordinal == 0 {
return Ok(());
}
depth.increment()?;
let envelope_size = 8;
let bytes_len = max_ordinal as usize * envelope_size;
#[allow(unused_variables)]
let offset = encoder.out_of_line_offset(bytes_len);
let mut _prev_end_offset: usize = 0;
if 1 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (1 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect>(
self.timers_properties.as_ref().map(<fidl::encoding::Vector<TimerProperties, 64> as fidl::encoding::ValueTypeMarker>::borrow),
encoder, offset + cur_offset, depth
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self, fidl::encoding::DefaultFuchsiaResourceDialect> for Properties {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<
'_,
fidl::encoding::DefaultFuchsiaResourceDialect,
>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
None => return Err(fidl::Error::NotNullable),
Some(len) => len,
};
if len == 0 {
return Ok(());
};
depth.increment()?;
let envelope_size = 8;
let bytes_len = len * envelope_size;
let offset = decoder.out_of_line_offset(bytes_len)?;
let mut _next_ordinal_to_read = 0;
let mut next_offset = offset;
let end_offset = offset + bytes_len;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 1 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size = <fidl::encoding::Vector<TimerProperties, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref =
self.timers_properties.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect));
fidl::decode!(fidl::encoding::Vector<TimerProperties, 64>, fidl::encoding::DefaultFuchsiaResourceDialect, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
while next_offset < end_offset {
_next_ordinal_to_read += 1;
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
next_offset += envelope_size;
}
Ok(())
}
}
impl TimerProperties {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.supports_wait {
return 5;
}
if let Some(_) = self.supports_event {
return 4;
}
if let Some(_) = self.max_ticks {
return 3;
}
if let Some(_) = self.supported_resolutions {
return 2;
}
if let Some(_) = self.id {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for TimerProperties {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for TimerProperties {
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<TimerProperties, D>
for &TimerProperties
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<TimerProperties>(offset);
let max_ordinal: u64 = self.max_ordinal_present();
encoder.write_num(max_ordinal, offset);
encoder.write_num(fidl::encoding::ALLOC_PRESENT_U64, offset + 8);
if max_ordinal == 0 {
return Ok(());
}
depth.increment()?;
let envelope_size = 8;
let bytes_len = max_ordinal as usize * envelope_size;
#[allow(unused_variables)]
let offset = encoder.out_of_line_offset(bytes_len);
let mut _prev_end_offset: usize = 0;
if 1 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (1 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<u64, D>(
self.id.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 2 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (2 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<Resolution, 64>, D>(
self.supported_resolutions.as_ref().map(<fidl::encoding::Vector<Resolution, 64> as fidl::encoding::ValueTypeMarker>::borrow),
encoder, offset + cur_offset, depth
)?;
_prev_end_offset = cur_offset + envelope_size;
if 3 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (3 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<u64, D>(
self.max_ticks.as_ref().map(<u64 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 4 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (4 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<bool, D>(
self.supports_event.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 5 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (5 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<bool, D>(
self.supports_wait.as_ref().map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for TimerProperties {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let len = match fidl::encoding::decode_vector_header(decoder, offset)? {
None => return Err(fidl::Error::NotNullable),
Some(len) => len,
};
if len == 0 {
return Ok(());
};
depth.increment()?;
let envelope_size = 8;
let bytes_len = len * envelope_size;
let offset = decoder.out_of_line_offset(bytes_len)?;
let mut _next_ordinal_to_read = 0;
let mut next_offset = offset;
let end_offset = offset + bytes_len;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 1 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.id.get_or_insert_with(|| fidl::new_empty!(u64, D));
fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 2 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size = <fidl::encoding::Vector<Resolution, 64> as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.supported_resolutions.get_or_insert_with(
|| fidl::new_empty!(fidl::encoding::Vector<Resolution, 64>, D),
);
fidl::decode!(fidl::encoding::Vector<Resolution, 64>, D, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 3 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<u64 as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.max_ticks.get_or_insert_with(|| fidl::new_empty!(u64, D));
fidl::decode!(u64, D, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 4 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.supports_event.get_or_insert_with(|| fidl::new_empty!(bool, D));
fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 5 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<bool as fidl::encoding::TypeMarker>::inline_size(decoder.context);
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let inner_offset;
let mut inner_depth = depth.clone();
if inlined {
decoder.check_inline_envelope_padding(next_offset, member_inline_size)?;
inner_offset = next_offset;
} else {
inner_offset = decoder.out_of_line_offset(member_inline_size)?;
inner_depth.increment()?;
}
let val_ref = self.supports_wait.get_or_insert_with(|| fidl::new_empty!(bool, D));
fidl::decode!(bool, D, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
while next_offset < end_offset {
_next_ordinal_to_read += 1;
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
next_offset += envelope_size;
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for Resolution {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for Resolution {
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<Resolution, D>
for &Resolution
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Resolution>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
Resolution::Duration(ref val) => fidl::encoding::encode_in_envelope::<i64, D>(
<i64 as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
),
Resolution::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for Resolution {
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
#[allow(unused_variables)]
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
let (ordinal, inlined, num_bytes, num_handles) =
fidl::encoding::decode_union_inline_portion(decoder, offset)?;
let member_inline_size = match ordinal {
1 => <i64 as fidl::encoding::TypeMarker>::inline_size(decoder.context),
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let _inner_offset;
if inlined {
decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
_inner_offset = offset + 8;
} else {
depth.increment()?;
_inner_offset = decoder.out_of_line_offset(member_inline_size)?;
}
match ordinal {
1 => {
#[allow(irrefutable_let_patterns)]
if let Resolution::Duration(_) = self {
} else {
*self = Resolution::Duration(fidl::new_empty!(i64, D));
}
#[allow(irrefutable_let_patterns)]
if let Resolution::Duration(ref mut val) = self {
fidl::decode!(i64, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = Resolution::__SourceBreaking { unknown_ordinal: ordinal };
}
}
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
Ok(())
}
}
}