#![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 type DeviceName = String;
pub type PeerIdString = String;
pub type UuidString = String;
pub const MAJOR_DEVICE_CLASS_AUDIO_VIDEO: u32 = 1024;
pub const MAJOR_DEVICE_CLASS_COMPUTER: u32 = 256;
pub const MAJOR_DEVICE_CLASS_HEALTH: u32 = 2304;
pub const MAJOR_DEVICE_CLASS_IMAGING: u32 = 1536;
pub const MAJOR_DEVICE_CLASS_LAN: u32 = 768;
pub const MAJOR_DEVICE_CLASS_MASK: u32 = 7936;
pub const MAJOR_DEVICE_CLASS_MISCELLANEOUS: u32 = 0;
pub const MAJOR_DEVICE_CLASS_PERIPHERAL: u32 = 1280;
pub const MAJOR_DEVICE_CLASS_PHONE: u32 = 512;
pub const MAJOR_DEVICE_CLASS_TOY: u32 = 2048;
pub const MAJOR_DEVICE_CLASS_UNCATEGORIZED: u32 = 7936;
pub const MAJOR_DEVICE_CLASS_WEARABLE: u32 = 1792;
pub const MAX_DEVICE_NAME_LENGTH: u8 = 248;
pub const UUID_STRING_REPRESENTATION_LENGTH: u8 = 36;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u8)]
pub enum AddressType {
Public = 1,
Random = 2,
}
impl AddressType {
#[inline]
pub fn from_primitive(prim: u8) -> Option<Self> {
match prim {
1 => Some(Self::Public),
2 => Some(Self::Random),
_ => 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)]
pub enum Appearance {
Unknown,
Phone,
Computer,
Watch,
WatchSports,
Clock,
Display,
RemoteControl,
EyeGlasses,
Tag,
Keyring,
MediaPlayer,
BarcodeScanner,
Thermometer,
ThermometerEar,
HeartRateSensor,
HeartRateSensorBelt,
BloodPressure,
BloodPressureArm,
BloodPressureWrist,
Hid,
HidKeyboard,
HidMouse,
HidJoystick,
HidGamepad,
HidDigitizerTablet,
HidCardReader,
HidDigitalPen,
HidBarcodeScanner,
GlucoseMeter,
RunningWalkingSensor,
RunningWalkingSensorInShoe,
RunningWalkingSensorOnShoe,
RunningWalkingSensorOnHip,
Cycling,
CyclingComputer,
CyclingSpeedSensor,
CyclingCadenceSensor,
CyclingPowerSensor,
CyclingSpeedAndCadenceSensor,
PulseOximeter,
PulseOximeterFingertip,
PulseOximeterWrist,
WeightScale,
PersonalMobility,
PersonalMobilityWheelchair,
PersonalMobilityScooter,
GlucoseMonitor,
SportsActivity,
SportsActivityLocationDisplay,
SportsActivityLocationAndNavDisplay,
SportsActivityLocationPod,
SportsActivityLocationAndNavPod,
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u16,
},
}
#[macro_export]
macro_rules! AppearanceUnknown {
() => {
_
};
}
impl Appearance {
#[inline]
pub fn from_primitive(prim: u16) -> Option<Self> {
match prim {
0 => Some(Self::Unknown),
64 => Some(Self::Phone),
128 => Some(Self::Computer),
192 => Some(Self::Watch),
193 => Some(Self::WatchSports),
256 => Some(Self::Clock),
320 => Some(Self::Display),
384 => Some(Self::RemoteControl),
448 => Some(Self::EyeGlasses),
512 => Some(Self::Tag),
576 => Some(Self::Keyring),
640 => Some(Self::MediaPlayer),
704 => Some(Self::BarcodeScanner),
768 => Some(Self::Thermometer),
769 => Some(Self::ThermometerEar),
832 => Some(Self::HeartRateSensor),
833 => Some(Self::HeartRateSensorBelt),
896 => Some(Self::BloodPressure),
897 => Some(Self::BloodPressureArm),
898 => Some(Self::BloodPressureWrist),
960 => Some(Self::Hid),
961 => Some(Self::HidKeyboard),
962 => Some(Self::HidMouse),
963 => Some(Self::HidJoystick),
964 => Some(Self::HidGamepad),
965 => Some(Self::HidDigitizerTablet),
966 => Some(Self::HidCardReader),
967 => Some(Self::HidDigitalPen),
968 => Some(Self::HidBarcodeScanner),
1024 => Some(Self::GlucoseMeter),
1088 => Some(Self::RunningWalkingSensor),
1089 => Some(Self::RunningWalkingSensorInShoe),
1090 => Some(Self::RunningWalkingSensorOnShoe),
1091 => Some(Self::RunningWalkingSensorOnHip),
1152 => Some(Self::Cycling),
1153 => Some(Self::CyclingComputer),
1154 => Some(Self::CyclingSpeedSensor),
1155 => Some(Self::CyclingCadenceSensor),
1156 => Some(Self::CyclingPowerSensor),
1157 => Some(Self::CyclingSpeedAndCadenceSensor),
3136 => Some(Self::PulseOximeter),
3137 => Some(Self::PulseOximeterFingertip),
3138 => Some(Self::PulseOximeterWrist),
3200 => Some(Self::WeightScale),
3264 => Some(Self::PersonalMobility),
3265 => Some(Self::PersonalMobilityWheelchair),
3266 => Some(Self::PersonalMobilityScooter),
3328 => Some(Self::GlucoseMonitor),
5184 => Some(Self::SportsActivity),
5185 => Some(Self::SportsActivityLocationDisplay),
5186 => Some(Self::SportsActivityLocationAndNavDisplay),
5187 => Some(Self::SportsActivityLocationPod),
5188 => Some(Self::SportsActivityLocationAndNavPod),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u16) -> Self {
match prim {
0 => Self::Unknown,
64 => Self::Phone,
128 => Self::Computer,
192 => Self::Watch,
193 => Self::WatchSports,
256 => Self::Clock,
320 => Self::Display,
384 => Self::RemoteControl,
448 => Self::EyeGlasses,
512 => Self::Tag,
576 => Self::Keyring,
640 => Self::MediaPlayer,
704 => Self::BarcodeScanner,
768 => Self::Thermometer,
769 => Self::ThermometerEar,
832 => Self::HeartRateSensor,
833 => Self::HeartRateSensorBelt,
896 => Self::BloodPressure,
897 => Self::BloodPressureArm,
898 => Self::BloodPressureWrist,
960 => Self::Hid,
961 => Self::HidKeyboard,
962 => Self::HidMouse,
963 => Self::HidJoystick,
964 => Self::HidGamepad,
965 => Self::HidDigitizerTablet,
966 => Self::HidCardReader,
967 => Self::HidDigitalPen,
968 => Self::HidBarcodeScanner,
1024 => Self::GlucoseMeter,
1088 => Self::RunningWalkingSensor,
1089 => Self::RunningWalkingSensorInShoe,
1090 => Self::RunningWalkingSensorOnShoe,
1091 => Self::RunningWalkingSensorOnHip,
1152 => Self::Cycling,
1153 => Self::CyclingComputer,
1154 => Self::CyclingSpeedSensor,
1155 => Self::CyclingCadenceSensor,
1156 => Self::CyclingPowerSensor,
1157 => Self::CyclingSpeedAndCadenceSensor,
3136 => Self::PulseOximeter,
3137 => Self::PulseOximeterFingertip,
3138 => Self::PulseOximeterWrist,
3200 => Self::WeightScale,
3264 => Self::PersonalMobility,
3265 => Self::PersonalMobilityWheelchair,
3266 => Self::PersonalMobilityScooter,
3328 => Self::GlucoseMonitor,
5184 => Self::SportsActivity,
5185 => Self::SportsActivityLocationDisplay,
5186 => Self::SportsActivityLocationAndNavDisplay,
5187 => Self::SportsActivityLocationPod,
5188 => Self::SportsActivityLocationAndNavPod,
unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
}
}
#[inline]
pub fn unknown() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0xffff }
}
#[inline]
pub const fn into_primitive(self) -> u16 {
match self {
Self::Unknown => 0,
Self::Phone => 64,
Self::Computer => 128,
Self::Watch => 192,
Self::WatchSports => 193,
Self::Clock => 256,
Self::Display => 320,
Self::RemoteControl => 384,
Self::EyeGlasses => 448,
Self::Tag => 512,
Self::Keyring => 576,
Self::MediaPlayer => 640,
Self::BarcodeScanner => 704,
Self::Thermometer => 768,
Self::ThermometerEar => 769,
Self::HeartRateSensor => 832,
Self::HeartRateSensorBelt => 833,
Self::BloodPressure => 896,
Self::BloodPressureArm => 897,
Self::BloodPressureWrist => 898,
Self::Hid => 960,
Self::HidKeyboard => 961,
Self::HidMouse => 962,
Self::HidJoystick => 963,
Self::HidGamepad => 964,
Self::HidDigitizerTablet => 965,
Self::HidCardReader => 966,
Self::HidDigitalPen => 967,
Self::HidBarcodeScanner => 968,
Self::GlucoseMeter => 1024,
Self::RunningWalkingSensor => 1088,
Self::RunningWalkingSensorInShoe => 1089,
Self::RunningWalkingSensorOnShoe => 1090,
Self::RunningWalkingSensorOnHip => 1091,
Self::Cycling => 1152,
Self::CyclingComputer => 1153,
Self::CyclingSpeedSensor => 1154,
Self::CyclingCadenceSensor => 1155,
Self::CyclingPowerSensor => 1156,
Self::CyclingSpeedAndCadenceSensor => 1157,
Self::PulseOximeter => 3136,
Self::PulseOximeterFingertip => 3137,
Self::PulseOximeterWrist => 3138,
Self::WeightScale => 3200,
Self::PersonalMobility => 3264,
Self::PersonalMobilityWheelchair => 3265,
Self::PersonalMobilityScooter => 3266,
Self::GlucoseMonitor => 3328,
Self::SportsActivity => 5184,
Self::SportsActivityLocationDisplay => 5185,
Self::SportsActivityLocationAndNavDisplay => 5186,
Self::SportsActivityLocationPod => 5187,
Self::SportsActivityLocationAndNavPod => 5188,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { unknown_ordinal: _ } => true,
_ => false,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum AssignedCodingFormat {
ULawLog,
ALawLog,
Cvsd,
Transparent,
LinearPcm,
Msbc,
Lc3,
G729A,
#[doc(hidden)]
__SourceBreaking {
unknown_ordinal: u8,
},
}
#[macro_export]
macro_rules! AssignedCodingFormatUnknown {
() => {
_
};
}
impl AssignedCodingFormat {
#[inline]
pub fn from_primitive(prim: u8) -> Option<Self> {
match prim {
0 => Some(Self::ULawLog),
1 => Some(Self::ALawLog),
2 => Some(Self::Cvsd),
3 => Some(Self::Transparent),
4 => Some(Self::LinearPcm),
5 => Some(Self::Msbc),
6 => Some(Self::Lc3),
7 => Some(Self::G729A),
_ => None,
}
}
#[inline]
pub fn from_primitive_allow_unknown(prim: u8) -> Self {
match prim {
0 => Self::ULawLog,
1 => Self::ALawLog,
2 => Self::Cvsd,
3 => Self::Transparent,
4 => Self::LinearPcm,
5 => Self::Msbc,
6 => Self::Lc3,
7 => Self::G729A,
unknown_ordinal => Self::__SourceBreaking { unknown_ordinal },
}
}
#[inline]
pub fn unknown() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0xff }
}
#[inline]
pub const fn into_primitive(self) -> u8 {
match self {
Self::ULawLog => 0,
Self::ALawLog => 1,
Self::Cvsd => 2,
Self::Transparent => 3,
Self::LinearPcm => 4,
Self::Msbc => 5,
Self::Lc3 => 6,
Self::G729A => 7,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { unknown_ordinal: _ } => true,
_ => false,
}
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[repr(u32)]
pub enum ConnectionRole {
Leader = 1,
Follower = 2,
}
impl ConnectionRole {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
1 => Some(Self::Leader),
2 => Some(Self::Follower),
_ => 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 DataDirection {
Input = 1,
Output = 2,
}
impl DataDirection {
#[inline]
pub fn from_primitive(prim: u8) -> Option<Self> {
match prim {
1 => Some(Self::Input),
2 => Some(Self::Output),
_ => 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(u32)]
pub enum ErrorCode {
Unknown = 0,
Failed = 1,
Canceled = 2,
InProgress = 3,
TimedOut = 4,
NotFound = 5,
NotSupported = 6,
BluetoothNotAvailable = 7,
BadState = 8,
InvalidArguments = 9,
Already = 10,
ProtocolError = 11,
}
impl ErrorCode {
#[inline]
pub fn from_primitive(prim: u32) -> Option<Self> {
match prim {
0 => Some(Self::Unknown),
1 => Some(Self::Failed),
2 => Some(Self::Canceled),
3 => Some(Self::InProgress),
4 => Some(Self::TimedOut),
5 => Some(Self::NotFound),
6 => Some(Self::NotSupported),
7 => Some(Self::BluetoothNotAvailable),
8 => Some(Self::BadState),
9 => Some(Self::InvalidArguments),
10 => Some(Self::Already),
11 => Some(Self::ProtocolError),
_ => 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(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Address {
pub type_: AddressType,
pub bytes: [u8; 6],
}
impl fidl::Persistable for Address {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Bool {
pub value: bool,
}
impl fidl::Persistable for Bool {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct DeviceClass {
pub value: u32,
}
impl fidl::Persistable for DeviceClass {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Error {
pub error_code: ErrorCode,
pub protocol_error_code: u32,
pub description: Option<String>,
}
impl fidl::Persistable for Error {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct HostId {
pub value: u64,
}
impl fidl::Persistable for HostId {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct Int8 {
pub value: i8,
}
impl fidl::Persistable for Int8 {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct PeerId {
pub value: u64,
}
impl fidl::Persistable for PeerId {}
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Status {
pub error: Option<Box<Error>>,
}
impl fidl::Persistable for Status {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct UInt16 {
pub value: u16,
}
impl fidl::Persistable for UInt16 {}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(C)]
pub struct Uuid {
pub value: [u8; 16],
}
impl fidl::Persistable for Uuid {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct CodecAttributes {
pub codec_id: Option<CodecId>,
pub codec_configuration: Option<Vec<u8>>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for CodecAttributes {}
#[derive(Clone, Debug, Default, PartialEq)]
pub struct VendorCodingFormat {
pub company_id: Option<u16>,
pub vendor_id: Option<u16>,
#[doc(hidden)]
pub __source_breaking: fidl::marker::SourceBreaking,
}
impl fidl::Persistable for VendorCodingFormat {}
#[derive(Clone, Debug)]
pub enum CodecId {
AssignedFormat(AssignedCodingFormat),
VendorFormat(VendorCodingFormat),
#[doc(hidden)]
__SourceBreaking { unknown_ordinal: u64 },
}
#[macro_export]
macro_rules! CodecIdUnknown {
() => {
_
};
}
impl PartialEq for CodecId {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::AssignedFormat(x), Self::AssignedFormat(y)) => *x == *y,
(Self::VendorFormat(x), Self::VendorFormat(y)) => *x == *y,
_ => false,
}
}
}
impl CodecId {
#[inline]
pub fn ordinal(&self) -> u64 {
match *self {
Self::AssignedFormat(_) => 1,
Self::VendorFormat(_) => 2,
Self::__SourceBreaking { unknown_ordinal } => unknown_ordinal,
}
}
#[inline]
pub fn unknown_variant_for_testing() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
pub fn is_unknown(&self) -> bool {
match self {
Self::__SourceBreaking { .. } => true,
_ => false,
}
}
}
impl fidl::Persistable for CodecId {}
mod internal {
use super::*;
unsafe impl fidl::encoding::TypeMarker for AddressType {
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 AddressType {
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 AddressType {
#[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 AddressType {
#[inline(always)]
fn new_empty() -> Self {
Self::Public
}
#[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 Appearance {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
std::mem::align_of::<u16>()
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
std::mem::size_of::<u16>()
}
#[inline(always)]
fn encode_is_copy() -> bool {
false
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for Appearance {
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 Appearance {
#[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 Appearance {
#[inline(always)]
fn new_empty() -> Self {
Self::unknown()
}
#[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::<u16>(offset);
*self = Self::from_primitive_allow_unknown(prim);
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for AssignedCodingFormat {
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 {
false
}
#[inline(always)]
fn decode_is_copy() -> bool {
false
}
}
impl fidl::encoding::ValueTypeMarker for AssignedCodingFormat {
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 AssignedCodingFormat {
#[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 AssignedCodingFormat {
#[inline(always)]
fn new_empty() -> Self {
Self::unknown()
}
#[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_allow_unknown(prim);
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for ConnectionRole {
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 ConnectionRole {
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 ConnectionRole {
#[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 ConnectionRole {
#[inline(always)]
fn new_empty() -> Self {
Self::Leader
}
#[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 DataDirection {
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 DataDirection {
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 DataDirection {
#[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 DataDirection {
#[inline(always)]
fn new_empty() -> Self {
Self::Input
}
#[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 ErrorCode {
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 ErrorCode {
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 ErrorCode {
#[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 ErrorCode {
#[inline(always)]
fn new_empty() -> Self {
Self::Unknown
}
#[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 Address {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
1
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
7
}
}
impl fidl::encoding::ValueTypeMarker for Address {
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<Address> for &Address {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Address>(offset);
fidl::encoding::Encode::<Address>::encode(
(
<AddressType as fidl::encoding::ValueTypeMarker>::borrow(&self.type_),
<fidl::encoding::Array<u8, 6> as fidl::encoding::ValueTypeMarker>::borrow(
&self.bytes,
),
),
encoder,
offset,
_depth,
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<AddressType>,
T1: fidl::encoding::Encode<fidl::encoding::Array<u8, 6>>,
> fidl::encoding::Encode<Address> 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::<Address>(offset);
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 1, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for Address {
#[inline(always)]
fn new_empty() -> Self {
Self {
type_: fidl::new_empty!(AddressType),
bytes: fidl::new_empty!(fidl::encoding::Array<u8, 6>),
}
}
#[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!(AddressType, &mut self.type_, decoder, offset + 0, _depth)?;
fidl::decode!(fidl::encoding::Array<u8, 6>, &mut self.bytes, decoder, offset + 1, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for Bool {
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 Bool {
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<Bool> for &Bool {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Bool>(offset);
fidl::encoding::Encode::<Bool>::encode(
(<bool as fidl::encoding::ValueTypeMarker>::borrow(&self.value),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<bool>> fidl::encoding::Encode<Bool> for (T0,) {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Bool>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for Bool {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(bool) }
}
#[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!(bool, &mut self.value, decoder, offset + 0, _depth)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for DeviceClass {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
4
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
impl fidl::encoding::ValueTypeMarker for DeviceClass {
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<DeviceClass> for &DeviceClass {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceClass>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut DeviceClass).write_unaligned((self as *const DeviceClass).read());
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<u32>> fidl::encoding::Encode<DeviceClass> for (T0,) {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<DeviceClass>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for DeviceClass {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(u32) }
}
#[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) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 4);
}
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for Error {
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::ValueTypeMarker for Error {
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<Error> for &Error {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Error>(offset);
fidl::encoding::Encode::<Error>::encode(
(
<ErrorCode as fidl::encoding::ValueTypeMarker>::borrow(&self.error_code),
<u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.protocol_error_code),
<fidl::encoding::Optional<fidl::encoding::UnboundedString> as fidl::encoding::ValueTypeMarker>::borrow(&self.description),
),
encoder, offset, _depth
)
}
}
unsafe impl<
T0: fidl::encoding::Encode<ErrorCode>,
T1: fidl::encoding::Encode<u32>,
T2: fidl::encoding::Encode<fidl::encoding::Optional<fidl::encoding::UnboundedString>>,
> fidl::encoding::Encode<Error> for (T0, T1, T2)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Error>(offset);
self.0.encode(encoder, offset + 0, depth)?;
self.1.encode(encoder, offset + 4, depth)?;
self.2.encode(encoder, offset + 8, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for Error {
#[inline(always)]
fn new_empty() -> Self {
Self {
error_code: fidl::new_empty!(ErrorCode),
protocol_error_code: fidl::new_empty!(u32),
description: fidl::new_empty!(
fidl::encoding::Optional<fidl::encoding::UnboundedString>
),
}
}
#[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!(ErrorCode, &mut self.error_code, decoder, offset + 0, _depth)?;
fidl::decode!(u32, &mut self.protocol_error_code, decoder, offset + 4, _depth)?;
fidl::decode!(
fidl::encoding::Optional<fidl::encoding::UnboundedString>,
&mut self.description,
decoder,
offset + 8,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for HostId {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
impl fidl::encoding::ValueTypeMarker for HostId {
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<HostId> for &HostId {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HostId>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut HostId).write_unaligned((self as *const HostId).read());
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<u64>> fidl::encoding::Encode<HostId> for (T0,) {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<HostId>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for HostId {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(u64) }
}
#[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) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
}
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for Int8 {
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
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
impl fidl::encoding::ValueTypeMarker for Int8 {
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<Int8> for &Int8 {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Int8>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut Int8).write_unaligned((self as *const Int8).read());
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<i8>> fidl::encoding::Encode<Int8> for (T0,) {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Int8>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for Int8 {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(i8) }
}
#[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) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 1);
}
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for PeerId {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
impl fidl::encoding::ValueTypeMarker for PeerId {
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<PeerId> for &PeerId {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerId>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut PeerId).write_unaligned((self as *const PeerId).read());
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<u64>> fidl::encoding::Encode<PeerId> for (T0,) {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<PeerId>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for PeerId {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(u64) }
}
#[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) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 8);
}
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for Status {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
8
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
8
}
}
impl fidl::encoding::ValueTypeMarker for Status {
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<Status> for &Status {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Status>(offset);
fidl::encoding::Encode::<Status>::encode(
(<fidl::encoding::Boxed<Error> as fidl::encoding::ValueTypeMarker>::borrow(
&self.error,
),),
encoder,
offset,
_depth,
)
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::Boxed<Error>>>
fidl::encoding::Encode<Status> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Status>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for Status {
#[inline(always)]
fn new_empty() -> Self {
Self { error: fidl::new_empty!(fidl::encoding::Boxed<Error>) }
}
#[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::Boxed<Error>,
&mut self.error,
decoder,
offset + 0,
_depth
)?;
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for UInt16 {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
2
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
2
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
impl fidl::encoding::ValueTypeMarker for UInt16 {
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<UInt16> for &UInt16 {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<UInt16>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut UInt16).write_unaligned((self as *const UInt16).read());
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<u16>> fidl::encoding::Encode<UInt16> for (T0,) {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<UInt16>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for UInt16 {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(u16) }
}
#[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) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 2);
}
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for Uuid {
type Owned = Self;
#[inline(always)]
fn inline_align(_context: fidl::encoding::Context) -> usize {
1
}
#[inline(always)]
fn inline_size(_context: fidl::encoding::Context) -> usize {
16
}
#[inline(always)]
fn encode_is_copy() -> bool {
true
}
#[inline(always)]
fn decode_is_copy() -> bool {
true
}
}
impl fidl::encoding::ValueTypeMarker for Uuid {
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<Uuid> for &Uuid {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Uuid>(offset);
unsafe {
let buf_ptr = encoder.buf.as_mut_ptr().add(offset);
(buf_ptr as *mut Uuid).write_unaligned((self as *const Uuid).read());
}
Ok(())
}
}
unsafe impl<T0: fidl::encoding::Encode<fidl::encoding::Array<u8, 16>>>
fidl::encoding::Encode<Uuid> for (T0,)
{
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<Uuid>(offset);
self.0.encode(encoder, offset + 0, depth)?;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for Uuid {
#[inline(always)]
fn new_empty() -> Self {
Self { value: fidl::new_empty!(fidl::encoding::Array<u8, 16>) }
}
#[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) };
unsafe {
std::ptr::copy_nonoverlapping(buf_ptr, self as *mut Self as *mut u8, 16);
}
Ok(())
}
}
impl CodecAttributes {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.codec_configuration {
return 2;
}
if let Some(_) = self.codec_id {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for CodecAttributes {
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 CodecAttributes {
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<CodecAttributes> for &CodecAttributes {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CodecAttributes>(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::<CodecId>(
self.codec_id.as_ref().map(<CodecId as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
if 2 > max_ordinal {
return Ok(());
}
let cur_offset: usize = (2 - 1) * envelope_size;
encoder.padding(offset + _prev_end_offset, cur_offset - _prev_end_offset);
fidl::encoding::encode_in_envelope_optional::<fidl::encoding::UnboundedVector<u8>>(
self.codec_configuration.as_ref().map(<fidl::encoding::UnboundedVector<u8> as fidl::encoding::ValueTypeMarker>::borrow),
encoder, offset + cur_offset, depth
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for CodecAttributes {
#[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 =
<CodecId 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.codec_id.get_or_insert_with(|| fidl::new_empty!(CodecId));
fidl::decode!(CodecId, val_ref, decoder, inner_offset, inner_depth)?;
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize)
{
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
}
next_offset += envelope_size;
_next_ordinal_to_read += 1;
if next_offset >= end_offset {
return Ok(());
}
while _next_ordinal_to_read < 2 {
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
_next_ordinal_to_read += 1;
next_offset += envelope_size;
}
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
if let Some((inlined, num_bytes, num_handles)) =
fidl::encoding::decode_envelope_header(decoder, next_offset)?
{
let member_inline_size = <fidl::encoding::UnboundedVector<u8> 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
.codec_configuration
.get_or_insert_with(|| fidl::new_empty!(fidl::encoding::UnboundedVector<u8>));
fidl::decode!(
fidl::encoding::UnboundedVector<u8>,
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 VendorCodingFormat {
#[inline(always)]
fn max_ordinal_present(&self) -> u64 {
if let Some(_) = self.vendor_id {
return 2;
}
if let Some(_) = self.company_id {
return 1;
}
0
}
}
unsafe impl fidl::encoding::TypeMarker for VendorCodingFormat {
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 VendorCodingFormat {
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<VendorCodingFormat> for &VendorCodingFormat {
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
mut depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<VendorCodingFormat>(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::<u16>(
self.company_id.as_ref().map(<u16 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::<u16>(
self.vendor_id.as_ref().map(<u16 as fidl::encoding::ValueTypeMarker>::borrow),
encoder,
offset + cur_offset,
depth,
)?;
_prev_end_offset = cur_offset + envelope_size;
Ok(())
}
}
impl fidl::encoding::Decode<Self> for VendorCodingFormat {
#[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 =
<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.company_id.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 < 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 =
<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.vendor_id.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;
while next_offset < end_offset {
_next_ordinal_to_read += 1;
fidl::encoding::decode_unknown_envelope(decoder, next_offset, depth)?;
next_offset += envelope_size;
}
Ok(())
}
}
unsafe impl fidl::encoding::TypeMarker for CodecId {
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 CodecId {
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<CodecId> for &CodecId {
#[inline]
unsafe fn encode(
self,
encoder: &mut fidl::encoding::Encoder<'_>,
offset: usize,
_depth: fidl::encoding::Depth,
) -> fidl::Result<()> {
encoder.debug_check_bounds::<CodecId>(offset);
encoder.write_num::<u64>(self.ordinal(), offset);
match self {
CodecId::AssignedFormat(ref val) => {
fidl::encoding::encode_in_envelope::<AssignedCodingFormat>(
<AssignedCodingFormat as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
CodecId::VendorFormat(ref val) => {
fidl::encoding::encode_in_envelope::<VendorCodingFormat>(
<VendorCodingFormat as fidl::encoding::ValueTypeMarker>::borrow(val),
encoder,
offset + 8,
_depth,
)
}
CodecId::__SourceBreaking { .. } => Err(fidl::Error::UnknownUnionTag),
}
}
}
impl fidl::encoding::Decode<Self> for CodecId {
#[inline(always)]
fn new_empty() -> Self {
Self::__SourceBreaking { unknown_ordinal: 0 }
}
#[inline]
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);
#[allow(unused_variables)]
let next_out_of_line = decoder.next_out_of_line();
let handles_before = decoder.remaining_handles();
let (ordinal, inlined, num_bytes, num_handles) =
fidl::encoding::decode_union_inline_portion(decoder, offset)?;
let member_inline_size = match ordinal {
1 => <AssignedCodingFormat as fidl::encoding::TypeMarker>::inline_size(
decoder.context,
),
2 => {
<VendorCodingFormat as fidl::encoding::TypeMarker>::inline_size(decoder.context)
}
0 => return Err(fidl::Error::UnknownUnionTag),
_ => num_bytes as usize,
};
if inlined != (member_inline_size <= 4) {
return Err(fidl::Error::InvalidInlineBitInEnvelope);
}
let _inner_offset;
if inlined {
decoder.check_inline_envelope_padding(offset + 8, member_inline_size)?;
_inner_offset = offset + 8;
} else {
depth.increment()?;
_inner_offset = decoder.out_of_line_offset(member_inline_size)?;
}
match ordinal {
1 => {
#[allow(irrefutable_let_patterns)]
if let CodecId::AssignedFormat(_) = self {
} else {
*self = CodecId::AssignedFormat(fidl::new_empty!(AssignedCodingFormat));
}
#[allow(irrefutable_let_patterns)]
if let CodecId::AssignedFormat(ref mut val) = self {
fidl::decode!(AssignedCodingFormat, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
2 => {
#[allow(irrefutable_let_patterns)]
if let CodecId::VendorFormat(_) = self {
} else {
*self = CodecId::VendorFormat(fidl::new_empty!(VendorCodingFormat));
}
#[allow(irrefutable_let_patterns)]
if let CodecId::VendorFormat(ref mut val) = self {
fidl::decode!(VendorCodingFormat, val, decoder, _inner_offset, depth)?;
} else {
unreachable!()
}
}
#[allow(deprecated)]
ordinal => {
for _ in 0..num_handles {
decoder.drop_next_handle()?;
}
*self = CodecId::__SourceBreaking { unknown_ordinal: ordinal };
}
}
if !inlined && decoder.next_out_of_line() != next_out_of_line + (num_bytes as usize) {
return Err(fidl::Error::InvalidNumBytesInEnvelope);
}
if handles_before != decoder.remaining_handles() + (num_handles as usize) {
return Err(fidl::Error::InvalidNumHandlesInEnvelope);
}
Ok(())
}
}
}