#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use bitflags::bitflags;
use fidl::client::QueryResponseFut;
use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
use fidl::endpoints::{ControlHandle as _, Responder as _};
use futures::future::{self, MaybeDone, TryFutureExt};
use zx_status;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum ActivateSensorError {
InvalidSensorId,
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u32 },
}
#[macro_export]
macro_rules! ActivateSensorErrorUnknown {
() => {
_
};
}
impl ActivateSensorError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::InvalidSensorId),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::InvalidSensorId,
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::InvalidSensorId => 1,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { unknown_ordinal: _ } => true,
_ => false,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum ConfigurePlaybackError {
InvalidConfigType,
ConfigMissingFields,
DuplicateSensorInfo,
NoEventsForSensor,
EventFromUnknownSensor,
EventSensorTypeMismatch,
EventPayloadTypeMismatch,
FileOpenFailed,
FileParseError,
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u32 },
}
#[macro_export]
macro_rules! ConfigurePlaybackErrorUnknown {
() => {
_
};
}
impl ConfigurePlaybackError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::InvalidConfigType),
2 => Some(Self::ConfigMissingFields),
3 => Some(Self::DuplicateSensorInfo),
4 => Some(Self::NoEventsForSensor),
5 => Some(Self::EventFromUnknownSensor),
6 => Some(Self::EventSensorTypeMismatch),
7 => Some(Self::EventPayloadTypeMismatch),
8 => Some(Self::FileOpenFailed),
9 => Some(Self::FileParseError),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::InvalidConfigType,
2 => Self::ConfigMissingFields,
3 => Self::DuplicateSensorInfo,
4 => Self::NoEventsForSensor,
5 => Self::EventFromUnknownSensor,
6 => Self::EventSensorTypeMismatch,
7 => Self::EventPayloadTypeMismatch,
8 => Self::FileOpenFailed,
9 => Self::FileParseError,
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::InvalidConfigType => 1,
Self::ConfigMissingFields => 2,
Self::DuplicateSensorInfo => 3,
Self::NoEventsForSensor => 4,
Self::EventFromUnknownSensor => 5,
Self::EventSensorTypeMismatch => 6,
Self::EventPayloadTypeMismatch => 7,
Self::FileOpenFailed => 8,
Self::FileParseError => 9,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { unknown_ordinal: _ } => true,
_ => false,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum ConfigureSensorRateError {
InvalidSensorId,
InvalidConfig,
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u32 },
}
#[macro_export]
macro_rules! ConfigureSensorRateErrorUnknown {
() => {
_
};
}
impl ConfigureSensorRateError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::InvalidSensorId),
2 => Some(Self::InvalidConfig),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::InvalidSensorId,
2 => Self::InvalidConfig,
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::InvalidSensorId => 1,
Self::InvalidConfig => 2,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { unknown_ordinal: _ } => true,
_ => false,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum DeactivateSensorError {
InvalidSensorId,
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u32 },
}
#[macro_export]
macro_rules! DeactivateSensorErrorUnknown {
() => {
_
};
}
impl DeactivateSensorError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::InvalidSensorId),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u32) -> Self {
match prim {
1 => Self::InvalidSensorId,
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::InvalidSensorId => 1,
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 DriverActivateSensorRequest {
pub sensor_id: i32,
}
impl fidl::Persistable for DriverActivateSensorRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct DriverConfigureSensorRateRequest {
pub sensor_id: i32,
pub sensor_rate_config: fidl_fuchsia_sensors_types::SensorRateConfig,
}
impl fidl::Persistable for DriverConfigureSensorRateRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct DriverDeactivateSensorRequest {
pub sensor_id: i32,
}
impl fidl::Persistable for DriverDeactivateSensorRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct DriverOnSensorEventRequest {
pub event: fidl_fuchsia_sensors_types::SensorEvent,
}
impl fidl::Persistable for DriverOnSensorEventRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct DriverGetSensorsListResponse {
pub sensor_list: Vec<fidl_fuchsia_sensors_types::SensorInfo>,
}
impl fidl::Persistable for DriverGetSensorsListResponse {}
#[derive(Clone, Debug, PartialEq)]
pub struct PlaybackConfigurePlaybackRequest {
pub source_config: PlaybackSourceConfig,
}
impl fidl::Persistable for PlaybackConfigurePlaybackRequest {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct FilePlaybackConfig {
pub file_path: Option<String>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for FilePlaybackConfig {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct FixedValuesPlaybackConfig {
pub sensor_list: Option<Vec<fidl_fuchsia_sensors_types::SensorInfo>>,
pub sensor_events: Option<Vec<fidl_fuchsia_sensors_types::SensorEvent>>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for FixedValuesPlaybackConfig {}
#[derive(Clone, Debug)]
pub enum PlaybackSourceConfig {
FixedValuesConfig(FixedValuesPlaybackConfig),
FilePlaybackConfig(FilePlaybackConfig),
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u64 },
}
#[macro_export]
macro_rules! PlaybackSourceConfigUnknown {
() => {
_
};
}
impl PartialEq for PlaybackSourceConfig {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::FixedValuesConfig(x), Self::FixedValuesConfig(y)) => *x == *y,
(Self::FilePlaybackConfig(x), Self::FilePlaybackConfig(y)) => *x == *y,
_ => false,
}
}
}
impl PlaybackSourceConfig {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::FixedValuesConfig(_) => 1,
Self::FilePlaybackConfig(_) => 2,
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 PlaybackSourceConfig {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct DriverMarker;
impl fidl::endpoints::ProtocolMarker for DriverMarker {
type Proxy = DriverProxy;
type RequestStream = DriverRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = DriverSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.Driver";
}
impl fidl::endpoints::DiscoverableProtocolMarker for DriverMarker {}
pub type DriverActivateSensorResult = Result<(), ActivateSensorError>;
pub type DriverDeactivateSensorResult = Result<(), DeactivateSensorError>;
pub type DriverConfigureSensorRateResult = Result<(), ConfigureSensorRateError>;
pub trait DriverProxyInterface: Send + Sync {
type GetSensorsListResponseFut: std::future::Future<
Output = Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error>,
> + Send;
fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut;
type ActivateSensorResponseFut: std::future::Future<Output = Result<DriverActivateSensorResult, fidl::Error>>
+ Send;
fn r#activate_sensor(&self, sensor_id: i32) -> Self::ActivateSensorResponseFut;
type DeactivateSensorResponseFut: std::future::Future<Output = Result<DriverDeactivateSensorResult, fidl::Error>>
+ Send;
fn r#deactivate_sensor(&self, sensor_id: i32) -> Self::DeactivateSensorResponseFut;
type ConfigureSensorRateResponseFut: std::future::Future<Output = Result<DriverConfigureSensorRateResult, fidl::Error>>
+ Send;
fn r#configure_sensor_rate(
&self,
sensor_id: i32,
sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
) -> Self::ConfigureSensorRateResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct DriverSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for DriverSynchronousProxy {
type Proxy = DriverProxy;
type Protocol = DriverMarker;
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 DriverSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <DriverMarker 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<DriverEvent, fidl::Error> {
DriverEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#get_sensors_list(
&self,
___deadline: zx::MonotonicInstant,
) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
fidl::encoding::FlexibleType<DriverGetSensorsListResponse>,
>(
(),
0x6a30da06929d426b,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DriverMarker>("get_sensors_list")?;
Ok(_response.sensor_list)
}
pub fn r#activate_sensor(
&self,
mut sensor_id: i32,
___deadline: zx::MonotonicInstant,
) -> Result<DriverActivateSensorResult, fidl::Error> {
let _response =
self.client
.send_query::<DriverActivateSensorRequest, fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ActivateSensorError,
>>(
(sensor_id,),
0x6ff16c620f9f3c5b,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DriverMarker>("activate_sensor")?;
Ok(_response.map(|x| x))
}
pub fn r#deactivate_sensor(
&self,
mut sensor_id: i32,
___deadline: zx::MonotonicInstant,
) -> Result<DriverDeactivateSensorResult, fidl::Error> {
let _response =
self.client
.send_query::<DriverDeactivateSensorRequest, fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
DeactivateSensorError,
>>(
(sensor_id,),
0x64f003527d44ec55,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DriverMarker>("deactivate_sensor")?;
Ok(_response.map(|x| x))
}
pub fn r#configure_sensor_rate(
&self,
mut sensor_id: i32,
mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
___deadline: zx::MonotonicInstant,
) -> Result<DriverConfigureSensorRateResult, fidl::Error> {
let _response = self
.client
.send_query::<DriverConfigureSensorRateRequest, fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ConfigureSensorRateError,
>>(
(sensor_id, sensor_rate_config),
0x78a264bc9c645045,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<DriverMarker>("configure_sensor_rate")?;
Ok(_response.map(|x| x))
}
}
#[derive(Debug, Clone)]
pub struct DriverProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for DriverProxy {
type Protocol = DriverMarker;
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 DriverProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> DriverEventStream {
DriverEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#get_sensors_list(
&self,
) -> fidl::client::QueryResponseFut<
Vec<fidl_fuchsia_sensors_types::SensorInfo>,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DriverProxyInterface::r#get_sensors_list(self)
}
pub fn r#activate_sensor(
&self,
mut sensor_id: i32,
) -> fidl::client::QueryResponseFut<
DriverActivateSensorResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DriverProxyInterface::r#activate_sensor(self, sensor_id)
}
pub fn r#deactivate_sensor(
&self,
mut sensor_id: i32,
) -> fidl::client::QueryResponseFut<
DriverDeactivateSensorResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DriverProxyInterface::r#deactivate_sensor(self, sensor_id)
}
pub fn r#configure_sensor_rate(
&self,
mut sensor_id: i32,
mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
) -> fidl::client::QueryResponseFut<
DriverConfigureSensorRateResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
DriverProxyInterface::r#configure_sensor_rate(self, sensor_id, sensor_rate_config)
}
}
impl DriverProxyInterface for DriverProxy {
type GetSensorsListResponseFut = fidl::client::QueryResponseFut<
Vec<fidl_fuchsia_sensors_types::SensorInfo>,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#get_sensors_list(&self) -> Self::GetSensorsListResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<Vec<fidl_fuchsia_sensors_types::SensorInfo>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleType<DriverGetSensorsListResponse>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x6a30da06929d426b,
>(_buf?)?
.into_result::<DriverMarker>("get_sensors_list")?;
Ok(_response.sensor_list)
}
self.client.send_query_and_decode::<
fidl::encoding::EmptyPayload,
Vec<fidl_fuchsia_sensors_types::SensorInfo>,
>(
(),
0x6a30da06929d426b,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type ActivateSensorResponseFut = fidl::client::QueryResponseFut<
DriverActivateSensorResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#activate_sensor(&self, mut sensor_id: i32) -> Self::ActivateSensorResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DriverActivateSensorResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ActivateSensorError,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x6ff16c620f9f3c5b,
>(_buf?)?
.into_result::<DriverMarker>("activate_sensor")?;
Ok(_response.map(|x| x))
}
self.client
.send_query_and_decode::<DriverActivateSensorRequest, DriverActivateSensorResult>(
(sensor_id,),
0x6ff16c620f9f3c5b,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type DeactivateSensorResponseFut = fidl::client::QueryResponseFut<
DriverDeactivateSensorResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#deactivate_sensor(&self, mut sensor_id: i32) -> Self::DeactivateSensorResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DriverDeactivateSensorResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
DeactivateSensorError,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x64f003527d44ec55,
>(_buf?)?
.into_result::<DriverMarker>("deactivate_sensor")?;
Ok(_response.map(|x| x))
}
self.client
.send_query_and_decode::<DriverDeactivateSensorRequest, DriverDeactivateSensorResult>(
(sensor_id,),
0x64f003527d44ec55,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
type ConfigureSensorRateResponseFut = fidl::client::QueryResponseFut<
DriverConfigureSensorRateResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#configure_sensor_rate(
&self,
mut sensor_id: i32,
mut sensor_rate_config: &fidl_fuchsia_sensors_types::SensorRateConfig,
) -> Self::ConfigureSensorRateResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<DriverConfigureSensorRateResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ConfigureSensorRateError,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x78a264bc9c645045,
>(_buf?)?
.into_result::<DriverMarker>("configure_sensor_rate")?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<
DriverConfigureSensorRateRequest,
DriverConfigureSensorRateResult,
>(
(sensor_id, sensor_rate_config,),
0x78a264bc9c645045,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
}
pub struct DriverEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for DriverEventStream {}
impl futures::stream::FusedStream for DriverEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for DriverEventStream {
type Item = Result<DriverEvent, 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(DriverEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum DriverEvent {
OnSensorEvent {
event: fidl_fuchsia_sensors_types::SensorEvent,
},
#[non_exhaustive]
_UnknownEvent {
ordinal: u64,
},
}
impl DriverEvent {
#[allow(irrefutable_let_patterns)]
pub fn into_on_sensor_event(self) -> Option<fidl_fuchsia_sensors_types::SensorEvent> {
if let DriverEvent::OnSensorEvent { event } = self {
Some((event))
} else {
None
}
}
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<DriverEvent, 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 {
0x2aaf0636bb3e1df9 => {
let mut out = fidl::new_empty!(
DriverOnSensorEventRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverOnSensorEventRequest>(&tx_header, _body_bytes, _handles, &mut out)?;
Ok((DriverEvent::OnSensorEvent { event: out.event }))
}
_ if tx_header.dynamic_flags().contains(fidl::encoding::DynamicFlags::FLEXIBLE) => {
Ok(DriverEvent::_UnknownEvent { ordinal: tx_header.ordinal })
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct DriverRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for DriverRequestStream {}
impl futures::stream::FusedStream for DriverRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for DriverRequestStream {
type Protocol = DriverMarker;
type ControlHandle = DriverControlHandle;
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 {
DriverControlHandle { 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 DriverRequestStream {
type Item = Result<DriverRequest, 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 DriverRequestStream 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 {
0x6a30da06929d426b => {
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 = DriverControlHandle { inner: this.inner.clone() };
Ok(DriverRequest::GetSensorsList {
responder: DriverGetSensorsListResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x6ff16c620f9f3c5b => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DriverActivateSensorRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverActivateSensorRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DriverControlHandle { inner: this.inner.clone() };
Ok(DriverRequest::ActivateSensor {
sensor_id: req.sensor_id,
responder: DriverActivateSensorResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x64f003527d44ec55 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DriverDeactivateSensorRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverDeactivateSensorRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DriverControlHandle { inner: this.inner.clone() };
Ok(DriverRequest::DeactivateSensor {
sensor_id: req.sensor_id,
responder: DriverDeactivateSensorResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x78a264bc9c645045 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
DriverConfigureSensorRateRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<DriverConfigureSensorRateRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = DriverControlHandle { inner: this.inner.clone() };
Ok(DriverRequest::ConfigureSensorRate {
sensor_id: req.sensor_id,
sensor_rate_config: req.sensor_rate_config,
responder: DriverConfigureSensorRateResponder {
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(DriverRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: DriverControlHandle { 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(DriverRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: DriverControlHandle { inner: this.inner.clone() },
method_type: fidl::MethodType::TwoWay,
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<DriverMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum DriverRequest {
GetSensorsList { responder: DriverGetSensorsListResponder },
ActivateSensor { sensor_id: i32, responder: DriverActivateSensorResponder },
DeactivateSensor { sensor_id: i32, responder: DriverDeactivateSensorResponder },
ConfigureSensorRate {
sensor_id: i32,
sensor_rate_config: fidl_fuchsia_sensors_types::SensorRateConfig,
responder: DriverConfigureSensorRateResponder,
},
#[non_exhaustive]
_UnknownMethod {
ordinal: u64,
control_handle: DriverControlHandle,
method_type: fidl::MethodType,
},
}
impl DriverRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_get_sensors_list(self) -> Option<(DriverGetSensorsListResponder)> {
if let DriverRequest::GetSensorsList { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_activate_sensor(self) -> Option<(i32, DriverActivateSensorResponder)> {
if let DriverRequest::ActivateSensor { sensor_id, responder } = self {
Some((sensor_id, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_deactivate_sensor(self) -> Option<(i32, DriverDeactivateSensorResponder)> {
if let DriverRequest::DeactivateSensor { sensor_id, responder } = self {
Some((sensor_id, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_configure_sensor_rate(
self,
) -> Option<(
i32,
fidl_fuchsia_sensors_types::SensorRateConfig,
DriverConfigureSensorRateResponder,
)> {
if let DriverRequest::ConfigureSensorRate { sensor_id, sensor_rate_config, responder } =
self
{
Some((sensor_id, sensor_rate_config, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
DriverRequest::GetSensorsList { .. } => "get_sensors_list",
DriverRequest::ActivateSensor { .. } => "activate_sensor",
DriverRequest::DeactivateSensor { .. } => "deactivate_sensor",
DriverRequest::ConfigureSensorRate { .. } => "configure_sensor_rate",
DriverRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
"unknown one-way method"
}
DriverRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
"unknown two-way method"
}
}
}
}
#[derive(Debug, Clone)]
pub struct DriverControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for DriverControlHandle {
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 DriverControlHandle {
pub fn send_on_sensor_event(
&self,
mut event: &fidl_fuchsia_sensors_types::SensorEvent,
) -> Result<(), fidl::Error> {
self.inner.send::<DriverOnSensorEventRequest>(
(event,),
0,
0x2aaf0636bb3e1df9,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DriverGetSensorsListResponder {
control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DriverGetSensorsListResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DriverGetSensorsListResponder {
type ControlHandle = DriverControlHandle;
fn control_handle(&self) -> &DriverControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DriverGetSensorsListResponder {
pub fn send(
self,
mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
) -> Result<(), fidl::Error> {
let _result = self.send_raw(sensor_list);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
) -> Result<(), fidl::Error> {
let _result = self.send_raw(sensor_list);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut sensor_list: &[fidl_fuchsia_sensors_types::SensorInfo],
) -> Result<(), fidl::Error> {
self.control_handle
.inner
.send::<fidl::encoding::FlexibleType<DriverGetSensorsListResponse>>(
fidl::encoding::Flexible::new((sensor_list,)),
self.tx_id,
0x6a30da06929d426b,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DriverActivateSensorResponder {
control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DriverActivateSensorResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DriverActivateSensorResponder {
type ControlHandle = DriverControlHandle;
fn control_handle(&self) -> &DriverControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DriverActivateSensorResponder {
pub fn send(self, mut result: Result<(), ActivateSensorError>) -> 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<(), ActivateSensorError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), ActivateSensorError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ActivateSensorError,
>>(
fidl::encoding::FlexibleResult::new(result),
self.tx_id,
0x6ff16c620f9f3c5b,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DriverDeactivateSensorResponder {
control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DriverDeactivateSensorResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DriverDeactivateSensorResponder {
type ControlHandle = DriverControlHandle;
fn control_handle(&self) -> &DriverControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DriverDeactivateSensorResponder {
pub fn send(self, mut result: Result<(), DeactivateSensorError>) -> 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<(), DeactivateSensorError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), DeactivateSensorError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
DeactivateSensorError,
>>(
fidl::encoding::FlexibleResult::new(result),
self.tx_id,
0x64f003527d44ec55,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct DriverConfigureSensorRateResponder {
control_handle: std::mem::ManuallyDrop<DriverControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for DriverConfigureSensorRateResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for DriverConfigureSensorRateResponder {
type ControlHandle = DriverControlHandle;
fn control_handle(&self) -> &DriverControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl DriverConfigureSensorRateResponder {
pub fn send(self, mut result: Result<(), ConfigureSensorRateError>) -> 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<(), ConfigureSensorRateError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(
&self,
mut result: Result<(), ConfigureSensorRateError>,
) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ConfigureSensorRateError,
>>(
fidl::encoding::FlexibleResult::new(result),
self.tx_id,
0x78a264bc9c645045,
fidl::encoding::DynamicFlags::FLEXIBLE,
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct PlaybackMarker;
impl fidl::endpoints::ProtocolMarker for PlaybackMarker {
type Proxy = PlaybackProxy;
type RequestStream = PlaybackRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = PlaybackSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.hardware.sensors.Playback";
}
impl fidl::endpoints::DiscoverableProtocolMarker for PlaybackMarker {}
pub type PlaybackConfigurePlaybackResult = Result<(), ConfigurePlaybackError>;
pub trait PlaybackProxyInterface: Send + Sync {
type ConfigurePlaybackResponseFut: std::future::Future<Output = Result<PlaybackConfigurePlaybackResult, fidl::Error>>
+ Send;
fn r#configure_playback(
&self,
source_config: &PlaybackSourceConfig,
) -> Self::ConfigurePlaybackResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct PlaybackSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for PlaybackSynchronousProxy {
type Proxy = PlaybackProxy;
type Protocol = PlaybackMarker;
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 PlaybackSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <PlaybackMarker 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<PlaybackEvent, fidl::Error> {
PlaybackEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#configure_playback(
&self,
mut source_config: &PlaybackSourceConfig,
___deadline: zx::MonotonicInstant,
) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
let _response =
self.client
.send_query::<PlaybackConfigurePlaybackRequest, fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ConfigurePlaybackError,
>>(
(source_config,),
0x64327bb27c3d8742,
fidl::encoding::DynamicFlags::FLEXIBLE,
___deadline,
)?
.into_result::<PlaybackMarker>("configure_playback")?;
Ok(_response.map(|x| x))
}
}
#[derive(Debug, Clone)]
pub struct PlaybackProxy {
client: fidl::client::Client<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl fidl::endpoints::Proxy for PlaybackProxy {
type Protocol = PlaybackMarker;
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 PlaybackProxy {
pub fn new(channel: ::fidl::AsyncChannel) -> Self {
let protocol_name = <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> PlaybackEventStream {
PlaybackEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#configure_playback(
&self,
mut source_config: &PlaybackSourceConfig,
) -> fidl::client::QueryResponseFut<
PlaybackConfigurePlaybackResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
> {
PlaybackProxyInterface::r#configure_playback(self, source_config)
}
}
impl PlaybackProxyInterface for PlaybackProxy {
type ConfigurePlaybackResponseFut = fidl::client::QueryResponseFut<
PlaybackConfigurePlaybackResult,
fidl::encoding::DefaultFuchsiaResourceDialect,
>;
fn r#configure_playback(
&self,
mut source_config: &PlaybackSourceConfig,
) -> Self::ConfigurePlaybackResponseFut {
fn _decode(
mut _buf: Result<<fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc, fidl::Error>,
) -> Result<PlaybackConfigurePlaybackResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ConfigurePlaybackError,
>,
fidl::encoding::DefaultFuchsiaResourceDialect,
0x64327bb27c3d8742,
>(_buf?)?
.into_result::<PlaybackMarker>("configure_playback")?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<
PlaybackConfigurePlaybackRequest,
PlaybackConfigurePlaybackResult,
>(
(source_config,),
0x64327bb27c3d8742,
fidl::encoding::DynamicFlags::FLEXIBLE,
_decode,
)
}
}
pub struct PlaybackEventStream {
event_receiver: fidl::client::EventReceiver<fidl::encoding::DefaultFuchsiaResourceDialect>,
}
impl std::marker::Unpin for PlaybackEventStream {}
impl futures::stream::FusedStream for PlaybackEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for PlaybackEventStream {
type Item = Result<PlaybackEvent, 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(PlaybackEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum PlaybackEvent {
#[non_exhaustive]
_UnknownEvent {
ordinal: u64,
},
}
impl PlaybackEvent {
fn decode(
mut buf: <fidl::encoding::DefaultFuchsiaResourceDialect as fidl::encoding::ResourceDialect>::MessageBufEtc,
) -> Result<PlaybackEvent, 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(PlaybackEvent::_UnknownEvent { ordinal: tx_header.ordinal })
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct PlaybackRequestStream {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
is_terminated: bool,
}
impl std::marker::Unpin for PlaybackRequestStream {}
impl futures::stream::FusedStream for PlaybackRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for PlaybackRequestStream {
type Protocol = PlaybackMarker;
type ControlHandle = PlaybackControlHandle;
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 {
PlaybackControlHandle { 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 PlaybackRequestStream {
type Item = Result<PlaybackRequest, 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 PlaybackRequestStream 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 {
0x64327bb27c3d8742 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(
PlaybackConfigurePlaybackRequest,
fidl::encoding::DefaultFuchsiaResourceDialect
);
fidl::encoding::Decoder::<fidl::encoding::DefaultFuchsiaResourceDialect>::decode_into::<PlaybackConfigurePlaybackRequest>(&header, _body_bytes, handles, &mut req)?;
let control_handle = PlaybackControlHandle { inner: this.inner.clone() };
Ok(PlaybackRequest::ConfigurePlayback {
source_config: req.source_config,
responder: PlaybackConfigurePlaybackResponder {
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(PlaybackRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: PlaybackControlHandle { 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(PlaybackRequest::_UnknownMethod {
ordinal: header.ordinal,
control_handle: PlaybackControlHandle { inner: this.inner.clone() },
method_type: fidl::MethodType::TwoWay,
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<PlaybackMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
},
)
}
}
#[derive(Debug)]
pub enum PlaybackRequest {
ConfigurePlayback {
source_config: PlaybackSourceConfig,
responder: PlaybackConfigurePlaybackResponder,
},
#[non_exhaustive]
_UnknownMethod {
ordinal: u64,
control_handle: PlaybackControlHandle,
method_type: fidl::MethodType,
},
}
impl PlaybackRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_configure_playback(
self,
) -> Option<(PlaybackSourceConfig, PlaybackConfigurePlaybackResponder)> {
if let PlaybackRequest::ConfigurePlayback { source_config, responder } = self {
Some((source_config, responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
PlaybackRequest::ConfigurePlayback { .. } => "configure_playback",
PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::OneWay, .. } => {
"unknown one-way method"
}
PlaybackRequest::_UnknownMethod { method_type: fidl::MethodType::TwoWay, .. } => {
"unknown two-way method"
}
}
}
}
#[derive(Debug, Clone)]
pub struct PlaybackControlHandle {
inner: std::sync::Arc<fidl::ServeInner<fidl::encoding::DefaultFuchsiaResourceDialect>>,
}
impl fidl::endpoints::ControlHandle for PlaybackControlHandle {
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 PlaybackControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct PlaybackConfigurePlaybackResponder {
control_handle: std::mem::ManuallyDrop<PlaybackControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for PlaybackConfigurePlaybackResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for PlaybackConfigurePlaybackResponder {
type ControlHandle = PlaybackControlHandle;
fn control_handle(&self) -> &PlaybackControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl PlaybackConfigurePlaybackResponder {
pub fn send(self, mut result: Result<(), ConfigurePlaybackError>) -> 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<(), ConfigurePlaybackError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), ConfigurePlaybackError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::FlexibleResultType<
fidl::encoding::EmptyStruct,
ConfigurePlaybackError,
>>(
fidl::encoding::FlexibleResult::new(result),
self.tx_id,
0x64327bb27c3d8742,
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.sensors.Service";
}
#[cfg(target_os = "fuchsia")]
pub enum ServiceRequest {
Driver(DriverRequestStream),
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::ServiceRequest for ServiceRequest {
type Service = ServiceMarker;
fn dispatch(name: &str, _channel: fidl::AsyncChannel) -> Self {
match name {
"driver" => Self::Driver(
<DriverRequestStream as fidl::endpoints::RequestStream>::from_channel(_channel),
),
_ => panic!("no such member protocol name for service Service"),
}
}
fn member_names() -> &'static [&'static str] {
&["driver"]
}
}
#[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_driver(&self) -> Result<DriverProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_proxy::<DriverMarker>();
self.connect_channel_to_driver(server_end)?;
Ok(proxy)
}
pub fn connect_to_driver_sync(&self) -> Result<DriverSynchronousProxy, fidl::Error> {
let (proxy, server_end) = fidl::endpoints::create_sync_proxy::<DriverMarker>();
self.connect_channel_to_driver(server_end)?;
Ok(proxy)
}
pub fn connect_channel_to_driver(
&self,
server_end: fidl::endpoints::ServerEnd<DriverMarker>,
) -> Result<(), fidl::Error> {
self.0.open_member("driver", server_end.into_channel())
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for ActivateSensorError {
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 ActivateSensorError {
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 ActivateSensorError
{
#[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 ActivateSensorError {
#[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(())
}
}
unsafe impl fidl::encoding::TypeMarker for ConfigurePlaybackError {
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 ConfigurePlaybackError {
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 ConfigurePlaybackError
{
#[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 ConfigurePlaybackError
{
#[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(())
}
}
unsafe impl fidl::encoding::TypeMarker for ConfigureSensorRateError {
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 ConfigureSensorRateError {
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 ConfigureSensorRateError
{
#[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 ConfigureSensorRateError
{
#[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(())
}
}
unsafe impl fidl::encoding::TypeMarker for DeactivateSensorError {
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 DeactivateSensorError {
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 DeactivateSensorError
{
#[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 DeactivateSensorError {
#[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 DriverActivateSensorRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DriverActivateSensorRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<DriverActivateSensorRequest, D> for &DriverActivateSensorRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DriverActivateSensorRequest>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut DriverActivateSensorRequest)
.write_unaligned((self as *const DriverActivateSensorRequest).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
fidl::encoding::Encode<DriverActivateSensorRequest, 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::<DriverActivateSensorRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for DriverActivateSensorRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { sensor_id: fidl::new_empty!(i32, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DriverConfigureSensorRateRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DriverConfigureSensorRateRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
24
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<DriverConfigureSensorRateRequest, D>
for &DriverConfigureSensorRateRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DriverConfigureSensorRateRequest>(offset);
fidl::encoding::Encode::<DriverConfigureSensorRateRequest, D>::encode(
(
<i32 as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_id),
<fidl_fuchsia_sensors_types::SensorRateConfig as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_rate_config),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<i32, D>,
T1: fidl::encoding::Encode<fidl_fuchsia_sensors_types::SensorRateConfig, D>,
> fidl::encoding::Encode<DriverConfigureSensorRateRequest, D> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DriverConfigureSensorRateRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(0);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 8, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for DriverConfigureSensorRateRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self {
sensor_id: fidl::new_empty!(i32, D),
sensor_rate_config: fidl::new_empty!(
fidl_fuchsia_sensors_types::SensorRateConfig,
D
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(0) };
let padval = unsafe { (ptr as *const u64).read_unaligned() };
let mask = 0xffffffff00000000u64;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 0 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(i32, D, &mut self.sensor_id, decoder, offset + 0, _depth)?;
fidl::decode!(
fidl_fuchsia_sensors_types::SensorRateConfig,
D,
&mut self.sensor_rate_config,
decoder,
offset + 8,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DriverDeactivateSensorRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DriverDeactivateSensorRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<DriverDeactivateSensorRequest, D>
for &DriverDeactivateSensorRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DriverDeactivateSensorRequest>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut DriverDeactivateSensorRequest)
.write_unaligned((self as *const DriverDeactivateSensorRequest).read());
}
Ok(())
}
}
unsafe impl<D: fidl::encoding::ResourceDialect, T0: fidl::encoding::Encode<i32, D>>
fidl::encoding::Encode<DriverDeactivateSensorRequest, 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::<DriverDeactivateSensorRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for DriverDeactivateSensorRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { sensor_id: fidl::new_empty!(i32, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DriverOnSensorEventRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DriverOnSensorEventRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
40
}
}
unsafe impl<D: fidl::encoding::ResourceDialect>
fidl::encoding::Encode<DriverOnSensorEventRequest, D> for &DriverOnSensorEventRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DriverOnSensorEventRequest>(offset);
fidl::encoding::Encode::<DriverOnSensorEventRequest, D>::encode(
(
<fidl_fuchsia_sensors_types::SensorEvent as fidl::encoding::ValueTypeMarker>::borrow(&self.event),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<fidl_fuchsia_sensors_types::SensorEvent, D>,
> fidl::encoding::Encode<DriverOnSensorEventRequest, 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::<DriverOnSensorEventRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for DriverOnSensorEventRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { event: fidl::new_empty!(fidl_fuchsia_sensors_types::SensorEvent, D) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl_fuchsia_sensors_types::SensorEvent,
D,
&mut self.event,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for DriverGetSensorsListResponse {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for DriverGetSensorsListResponse {
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<DriverGetSensorsListResponse, D> for &DriverGetSensorsListResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DriverGetSensorsListResponse>(offset);
fidl::encoding::Encode::<DriverGetSensorsListResponse, D>::encode(
(
<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.sensor_list),
),
encoder, offset, _depth
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<
fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
D,
>,
> fidl::encoding::Encode<DriverGetSensorsListResponse, 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::<DriverGetSensorsListResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for DriverGetSensorsListResponse
{
#[inline(always)]
fn new_empty() -> Self {
Self {
sensor_list: fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
D
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
D,
&mut self.sensor_list,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl fidl::encoding::ValueTypeMarker for PlaybackConfigurePlaybackRequest {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for PlaybackConfigurePlaybackRequest {
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<PlaybackConfigurePlaybackRequest, D>
for &PlaybackConfigurePlaybackRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PlaybackConfigurePlaybackRequest>(offset);
fidl::encoding::Encode::<PlaybackConfigurePlaybackRequest, D>::encode(
(<PlaybackSourceConfig as fidl::encoding::ValueTypeMarker>::borrow(
&self.source_config,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
D: fidl::encoding::ResourceDialect,
T0: fidl::encoding::Encode<PlaybackSourceConfig, D>,
> fidl::encoding::Encode<PlaybackConfigurePlaybackRequest, 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::<PlaybackConfigurePlaybackRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D>
for PlaybackConfigurePlaybackRequest
{
#[inline(always)]
fn new_empty() -> Self {
Self { source_config: fidl::new_empty!(PlaybackSourceConfig, 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!(
PlaybackSourceConfig,
D,
&mut self.source_config,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl FilePlaybackConfig {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.file_path {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for FilePlaybackConfig {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for FilePlaybackConfig {
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<FilePlaybackConfig, D>
for &FilePlaybackConfig
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<FilePlaybackConfig>(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::UnboundedString, D>(
self.file_path.as_ref().map(
<fidl::encoding::UnboundedString 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 FilePlaybackConfig {
#[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 =
<fidl::encoding::UnboundedString 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
.file_path
.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedString, D));
fidl::decode!(
fidl::encoding::UnboundedString,
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 FixedValuesPlaybackConfig {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.sensor_events {
return 2;
}
if let Some(_) = self.sensor_list {
return 1;
}
0
}
}
impl fidl::encoding::ValueTypeMarker for FixedValuesPlaybackConfig {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for FixedValuesPlaybackConfig {
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<FixedValuesPlaybackConfig, D> for &FixedValuesPlaybackConfig
{
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<FixedValuesPlaybackConfig>(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::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>, D>(
self.sensor_list.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo> 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::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent>, D>(
self.sensor_events.as_ref().map(<fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent> 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 FixedValuesPlaybackConfig
{
#[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 = <fidl::encoding::UnboundedVector<
fidl_fuchsia_sensors_types::SensorInfo,
> 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.sensor_list.get_or_insert_with(|| {
fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
D
)
});
fidl::decode!(
fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorInfo>,
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::UnboundedVector<
fidl_fuchsia_sensors_types::SensorEvent,
> 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.sensor_events.get_or_insert_with(|| {
fidl::new_empty!(
fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent>,
D
)
});
fidl::decode!(
fidl::encoding::UnboundedVector<fidl_fuchsia_sensors_types::SensorEvent>,
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 PlaybackSourceConfig {
type Borrowed<'a> = &'a Self;
fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
value
}
}
unsafe impl fidl::encoding::TypeMarker for PlaybackSourceConfig {
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<PlaybackSourceConfig, D>
for &PlaybackSourceConfig
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_, D>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PlaybackSourceConfig>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
PlaybackSourceConfig::FixedValuesConfig(ref val) => {
fidl::encoding::encode_in_envelope::<FixedValuesPlaybackConfig, D>(
<FixedValuesPlaybackConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
PlaybackSourceConfig::FilePlaybackConfig(ref val) => {
fidl::encoding::encode_in_envelope::<FilePlaybackConfig, D>(
<FilePlaybackConfig as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
PlaybackSourceConfig::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for PlaybackSourceConfig {
#[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 => <FixedValuesPlaybackConfig as fidl::encoding::TypeMarker>::inline_size(
decoder.context,
),
2 => {
<FilePlaybackConfig 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 PlaybackSourceConfig::FixedValuesConfig(_) = self {
} else {
*self = PlaybackSourceConfig::FixedValuesConfig(fidl::new_empty!(
FixedValuesPlaybackConfig,
D
));
}
#[allow(irrefutable_let_patterns)]
if let PlaybackSourceConfig::FixedValuesConfig(ref mut val) = self {
fidl::decode!(
FixedValuesPlaybackConfig,
D,
val,
decoder,
_inner_offset,
depth
)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let PlaybackSourceConfig::FilePlaybackConfig(_) = self {
} else {
*self = PlaybackSourceConfig::FilePlaybackConfig(fidl::new_empty!(
FilePlaybackConfig,
D
));
}
#[allow(irrefutable_let_patterns)]
if let PlaybackSourceConfig::FilePlaybackConfig(ref mut val) = self {
fidl::decode!(FilePlaybackConfig, D, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = PlaybackSourceConfig::__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(())
}
}
}