Skip to main content

pw_bluetooth_hci_h4_emb/
hci_h4.rs

1#![allow(dead_code, unused_imports, unused_variables, non_camel_case_types, unused_parens)]
2
3use emboss_runtime::prelude::*;
4pub use emboss_runtime::{BitFlag, Error, Flag, InfallibleRead, Int, MutStorage, Storage, TryRead, TryWrite, UInt, View, VirtualField};
5
6
7
8#[derive(Copy, Clone, Debug, Eq, PartialEq)]
9#[repr(u64)]
10pub enum H4PacketType {
11    UNKNOWN = 0,
12    COMMAND = 1,
13    ACL_DATA = 2,
14    SYNC_DATA = 3,
15    EVENT = 4,
16    ISO_DATA = 5,
17
18}
19
20impl core::convert::From<H4PacketType> for u8 { fn from(val: H4PacketType) -> Self { val as u8 } }
21impl core::convert::From<H4PacketType> for u16 { fn from(val: H4PacketType) -> Self { val as u16 } }
22impl core::convert::From<H4PacketType> for u32 { fn from(val: H4PacketType) -> Self { val as u32 } }
23impl core::convert::From<H4PacketType> for u64 { fn from(val: H4PacketType) -> Self { val as u64 } }
24impl core::convert::From<H4PacketType> for i8 { fn from(val: H4PacketType) -> Self { val as i8 } }
25impl core::convert::From<H4PacketType> for i16 { fn from(val: H4PacketType) -> Self { val as i16 } }
26impl core::convert::From<H4PacketType> for i32 { fn from(val: H4PacketType) -> Self { val as i32 } }
27impl core::convert::From<H4PacketType> for i64 { fn from(val: H4PacketType) -> Self { val as i64 } }
28
29impl emboss_runtime::SafeCmp<H4PacketType> for H4PacketType {
30    fn safe_eq(&self, other: Self) -> bool { *self == other }
31    fn safe_less(&self, other: Self) -> bool { (*self as u64) < (other as u64) }
32}
33
34impl emboss_runtime::SafeCmp<u64> for H4PacketType {
35    fn safe_eq(&self, other: u64) -> bool { emboss_runtime::SafeCmp::safe_eq(&(*self as u64), other) }
36    fn safe_less(&self, other: u64) -> bool { emboss_runtime::SafeCmp::safe_less(&(*self as u64), other) }
37}
38
39impl emboss_runtime::SafeCmp<i64> for H4PacketType {
40    fn safe_eq(&self, other: i64) -> bool { emboss_runtime::SafeCmp::safe_eq(&(*self as u64), other) }
41    fn safe_less(&self, other: i64) -> bool { emboss_runtime::SafeCmp::safe_less(&(*self as u64), other) }
42}
43
44impl emboss_runtime::SafeCmp<i32> for H4PacketType {
45    fn safe_eq(&self, other: i32) -> bool { emboss_runtime::SafeCmp::safe_eq(&(*self as u64), other as i64) }
46    fn safe_less(&self, other: i32) -> bool { emboss_runtime::SafeCmp::safe_less(&(*self as u64), other as i64) }
47}
48
49impl emboss_runtime::SafeCmp<u32> for H4PacketType {
50    fn safe_eq(&self, other: u32) -> bool { emboss_runtime::SafeCmp::safe_eq(&(*self as u64), other as u64) }
51    fn safe_less(&self, other: u32) -> bool { emboss_runtime::SafeCmp::safe_less(&(*self as u64), other as u64) }
52}
53
54impl emboss_runtime::SafeCmp<H4PacketType> for u64 {
55    fn safe_eq(&self, other: H4PacketType) -> bool { emboss_runtime::SafeCmp::safe_eq(self, other as u64) }
56    fn safe_less(&self, other: H4PacketType) -> bool { emboss_runtime::SafeCmp::safe_less(self, other as u64) }
57}
58
59impl emboss_runtime::SafeCmp<H4PacketType> for i64 {
60    fn safe_eq(&self, other: H4PacketType) -> bool { emboss_runtime::SafeCmp::safe_eq(self, other as u64) }
61    fn safe_less(&self, other: H4PacketType) -> bool { emboss_runtime::SafeCmp::safe_less(self, other as u64) }
62}
63
64impl<V: core::convert::Into<u64> + core::marker::Copy> emboss_runtime::TryFromRaw<V> for H4PacketType {
65    fn try_from_raw(val: V) -> core::result::Result<Self, emboss_runtime::Error<V>> {
66        let v_raw: u64 = val.into();
67        match v_raw {
68            0 => Ok(H4PacketType::UNKNOWN),
69            1 => Ok(H4PacketType::COMMAND),
70            2 => Ok(H4PacketType::ACL_DATA),
71            3 => Ok(H4PacketType::SYNC_DATA),
72            4 => Ok(H4PacketType::EVENT),
73            5 => Ok(H4PacketType::ISO_DATA),
74
75            _ => Err(emboss_runtime::Error::UnknownEnum(val)),
76        }
77    }
78}
79
80impl H4PacketType {
81
82}
83