#![warn(clippy::all)]
#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
use {
bitflags::bitflags,
fidl::{
client::QueryResponseFut,
endpoints::{ControlHandle as _, Responder as _},
},
fuchsia_zircon_status as zx_status,
futures::future::{self, MaybeDone, TryFutureExt},
};
#[cfg(target_os = "fuchsia")]
use fuchsia_zircon as zx;
pub const MAX_EXTENDED_ADVERTISING_DATA_LENGTH: u8 = 251;
pub const MAX_LEGACY_ADVERTISING_DATA_LENGTH: u8 = 31;
pub const MAX_LOCAL_NAME_LENGTH: u8 = 248;
pub const MAX_PEER_SERVICES: u8 = 32;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum ConnectionState {
Connected = 1,
Disconnected = 2,
}
impl ConnectionState {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::Connected),
2 => Some(Self::Disconnected),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u32 {
self as u32
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum EmulatorError {
Failed = 1,
HciAlreadyPublished = 2,
}
impl EmulatorError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::Failed),
2 => Some(Self::HciAlreadyPublished),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u32 {
self as u32
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum EmulatorPeerError {
AddressRepeated = 1,
ParametersInvalid = 2,
NotFound = 3,
}
impl EmulatorPeerError {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::AddressRepeated),
2 => Some(Self::ParametersInvalid),
3 => Some(Self::NotFound),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u32 {
self as u32
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum HciConfig {
DualMode = 1,
LeOnly = 2,
}
impl HciConfig {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::DualMode),
2 => Some(Self::LeOnly),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u32 {
self as u32
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u8)]
pub enum HciError {
Success = 0,
UnknownCommand = 1,
UnknownConnectionId = 2,
HardwareFailure = 3,
PageTimeout = 4,
AuthenticationFailure = 5,
PinOrKeyMissing = 6,
MemoryCapacityExceeded = 7,
ConnectionTimeout = 8,
ConnectionLimitExceeded = 9,
SynchronousConnectionLimitExceeded = 10,
ConnectionAlreadyExists = 11,
CommandDisallowed = 12,
ConnectionRejectedLimitedResources = 13,
ConnectionRejectedSecurity = 14,
ConnectionRejectedBadBdAddr = 15,
ConnectionAcceptTimeoutExceeded = 16,
UnsupportedFeatureOrParameter = 17,
InvalidHcicommandParameters = 18,
RemoteUserTerminatedConnection = 19,
RemoteDeviceTerminatedConnectionLowResources = 20,
RemoteDeviceTerminatedConnectionPowerOff = 21,
ConnectionTerminatedByLocalHost = 22,
RepeatedAttempts = 23,
PairingNotAllowed = 24,
UnknownLmpPdu = 25,
UnsupportedRemoteFeature = 26,
ScoOffsetRejected = 27,
ScoIntervalRejected = 28,
ScoAirModeRejected = 29,
InvalidLmpOrLlParameters = 30,
UnspecifiedError = 31,
UnsupportedLmpOrLlParameterValue = 32,
RoleChangeNotAllowed = 33,
LmpOrLlResponseTimeout = 34,
LmpErrorTransactionCollision = 35,
LmpPduNotAllowed = 36,
EncryptionModeNotAcceptable = 37,
LinkKeyCannotBeChanged = 38,
RequestedQosNotSupported = 39,
InstantPassed = 40,
PairingWithUnitKeyNotSupported = 41,
DifferentTransactionCollision = 42,
Reserved0 = 43,
QosUnacceptableParameter = 44,
QosRejected = 45,
ChannelClassificationNotSupported = 46,
InsufficientSecurity = 47,
ParameterOutOfMandatoryRange = 48,
Reserved1 = 49,
RoleSwitchPending = 50,
Reserved2 = 51,
ReservedSlotViolation = 52,
RoleSwitchFailed = 53,
ExtendedInquiryResponseTooLarge = 54,
SecureSimplePairingNotSupportedByHost = 55,
HostBusyPairing = 56,
ConnectionRejectedNoSuitableChannelFound = 57,
ControllerBusy = 58,
UnacceptableConnectionParameters = 59,
DirectedAdvertisingTimeout = 60,
ConnectionTerminatedMicFailure = 61,
ConnectionFailedToBeEstablished = 62,
MacConnectionFailed = 63,
CoarseClockAdjustmentRejected = 64,
Type0SubmapNotDefined = 65,
UnknownAdvertisingIdentifier = 66,
LimitReached = 67,
OperationCancelledByHost = 68,
}
impl HciError {
#[inline]
pub fn from_primitive(prim: u8) -> Option<Self> {
match prim {
0 => Some(Self::Success),
1 => Some(Self::UnknownCommand),
2 => Some(Self::UnknownConnectionId),
3 => Some(Self::HardwareFailure),
4 => Some(Self::PageTimeout),
5 => Some(Self::AuthenticationFailure),
6 => Some(Self::PinOrKeyMissing),
7 => Some(Self::MemoryCapacityExceeded),
8 => Some(Self::ConnectionTimeout),
9 => Some(Self::ConnectionLimitExceeded),
10 => Some(Self::SynchronousConnectionLimitExceeded),
11 => Some(Self::ConnectionAlreadyExists),
12 => Some(Self::CommandDisallowed),
13 => Some(Self::ConnectionRejectedLimitedResources),
14 => Some(Self::ConnectionRejectedSecurity),
15 => Some(Self::ConnectionRejectedBadBdAddr),
16 => Some(Self::ConnectionAcceptTimeoutExceeded),
17 => Some(Self::UnsupportedFeatureOrParameter),
18 => Some(Self::InvalidHcicommandParameters),
19 => Some(Self::RemoteUserTerminatedConnection),
20 => Some(Self::RemoteDeviceTerminatedConnectionLowResources),
21 => Some(Self::RemoteDeviceTerminatedConnectionPowerOff),
22 => Some(Self::ConnectionTerminatedByLocalHost),
23 => Some(Self::RepeatedAttempts),
24 => Some(Self::PairingNotAllowed),
25 => Some(Self::UnknownLmpPdu),
26 => Some(Self::UnsupportedRemoteFeature),
27 => Some(Self::ScoOffsetRejected),
28 => Some(Self::ScoIntervalRejected),
29 => Some(Self::ScoAirModeRejected),
30 => Some(Self::InvalidLmpOrLlParameters),
31 => Some(Self::UnspecifiedError),
32 => Some(Self::UnsupportedLmpOrLlParameterValue),
33 => Some(Self::RoleChangeNotAllowed),
34 => Some(Self::LmpOrLlResponseTimeout),
35 => Some(Self::LmpErrorTransactionCollision),
36 => Some(Self::LmpPduNotAllowed),
37 => Some(Self::EncryptionModeNotAcceptable),
38 => Some(Self::LinkKeyCannotBeChanged),
39 => Some(Self::RequestedQosNotSupported),
40 => Some(Self::InstantPassed),
41 => Some(Self::PairingWithUnitKeyNotSupported),
42 => Some(Self::DifferentTransactionCollision),
43 => Some(Self::Reserved0),
44 => Some(Self::QosUnacceptableParameter),
45 => Some(Self::QosRejected),
46 => Some(Self::ChannelClassificationNotSupported),
47 => Some(Self::InsufficientSecurity),
48 => Some(Self::ParameterOutOfMandatoryRange),
49 => Some(Self::Reserved1),
50 => Some(Self::RoleSwitchPending),
51 => Some(Self::Reserved2),
52 => Some(Self::ReservedSlotViolation),
53 => Some(Self::RoleSwitchFailed),
54 => Some(Self::ExtendedInquiryResponseTooLarge),
55 => Some(Self::SecureSimplePairingNotSupportedByHost),
56 => Some(Self::HostBusyPairing),
57 => Some(Self::ConnectionRejectedNoSuitableChannelFound),
58 => Some(Self::ControllerBusy),
59 => Some(Self::UnacceptableConnectionParameters),
60 => Some(Self::DirectedAdvertisingTimeout),
61 => Some(Self::ConnectionTerminatedMicFailure),
62 => Some(Self::ConnectionFailedToBeEstablished),
63 => Some(Self::MacConnectionFailed),
64 => Some(Self::CoarseClockAdjustmentRejected),
65 => Some(Self::Type0SubmapNotDefined),
66 => Some(Self::UnknownAdvertisingIdentifier),
67 => Some(Self::LimitReached),
68 => Some(Self::OperationCancelledByHost),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u8 {
self as u8
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u8)]
pub enum LegacyAdvertisingType {
AdvInd = 0,
AdvDirectInd = 1,
AdvScanInd = 2,
AdvNonconnInd = 3,
ScanRsp = 4,
}
impl LegacyAdvertisingType {
#[inline]
pub fn from_primitive(prim: u8) -> Option<Self> {
match prim {
0 => Some(Self::AdvInd),
1 => Some(Self::AdvDirectInd),
2 => Some(Self::AdvScanInd),
3 => Some(Self::AdvNonconnInd),
4 => Some(Self::ScanRsp),
_ => None,
}
}
#[inline]
pub const fn into_primitive(self) -> u8 {
self as u8
}
#[deprecated = "Strict enums should not use `is_unknown`"]
#[inline]
pub fn is_unknown(&self) -> bool {
false
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct AclBufferSettings {
pub data_packet_length: u16,
pub total_num_data_packets: u8,
}
impl fidl::Persistable for AclBufferSettings {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct AdvertisingData {
pub data: Vec<u8>,
}
impl fidl::Persistable for AdvertisingData {}
#[derive(Debug, PartialEq)]
pub struct HciEmulatorAddBredrPeerRequest {
pub parameters: BredrPeerParameters,
pub peer: fidl::endpoints::ServerEnd<PeerMarker>,
}
impl fidl::Standalone for HciEmulatorAddBredrPeerRequest {}
#[derive(Debug, PartialEq)]
pub struct HciEmulatorAddLowEnergyPeerRequest {
pub parameters: LowEnergyPeerParameters,
pub peer: fidl::endpoints::ServerEnd<PeerMarker>,
}
impl fidl::Standalone for HciEmulatorAddLowEnergyPeerRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct HciEmulatorPublishRequest {
pub settings: EmulatorSettings,
}
impl fidl::Persistable for HciEmulatorPublishRequest {}
#[derive(Clone, Debug, PartialEq)]
pub struct HciEmulatorWatchControllerParametersResponse {
pub parameters: ControllerParameters,
}
impl fidl::Persistable for HciEmulatorWatchControllerParametersResponse {}
#[derive(Clone, Debug, PartialEq)]
pub struct HciEmulatorWatchLeScanStatesResponse {
pub states: Vec<LeScanState>,
}
impl fidl::Persistable for HciEmulatorWatchLeScanStatesResponse {}
#[derive(Clone, Debug, PartialEq)]
pub struct HciEmulatorWatchLegacyAdvertisingStatesResponse {
pub states: Vec<LegacyAdvertisingState>,
}
impl fidl::Persistable for HciEmulatorWatchLegacyAdvertisingStatesResponse {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct PeerAssignConnectionStatusRequest {
pub status: HciError,
}
impl fidl::Persistable for PeerAssignConnectionStatusRequest {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct PeerEmulateLeConnectionCompleteRequest {
pub role: fidl_fuchsia_bluetooth::ConnectionRole,
}
impl fidl::Persistable for PeerEmulateLeConnectionCompleteRequest {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct PeerWatchConnectionStatesResponse {
pub states: Vec<ConnectionState>,
}
impl fidl::Persistable for PeerWatchConnectionStatesResponse {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct BredrPeerParameters {
pub address: Option<fidl_fuchsia_bluetooth::Address>,
pub connectable: Option<bool>,
pub device_class: Option<fidl_fuchsia_bluetooth::DeviceClass>,
pub service_definition: Option<Vec<fidl_fuchsia_bluetooth_bredr::ServiceDefinition>>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for BredrPeerParameters {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct ControllerParameters {
pub local_name: Option<String>,
pub device_class: Option<fidl_fuchsia_bluetooth::DeviceClass>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for ControllerParameters {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct EmulatorSettings {
pub address: Option<fidl_fuchsia_bluetooth::Address>,
pub hci_config: Option<HciConfig>,
pub extended_advertising: Option<bool>,
pub acl_buffer_settings: Option<AclBufferSettings>,
pub le_acl_buffer_settings: Option<AclBufferSettings>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for EmulatorSettings {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct LeScanState {
pub enabled: Option<bool>,
pub active: Option<bool>,
pub interval: Option<u16>,
pub window: Option<u16>,
pub filter_duplicates: Option<bool>,
pub address_type: Option<fidl_fuchsia_bluetooth::AddressType>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for LeScanState {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct LegacyAdvertisingState {
pub enabled: Option<bool>,
pub type_: Option<LegacyAdvertisingType>,
pub address_type: Option<fidl_fuchsia_bluetooth::AddressType>,
pub interval_min: Option<u16>,
pub interval_max: Option<u16>,
pub advertising_data: Option<Vec<u8>>,
pub scan_response: Option<Vec<u8>>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for LegacyAdvertisingState {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct LowEnergyPeerParameters {
pub address: Option<fidl_fuchsia_bluetooth::Address>,
pub connectable: Option<bool>,
pub advertisement: Option<AdvertisingData>,
pub scan_response: Option<AdvertisingData>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for LowEnergyPeerParameters {}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct HciEmulatorMarker;
impl fidl::endpoints::ProtocolMarker for HciEmulatorMarker {
type Proxy = HciEmulatorProxy;
type RequestStream = HciEmulatorRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = HciEmulatorSynchronousProxy;
const DEBUG_NAME: &'static str = "fuchsia.bluetooth.test.HciEmulator";
}
impl fidl::endpoints::DiscoverableProtocolMarker for HciEmulatorMarker {}
pub type HciEmulatorPublishResult = Result<(), EmulatorError>;
pub type HciEmulatorAddLowEnergyPeerResult = Result<(), EmulatorPeerError>;
pub type HciEmulatorAddBredrPeerResult = Result<(), EmulatorPeerError>;
pub trait HciEmulatorProxyInterface: Send + Sync {
type PublishResponseFut: std::future::Future<Output = Result<HciEmulatorPublishResult, fidl::Error>>
+ Send;
fn r#publish(&self, settings: &EmulatorSettings) -> Self::PublishResponseFut;
type AddLowEnergyPeerResponseFut: std::future::Future<Output = Result<HciEmulatorAddLowEnergyPeerResult, fidl::Error>>
+ Send;
fn r#add_low_energy_peer(
&self,
parameters: &LowEnergyPeerParameters,
peer: fidl::endpoints::ServerEnd<PeerMarker>,
) -> Self::AddLowEnergyPeerResponseFut;
type AddBredrPeerResponseFut: std::future::Future<Output = Result<HciEmulatorAddBredrPeerResult, fidl::Error>>
+ Send;
fn r#add_bredr_peer(
&self,
parameters: &BredrPeerParameters,
peer: fidl::endpoints::ServerEnd<PeerMarker>,
) -> Self::AddBredrPeerResponseFut;
type WatchControllerParametersResponseFut: std::future::Future<Output = Result<ControllerParameters, fidl::Error>>
+ Send;
fn r#watch_controller_parameters(&self) -> Self::WatchControllerParametersResponseFut;
type WatchLeScanStatesResponseFut: std::future::Future<Output = Result<Vec<LeScanState>, fidl::Error>>
+ Send;
fn r#watch_le_scan_states(&self) -> Self::WatchLeScanStatesResponseFut;
type WatchLegacyAdvertisingStatesResponseFut: std::future::Future<Output = Result<Vec<LegacyAdvertisingState>, fidl::Error>>
+ Send;
fn r#watch_legacy_advertising_states(&self) -> Self::WatchLegacyAdvertisingStatesResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct HciEmulatorSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for HciEmulatorSynchronousProxy {
type Proxy = HciEmulatorProxy;
type Protocol = HciEmulatorMarker;
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 HciEmulatorSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <HciEmulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(&self, deadline: zx::Time) -> Result<HciEmulatorEvent, fidl::Error> {
HciEmulatorEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#publish(
&self,
mut settings: &EmulatorSettings,
___deadline: zx::Time,
) -> Result<HciEmulatorPublishResult, fidl::Error> {
let _response = self.client.send_query::<
HciEmulatorPublishRequest,
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, EmulatorError>,
>(
(settings,),
0x567204c8e9767356,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x))
}
pub fn r#add_low_energy_peer(
&self,
mut parameters: &LowEnergyPeerParameters,
mut peer: fidl::endpoints::ServerEnd<PeerMarker>,
___deadline: zx::Time,
) -> Result<HciEmulatorAddLowEnergyPeerResult, fidl::Error> {
let _response = self.client.send_query::<
HciEmulatorAddLowEnergyPeerRequest,
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
>(
(parameters, peer,),
0x1b30a112d5a85889,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x))
}
pub fn r#add_bredr_peer(
&self,
mut parameters: &BredrPeerParameters,
mut peer: fidl::endpoints::ServerEnd<PeerMarker>,
___deadline: zx::Time,
) -> Result<HciEmulatorAddBredrPeerResult, fidl::Error> {
let _response =
self.client.send_query::<HciEmulatorAddBredrPeerRequest, fidl::encoding::ResultType<
fidl::encoding::EmptyStruct,
EmulatorPeerError,
>>(
(parameters, peer),
0x1f60733639e32468,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.map(|x| x))
}
pub fn r#watch_controller_parameters(
&self,
___deadline: zx::Time,
) -> Result<ControllerParameters, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
HciEmulatorWatchControllerParametersResponse,
>(
(),
0x45ab703b8319e2a,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.parameters)
}
pub fn r#watch_le_scan_states(
&self,
___deadline: zx::Time,
) -> Result<Vec<LeScanState>, fidl::Error> {
let _response = self
.client
.send_query::<fidl::encoding::EmptyPayload, HciEmulatorWatchLeScanStatesResponse>(
(),
0x569c8384f679bb9f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.states)
}
pub fn r#watch_legacy_advertising_states(
&self,
___deadline: zx::Time,
) -> Result<Vec<LegacyAdvertisingState>, fidl::Error> {
let _response = self.client.send_query::<
fidl::encoding::EmptyPayload,
HciEmulatorWatchLegacyAdvertisingStatesResponse,
>(
(),
0x38ed38b0aef97b54,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.states)
}
}
#[derive(Debug, Clone)]
pub struct HciEmulatorProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for HciEmulatorProxy {
type Protocol = HciEmulatorMarker;
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 HciEmulatorProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <HciEmulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> HciEmulatorEventStream {
HciEmulatorEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#publish(
&self,
mut settings: &EmulatorSettings,
) -> fidl::client::QueryResponseFut<HciEmulatorPublishResult> {
HciEmulatorProxyInterface::r#publish(self, settings)
}
pub fn r#add_low_energy_peer(
&self,
mut parameters: &LowEnergyPeerParameters,
mut peer: fidl::endpoints::ServerEnd<PeerMarker>,
) -> fidl::client::QueryResponseFut<HciEmulatorAddLowEnergyPeerResult> {
HciEmulatorProxyInterface::r#add_low_energy_peer(self, parameters, peer)
}
pub fn r#add_bredr_peer(
&self,
mut parameters: &BredrPeerParameters,
mut peer: fidl::endpoints::ServerEnd<PeerMarker>,
) -> fidl::client::QueryResponseFut<HciEmulatorAddBredrPeerResult> {
HciEmulatorProxyInterface::r#add_bredr_peer(self, parameters, peer)
}
pub fn r#watch_controller_parameters(
&self,
) -> fidl::client::QueryResponseFut<ControllerParameters> {
HciEmulatorProxyInterface::r#watch_controller_parameters(self)
}
pub fn r#watch_le_scan_states(&self) -> fidl::client::QueryResponseFut<Vec<LeScanState>> {
HciEmulatorProxyInterface::r#watch_le_scan_states(self)
}
pub fn r#watch_legacy_advertising_states(
&self,
) -> fidl::client::QueryResponseFut<Vec<LegacyAdvertisingState>> {
HciEmulatorProxyInterface::r#watch_legacy_advertising_states(self)
}
}
impl HciEmulatorProxyInterface for HciEmulatorProxy {
type PublishResponseFut = fidl::client::QueryResponseFut<HciEmulatorPublishResult>;
fn r#publish(&self, mut settings: &EmulatorSettings) -> Self::PublishResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<HciEmulatorPublishResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, EmulatorError>,
0x567204c8e9767356,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<HciEmulatorPublishRequest, HciEmulatorPublishResult>(
(settings,),
0x567204c8e9767356,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type AddLowEnergyPeerResponseFut =
fidl::client::QueryResponseFut<HciEmulatorAddLowEnergyPeerResult>;
fn r#add_low_energy_peer(
&self,
mut parameters: &LowEnergyPeerParameters,
mut peer: fidl::endpoints::ServerEnd<PeerMarker>,
) -> Self::AddLowEnergyPeerResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<HciEmulatorAddLowEnergyPeerResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
0x1b30a112d5a85889,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client.send_query_and_decode::<
HciEmulatorAddLowEnergyPeerRequest,
HciEmulatorAddLowEnergyPeerResult,
>(
(parameters, peer,),
0x1b30a112d5a85889,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type AddBredrPeerResponseFut = fidl::client::QueryResponseFut<HciEmulatorAddBredrPeerResult>;
fn r#add_bredr_peer(
&self,
mut parameters: &BredrPeerParameters,
mut peer: fidl::endpoints::ServerEnd<PeerMarker>,
) -> Self::AddBredrPeerResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<HciEmulatorAddBredrPeerResult, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::ResultType<fidl::encoding::EmptyStruct, EmulatorPeerError>,
0x1f60733639e32468,
>(_buf?)?;
Ok(_response.map(|x| x))
}
self.client
.send_query_and_decode::<HciEmulatorAddBredrPeerRequest, HciEmulatorAddBredrPeerResult>(
(parameters, peer),
0x1f60733639e32468,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type WatchControllerParametersResponseFut =
fidl::client::QueryResponseFut<ControllerParameters>;
fn r#watch_controller_parameters(&self) -> Self::WatchControllerParametersResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<ControllerParameters, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
HciEmulatorWatchControllerParametersResponse,
0x45ab703b8319e2a,
>(_buf?)?;
Ok(_response.parameters)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, ControllerParameters>(
(),
0x45ab703b8319e2a,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type WatchLeScanStatesResponseFut = fidl::client::QueryResponseFut<Vec<LeScanState>>;
fn r#watch_le_scan_states(&self) -> Self::WatchLeScanStatesResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<Vec<LeScanState>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
HciEmulatorWatchLeScanStatesResponse,
0x569c8384f679bb9f,
>(_buf?)?;
Ok(_response.states)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<LeScanState>>(
(),
0x569c8384f679bb9f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
type WatchLegacyAdvertisingStatesResponseFut =
fidl::client::QueryResponseFut<Vec<LegacyAdvertisingState>>;
fn r#watch_legacy_advertising_states(&self) -> Self::WatchLegacyAdvertisingStatesResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<Vec<LegacyAdvertisingState>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
HciEmulatorWatchLegacyAdvertisingStatesResponse,
0x38ed38b0aef97b54,
>(_buf?)?;
Ok(_response.states)
}
self.client
.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<LegacyAdvertisingState>>(
(),
0x38ed38b0aef97b54,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct HciEmulatorEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for HciEmulatorEventStream {}
impl futures::stream::FusedStream for HciEmulatorEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for HciEmulatorEventStream {
type Item = Result<HciEmulatorEvent, 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(HciEmulatorEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum HciEmulatorEvent {}
impl HciEmulatorEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<HciEmulatorEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <HciEmulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct HciEmulatorRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for HciEmulatorRequestStream {}
impl futures::stream::FusedStream for HciEmulatorRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for HciEmulatorRequestStream {
type Protocol = HciEmulatorMarker;
type ControlHandle = HciEmulatorControlHandle;
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 {
HciEmulatorControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for HciEmulatorRequestStream {
type Item = Result<HciEmulatorRequest, 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 HciEmulatorRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x567204c8e9767356 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(HciEmulatorPublishRequest);
fidl::encoding::Decoder::decode_into::<HciEmulatorPublishRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = HciEmulatorControlHandle { inner: this.inner.clone() };
Ok(HciEmulatorRequest::Publish {
settings: req.settings,
responder: HciEmulatorPublishResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x1b30a112d5a85889 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(HciEmulatorAddLowEnergyPeerRequest);
fidl::encoding::Decoder::decode_into::<HciEmulatorAddLowEnergyPeerRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = HciEmulatorControlHandle { inner: this.inner.clone() };
Ok(HciEmulatorRequest::AddLowEnergyPeer {
parameters: req.parameters,
peer: req.peer,
responder: HciEmulatorAddLowEnergyPeerResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x1f60733639e32468 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(HciEmulatorAddBredrPeerRequest);
fidl::encoding::Decoder::decode_into::<HciEmulatorAddBredrPeerRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = HciEmulatorControlHandle { inner: this.inner.clone() };
Ok(HciEmulatorRequest::AddBredrPeer {
parameters: req.parameters,
peer: req.peer,
responder: HciEmulatorAddBredrPeerResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x45ab703b8319e2a => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload);
fidl::encoding::Decoder::decode_into::<fidl::encoding::EmptyPayload>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = HciEmulatorControlHandle { inner: this.inner.clone() };
Ok(HciEmulatorRequest::WatchControllerParameters {
responder: HciEmulatorWatchControllerParametersResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x569c8384f679bb9f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload);
fidl::encoding::Decoder::decode_into::<fidl::encoding::EmptyPayload>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = HciEmulatorControlHandle { inner: this.inner.clone() };
Ok(HciEmulatorRequest::WatchLeScanStates {
responder: HciEmulatorWatchLeScanStatesResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x38ed38b0aef97b54 => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload);
fidl::encoding::Decoder::decode_into::<fidl::encoding::EmptyPayload>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = HciEmulatorControlHandle { inner: this.inner.clone() };
Ok(HciEmulatorRequest::WatchLegacyAdvertisingStates {
responder: HciEmulatorWatchLegacyAdvertisingStatesResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name:
<HciEmulatorMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum HciEmulatorRequest {
Publish { settings: EmulatorSettings, responder: HciEmulatorPublishResponder },
AddLowEnergyPeer {
parameters: LowEnergyPeerParameters,
peer: fidl::endpoints::ServerEnd<PeerMarker>,
responder: HciEmulatorAddLowEnergyPeerResponder,
},
AddBredrPeer {
parameters: BredrPeerParameters,
peer: fidl::endpoints::ServerEnd<PeerMarker>,
responder: HciEmulatorAddBredrPeerResponder,
},
WatchControllerParameters { responder: HciEmulatorWatchControllerParametersResponder },
WatchLeScanStates { responder: HciEmulatorWatchLeScanStatesResponder },
WatchLegacyAdvertisingStates { responder: HciEmulatorWatchLegacyAdvertisingStatesResponder },
}
impl HciEmulatorRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_publish(self) -> Option<(EmulatorSettings, HciEmulatorPublishResponder)> {
if let HciEmulatorRequest::Publish { settings, responder } = self {
Some((settings, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_add_low_energy_peer(
self,
) -> Option<(
LowEnergyPeerParameters,
fidl::endpoints::ServerEnd<PeerMarker>,
HciEmulatorAddLowEnergyPeerResponder,
)> {
if let HciEmulatorRequest::AddLowEnergyPeer { parameters, peer, responder } = self {
Some((parameters, peer, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_add_bredr_peer(
self,
) -> Option<(
BredrPeerParameters,
fidl::endpoints::ServerEnd<PeerMarker>,
HciEmulatorAddBredrPeerResponder,
)> {
if let HciEmulatorRequest::AddBredrPeer { parameters, peer, responder } = self {
Some((parameters, peer, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_watch_controller_parameters(
self,
) -> Option<(HciEmulatorWatchControllerParametersResponder)> {
if let HciEmulatorRequest::WatchControllerParameters { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_watch_le_scan_states(self) -> Option<(HciEmulatorWatchLeScanStatesResponder)> {
if let HciEmulatorRequest::WatchLeScanStates { responder } = self {
Some((responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_watch_legacy_advertising_states(
self,
) -> Option<(HciEmulatorWatchLegacyAdvertisingStatesResponder)> {
if let HciEmulatorRequest::WatchLegacyAdvertisingStates { responder } = self {
Some((responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
HciEmulatorRequest::Publish { .. } => "publish",
HciEmulatorRequest::AddLowEnergyPeer { .. } => "add_low_energy_peer",
HciEmulatorRequest::AddBredrPeer { .. } => "add_bredr_peer",
HciEmulatorRequest::WatchControllerParameters { .. } => "watch_controller_parameters",
HciEmulatorRequest::WatchLeScanStates { .. } => "watch_le_scan_states",
HciEmulatorRequest::WatchLegacyAdvertisingStates { .. } => {
"watch_legacy_advertising_states"
}
}
}
}
#[derive(Debug, Clone)]
pub struct HciEmulatorControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for HciEmulatorControlHandle {
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()
}
}
impl HciEmulatorControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct HciEmulatorPublishResponder {
control_handle: std::mem::ManuallyDrop<HciEmulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for HciEmulatorPublishResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for HciEmulatorPublishResponder {
type ControlHandle = HciEmulatorControlHandle;
fn control_handle(&self) -> &HciEmulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl HciEmulatorPublishResponder {
pub fn send(self, mut result: Result<(), EmulatorError>) -> 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<(), EmulatorError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), EmulatorError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::ResultType<
fidl::encoding::EmptyStruct,
EmulatorError,
>>(
result,
self.tx_id,
0x567204c8e9767356,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct HciEmulatorAddLowEnergyPeerResponder {
control_handle: std::mem::ManuallyDrop<HciEmulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for HciEmulatorAddLowEnergyPeerResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for HciEmulatorAddLowEnergyPeerResponder {
type ControlHandle = HciEmulatorControlHandle;
fn control_handle(&self) -> &HciEmulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl HciEmulatorAddLowEnergyPeerResponder {
pub fn send(self, mut result: Result<(), EmulatorPeerError>) -> 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<(), EmulatorPeerError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::ResultType<
fidl::encoding::EmptyStruct,
EmulatorPeerError,
>>(
result,
self.tx_id,
0x1b30a112d5a85889,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct HciEmulatorAddBredrPeerResponder {
control_handle: std::mem::ManuallyDrop<HciEmulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for HciEmulatorAddBredrPeerResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for HciEmulatorAddBredrPeerResponder {
type ControlHandle = HciEmulatorControlHandle;
fn control_handle(&self) -> &HciEmulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl HciEmulatorAddBredrPeerResponder {
pub fn send(self, mut result: Result<(), EmulatorPeerError>) -> 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<(), EmulatorPeerError>,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(result);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut result: Result<(), EmulatorPeerError>) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::ResultType<
fidl::encoding::EmptyStruct,
EmulatorPeerError,
>>(
result,
self.tx_id,
0x1f60733639e32468,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct HciEmulatorWatchControllerParametersResponder {
control_handle: std::mem::ManuallyDrop<HciEmulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for HciEmulatorWatchControllerParametersResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for HciEmulatorWatchControllerParametersResponder {
type ControlHandle = HciEmulatorControlHandle;
fn control_handle(&self) -> &HciEmulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl HciEmulatorWatchControllerParametersResponder {
pub fn send(self, mut parameters: &ControllerParameters) -> Result<(), fidl::Error> {
let _result = self.send_raw(parameters);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut parameters: &ControllerParameters,
) -> Result<(), fidl::Error> {
let _result = self.send_raw(parameters);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut parameters: &ControllerParameters) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<HciEmulatorWatchControllerParametersResponse>(
(parameters,),
self.tx_id,
0x45ab703b8319e2a,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct HciEmulatorWatchLeScanStatesResponder {
control_handle: std::mem::ManuallyDrop<HciEmulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for HciEmulatorWatchLeScanStatesResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for HciEmulatorWatchLeScanStatesResponder {
type ControlHandle = HciEmulatorControlHandle;
fn control_handle(&self) -> &HciEmulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl HciEmulatorWatchLeScanStatesResponder {
pub fn send(self, mut states: &[LeScanState]) -> Result<(), fidl::Error> {
let _result = self.send_raw(states);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self, mut states: &[LeScanState]) -> Result<(), fidl::Error> {
let _result = self.send_raw(states);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut states: &[LeScanState]) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<HciEmulatorWatchLeScanStatesResponse>(
(states,),
self.tx_id,
0x569c8384f679bb9f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct HciEmulatorWatchLegacyAdvertisingStatesResponder {
control_handle: std::mem::ManuallyDrop<HciEmulatorControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for HciEmulatorWatchLegacyAdvertisingStatesResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for HciEmulatorWatchLegacyAdvertisingStatesResponder {
type ControlHandle = HciEmulatorControlHandle;
fn control_handle(&self) -> &HciEmulatorControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl HciEmulatorWatchLegacyAdvertisingStatesResponder {
pub fn send(self, mut states: &[LegacyAdvertisingState]) -> Result<(), fidl::Error> {
let _result = self.send_raw(states);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut states: &[LegacyAdvertisingState],
) -> Result<(), fidl::Error> {
let _result = self.send_raw(states);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut states: &[LegacyAdvertisingState]) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<HciEmulatorWatchLegacyAdvertisingStatesResponse>(
(states,),
self.tx_id,
0x38ed38b0aef97b54,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct PeerMarker;
impl fidl::endpoints::ProtocolMarker for PeerMarker {
type Proxy = PeerProxy;
type RequestStream = PeerRequestStream;
#[cfg(target_os = "fuchsia")]
type SynchronousProxy = PeerSynchronousProxy;
const DEBUG_NAME: &'static str = "(anonymous) Peer";
}
pub trait PeerProxyInterface: Send + Sync {
type AssignConnectionStatusResponseFut: std::future::Future<Output = Result<(), fidl::Error>>
+ Send;
fn r#assign_connection_status(
&self,
status: HciError,
) -> Self::AssignConnectionStatusResponseFut;
fn r#emulate_le_connection_complete(
&self,
role: fidl_fuchsia_bluetooth::ConnectionRole,
) -> Result<(), fidl::Error>;
fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error>;
type WatchConnectionStatesResponseFut: std::future::Future<Output = Result<Vec<ConnectionState>, fidl::Error>>
+ Send;
fn r#watch_connection_states(&self) -> Self::WatchConnectionStatesResponseFut;
}
#[derive(Debug)]
#[cfg(target_os = "fuchsia")]
pub struct PeerSynchronousProxy {
client: fidl::client::sync::Client,
}
#[cfg(target_os = "fuchsia")]
impl fidl::endpoints::SynchronousProxy for PeerSynchronousProxy {
type Proxy = PeerProxy;
type Protocol = PeerMarker;
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 PeerSynchronousProxy {
pub fn new(channel: fidl::Channel) -> Self {
let protocol_name = <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::sync::Client::new(channel, protocol_name) }
}
pub fn into_channel(self) -> fidl::Channel {
self.client.into_channel()
}
pub fn wait_for_event(&self, deadline: zx::Time) -> Result<PeerEvent, fidl::Error> {
PeerEvent::decode(self.client.wait_for_event(deadline)?)
}
pub fn r#assign_connection_status(
&self,
mut status: HciError,
___deadline: zx::Time,
) -> Result<(), fidl::Error> {
let _response = self
.client
.send_query::<PeerAssignConnectionStatusRequest, fidl::encoding::EmptyPayload>(
(status,),
0x50c4e09638cc369f,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response)
}
pub fn r#emulate_le_connection_complete(
&self,
mut role: fidl_fuchsia_bluetooth::ConnectionRole,
) -> Result<(), fidl::Error> {
self.client.send::<PeerEmulateLeConnectionCompleteRequest>(
(role,),
0x72a147fdfee41d9c,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x6f888e445c08a260,
fidl::encoding::DynamicFlags::empty(),
)
}
pub fn r#watch_connection_states(
&self,
___deadline: zx::Time,
) -> Result<Vec<ConnectionState>, fidl::Error> {
let _response = self
.client
.send_query::<fidl::encoding::EmptyPayload, PeerWatchConnectionStatesResponse>(
(),
0x3fe8bfa2de417e5d,
fidl::encoding::DynamicFlags::empty(),
___deadline,
)?;
Ok(_response.states)
}
}
#[derive(Debug, Clone)]
pub struct PeerProxy {
client: fidl::client::Client,
}
impl fidl::endpoints::Proxy for PeerProxy {
type Protocol = PeerMarker;
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 PeerProxy {
pub fn new(channel: fidl::AsyncChannel) -> Self {
let protocol_name = <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME;
Self { client: fidl::client::Client::new(channel, protocol_name) }
}
pub fn take_event_stream(&self) -> PeerEventStream {
PeerEventStream { event_receiver: self.client.take_event_receiver() }
}
pub fn r#assign_connection_status(
&self,
mut status: HciError,
) -> fidl::client::QueryResponseFut<()> {
PeerProxyInterface::r#assign_connection_status(self, status)
}
pub fn r#emulate_le_connection_complete(
&self,
mut role: fidl_fuchsia_bluetooth::ConnectionRole,
) -> Result<(), fidl::Error> {
PeerProxyInterface::r#emulate_le_connection_complete(self, role)
}
pub fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
PeerProxyInterface::r#emulate_disconnection_complete(self)
}
pub fn r#watch_connection_states(
&self,
) -> fidl::client::QueryResponseFut<Vec<ConnectionState>> {
PeerProxyInterface::r#watch_connection_states(self)
}
}
impl PeerProxyInterface for PeerProxy {
type AssignConnectionStatusResponseFut = fidl::client::QueryResponseFut<()>;
fn r#assign_connection_status(
&self,
mut status: HciError,
) -> Self::AssignConnectionStatusResponseFut {
fn _decode(mut _buf: Result<fidl::MessageBufEtc, fidl::Error>) -> Result<(), fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
fidl::encoding::EmptyPayload,
0x50c4e09638cc369f,
>(_buf?)?;
Ok(_response)
}
self.client.send_query_and_decode::<PeerAssignConnectionStatusRequest, ()>(
(status,),
0x50c4e09638cc369f,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
fn r#emulate_le_connection_complete(
&self,
mut role: fidl_fuchsia_bluetooth::ConnectionRole,
) -> Result<(), fidl::Error> {
self.client.send::<PeerEmulateLeConnectionCompleteRequest>(
(role,),
0x72a147fdfee41d9c,
fidl::encoding::DynamicFlags::empty(),
)
}
fn r#emulate_disconnection_complete(&self) -> Result<(), fidl::Error> {
self.client.send::<fidl::encoding::EmptyPayload>(
(),
0x6f888e445c08a260,
fidl::encoding::DynamicFlags::empty(),
)
}
type WatchConnectionStatesResponseFut = fidl::client::QueryResponseFut<Vec<ConnectionState>>;
fn r#watch_connection_states(&self) -> Self::WatchConnectionStatesResponseFut {
fn _decode(
mut _buf: Result<fidl::MessageBufEtc, fidl::Error>,
) -> Result<Vec<ConnectionState>, fidl::Error> {
let _response = fidl::client::decode_transaction_body::<
PeerWatchConnectionStatesResponse,
0x3fe8bfa2de417e5d,
>(_buf?)?;
Ok(_response.states)
}
self.client.send_query_and_decode::<fidl::encoding::EmptyPayload, Vec<ConnectionState>>(
(),
0x3fe8bfa2de417e5d,
fidl::encoding::DynamicFlags::empty(),
_decode,
)
}
}
pub struct PeerEventStream {
event_receiver: fidl::client::EventReceiver,
}
impl std::marker::Unpin for PeerEventStream {}
impl futures::stream::FusedStream for PeerEventStream {
fn is_terminated(&self) -> bool {
self.event_receiver.is_terminated()
}
}
impl futures::Stream for PeerEventStream {
type Item = Result<PeerEvent, 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(PeerEvent::decode(buf))),
None => std::task::Poll::Ready(None),
}
}
}
#[derive(Debug)]
pub enum PeerEvent {}
impl PeerEvent {
fn decode(mut buf: fidl::MessageBufEtc) -> Result<PeerEvent, fidl::Error> {
let (bytes, _handles) = buf.split_mut();
let (tx_header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
debug_assert_eq!(tx_header.tx_id, 0);
match tx_header.ordinal {
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: tx_header.ordinal,
protocol_name: <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}
}
}
pub struct PeerRequestStream {
inner: std::sync::Arc<fidl::ServeInner>,
is_terminated: bool,
}
impl std::marker::Unpin for PeerRequestStream {}
impl futures::stream::FusedStream for PeerRequestStream {
fn is_terminated(&self) -> bool {
self.is_terminated
}
}
impl fidl::endpoints::RequestStream for PeerRequestStream {
type Protocol = PeerMarker;
type ControlHandle = PeerControlHandle;
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 {
PeerControlHandle { inner: self.inner.clone() }
}
fn into_inner(self) -> (::std::sync::Arc<fidl::ServeInner>, bool) {
(self.inner, self.is_terminated)
}
fn from_inner(inner: std::sync::Arc<fidl::ServeInner>, is_terminated: bool) -> Self {
Self { inner, is_terminated }
}
}
impl futures::Stream for PeerRequestStream {
type Item = Result<PeerRequest, 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 PeerRequestStream after completion");
}
fidl::encoding::with_tls_decode_buf(|bytes, handles| {
match this.inner.channel().read_etc(cx, bytes, handles) {
std::task::Poll::Ready(Ok(())) => {}
std::task::Poll::Pending => return std::task::Poll::Pending,
std::task::Poll::Ready(Err(zx_status::Status::PEER_CLOSED)) => {
this.is_terminated = true;
return std::task::Poll::Ready(None);
}
std::task::Poll::Ready(Err(e)) => {
return std::task::Poll::Ready(Some(Err(fidl::Error::ServerRequestRead(e))))
}
}
let (header, _body_bytes) = fidl::encoding::decode_transaction_header(bytes)?;
std::task::Poll::Ready(Some(match header.ordinal {
0x50c4e09638cc369f => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(PeerAssignConnectionStatusRequest);
fidl::encoding::Decoder::decode_into::<PeerAssignConnectionStatusRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = PeerControlHandle { inner: this.inner.clone() };
Ok(PeerRequest::AssignConnectionStatus {
status: req.status,
responder: PeerAssignConnectionStatusResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
0x72a147fdfee41d9c => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(PeerEmulateLeConnectionCompleteRequest);
fidl::encoding::Decoder::decode_into::<PeerEmulateLeConnectionCompleteRequest>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = PeerControlHandle { inner: this.inner.clone() };
Ok(PeerRequest::EmulateLeConnectionComplete { role: req.role, control_handle })
}
0x6f888e445c08a260 => {
header.validate_request_tx_id(fidl::MethodType::OneWay)?;
let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload);
fidl::encoding::Decoder::decode_into::<fidl::encoding::EmptyPayload>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = PeerControlHandle { inner: this.inner.clone() };
Ok(PeerRequest::EmulateDisconnectionComplete { control_handle })
}
0x3fe8bfa2de417e5d => {
header.validate_request_tx_id(fidl::MethodType::TwoWay)?;
let mut req = fidl::new_empty!(fidl::encoding::EmptyPayload);
fidl::encoding::Decoder::decode_into::<fidl::encoding::EmptyPayload>(
&header,
_body_bytes,
handles,
&mut req,
)?;
let control_handle = PeerControlHandle { inner: this.inner.clone() };
Ok(PeerRequest::WatchConnectionStates {
responder: PeerWatchConnectionStatesResponder {
control_handle: std::mem::ManuallyDrop::new(control_handle),
tx_id: header.tx_id,
},
})
}
_ => Err(fidl::Error::UnknownOrdinal {
ordinal: header.ordinal,
protocol_name: <PeerMarker as fidl::endpoints::ProtocolMarker>::DEBUG_NAME,
}),
}))
})
}
}
#[derive(Debug)]
pub enum PeerRequest {
AssignConnectionStatus { status: HciError, responder: PeerAssignConnectionStatusResponder },
EmulateLeConnectionComplete {
role: fidl_fuchsia_bluetooth::ConnectionRole,
control_handle: PeerControlHandle,
},
EmulateDisconnectionComplete { control_handle: PeerControlHandle },
WatchConnectionStates { responder: PeerWatchConnectionStatesResponder },
}
impl PeerRequest {
#[allow(irrefutable_let_patterns)]
pub fn into_assign_connection_status(
self,
) -> Option<(HciError, PeerAssignConnectionStatusResponder)> {
if let PeerRequest::AssignConnectionStatus { status, responder } = self {
Some((status, responder))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_emulate_le_connection_complete(
self,
) -> Option<(fidl_fuchsia_bluetooth::ConnectionRole, PeerControlHandle)> {
if let PeerRequest::EmulateLeConnectionComplete { role, control_handle } = self {
Some((role, control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_emulate_disconnection_complete(self) -> Option<(PeerControlHandle)> {
if let PeerRequest::EmulateDisconnectionComplete { control_handle } = self {
Some((control_handle))
} else {
None
}
}
#[allow(irrefutable_let_patterns)]
pub fn into_watch_connection_states(self) -> Option<(PeerWatchConnectionStatesResponder)> {
if let PeerRequest::WatchConnectionStates { responder } = self {
Some((responder))
} else {
None
}
}
pub fn method_name(&self) -> &'static str {
match *self {
PeerRequest::AssignConnectionStatus { .. } => "assign_connection_status",
PeerRequest::EmulateLeConnectionComplete { .. } => "emulate_le_connection_complete",
PeerRequest::EmulateDisconnectionComplete { .. } => "emulate_disconnection_complete",
PeerRequest::WatchConnectionStates { .. } => "watch_connection_states",
}
}
}
#[derive(Debug, Clone)]
pub struct PeerControlHandle {
inner: std::sync::Arc<fidl::ServeInner>,
}
impl fidl::endpoints::ControlHandle for PeerControlHandle {
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()
}
}
impl PeerControlHandle {}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct PeerAssignConnectionStatusResponder {
control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for PeerAssignConnectionStatusResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for PeerAssignConnectionStatusResponder {
type ControlHandle = PeerControlHandle;
fn control_handle(&self) -> &PeerControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl PeerAssignConnectionStatusResponder {
pub fn send(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(self) -> Result<(), fidl::Error> {
let _result = self.send_raw();
self.drop_without_shutdown();
_result
}
fn send_raw(&self) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<fidl::encoding::EmptyPayload>(
(),
self.tx_id,
0x50c4e09638cc369f,
fidl::encoding::DynamicFlags::empty(),
)
}
}
#[must_use = "FIDL methods require a response to be sent"]
#[derive(Debug)]
pub struct PeerWatchConnectionStatesResponder {
control_handle: std::mem::ManuallyDrop<PeerControlHandle>,
tx_id: u32,
}
impl std::ops::Drop for PeerWatchConnectionStatesResponder {
fn drop(&mut self) {
self.control_handle.shutdown();
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
}
}
impl fidl::endpoints::Responder for PeerWatchConnectionStatesResponder {
type ControlHandle = PeerControlHandle;
fn control_handle(&self) -> &PeerControlHandle {
&self.control_handle
}
fn drop_without_shutdown(mut self) {
unsafe { std::mem::ManuallyDrop::drop(&mut self.control_handle) };
std::mem::forget(self);
}
}
impl PeerWatchConnectionStatesResponder {
pub fn send(self, mut states: &[ConnectionState]) -> Result<(), fidl::Error> {
let _result = self.send_raw(states);
if _result.is_err() {
self.control_handle.shutdown();
}
self.drop_without_shutdown();
_result
}
pub fn send_no_shutdown_on_err(
self,
mut states: &[ConnectionState],
) -> Result<(), fidl::Error> {
let _result = self.send_raw(states);
self.drop_without_shutdown();
_result
}
fn send_raw(&self, mut states: &[ConnectionState]) -> Result<(), fidl::Error> {
self.control_handle.inner.send::<PeerWatchConnectionStatesResponse>(
(states,),
self.tx_id,
0x3fe8bfa2de417e5d,
fidl::encoding::DynamicFlags::empty(),
)
}
}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for ConnectionState {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u32>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u32>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for ConnectionState {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
*value
}
}
unsafe impl fidl::encoding::Encode<Self> for ConnectionState {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ConnectionState {
#[inline(always)]
fn new_empty() -> Self {
Self::Connected
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for EmulatorError {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u32>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u32>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for EmulatorError {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
*value
}
}
unsafe impl fidl::encoding::Encode<Self> for EmulatorError {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl fidl::encoding::Decode<Self> for EmulatorError {
#[inline(always)]
fn new_empty() -> Self {
Self::Failed
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for EmulatorPeerError {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u32>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u32>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for EmulatorPeerError {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
*value
}
}
unsafe impl fidl::encoding::Encode<Self> for EmulatorPeerError {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl fidl::encoding::Decode<Self> for EmulatorPeerError {
#[inline(always)]
fn new_empty() -> Self {
Self::AddressRepeated
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciConfig {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u32>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u32>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for HciConfig {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
*value
}
}
unsafe impl fidl::encoding::Encode<Self> for HciConfig {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciConfig {
#[inline(always)]
fn new_empty() -> Self {
Self::DualMode
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u32>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciError {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u8>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u8>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for HciError {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
*value
}
}
unsafe impl fidl::encoding::Encode<Self> for HciError {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciError {
#[inline(always)]
fn new_empty() -> Self {
Self::Success
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u8>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for LegacyAdvertisingType {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u8>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u8>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for LegacyAdvertisingType {
type Borrowed<'a> = Self;
#[inline(always)]
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
*value
}
}
unsafe impl fidl::encoding::Encode<Self> for LegacyAdvertisingType {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Self>(offset);
encoder.write_num(self.into_primitive(), offset);
Ok(())
}
}
impl fidl::encoding::Decode<Self> for LegacyAdvertisingType {
#[inline(always)]
fn new_empty() -> Self {
Self::AdvInd
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let prim = decoder.read_num::<u8>(offset);
*self = Self::from_primitive(prim).ok_or(fidl::Error::InvalidEnumValue)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for AclBufferSettings {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
2
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
}
impl fidl::encoding::ValueTypeMarker for AclBufferSettings {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<AclBufferSettings> for &AclBufferSettings {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<AclBufferSettings>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut AclBufferSettings)
.write_unaligned((self as *const AclBufferSettings).read());
let padding_ptr = buf_ptr.offset(2) as *mut u16;
let padding_mask = 0xff00u16;
padding_ptr.write_unaligned(padding_ptr.read_unaligned() & !padding_mask);
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<u16>, T1: fidl::encoding::Encode<u8>>
fidl::encoding::Encode<AclBufferSettings> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<AclBufferSettings>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(2);
(ptr as *mut u16).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 2, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for AclBufferSettings {
#[inline(always)]
fn new_empty() -> Self {
Self {
data_packet_length: fidl::new_empty!(u16),
total_num_data_packets: fidl::new_empty!(u8),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let buf_ptr = unsafe { decoder.buf.as_ptr().add(offset) };
let ptr = unsafe { buf_ptr.offset(2) };
let padval = unsafe { (ptr as *const u16).read_unaligned() };
let mask = 0xff00u16;
let maskedval = padval & mask;
if maskedval != 0 {
return Err(fidl::Error::NonZeroPadding {
padding_start: offset + 2 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for AdvertisingData {
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
}
}
impl fidl::encoding::ValueTypeMarker for AdvertisingData {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<AdvertisingData> for &AdvertisingData {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<AdvertisingData>(offset);
fidl::encoding::Encode::<AdvertisingData>::encode(
(<fidl::encoding::Vector<u8, 31> as fidl::encoding::ValueTypeMarker>::borrow(
&self.data,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::Vector<u8, 31>>>
fidl::encoding::Encode<AdvertisingData> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<AdvertisingData>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for AdvertisingData {
#[inline(always)]
fn new_empty() -> Self {
Self { data: fidl::new_empty!(fidl::encoding::Vector<u8, 31>) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(fidl::encoding::Vector<u8, 31>, &mut self.data, decoder, offset + 0, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciEmulatorAddBredrPeerRequest {
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
}
}
impl fidl::encoding::ResourceTypeMarker for HciEmulatorAddBredrPeerRequest {
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::Encode<HciEmulatorAddBredrPeerRequest>
for &mut HciEmulatorAddBredrPeerRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorAddBredrPeerRequest>(offset);
fidl::encoding::Encode::<HciEmulatorAddBredrPeerRequest>::encode(
(
<BredrPeerParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.parameters),
<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.peer),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<BredrPeerParameters>,
T1: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
>,
> fidl::encoding::Encode<HciEmulatorAddBredrPeerRequest> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorAddBredrPeerRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 16, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciEmulatorAddBredrPeerRequest {
#[inline(always)]
fn new_empty() -> Self {
Self {
parameters: fidl::new_empty!(BredrPeerParameters),
peer: fidl::new_empty!(
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
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 + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(BredrPeerParameters, &mut self.parameters, decoder, offset + 0, _depth)?;
fidl::decode!(
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
&mut self.peer,
decoder,
offset + 16,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciEmulatorAddLowEnergyPeerRequest {
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
}
}
impl fidl::encoding::ResourceTypeMarker for HciEmulatorAddLowEnergyPeerRequest {
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::Encode<HciEmulatorAddLowEnergyPeerRequest>
for &mut HciEmulatorAddLowEnergyPeerRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorAddLowEnergyPeerRequest>(offset);
fidl::encoding::Encode::<HciEmulatorAddLowEnergyPeerRequest>::encode(
(
<LowEnergyPeerParameters as fidl::encoding::ValueTypeMarker>::borrow(&self.parameters),
<fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>> as fidl::encoding::ResourceTypeMarker>::take_or_borrow(&mut self.peer),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<LowEnergyPeerParameters>,
T1: fidl::encoding::Encode<
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
>,
> fidl::encoding::Encode<HciEmulatorAddLowEnergyPeerRequest> for (T0, T1)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorAddLowEnergyPeerRequest>(offset);
unsafe {
let ptr = encoder.buf.as_mut_ptr().add(offset).offset(16);
(ptr as *mut u64).write_unaligned(0);
}
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 16, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciEmulatorAddLowEnergyPeerRequest {
#[inline(always)]
fn new_empty() -> Self {
Self {
parameters: fidl::new_empty!(LowEnergyPeerParameters),
peer: fidl::new_empty!(
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>
),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(16) };
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 + 16 + ((mask as u64).trailing_zeros() / 8) as usize,
});
}
fidl::decode!(
LowEnergyPeerParameters,
&mut self.parameters,
decoder,
offset + 0,
_depth
)?;
fidl::decode!(
fidl::encoding::Endpoint<fidl::endpoints::ServerEnd<PeerMarker>>,
&mut self.peer,
decoder,
offset + 16,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciEmulatorPublishRequest {
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
}
}
impl fidl::encoding::ValueTypeMarker for HciEmulatorPublishRequest {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<HciEmulatorPublishRequest> for &HciEmulatorPublishRequest {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorPublishRequest>(offset);
fidl::encoding::Encode::<HciEmulatorPublishRequest>::encode(
(<EmulatorSettings as fidl::encoding::ValueTypeMarker>::borrow(&self.settings),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<EmulatorSettings>>
fidl::encoding::Encode<HciEmulatorPublishRequest> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorPublishRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciEmulatorPublishRequest {
#[inline(always)]
fn new_empty() -> Self {
Self { settings: fidl::new_empty!(EmulatorSettings) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(EmulatorSettings, &mut self.settings, decoder, offset + 0, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciEmulatorWatchControllerParametersResponse {
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
}
}
impl fidl::encoding::ValueTypeMarker for HciEmulatorWatchControllerParametersResponse {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<HciEmulatorWatchControllerParametersResponse>
for &HciEmulatorWatchControllerParametersResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorWatchControllerParametersResponse>(offset);
fidl::encoding::Encode::<HciEmulatorWatchControllerParametersResponse>::encode(
(<ControllerParameters as fidl::encoding::ValueTypeMarker>::borrow(
&self.parameters,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<ControllerParameters>>
fidl::encoding::Encode<HciEmulatorWatchControllerParametersResponse> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorWatchControllerParametersResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciEmulatorWatchControllerParametersResponse {
#[inline(always)]
fn new_empty() -> Self {
Self { parameters: fidl::new_empty!(ControllerParameters) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(ControllerParameters, &mut self.parameters, decoder, offset + 0, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciEmulatorWatchLeScanStatesResponse {
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
}
}
impl fidl::encoding::ValueTypeMarker for HciEmulatorWatchLeScanStatesResponse {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<HciEmulatorWatchLeScanStatesResponse>
for &HciEmulatorWatchLeScanStatesResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorWatchLeScanStatesResponse>(offset);
fidl::encoding::Encode::<HciEmulatorWatchLeScanStatesResponse>::encode(
(
<fidl::encoding::UnboundedVector<LeScanState> as fidl::encoding::ValueTypeMarker>::borrow(&self.states),
),
encoder, offset, _depth
)
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<LeScanState>>>
fidl::encoding::Encode<HciEmulatorWatchLeScanStatesResponse> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorWatchLeScanStatesResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciEmulatorWatchLeScanStatesResponse {
#[inline(always)]
fn new_empty() -> Self {
Self { states: fidl::new_empty!(fidl::encoding::UnboundedVector<LeScanState>) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::UnboundedVector<LeScanState>,
&mut self.states,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HciEmulatorWatchLegacyAdvertisingStatesResponse {
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
}
}
impl fidl::encoding::ValueTypeMarker for HciEmulatorWatchLegacyAdvertisingStatesResponse {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<HciEmulatorWatchLegacyAdvertisingStatesResponse>
for &HciEmulatorWatchLegacyAdvertisingStatesResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorWatchLegacyAdvertisingStatesResponse>(offset);
fidl::encoding::Encode::<HciEmulatorWatchLegacyAdvertisingStatesResponse>::encode(
(
<fidl::encoding::UnboundedVector<LegacyAdvertisingState> as fidl::encoding::ValueTypeMarker>::borrow(&self.states),
),
encoder, offset, _depth
)
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<LegacyAdvertisingState>>>
fidl::encoding::Encode<HciEmulatorWatchLegacyAdvertisingStatesResponse> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HciEmulatorWatchLegacyAdvertisingStatesResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HciEmulatorWatchLegacyAdvertisingStatesResponse {
#[inline(always)]
fn new_empty() -> Self {
Self {
states: fidl::new_empty!(fidl::encoding::UnboundedVector<LegacyAdvertisingState>),
}
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::UnboundedVector<LegacyAdvertisingState>,
&mut self.states,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for PeerAssignConnectionStatusRequest {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
1
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
1
}
}
impl fidl::encoding::ValueTypeMarker for PeerAssignConnectionStatusRequest {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<PeerAssignConnectionStatusRequest>
for &PeerAssignConnectionStatusRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerAssignConnectionStatusRequest>(offset);
fidl::encoding::Encode::<PeerAssignConnectionStatusRequest>::encode(
(<HciError as fidl::encoding::ValueTypeMarker>::borrow(&self.status),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<HciError>>
fidl::encoding::Encode<PeerAssignConnectionStatusRequest> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerAssignConnectionStatusRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for PeerAssignConnectionStatusRequest {
#[inline(always)]
fn new_empty() -> Self {
Self { status: fidl::new_empty!(HciError) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(HciError, &mut self.status, decoder, offset + 0, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for PeerEmulateLeConnectionCompleteRequest {
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
}
}
impl fidl::encoding::ValueTypeMarker for PeerEmulateLeConnectionCompleteRequest {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<PeerEmulateLeConnectionCompleteRequest>
for &PeerEmulateLeConnectionCompleteRequest
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerEmulateLeConnectionCompleteRequest>(offset);
fidl::encoding::Encode::<PeerEmulateLeConnectionCompleteRequest>::encode(
(
<fidl_fuchsia_bluetooth::ConnectionRole as fidl::encoding::ValueTypeMarker>::borrow(&self.role),
),
encoder, offset, _depth
)
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl_fuchsia_bluetooth::ConnectionRole>>
fidl::encoding::Encode<PeerEmulateLeConnectionCompleteRequest> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerEmulateLeConnectionCompleteRequest>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for PeerEmulateLeConnectionCompleteRequest {
#[inline(always)]
fn new_empty() -> Self {
Self { role: fidl::new_empty!(fidl_fuchsia_bluetooth::ConnectionRole) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl_fuchsia_bluetooth::ConnectionRole,
&mut self.role,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for PeerWatchConnectionStatesResponse {
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
}
}
impl fidl::encoding::ValueTypeMarker for PeerWatchConnectionStatesResponse {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<PeerWatchConnectionStatesResponse>
for &PeerWatchConnectionStatesResponse
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerWatchConnectionStatesResponse>(offset);
fidl::encoding::Encode::<PeerWatchConnectionStatesResponse>::encode(
(
<fidl::encoding::UnboundedVector<ConnectionState> as fidl::encoding::ValueTypeMarker>::borrow(&self.states),
),
encoder, offset, _depth
)
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::UnboundedVector<ConnectionState>>>
fidl::encoding::Encode<PeerWatchConnectionStatesResponse> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerWatchConnectionStatesResponse>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for PeerWatchConnectionStatesResponse {
#[inline(always)]
fn new_empty() -> Self {
Self { states: fidl::new_empty!(fidl::encoding::UnboundedVector<ConnectionState>) }
}
#[inline]
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
decoder.debug_check_bounds::<Self>(offset);
fidl::decode!(
fidl::encoding::UnboundedVector<ConnectionState>,
&mut self.states,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
impl BredrPeerParameters {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.service_definition {
return 4;
}
if let Some(_) = self.device_class {
return 3;
}
if let Some(_) = self.connectable {
return 2;
}
if let Some(_) = self.address {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for BredrPeerParameters {
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
}
}
impl fidl::encoding::ValueTypeMarker for BredrPeerParameters {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<BredrPeerParameters> for &BredrPeerParameters {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<BredrPeerParameters>(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_fuchsia_bluetooth::Address>(
self.address.as_ref().map(
<fidl_fuchsia_bluetooth::Address 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::<bool>(
self.connectable.as_ref().map(<bool 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::<fidl_fuchsia_bluetooth::DeviceClass>(
self.device_class.as_ref().map(<fidl_fuchsia_bluetooth::DeviceClass 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::<fidl::encoding::Vector<fidl_fuchsia_bluetooth_bredr::ServiceDefinition, 32>>(
self.service_definition.as_ref().map(<fidl::encoding::Vector<fidl_fuchsia_bluetooth_bredr::ServiceDefinition, 32> as fidl::encoding::ValueTypeMarker>::borrow),
encoder, offset + cur_offset, depth
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for BredrPeerParameters {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
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_fuchsia_bluetooth::Address 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
.address
.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_bluetooth::Address));
fidl::decode!(
fidl_fuchsia_bluetooth::Address,
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 =
<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.connectable.get_or_insert_with(|| fidl::new_empty!(bool));
fidl::decode!(bool, 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 = <fidl_fuchsia_bluetooth::DeviceClass 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
.device_class
.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_bluetooth::DeviceClass));
fidl::decode!(
fidl_fuchsia_bluetooth::DeviceClass,
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 = <fidl::encoding::Vector<
fidl_fuchsia_bluetooth_bredr::ServiceDefinition,
32,
> 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.service_definition.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<fidl_fuchsia_bluetooth_bredr::ServiceDefinition, 32>));
fidl::decode!(fidl::encoding::Vector<fidl_fuchsia_bluetooth_bredr::ServiceDefinition, 32>, 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 ControllerParameters {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.device_class {
return 2;
}
if let Some(_) = self.local_name {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for ControllerParameters {
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
}
}
impl fidl::encoding::ValueTypeMarker for ControllerParameters {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<ControllerParameters> for &ControllerParameters {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<ControllerParameters>(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::BoundedString<248>>(
self.local_name.as_ref().map(
<fidl::encoding::BoundedString<248> 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_fuchsia_bluetooth::DeviceClass>(
self.device_class.as_ref().map(<fidl_fuchsia_bluetooth::DeviceClass as fidl::encoding::ValueTypeMarker>::borrow),
encoder, offset + cur_offset, depth
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for ControllerParameters {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
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::BoundedString<248> 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
.local_name
.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::BoundedString<248>));
fidl::decode!(
fidl::encoding::BoundedString<248>,
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_fuchsia_bluetooth::DeviceClass 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
.device_class
.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_bluetooth::DeviceClass));
fidl::decode!(
fidl_fuchsia_bluetooth::DeviceClass,
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 EmulatorSettings {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.le_acl_buffer_settings {
return 5;
}
if let Some(_) = self.acl_buffer_settings {
return 4;
}
if let Some(_) = self.extended_advertising {
return 3;
}
if let Some(_) = self.hci_config {
return 2;
}
if let Some(_) = self.address {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for EmulatorSettings {
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
}
}
impl fidl::encoding::ValueTypeMarker for EmulatorSettings {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<EmulatorSettings> for &EmulatorSettings {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<EmulatorSettings>(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_fuchsia_bluetooth::Address>(
self.address.as_ref().map(
<fidl_fuchsia_bluetooth::Address 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::<HciConfig>(
self.hci_config
.as_ref()
.map(<HciConfig 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::<bool>(
self.extended_advertising
.as_ref()
.map(<bool 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::<AclBufferSettings>(
self.acl_buffer_settings
.as_ref()
.map(<AclBufferSettings 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::<AclBufferSettings>(
self.le_acl_buffer_settings
.as_ref()
.map(<AclBufferSettings as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for EmulatorSettings {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
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_fuchsia_bluetooth::Address 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
.address
.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_bluetooth::Address));
fidl::decode!(
fidl_fuchsia_bluetooth::Address,
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 =
<HciConfig 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.hci_config.get_or_insert_with(|| fidl::new_empty!(HciConfig));
fidl::decode!(HciConfig, 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 =
<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.extended_advertising.get_or_insert_with(|| fidl::new_empty!(bool));
fidl::decode!(bool, 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 =
<AclBufferSettings 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
.acl_buffer_settings
.get_or_insert_with(|| fidl::new_empty!(AclBufferSettings));
fidl::decode!(AclBufferSettings, 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 =
<AclBufferSettings 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
.le_acl_buffer_settings
.get_or_insert_with(|| fidl::new_empty!(AclBufferSettings));
fidl::decode!(AclBufferSettings, 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 LeScanState {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.address_type {
return 6;
}
if let Some(_) = self.filter_duplicates {
return 5;
}
if let Some(_) = self.window {
return 4;
}
if let Some(_) = self.interval {
return 3;
}
if let Some(_) = self.active {
return 2;
}
if let Some(_) = self.enabled {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for LeScanState {
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
}
}
impl fidl::encoding::ValueTypeMarker for LeScanState {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<LeScanState> for &LeScanState {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<LeScanState>(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::<bool>(
self.enabled.as_ref().map(<bool 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::<bool>(
self.active.as_ref().map(<bool 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::<u16>(
self.interval.as_ref().map(<u16 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::<u16>(
self.window.as_ref().map(<u16 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>(
self.filter_duplicates
.as_ref()
.map(<bool as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 6 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (6 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<fidl_fuchsia_bluetooth::AddressType>(
self.address_type.as_ref().map(<fidl_fuchsia_bluetooth::AddressType as fidl::encoding::ValueTypeMarker>::borrow),
encoder, offset + cur_offset, depth
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for LeScanState {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
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 =
<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.enabled.get_or_insert_with(|| fidl::new_empty!(bool));
fidl::decode!(bool, 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 =
<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.active.get_or_insert_with(|| fidl::new_empty!(bool));
fidl::decode!(bool, 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 =
<u16 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.interval.get_or_insert_with(|| fidl::new_empty!(u16));
fidl::decode!(u16, 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 =
<u16 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.window.get_or_insert_with(|| fidl::new_empty!(u16));
fidl::decode!(u16, 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.filter_duplicates.get_or_insert_with(|| fidl::new_empty!(bool));
fidl::decode!(bool, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 6 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size = <fidl_fuchsia_bluetooth::AddressType 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
.address_type
.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_bluetooth::AddressType));
fidl::decode!(
fidl_fuchsia_bluetooth::AddressType,
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 LegacyAdvertisingState {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.scan_response {
return 7;
}
if let Some(_) = self.advertising_data {
return 6;
}
if let Some(_) = self.interval_max {
return 5;
}
if let Some(_) = self.interval_min {
return 4;
}
if let Some(_) = self.address_type {
return 3;
}
if let Some(_) = self.type_ {
return 2;
}
if let Some(_) = self.enabled {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for LegacyAdvertisingState {
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
}
}
impl fidl::encoding::ValueTypeMarker for LegacyAdvertisingState {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<LegacyAdvertisingState> for &LegacyAdvertisingState {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<LegacyAdvertisingState>(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::<bool>(
self.enabled.as_ref().map(<bool 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::<LegacyAdvertisingType>(
self.type_
.as_ref()
.map(<LegacyAdvertisingType 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::<fidl_fuchsia_bluetooth::AddressType>(
self.address_type.as_ref().map(<fidl_fuchsia_bluetooth::AddressType 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::<u16>(
self.interval_min.as_ref().map(<u16 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::<u16>(
self.interval_max.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 6 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (6 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 31>>(
self.advertising_data.as_ref().map(
<fidl::encoding::Vector<u8, 31> as fidl::encoding::ValueTypeMarker>::borrow,
),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 7 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (7 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<fidl::encoding::Vector<u8, 31>>(
self.scan_response.as_ref().map(
<fidl::encoding::Vector<u8, 31> as fidl::encoding::ValueTypeMarker>::borrow,
),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for LegacyAdvertisingState {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
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 =
<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.enabled.get_or_insert_with(|| fidl::new_empty!(bool));
fidl::decode!(bool, 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 =
<LegacyAdvertisingType 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.type_.get_or_insert_with(|| fidl::new_empty!(LegacyAdvertisingType));
fidl::decode!(LegacyAdvertisingType, 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 = <fidl_fuchsia_bluetooth::AddressType 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
.address_type
.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_bluetooth::AddressType));
fidl::decode!(
fidl_fuchsia_bluetooth::AddressType,
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 =
<u16 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.interval_min.get_or_insert_with(|| fidl::new_empty!(u16));
fidl::decode!(u16, 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 =
<u16 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.interval_max.get_or_insert_with(|| fidl::new_empty!(u16));
fidl::decode!(u16, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 6 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<fidl::encoding::Vector<u8, 31> 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
.advertising_data
.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 31>));
fidl::decode!(fidl::encoding::Vector<u8, 31>, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 7 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size =
<fidl::encoding::Vector<u8, 31> 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
.scan_response
.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::Vector<u8, 31>));
fidl::decode!(fidl::encoding::Vector<u8, 31>, 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 LowEnergyPeerParameters {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.scan_response {
return 4;
}
if let Some(_) = self.advertisement {
return 3;
}
if let Some(_) = self.connectable {
return 2;
}
if let Some(_) = self.address {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for LowEnergyPeerParameters {
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
}
}
impl fidl::encoding::ValueTypeMarker for LowEnergyPeerParameters {
type Borrowed<'a> = &'a Self;
fn borrow<'a>(
value: &'a <Self as fidl::encoding::TypeMarker>::Owned,
) -> Self::Borrowed<'a> {
value
}
}
unsafe impl fidl::encoding::Encode<LowEnergyPeerParameters> for &LowEnergyPeerParameters {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<LowEnergyPeerParameters>(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_fuchsia_bluetooth::Address>(
self.address.as_ref().map(
<fidl_fuchsia_bluetooth::Address 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::<bool>(
self.connectable.as_ref().map(<bool 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::<AdvertisingData>(
self.advertisement
.as_ref()
.map(<AdvertisingData 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::<AdvertisingData>(
self.scan_response
.as_ref()
.map(<AdvertisingData as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for LowEnergyPeerParameters {
#[inline(always)]
fn new_empty() -> Self {
Self::default()
}
unsafe fn decode(
&mut self,
decoder: &mut fidl::encoding::Decoder<'_>,
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_fuchsia_bluetooth::Address 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
.address
.get_or_insert_with(|| fidl::new_empty!(fidl_fuchsia_bluetooth::Address));
fidl::decode!(
fidl_fuchsia_bluetooth::Address,
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 =
<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.connectable.get_or_insert_with(|| fidl::new_empty!(bool));
fidl::decode!(bool, 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 =
<AdvertisingData 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.advertisement.get_or_insert_with(|| fidl::new_empty!(AdvertisingData));
fidl::decode!(AdvertisingData, 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 =
<AdvertisingData 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.scan_response.get_or_insert_with(|| fidl::new_empty!(AdvertisingData));
fidl::decode!(AdvertisingData, 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(())
}
}
}