#[allow(non_snake_case)]
pub mod DDS {
#[allow(non_snake_case)]
pub mod XTypes {
pub type EquivalenceKind = u8;
pub const EK_MINIMAL: u8 = 241;
pub const EK_COMPLETE: u8 = 242;
pub const EK_BOTH: u8 = 243;
pub type TypeKind = u8;
pub const TK_NONE: u8 = 0;
pub const TK_BOOLEAN: u8 = 1;
pub const TK_BYTE: u8 = 2;
pub const TK_INT16: u8 = 3;
pub const TK_INT32: u8 = 4;
pub const TK_INT64: u8 = 5;
pub const TK_UINT16: u8 = 6;
pub const TK_UINT32: u8 = 7;
pub const TK_UINT64: u8 = 8;
pub const TK_FLOAT32: u8 = 9;
pub const TK_FLOAT64: u8 = 10;
pub const TK_FLOAT128: u8 = 11;
pub const TK_CHAR8: u8 = 16;
pub const TK_CHAR16: u8 = 17;
pub const TK_STRING8: u8 = 32;
pub const TK_STRING16: u8 = 33;
pub const TK_ALIAS: u8 = 48;
pub const TK_ENUM: u8 = 64;
pub const TK_BITMASK: u8 = 65;
pub const TK_ANNOTATION: u8 = 80;
pub const TK_STRUCTURE: u8 = 81;
pub const TK_UNION: u8 = 82;
pub const TK_BITSET: u8 = 83;
pub const TK_SEQUENCE: u8 = 96;
pub const TK_ARRAY: u8 = 97;
pub const TK_MAP: u8 = 98;
pub type TypeIdentiferKind = u8;
pub const TI_STRING8_SMALL: u8 = 112;
pub const TI_STRING8_LARGE: u8 = 113;
pub const TI_STRING16_SMALL: u8 = 114;
pub const TI_STRING16_LARGE: u8 = 115;
pub const TI_PLAIN_SEQUENCE_SMALL: u8 = 128;
pub const TI_PLAIN_SEQUENCE_LARGE: u8 = 129;
pub const TI_PLAIN_ARRAY_SMALL: u8 = 144;
pub const TI_PLAIN_ARRAY_LARGE: u8 = 145;
pub const TI_PLAIN_MAP_SMALL: u8 = 160;
pub const TI_PLAIN_MAP_LARGE: u8 = 161;
pub const TI_STRONGLY_CONNECTED_COMPONENT: u8 = 176;
pub const MEMBER_NAME_MAX_LENGTH: i32 = 256;
pub type MemberName = String;
pub const TYPE_NAME_MAX_LENGTH: i32 = 256;
pub type QualifiedTypeName = String;
pub type PrimitiveTypeId = u8;
pub type EquivalenceHash = [u8; 14];
pub type NameHash = [u8; 4];
pub type LBound = u32;
pub type LBoundSeq = Vec<LBound>;
pub const INVALID_LBOUND: LBound = 0;
pub type SBound = u8;
pub type SBoundSeq = Vec<SBound>;
pub const INVALID_SBOUND: SBound = 0;
pub struct TypeObjectHashId {
tag: u8,
data: TypeObjectHashIdData,
}
union TypeObjectHashIdData {
hash: core::mem::ManuallyDrop<EquivalenceHash>,
}
impl Drop for TypeObjectHashId {
#[allow(unreachable_patterns)]
fn drop(&mut self) {
match self.tag {
EK_COMPLETE | EK_MINIMAL => unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.hash);
},
_ => {}
}
}
}
impl Clone for TypeObjectHashId {
#[allow(clippy::clone_on_copy)]
#[allow(unreachable_patterns)]
fn clone(&self) -> Self {
match self.tag {
EK_COMPLETE | EK_MINIMAL => Self::new_hash(self.as_hash().clone()),
_ => unreachable!(),
}
}
}
impl core::fmt::Debug for TypeObjectHashId {
#[allow(unreachable_patterns)]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut d = f.debug_struct("TypeObjectHashId");
d.field("tag", &self.tag);
match self.tag {
EK_COMPLETE | EK_MINIMAL => {
d.field("hash", self.as_hash());
}
_ => {}
}
d.finish()
}
}
impl PartialEq for TypeObjectHashId {
#[allow(unreachable_patterns)]
fn eq(&self, other: &Self) -> bool {
if self.tag != other.tag {
return false;
}
match self.tag {
EK_COMPLETE | EK_MINIMAL => self.as_hash() == other.as_hash(),
_ => false,
}
}
}
impl TypeObjectHashId {
pub fn new_hash(value: EquivalenceHash) -> Self {
Self {
tag: EK_COMPLETE,
data: TypeObjectHashIdData {
hash: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_hash(&self) -> bool {
matches!(self.tag, EK_COMPLETE | EK_MINIMAL)
}
#[allow(clippy::borrowed_box)]
pub fn as_hash(&self) -> &EquivalenceHash {
debug_assert!(self.is_hash());
unsafe { &self.data.hash }
}
#[allow(clippy::borrowed_box)]
pub fn as_hash_mut(&mut self) -> &mut EquivalenceHash {
debug_assert!(self.is_hash());
unsafe { &mut self.data.hash }
}
pub fn into_hash(self) -> EquivalenceHash {
debug_assert!(self.is_hash());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.hash)
}
}
pub fn tag(&self) -> &u8 {
&self.tag
}
}
impl Default for TypeObjectHashId {
fn default() -> Self {
Self {
tag: EK_COMPLETE,
data: TypeObjectHashIdData {
hash: core::mem::ManuallyDrop::new(EquivalenceHash::default()),
},
}
}
}
#[derive(::serde::Serialize)]
struct TypeObjectHashIdSerdeRef<'__a> {
tag: &'__a str,
data: TypeObjectHashIdSerdeRefData<'__a>,
}
#[allow(clippy::borrowed_box)]
#[derive(::serde::Serialize)]
#[serde(untagged)]
enum TypeObjectHashIdSerdeRefData<'__a> {
Case0(&'__a EquivalenceHash),
}
impl serde::Serialize for TypeObjectHashId {
#[allow(unreachable_patterns)]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
__S: serde::Serializer,
{
let helper = match self.tag {
EK_COMPLETE | EK_MINIMAL => {
let tag = match self.tag {
EK_COMPLETE => "EK_COMPLETE",
_ => "EK_MINIMAL",
};
TypeObjectHashIdSerdeRef {
tag,
data: TypeObjectHashIdSerdeRefData::Case0(self.as_hash()),
}
}
_ => unreachable!(),
};
helper.serialize(__serializer)
}
}
#[derive(::serde::Deserialize)]
struct TypeObjectHashIdSerdeOwned {
tag: String,
data: ::serde_json::Value,
}
impl<'de> serde::Deserialize<'de> for TypeObjectHashId {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let helper = TypeObjectHashIdSerdeOwned::deserialize(deserializer)?;
match helper.tag.as_str() {
"EK_COMPLETE" => {
let value = ::serde_json::from_value::<
EquivalenceHash,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeObjectHashId payload decode failed for tag `EK_COMPLETE`: {err}"
),
))?;
Ok(Self {
tag: EK_COMPLETE,
data: TypeObjectHashIdData {
hash: core::mem::ManuallyDrop::new(value),
},
})
}
"EK_MINIMAL" => {
let value = ::serde_json::from_value::<
EquivalenceHash,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeObjectHashId payload decode failed for tag `EK_MINIMAL`: {err}"
),
))?;
Ok(Self {
tag: EK_MINIMAL,
data: TypeObjectHashIdData {
hash: core::mem::ManuallyDrop::new(value),
},
})
}
_ => Err(serde::de::Error::custom(format!(
"union TypeObjectHashId tag/data mismatch for tag `{}`",
helper.tag
))),
}
}
}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MemberFlag {
pub value: u32,
}
impl MemberFlag {
pub const TRY_CONSTRUCT1: u32 = 1u32 << 0;
pub const TRY_CONSTRUCT2: u32 = 1u32 << 1;
pub const IS_EXTERNAL: u32 = 1u32 << 2;
pub const IS_OPTIONAL: u32 = 1u32 << 3;
pub const IS_MUST_UNDERSTAND: u32 = 1u32 << 4;
pub const IS_KEY: u32 = 1u32 << 5;
pub const IS_DEFAULT: u32 = 1u32 << 6;
}
pub type CollectionElementFlag = MemberFlag;
pub type StructMemberFlag = MemberFlag;
pub type UnionMemberFlag = MemberFlag;
pub type UnionDiscriminatorFlag = MemberFlag;
pub type EnumeratedLiteralFlag = MemberFlag;
pub type AnnotationParameterFlag = MemberFlag;
pub type AliasMemberFlag = MemberFlag;
pub type BitflagFlag = MemberFlag;
pub type BitsetMemberFlag = MemberFlag;
#[allow(non_upper_case_globals)]
pub const MemberFlagMinimalMask: u16 = 63;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct TypeFlag {
pub value: u32,
}
impl TypeFlag {
pub const IS_FINAL: u32 = 1u32 << 0;
pub const IS_APPENDABLE: u32 = 1u32 << 1;
pub const IS_MUTABLE: u32 = 1u32 << 2;
pub const IS_NESTED: u32 = 1u32 << 3;
pub const IS_AUTOID_HASH: u32 = 1u32 << 4;
}
pub type StructTypeFlag = TypeFlag;
pub type UnionTypeFlag = TypeFlag;
pub type CollectionTypeFlag = TypeFlag;
pub type AnnotationTypeFlag = TypeFlag;
pub type AliasTypeFlag = TypeFlag;
pub type EnumTypeFlag = TypeFlag;
pub type BitmaskTypeFlag = TypeFlag;
pub type BitsetTypeFlag = TypeFlag;
#[allow(non_upper_case_globals)]
pub const TypeFlagMinimalMask: u16 = 7;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct StringSTypeDefn {
pub bound: SBound,
}
impl StringSTypeDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct StringLTypeDefn {
pub bound: LBound,
}
impl StringLTypeDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct PlainCollectionHeader {
pub equiv_kind: EquivalenceKind,
pub element_flags: CollectionElementFlag,
}
impl PlainCollectionHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct PlainSequenceSElemDefn {
pub header: PlainCollectionHeader,
pub bound: SBound,
pub element_identifier: Box<TypeIdentifier>,
}
impl PlainSequenceSElemDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct PlainSequenceLElemDefn {
pub header: PlainCollectionHeader,
pub bound: LBound,
pub element_identifier: Box<TypeIdentifier>,
}
impl PlainSequenceLElemDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct PlainArraySElemDefn {
pub header: PlainCollectionHeader,
pub array_bound_seq: SBoundSeq,
pub element_identifier: Box<TypeIdentifier>,
}
impl PlainArraySElemDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct PlainArrayLElemDefn {
pub header: PlainCollectionHeader,
pub array_bound_seq: LBoundSeq,
pub element_identifier: Box<TypeIdentifier>,
}
impl PlainArrayLElemDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct PlainMapSTypeDefn {
pub header: PlainCollectionHeader,
pub bound: SBound,
pub element_identifier: Box<TypeIdentifier>,
pub key_flags: CollectionElementFlag,
pub key_identifier: Box<TypeIdentifier>,
}
impl PlainMapSTypeDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct PlainMapLTypeDefn {
pub header: PlainCollectionHeader,
pub bound: LBound,
pub element_identifier: Box<TypeIdentifier>,
pub key_flags: CollectionElementFlag,
pub key_identifier: Box<TypeIdentifier>,
}
impl PlainMapLTypeDefn {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct StronglyConnectedComponentId {
pub sc_component_id: TypeObjectHashId,
pub scc_length: i32,
pub scc_index: i32,
}
impl StronglyConnectedComponentId {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct ExtendedTypeDefn {}
impl ExtendedTypeDefn {}
pub struct TypeIdentifier {
tag: u8,
data: TypeIdentifierData,
}
union TypeIdentifierData {
string_sdefn: core::mem::ManuallyDrop<StringSTypeDefn>,
string_ldefn: core::mem::ManuallyDrop<StringLTypeDefn>,
seq_sdefn: core::mem::ManuallyDrop<Box<PlainSequenceSElemDefn>>,
seq_ldefn: core::mem::ManuallyDrop<Box<PlainSequenceLElemDefn>>,
array_sdefn: core::mem::ManuallyDrop<Box<PlainArraySElemDefn>>,
array_ldefn: core::mem::ManuallyDrop<Box<PlainArrayLElemDefn>>,
map_sdefn: core::mem::ManuallyDrop<Box<PlainMapSTypeDefn>>,
map_ldefn: core::mem::ManuallyDrop<Box<PlainMapLTypeDefn>>,
sc_component_id: core::mem::ManuallyDrop<StronglyConnectedComponentId>,
equivalence_hash: core::mem::ManuallyDrop<EquivalenceHash>,
extended_defn: core::mem::ManuallyDrop<ExtendedTypeDefn>,
}
impl Drop for TypeIdentifier {
#[allow(unreachable_patterns)]
fn drop(&mut self) {
if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.string_sdefn);
}
} else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.string_ldefn);
}
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.seq_sdefn);
}
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.seq_ldefn);
}
} else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.array_sdefn);
}
} else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.array_ldefn);
}
} else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.map_sdefn);
}
} else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.map_ldefn);
}
} else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.sc_component_id);
}
} else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.equivalence_hash);
}
} else {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.extended_defn);
}
}
}
}
impl Clone for TypeIdentifier {
#[allow(clippy::clone_on_copy)]
#[allow(unreachable_patterns)]
fn clone(&self) -> Self {
if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
Self::new_string_sdefn(self.as_string_sdefn().clone())
} else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
Self::new_string_ldefn(self.as_string_ldefn().clone())
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
Self::new_seq_sdefn(self.as_seq_sdefn().clone())
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
Self::new_seq_ldefn(self.as_seq_ldefn().clone())
} else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
Self::new_array_sdefn(self.as_array_sdefn().clone())
} else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
Self::new_array_ldefn(self.as_array_ldefn().clone())
} else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
Self::new_map_sdefn(self.as_map_sdefn().clone())
} else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
Self::new_map_ldefn(self.as_map_ldefn().clone())
} else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
Self::new_sc_component_id(self.as_sc_component_id().clone())
} else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
Self::new_equivalence_hash(self.as_equivalence_hash().clone())
} else {
Self::new_extended_defn(self.as_extended_defn().clone())
}
}
}
impl core::fmt::Debug for TypeIdentifier {
#[allow(unreachable_patterns)]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut d = f.debug_struct("TypeIdentifier");
d.field("tag", &self.tag);
if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
d.field("string_sdefn", self.as_string_sdefn());
} else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
d.field("string_ldefn", self.as_string_ldefn());
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
d.field("seq_sdefn", self.as_seq_sdefn());
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
d.field("seq_ldefn", self.as_seq_ldefn());
} else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
d.field("array_sdefn", self.as_array_sdefn());
} else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
d.field("array_ldefn", self.as_array_ldefn());
} else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
d.field("map_sdefn", self.as_map_sdefn());
} else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
d.field("map_ldefn", self.as_map_ldefn());
} else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
d.field("sc_component_id", self.as_sc_component_id());
} else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
d.field("equivalence_hash", self.as_equivalence_hash());
} else {
d.field("extended_defn", self.as_extended_defn());
}
d.finish()
}
}
impl PartialEq for TypeIdentifier {
#[allow(unreachable_patterns)]
fn eq(&self, other: &Self) -> bool {
if self.tag != other.tag {
return false;
}
if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
self.as_string_sdefn() == other.as_string_sdefn()
} else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
self.as_string_ldefn() == other.as_string_ldefn()
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
self.as_seq_sdefn() == other.as_seq_sdefn()
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
self.as_seq_ldefn() == other.as_seq_ldefn()
} else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
self.as_array_sdefn() == other.as_array_sdefn()
} else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
self.as_array_ldefn() == other.as_array_ldefn()
} else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
self.as_map_sdefn() == other.as_map_sdefn()
} else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
self.as_map_ldefn() == other.as_map_ldefn()
} else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
self.as_sc_component_id() == other.as_sc_component_id()
} else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
self.as_equivalence_hash() == other.as_equivalence_hash()
} else {
self.as_extended_defn() == other.as_extended_defn()
}
}
}
impl TypeIdentifier {
pub fn new_string_sdefn(value: StringSTypeDefn) -> Self {
Self {
tag: TI_STRING8_SMALL,
data: TypeIdentifierData {
string_sdefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_string_sdefn(&self) -> bool {
matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL)
}
#[allow(clippy::borrowed_box)]
pub fn as_string_sdefn(&self) -> &StringSTypeDefn {
debug_assert!(self.is_string_sdefn());
unsafe { &self.data.string_sdefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_string_sdefn_mut(&mut self) -> &mut StringSTypeDefn {
debug_assert!(self.is_string_sdefn());
unsafe { &mut self.data.string_sdefn }
}
pub fn into_string_sdefn(self) -> StringSTypeDefn {
debug_assert!(self.is_string_sdefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.string_sdefn)
}
}
pub fn new_string_ldefn(value: StringLTypeDefn) -> Self {
Self {
tag: TI_STRING8_LARGE,
data: TypeIdentifierData {
string_ldefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_string_ldefn(&self) -> bool {
matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE)
}
#[allow(clippy::borrowed_box)]
pub fn as_string_ldefn(&self) -> &StringLTypeDefn {
debug_assert!(self.is_string_ldefn());
unsafe { &self.data.string_ldefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_string_ldefn_mut(&mut self) -> &mut StringLTypeDefn {
debug_assert!(self.is_string_ldefn());
unsafe { &mut self.data.string_ldefn }
}
pub fn into_string_ldefn(self) -> StringLTypeDefn {
debug_assert!(self.is_string_ldefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.string_ldefn)
}
}
pub fn new_seq_sdefn(value: Box<PlainSequenceSElemDefn>) -> Self {
Self {
tag: TI_PLAIN_SEQUENCE_SMALL,
data: TypeIdentifierData {
seq_sdefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_seq_sdefn(&self) -> bool {
matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL)
}
#[allow(clippy::borrowed_box)]
pub fn as_seq_sdefn(&self) -> &Box<PlainSequenceSElemDefn> {
debug_assert!(self.is_seq_sdefn());
unsafe { &self.data.seq_sdefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_seq_sdefn_mut(&mut self) -> &mut Box<PlainSequenceSElemDefn> {
debug_assert!(self.is_seq_sdefn());
unsafe { &mut self.data.seq_sdefn }
}
pub fn into_seq_sdefn(self) -> Box<PlainSequenceSElemDefn> {
debug_assert!(self.is_seq_sdefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.seq_sdefn)
}
}
pub fn new_seq_ldefn(value: Box<PlainSequenceLElemDefn>) -> Self {
Self {
tag: TI_PLAIN_SEQUENCE_LARGE,
data: TypeIdentifierData {
seq_ldefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_seq_ldefn(&self) -> bool {
matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE)
}
#[allow(clippy::borrowed_box)]
pub fn as_seq_ldefn(&self) -> &Box<PlainSequenceLElemDefn> {
debug_assert!(self.is_seq_ldefn());
unsafe { &self.data.seq_ldefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_seq_ldefn_mut(&mut self) -> &mut Box<PlainSequenceLElemDefn> {
debug_assert!(self.is_seq_ldefn());
unsafe { &mut self.data.seq_ldefn }
}
pub fn into_seq_ldefn(self) -> Box<PlainSequenceLElemDefn> {
debug_assert!(self.is_seq_ldefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.seq_ldefn)
}
}
pub fn new_array_sdefn(value: Box<PlainArraySElemDefn>) -> Self {
Self {
tag: TI_PLAIN_ARRAY_SMALL,
data: TypeIdentifierData {
array_sdefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_array_sdefn(&self) -> bool {
matches!(self.tag, TI_PLAIN_ARRAY_SMALL)
}
#[allow(clippy::borrowed_box)]
pub fn as_array_sdefn(&self) -> &Box<PlainArraySElemDefn> {
debug_assert!(self.is_array_sdefn());
unsafe { &self.data.array_sdefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_array_sdefn_mut(&mut self) -> &mut Box<PlainArraySElemDefn> {
debug_assert!(self.is_array_sdefn());
unsafe { &mut self.data.array_sdefn }
}
pub fn into_array_sdefn(self) -> Box<PlainArraySElemDefn> {
debug_assert!(self.is_array_sdefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.array_sdefn)
}
}
pub fn new_array_ldefn(value: Box<PlainArrayLElemDefn>) -> Self {
Self {
tag: TI_PLAIN_ARRAY_LARGE,
data: TypeIdentifierData {
array_ldefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_array_ldefn(&self) -> bool {
matches!(self.tag, TI_PLAIN_ARRAY_LARGE)
}
#[allow(clippy::borrowed_box)]
pub fn as_array_ldefn(&self) -> &Box<PlainArrayLElemDefn> {
debug_assert!(self.is_array_ldefn());
unsafe { &self.data.array_ldefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_array_ldefn_mut(&mut self) -> &mut Box<PlainArrayLElemDefn> {
debug_assert!(self.is_array_ldefn());
unsafe { &mut self.data.array_ldefn }
}
pub fn into_array_ldefn(self) -> Box<PlainArrayLElemDefn> {
debug_assert!(self.is_array_ldefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.array_ldefn)
}
}
pub fn new_map_sdefn(value: Box<PlainMapSTypeDefn>) -> Self {
Self {
tag: TI_PLAIN_MAP_SMALL,
data: TypeIdentifierData {
map_sdefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_map_sdefn(&self) -> bool {
matches!(self.tag, TI_PLAIN_MAP_SMALL)
}
#[allow(clippy::borrowed_box)]
pub fn as_map_sdefn(&self) -> &Box<PlainMapSTypeDefn> {
debug_assert!(self.is_map_sdefn());
unsafe { &self.data.map_sdefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_map_sdefn_mut(&mut self) -> &mut Box<PlainMapSTypeDefn> {
debug_assert!(self.is_map_sdefn());
unsafe { &mut self.data.map_sdefn }
}
pub fn into_map_sdefn(self) -> Box<PlainMapSTypeDefn> {
debug_assert!(self.is_map_sdefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.map_sdefn)
}
}
pub fn new_map_ldefn(value: Box<PlainMapLTypeDefn>) -> Self {
Self {
tag: TI_PLAIN_MAP_LARGE,
data: TypeIdentifierData {
map_ldefn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_map_ldefn(&self) -> bool {
matches!(self.tag, TI_PLAIN_MAP_LARGE)
}
#[allow(clippy::borrowed_box)]
pub fn as_map_ldefn(&self) -> &Box<PlainMapLTypeDefn> {
debug_assert!(self.is_map_ldefn());
unsafe { &self.data.map_ldefn }
}
#[allow(clippy::borrowed_box)]
pub fn as_map_ldefn_mut(&mut self) -> &mut Box<PlainMapLTypeDefn> {
debug_assert!(self.is_map_ldefn());
unsafe { &mut self.data.map_ldefn }
}
pub fn into_map_ldefn(self) -> Box<PlainMapLTypeDefn> {
debug_assert!(self.is_map_ldefn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.map_ldefn)
}
}
pub fn new_sc_component_id(value: StronglyConnectedComponentId) -> Self {
Self {
tag: TI_STRONGLY_CONNECTED_COMPONENT,
data: TypeIdentifierData {
sc_component_id: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_sc_component_id(&self) -> bool {
matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT)
}
#[allow(clippy::borrowed_box)]
pub fn as_sc_component_id(&self) -> &StronglyConnectedComponentId {
debug_assert!(self.is_sc_component_id());
unsafe { &self.data.sc_component_id }
}
#[allow(clippy::borrowed_box)]
pub fn as_sc_component_id_mut(&mut self) -> &mut StronglyConnectedComponentId {
debug_assert!(self.is_sc_component_id());
unsafe { &mut self.data.sc_component_id }
}
pub fn into_sc_component_id(self) -> StronglyConnectedComponentId {
debug_assert!(self.is_sc_component_id());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.sc_component_id)
}
}
pub fn new_equivalence_hash(value: EquivalenceHash) -> Self {
Self {
tag: EK_COMPLETE,
data: TypeIdentifierData {
equivalence_hash: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_equivalence_hash(&self) -> bool {
matches!(self.tag, EK_COMPLETE | EK_MINIMAL)
}
#[allow(clippy::borrowed_box)]
pub fn as_equivalence_hash(&self) -> &EquivalenceHash {
debug_assert!(self.is_equivalence_hash());
unsafe { &self.data.equivalence_hash }
}
#[allow(clippy::borrowed_box)]
pub fn as_equivalence_hash_mut(&mut self) -> &mut EquivalenceHash {
debug_assert!(self.is_equivalence_hash());
unsafe { &mut self.data.equivalence_hash }
}
pub fn into_equivalence_hash(self) -> EquivalenceHash {
debug_assert!(self.is_equivalence_hash());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.equivalence_hash)
}
}
pub fn new_extended_defn(value: ExtendedTypeDefn) -> Self {
Self {
tag: u8::default(),
data: TypeIdentifierData {
extended_defn: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_extended_defn(&self) -> bool {
matches!(self.tag, _)
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_defn(&self) -> &ExtendedTypeDefn {
debug_assert!(self.is_extended_defn());
unsafe { &self.data.extended_defn }
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_defn_mut(&mut self) -> &mut ExtendedTypeDefn {
debug_assert!(self.is_extended_defn());
unsafe { &mut self.data.extended_defn }
}
pub fn into_extended_defn(self) -> ExtendedTypeDefn {
debug_assert!(self.is_extended_defn());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.extended_defn)
}
}
pub fn tag(&self) -> &u8 {
&self.tag
}
}
impl Default for TypeIdentifier {
fn default() -> Self {
Self {
tag: u8::default(),
data: TypeIdentifierData {
extended_defn: core::mem::ManuallyDrop::new(ExtendedTypeDefn::default()),
},
}
}
}
#[derive(::serde::Serialize)]
struct TypeIdentifierSerdeRef<'__a> {
tag: &'__a str,
data: TypeIdentifierSerdeRefData<'__a>,
}
#[allow(clippy::borrowed_box)]
#[derive(::serde::Serialize)]
#[serde(untagged)]
enum TypeIdentifierSerdeRefData<'__a> {
Case0(&'__a StringSTypeDefn),
Case1(&'__a StringLTypeDefn),
Case2(&'__a Box<PlainSequenceSElemDefn>),
Case3(&'__a Box<PlainSequenceLElemDefn>),
Case4(&'__a Box<PlainArraySElemDefn>),
Case5(&'__a Box<PlainArrayLElemDefn>),
Case6(&'__a Box<PlainMapSTypeDefn>),
Case7(&'__a Box<PlainMapLTypeDefn>),
Case8(&'__a StronglyConnectedComponentId),
Case9(&'__a EquivalenceHash),
Case10(&'__a ExtendedTypeDefn),
}
impl serde::Serialize for TypeIdentifier {
#[allow(unreachable_patterns)]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
__S: serde::Serializer,
{
let helper = if matches!(self.tag, TI_STRING8_SMALL | TI_STRING16_SMALL) {
let tag = match self.tag {
TI_STRING8_SMALL => "TI_STRING8_SMALL",
_ => "TI_STRING16_SMALL",
};
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case0(self.as_string_sdefn()),
}
} else if matches!(self.tag, TI_STRING8_LARGE | TI_STRING16_LARGE) {
let tag = match self.tag {
TI_STRING8_LARGE => "TI_STRING8_LARGE",
_ => "TI_STRING16_LARGE",
};
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case1(self.as_string_ldefn()),
}
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_SMALL) {
let tag = "TI_PLAIN_SEQUENCE_SMALL";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case2(self.as_seq_sdefn()),
}
} else if matches!(self.tag, TI_PLAIN_SEQUENCE_LARGE) {
let tag = "TI_PLAIN_SEQUENCE_LARGE";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case3(self.as_seq_ldefn()),
}
} else if matches!(self.tag, TI_PLAIN_ARRAY_SMALL) {
let tag = "TI_PLAIN_ARRAY_SMALL";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case4(self.as_array_sdefn()),
}
} else if matches!(self.tag, TI_PLAIN_ARRAY_LARGE) {
let tag = "TI_PLAIN_ARRAY_LARGE";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case5(self.as_array_ldefn()),
}
} else if matches!(self.tag, TI_PLAIN_MAP_SMALL) {
let tag = "TI_PLAIN_MAP_SMALL";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case6(self.as_map_sdefn()),
}
} else if matches!(self.tag, TI_PLAIN_MAP_LARGE) {
let tag = "TI_PLAIN_MAP_LARGE";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case7(self.as_map_ldefn()),
}
} else if matches!(self.tag, TI_STRONGLY_CONNECTED_COMPONENT) {
let tag = "TI_STRONGLY_CONNECTED_COMPONENT";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case8(self.as_sc_component_id()),
}
} else if matches!(self.tag, EK_COMPLETE | EK_MINIMAL) {
let tag = match self.tag {
EK_COMPLETE => "EK_COMPLETE",
_ => "EK_MINIMAL",
};
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case9(self.as_equivalence_hash()),
}
} else {
let tag = "default";
TypeIdentifierSerdeRef {
tag,
data: TypeIdentifierSerdeRefData::Case10(self.as_extended_defn()),
}
};
helper.serialize(__serializer)
}
}
#[derive(::serde::Deserialize)]
struct TypeIdentifierSerdeOwned {
tag: String,
data: ::serde_json::Value,
}
impl<'de> serde::Deserialize<'de> for TypeIdentifier {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let helper = TypeIdentifierSerdeOwned::deserialize(deserializer)?;
match helper.tag.as_str() {
"TI_STRING8_SMALL" => {
let value = ::serde_json::from_value::<
StringSTypeDefn,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_STRING8_SMALL`: {err}"
),
))?;
Ok(Self {
tag: TI_STRING8_SMALL,
data: TypeIdentifierData {
string_sdefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_STRING16_SMALL" => {
let value = ::serde_json::from_value::<
StringSTypeDefn,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_STRING16_SMALL`: {err}"
),
))?;
Ok(Self {
tag: TI_STRING16_SMALL,
data: TypeIdentifierData {
string_sdefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_STRING8_LARGE" => {
let value = ::serde_json::from_value::<
StringLTypeDefn,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_STRING8_LARGE`: {err}"
),
))?;
Ok(Self {
tag: TI_STRING8_LARGE,
data: TypeIdentifierData {
string_ldefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_STRING16_LARGE" => {
let value = ::serde_json::from_value::<
StringLTypeDefn,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_STRING16_LARGE`: {err}"
),
))?;
Ok(Self {
tag: TI_STRING16_LARGE,
data: TypeIdentifierData {
string_ldefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_PLAIN_SEQUENCE_SMALL" => {
let value = ::serde_json::from_value::<
Box<PlainSequenceSElemDefn>,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_PLAIN_SEQUENCE_SMALL`: {err}"
),
))?;
Ok(Self {
tag: TI_PLAIN_SEQUENCE_SMALL,
data: TypeIdentifierData {
seq_sdefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_PLAIN_SEQUENCE_LARGE" => {
let value = ::serde_json::from_value::<
Box<PlainSequenceLElemDefn>,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_PLAIN_SEQUENCE_LARGE`: {err}"
),
))?;
Ok(Self {
tag: TI_PLAIN_SEQUENCE_LARGE,
data: TypeIdentifierData {
seq_ldefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_PLAIN_ARRAY_SMALL" => {
let value = ::serde_json::from_value::<
Box<PlainArraySElemDefn>,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_PLAIN_ARRAY_SMALL`: {err}"
),
))?;
Ok(Self {
tag: TI_PLAIN_ARRAY_SMALL,
data: TypeIdentifierData {
array_sdefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_PLAIN_ARRAY_LARGE" => {
let value = ::serde_json::from_value::<
Box<PlainArrayLElemDefn>,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_PLAIN_ARRAY_LARGE`: {err}"
),
))?;
Ok(Self {
tag: TI_PLAIN_ARRAY_LARGE,
data: TypeIdentifierData {
array_ldefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_PLAIN_MAP_SMALL" => {
let value = ::serde_json::from_value::<
Box<PlainMapSTypeDefn>,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_PLAIN_MAP_SMALL`: {err}"
),
))?;
Ok(Self {
tag: TI_PLAIN_MAP_SMALL,
data: TypeIdentifierData {
map_sdefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_PLAIN_MAP_LARGE" => {
let value = ::serde_json::from_value::<
Box<PlainMapLTypeDefn>,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_PLAIN_MAP_LARGE`: {err}"
),
))?;
Ok(Self {
tag: TI_PLAIN_MAP_LARGE,
data: TypeIdentifierData {
map_ldefn: core::mem::ManuallyDrop::new(value),
},
})
}
"TI_STRONGLY_CONNECTED_COMPONENT" => {
let value = ::serde_json::from_value::<
StronglyConnectedComponentId,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `TI_STRONGLY_CONNECTED_COMPONENT`: {err}"
),
))?;
Ok(Self {
tag: TI_STRONGLY_CONNECTED_COMPONENT,
data: TypeIdentifierData {
sc_component_id: core::mem::ManuallyDrop::new(value),
},
})
}
"EK_COMPLETE" => {
let value = ::serde_json::from_value::<
EquivalenceHash,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `EK_COMPLETE`: {err}"
),
))?;
Ok(Self {
tag: EK_COMPLETE,
data: TypeIdentifierData {
equivalence_hash: core::mem::ManuallyDrop::new(value),
},
})
}
"EK_MINIMAL" => {
let value = ::serde_json::from_value::<
EquivalenceHash,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `EK_MINIMAL`: {err}"
),
))?;
Ok(Self {
tag: EK_MINIMAL,
data: TypeIdentifierData {
equivalence_hash: core::mem::ManuallyDrop::new(value),
},
})
}
"default" => {
let value = ::serde_json::from_value::<
ExtendedTypeDefn,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeIdentifier payload decode failed for tag `default`: {err}"
),
))?;
Ok(Self {
tag: u8::default(),
data: TypeIdentifierData {
extended_defn: core::mem::ManuallyDrop::new(value),
},
})
}
_ => Err(serde::de::Error::custom(format!(
"union TypeIdentifier tag/data mismatch for tag `{}`",
helper.tag
))),
}
}
}
pub type TypeIdentifierSeq = Vec<TypeIdentifier>;
pub type MemberId = u32;
pub const ANNOTATION_STR_VALUE_MAX_LEN: u32 = 128;
pub const ANNOTATION_OCTETSEC_VALUE_MAX_LEN: u32 = 128;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct ExtendedAnnotationParameterValue {}
impl ExtendedAnnotationParameterValue {}
pub struct AnnotationParameterValue {
tag: u8,
data: AnnotationParameterValueData,
}
union AnnotationParameterValueData {
boolean_value: core::mem::ManuallyDrop<bool>,
byte_value: core::mem::ManuallyDrop<u8>,
int16_value: core::mem::ManuallyDrop<i16>,
uint_16_value: core::mem::ManuallyDrop<u16>,
int32_value: core::mem::ManuallyDrop<i32>,
uint32_value: core::mem::ManuallyDrop<u32>,
int64_value: core::mem::ManuallyDrop<i64>,
uint64_value: core::mem::ManuallyDrop<u64>,
float32_value: core::mem::ManuallyDrop<f64>,
float64_value: core::mem::ManuallyDrop<f64>,
float128_value: core::mem::ManuallyDrop<f64>,
char_value: core::mem::ManuallyDrop<char>,
wchar_value: core::mem::ManuallyDrop<char>,
enumerated_value: core::mem::ManuallyDrop<i32>,
string8_value: core::mem::ManuallyDrop<String>,
string16_value: core::mem::ManuallyDrop<String>,
extended_value: core::mem::ManuallyDrop<ExtendedAnnotationParameterValue>,
}
impl Drop for AnnotationParameterValue {
#[allow(unreachable_patterns)]
fn drop(&mut self) {
if matches!(self.tag, TK_BOOLEAN) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.boolean_value);
}
} else if matches!(self.tag, TK_BYTE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.byte_value);
}
} else if matches!(self.tag, TK_INT16) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.int16_value);
}
} else if matches!(self.tag, TK_UINT16) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.uint_16_value);
}
} else if matches!(self.tag, TK_INT32) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.int32_value);
}
} else if matches!(self.tag, TK_UINT32) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.uint32_value);
}
} else if matches!(self.tag, TK_INT64) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.int64_value);
}
} else if matches!(self.tag, TK_UINT64) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.uint64_value);
}
} else if matches!(self.tag, TK_FLOAT32) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.float32_value);
}
} else if matches!(self.tag, TK_FLOAT64) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.float64_value);
}
} else if matches!(self.tag, TK_FLOAT128) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.float128_value);
}
} else if matches!(self.tag, TK_CHAR8) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.char_value);
}
} else if matches!(self.tag, TK_CHAR16) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.wchar_value);
}
} else if matches!(self.tag, TK_ENUM) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.enumerated_value);
}
} else if matches!(self.tag, TK_STRING8) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.string8_value);
}
} else if matches!(self.tag, TK_STRING16) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.string16_value);
}
} else {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.extended_value);
}
}
}
}
impl Clone for AnnotationParameterValue {
#[allow(clippy::clone_on_copy)]
#[allow(unreachable_patterns)]
fn clone(&self) -> Self {
if matches!(self.tag, TK_BOOLEAN) {
Self::new_boolean_value(self.as_boolean_value().clone())
} else if matches!(self.tag, TK_BYTE) {
Self::new_byte_value(self.as_byte_value().clone())
} else if matches!(self.tag, TK_INT16) {
Self::new_int16_value(self.as_int16_value().clone())
} else if matches!(self.tag, TK_UINT16) {
Self::new_uint_16_value(self.as_uint_16_value().clone())
} else if matches!(self.tag, TK_INT32) {
Self::new_int32_value(self.as_int32_value().clone())
} else if matches!(self.tag, TK_UINT32) {
Self::new_uint32_value(self.as_uint32_value().clone())
} else if matches!(self.tag, TK_INT64) {
Self::new_int64_value(self.as_int64_value().clone())
} else if matches!(self.tag, TK_UINT64) {
Self::new_uint64_value(self.as_uint64_value().clone())
} else if matches!(self.tag, TK_FLOAT32) {
Self::new_float32_value(self.as_float32_value().clone())
} else if matches!(self.tag, TK_FLOAT64) {
Self::new_float64_value(self.as_float64_value().clone())
} else if matches!(self.tag, TK_FLOAT128) {
Self::new_float128_value(self.as_float128_value().clone())
} else if matches!(self.tag, TK_CHAR8) {
Self::new_char_value(self.as_char_value().clone())
} else if matches!(self.tag, TK_CHAR16) {
Self::new_wchar_value(self.as_wchar_value().clone())
} else if matches!(self.tag, TK_ENUM) {
Self::new_enumerated_value(self.as_enumerated_value().clone())
} else if matches!(self.tag, TK_STRING8) {
Self::new_string8_value(self.as_string8_value().clone())
} else if matches!(self.tag, TK_STRING16) {
Self::new_string16_value(self.as_string16_value().clone())
} else {
Self::new_extended_value(self.as_extended_value().clone())
}
}
}
impl core::fmt::Debug for AnnotationParameterValue {
#[allow(unreachable_patterns)]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut d = f.debug_struct("AnnotationParameterValue");
d.field("tag", &self.tag);
if matches!(self.tag, TK_BOOLEAN) {
d.field("boolean_value", self.as_boolean_value());
} else if matches!(self.tag, TK_BYTE) {
d.field("byte_value", self.as_byte_value());
} else if matches!(self.tag, TK_INT16) {
d.field("int16_value", self.as_int16_value());
} else if matches!(self.tag, TK_UINT16) {
d.field("uint_16_value", self.as_uint_16_value());
} else if matches!(self.tag, TK_INT32) {
d.field("int32_value", self.as_int32_value());
} else if matches!(self.tag, TK_UINT32) {
d.field("uint32_value", self.as_uint32_value());
} else if matches!(self.tag, TK_INT64) {
d.field("int64_value", self.as_int64_value());
} else if matches!(self.tag, TK_UINT64) {
d.field("uint64_value", self.as_uint64_value());
} else if matches!(self.tag, TK_FLOAT32) {
d.field("float32_value", self.as_float32_value());
} else if matches!(self.tag, TK_FLOAT64) {
d.field("float64_value", self.as_float64_value());
} else if matches!(self.tag, TK_FLOAT128) {
d.field("float128_value", self.as_float128_value());
} else if matches!(self.tag, TK_CHAR8) {
d.field("char_value", self.as_char_value());
} else if matches!(self.tag, TK_CHAR16) {
d.field("wchar_value", self.as_wchar_value());
} else if matches!(self.tag, TK_ENUM) {
d.field("enumerated_value", self.as_enumerated_value());
} else if matches!(self.tag, TK_STRING8) {
d.field("string8_value", self.as_string8_value());
} else if matches!(self.tag, TK_STRING16) {
d.field("string16_value", self.as_string16_value());
} else {
d.field("extended_value", self.as_extended_value());
}
d.finish()
}
}
impl PartialEq for AnnotationParameterValue {
#[allow(unreachable_patterns)]
fn eq(&self, other: &Self) -> bool {
if self.tag != other.tag {
return false;
}
if matches!(self.tag, TK_BOOLEAN) {
self.as_boolean_value() == other.as_boolean_value()
} else if matches!(self.tag, TK_BYTE) {
self.as_byte_value() == other.as_byte_value()
} else if matches!(self.tag, TK_INT16) {
self.as_int16_value() == other.as_int16_value()
} else if matches!(self.tag, TK_UINT16) {
self.as_uint_16_value() == other.as_uint_16_value()
} else if matches!(self.tag, TK_INT32) {
self.as_int32_value() == other.as_int32_value()
} else if matches!(self.tag, TK_UINT32) {
self.as_uint32_value() == other.as_uint32_value()
} else if matches!(self.tag, TK_INT64) {
self.as_int64_value() == other.as_int64_value()
} else if matches!(self.tag, TK_UINT64) {
self.as_uint64_value() == other.as_uint64_value()
} else if matches!(self.tag, TK_FLOAT32) {
self.as_float32_value() == other.as_float32_value()
} else if matches!(self.tag, TK_FLOAT64) {
self.as_float64_value() == other.as_float64_value()
} else if matches!(self.tag, TK_FLOAT128) {
self.as_float128_value() == other.as_float128_value()
} else if matches!(self.tag, TK_CHAR8) {
self.as_char_value() == other.as_char_value()
} else if matches!(self.tag, TK_CHAR16) {
self.as_wchar_value() == other.as_wchar_value()
} else if matches!(self.tag, TK_ENUM) {
self.as_enumerated_value() == other.as_enumerated_value()
} else if matches!(self.tag, TK_STRING8) {
self.as_string8_value() == other.as_string8_value()
} else if matches!(self.tag, TK_STRING16) {
self.as_string16_value() == other.as_string16_value()
} else {
self.as_extended_value() == other.as_extended_value()
}
}
}
impl AnnotationParameterValue {
pub fn new_boolean_value(value: bool) -> Self {
Self {
tag: TK_BOOLEAN,
data: AnnotationParameterValueData {
boolean_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_boolean_value(&self) -> bool {
matches!(self.tag, TK_BOOLEAN)
}
#[allow(clippy::borrowed_box)]
pub fn as_boolean_value(&self) -> &bool {
debug_assert!(self.is_boolean_value());
unsafe { &self.data.boolean_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_boolean_value_mut(&mut self) -> &mut bool {
debug_assert!(self.is_boolean_value());
unsafe { &mut self.data.boolean_value }
}
pub fn into_boolean_value(self) -> bool {
debug_assert!(self.is_boolean_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.boolean_value)
}
}
pub fn new_byte_value(value: u8) -> Self {
Self {
tag: TK_BYTE,
data: AnnotationParameterValueData {
byte_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_byte_value(&self) -> bool {
matches!(self.tag, TK_BYTE)
}
#[allow(clippy::borrowed_box)]
pub fn as_byte_value(&self) -> &u8 {
debug_assert!(self.is_byte_value());
unsafe { &self.data.byte_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_byte_value_mut(&mut self) -> &mut u8 {
debug_assert!(self.is_byte_value());
unsafe { &mut self.data.byte_value }
}
pub fn into_byte_value(self) -> u8 {
debug_assert!(self.is_byte_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.byte_value)
}
}
pub fn new_int16_value(value: i16) -> Self {
Self {
tag: TK_INT16,
data: AnnotationParameterValueData {
int16_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_int16_value(&self) -> bool {
matches!(self.tag, TK_INT16)
}
#[allow(clippy::borrowed_box)]
pub fn as_int16_value(&self) -> &i16 {
debug_assert!(self.is_int16_value());
unsafe { &self.data.int16_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_int16_value_mut(&mut self) -> &mut i16 {
debug_assert!(self.is_int16_value());
unsafe { &mut self.data.int16_value }
}
pub fn into_int16_value(self) -> i16 {
debug_assert!(self.is_int16_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.int16_value)
}
}
pub fn new_uint_16_value(value: u16) -> Self {
Self {
tag: TK_UINT16,
data: AnnotationParameterValueData {
uint_16_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_uint_16_value(&self) -> bool {
matches!(self.tag, TK_UINT16)
}
#[allow(clippy::borrowed_box)]
pub fn as_uint_16_value(&self) -> &u16 {
debug_assert!(self.is_uint_16_value());
unsafe { &self.data.uint_16_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_uint_16_value_mut(&mut self) -> &mut u16 {
debug_assert!(self.is_uint_16_value());
unsafe { &mut self.data.uint_16_value }
}
pub fn into_uint_16_value(self) -> u16 {
debug_assert!(self.is_uint_16_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.uint_16_value)
}
}
pub fn new_int32_value(value: i32) -> Self {
Self {
tag: TK_INT32,
data: AnnotationParameterValueData {
int32_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_int32_value(&self) -> bool {
matches!(self.tag, TK_INT32)
}
#[allow(clippy::borrowed_box)]
pub fn as_int32_value(&self) -> &i32 {
debug_assert!(self.is_int32_value());
unsafe { &self.data.int32_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_int32_value_mut(&mut self) -> &mut i32 {
debug_assert!(self.is_int32_value());
unsafe { &mut self.data.int32_value }
}
pub fn into_int32_value(self) -> i32 {
debug_assert!(self.is_int32_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.int32_value)
}
}
pub fn new_uint32_value(value: u32) -> Self {
Self {
tag: TK_UINT32,
data: AnnotationParameterValueData {
uint32_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_uint32_value(&self) -> bool {
matches!(self.tag, TK_UINT32)
}
#[allow(clippy::borrowed_box)]
pub fn as_uint32_value(&self) -> &u32 {
debug_assert!(self.is_uint32_value());
unsafe { &self.data.uint32_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_uint32_value_mut(&mut self) -> &mut u32 {
debug_assert!(self.is_uint32_value());
unsafe { &mut self.data.uint32_value }
}
pub fn into_uint32_value(self) -> u32 {
debug_assert!(self.is_uint32_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.uint32_value)
}
}
pub fn new_int64_value(value: i64) -> Self {
Self {
tag: TK_INT64,
data: AnnotationParameterValueData {
int64_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_int64_value(&self) -> bool {
matches!(self.tag, TK_INT64)
}
#[allow(clippy::borrowed_box)]
pub fn as_int64_value(&self) -> &i64 {
debug_assert!(self.is_int64_value());
unsafe { &self.data.int64_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_int64_value_mut(&mut self) -> &mut i64 {
debug_assert!(self.is_int64_value());
unsafe { &mut self.data.int64_value }
}
pub fn into_int64_value(self) -> i64 {
debug_assert!(self.is_int64_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.int64_value)
}
}
pub fn new_uint64_value(value: u64) -> Self {
Self {
tag: TK_UINT64,
data: AnnotationParameterValueData {
uint64_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_uint64_value(&self) -> bool {
matches!(self.tag, TK_UINT64)
}
#[allow(clippy::borrowed_box)]
pub fn as_uint64_value(&self) -> &u64 {
debug_assert!(self.is_uint64_value());
unsafe { &self.data.uint64_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_uint64_value_mut(&mut self) -> &mut u64 {
debug_assert!(self.is_uint64_value());
unsafe { &mut self.data.uint64_value }
}
pub fn into_uint64_value(self) -> u64 {
debug_assert!(self.is_uint64_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.uint64_value)
}
}
pub fn new_float32_value(value: f64) -> Self {
Self {
tag: TK_FLOAT32,
data: AnnotationParameterValueData {
float32_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_float32_value(&self) -> bool {
matches!(self.tag, TK_FLOAT32)
}
#[allow(clippy::borrowed_box)]
pub fn as_float32_value(&self) -> &f64 {
debug_assert!(self.is_float32_value());
unsafe { &self.data.float32_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_float32_value_mut(&mut self) -> &mut f64 {
debug_assert!(self.is_float32_value());
unsafe { &mut self.data.float32_value }
}
pub fn into_float32_value(self) -> f64 {
debug_assert!(self.is_float32_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.float32_value)
}
}
pub fn new_float64_value(value: f64) -> Self {
Self {
tag: TK_FLOAT64,
data: AnnotationParameterValueData {
float64_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_float64_value(&self) -> bool {
matches!(self.tag, TK_FLOAT64)
}
#[allow(clippy::borrowed_box)]
pub fn as_float64_value(&self) -> &f64 {
debug_assert!(self.is_float64_value());
unsafe { &self.data.float64_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_float64_value_mut(&mut self) -> &mut f64 {
debug_assert!(self.is_float64_value());
unsafe { &mut self.data.float64_value }
}
pub fn into_float64_value(self) -> f64 {
debug_assert!(self.is_float64_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.float64_value)
}
}
pub fn new_float128_value(value: f64) -> Self {
Self {
tag: TK_FLOAT128,
data: AnnotationParameterValueData {
float128_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_float128_value(&self) -> bool {
matches!(self.tag, TK_FLOAT128)
}
#[allow(clippy::borrowed_box)]
pub fn as_float128_value(&self) -> &f64 {
debug_assert!(self.is_float128_value());
unsafe { &self.data.float128_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_float128_value_mut(&mut self) -> &mut f64 {
debug_assert!(self.is_float128_value());
unsafe { &mut self.data.float128_value }
}
pub fn into_float128_value(self) -> f64 {
debug_assert!(self.is_float128_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.float128_value)
}
}
pub fn new_char_value(value: char) -> Self {
Self {
tag: TK_CHAR8,
data: AnnotationParameterValueData {
char_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_char_value(&self) -> bool {
matches!(self.tag, TK_CHAR8)
}
#[allow(clippy::borrowed_box)]
pub fn as_char_value(&self) -> &char {
debug_assert!(self.is_char_value());
unsafe { &self.data.char_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_char_value_mut(&mut self) -> &mut char {
debug_assert!(self.is_char_value());
unsafe { &mut self.data.char_value }
}
pub fn into_char_value(self) -> char {
debug_assert!(self.is_char_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.char_value)
}
}
pub fn new_wchar_value(value: char) -> Self {
Self {
tag: TK_CHAR16,
data: AnnotationParameterValueData {
wchar_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_wchar_value(&self) -> bool {
matches!(self.tag, TK_CHAR16)
}
#[allow(clippy::borrowed_box)]
pub fn as_wchar_value(&self) -> &char {
debug_assert!(self.is_wchar_value());
unsafe { &self.data.wchar_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_wchar_value_mut(&mut self) -> &mut char {
debug_assert!(self.is_wchar_value());
unsafe { &mut self.data.wchar_value }
}
pub fn into_wchar_value(self) -> char {
debug_assert!(self.is_wchar_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.wchar_value)
}
}
pub fn new_enumerated_value(value: i32) -> Self {
Self {
tag: TK_ENUM,
data: AnnotationParameterValueData {
enumerated_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_enumerated_value(&self) -> bool {
matches!(self.tag, TK_ENUM)
}
#[allow(clippy::borrowed_box)]
pub fn as_enumerated_value(&self) -> &i32 {
debug_assert!(self.is_enumerated_value());
unsafe { &self.data.enumerated_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_enumerated_value_mut(&mut self) -> &mut i32 {
debug_assert!(self.is_enumerated_value());
unsafe { &mut self.data.enumerated_value }
}
pub fn into_enumerated_value(self) -> i32 {
debug_assert!(self.is_enumerated_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.enumerated_value)
}
}
pub fn new_string8_value(value: String) -> Self {
Self {
tag: TK_STRING8,
data: AnnotationParameterValueData {
string8_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_string8_value(&self) -> bool {
matches!(self.tag, TK_STRING8)
}
#[allow(clippy::borrowed_box)]
pub fn as_string8_value(&self) -> &String {
debug_assert!(self.is_string8_value());
unsafe { &self.data.string8_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_string8_value_mut(&mut self) -> &mut String {
debug_assert!(self.is_string8_value());
unsafe { &mut self.data.string8_value }
}
pub fn into_string8_value(self) -> String {
debug_assert!(self.is_string8_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.string8_value)
}
}
pub fn new_string16_value(value: String) -> Self {
Self {
tag: TK_STRING16,
data: AnnotationParameterValueData {
string16_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_string16_value(&self) -> bool {
matches!(self.tag, TK_STRING16)
}
#[allow(clippy::borrowed_box)]
pub fn as_string16_value(&self) -> &String {
debug_assert!(self.is_string16_value());
unsafe { &self.data.string16_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_string16_value_mut(&mut self) -> &mut String {
debug_assert!(self.is_string16_value());
unsafe { &mut self.data.string16_value }
}
pub fn into_string16_value(self) -> String {
debug_assert!(self.is_string16_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.string16_value)
}
}
pub fn new_extended_value(value: ExtendedAnnotationParameterValue) -> Self {
Self {
tag: u8::default(),
data: AnnotationParameterValueData {
extended_value: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_extended_value(&self) -> bool {
matches!(self.tag, _)
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_value(&self) -> &ExtendedAnnotationParameterValue {
debug_assert!(self.is_extended_value());
unsafe { &self.data.extended_value }
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_value_mut(&mut self) -> &mut ExtendedAnnotationParameterValue {
debug_assert!(self.is_extended_value());
unsafe { &mut self.data.extended_value }
}
pub fn into_extended_value(self) -> ExtendedAnnotationParameterValue {
debug_assert!(self.is_extended_value());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.extended_value)
}
}
pub fn tag(&self) -> &u8 {
&self.tag
}
}
impl Default for AnnotationParameterValue {
fn default() -> Self {
Self {
tag: u8::default(),
data: AnnotationParameterValueData {
extended_value: core::mem::ManuallyDrop::new(
ExtendedAnnotationParameterValue::default(),
),
},
}
}
}
#[derive(::serde::Serialize)]
struct AnnotationParameterValueSerdeRef<'__a> {
tag: &'__a str,
data: AnnotationParameterValueSerdeRefData<'__a>,
}
#[allow(clippy::borrowed_box)]
#[derive(::serde::Serialize)]
#[serde(untagged)]
enum AnnotationParameterValueSerdeRefData<'__a> {
Case0(&'__a bool),
Case1(&'__a u8),
Case2(&'__a i16),
Case3(&'__a u16),
Case4(&'__a i32),
Case5(&'__a u32),
Case6(&'__a i64),
Case7(&'__a u64),
Case8(&'__a f64),
Case9(&'__a f64),
Case10(&'__a f64),
Case11(&'__a char),
Case12(&'__a char),
Case13(&'__a i32),
Case14(&'__a String),
Case15(&'__a String),
Case16(&'__a ExtendedAnnotationParameterValue),
}
impl serde::Serialize for AnnotationParameterValue {
#[allow(unreachable_patterns)]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
__S: serde::Serializer,
{
let helper = if matches!(self.tag, TK_BOOLEAN) {
let tag = "TK_BOOLEAN";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case0(self.as_boolean_value()),
}
} else if matches!(self.tag, TK_BYTE) {
let tag = "TK_BYTE";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case1(self.as_byte_value()),
}
} else if matches!(self.tag, TK_INT16) {
let tag = "TK_INT16";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case2(self.as_int16_value()),
}
} else if matches!(self.tag, TK_UINT16) {
let tag = "TK_UINT16";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case3(self.as_uint_16_value()),
}
} else if matches!(self.tag, TK_INT32) {
let tag = "TK_INT32";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case4(self.as_int32_value()),
}
} else if matches!(self.tag, TK_UINT32) {
let tag = "TK_UINT32";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case5(self.as_uint32_value()),
}
} else if matches!(self.tag, TK_INT64) {
let tag = "TK_INT64";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case6(self.as_int64_value()),
}
} else if matches!(self.tag, TK_UINT64) {
let tag = "TK_UINT64";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case7(self.as_uint64_value()),
}
} else if matches!(self.tag, TK_FLOAT32) {
let tag = "TK_FLOAT32";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case8(self.as_float32_value()),
}
} else if matches!(self.tag, TK_FLOAT64) {
let tag = "TK_FLOAT64";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case9(self.as_float64_value()),
}
} else if matches!(self.tag, TK_FLOAT128) {
let tag = "TK_FLOAT128";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case10(
self.as_float128_value(),
),
}
} else if matches!(self.tag, TK_CHAR8) {
let tag = "TK_CHAR8";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case11(self.as_char_value()),
}
} else if matches!(self.tag, TK_CHAR16) {
let tag = "TK_CHAR16";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case12(self.as_wchar_value()),
}
} else if matches!(self.tag, TK_ENUM) {
let tag = "TK_ENUM";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case13(
self.as_enumerated_value(),
),
}
} else if matches!(self.tag, TK_STRING8) {
let tag = "TK_STRING8";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case14(self.as_string8_value()),
}
} else if matches!(self.tag, TK_STRING16) {
let tag = "TK_STRING16";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case15(
self.as_string16_value(),
),
}
} else {
let tag = "default";
AnnotationParameterValueSerdeRef {
tag,
data: AnnotationParameterValueSerdeRefData::Case16(
self.as_extended_value(),
),
}
};
helper.serialize(__serializer)
}
}
#[derive(::serde::Deserialize)]
struct AnnotationParameterValueSerdeOwned {
tag: String,
data: ::serde_json::Value,
}
impl<'de> serde::Deserialize<'de> for AnnotationParameterValue {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let helper = AnnotationParameterValueSerdeOwned::deserialize(deserializer)?;
match helper.tag.as_str() {
"TK_BOOLEAN" => {
let value = ::serde_json::from_value::<bool>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_BOOLEAN`: {err}"
),
))?;
Ok(Self {
tag: TK_BOOLEAN,
data: AnnotationParameterValueData {
boolean_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_BYTE" => {
let value = ::serde_json::from_value::<u8>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_BYTE`: {err}"
),
))?;
Ok(Self {
tag: TK_BYTE,
data: AnnotationParameterValueData {
byte_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_INT16" => {
let value = ::serde_json::from_value::<i16>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_INT16`: {err}"
),
))?;
Ok(Self {
tag: TK_INT16,
data: AnnotationParameterValueData {
int16_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_UINT16" => {
let value = ::serde_json::from_value::<u16>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_UINT16`: {err}"
),
))?;
Ok(Self {
tag: TK_UINT16,
data: AnnotationParameterValueData {
uint_16_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_INT32" => {
let value = ::serde_json::from_value::<i32>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_INT32`: {err}"
),
))?;
Ok(Self {
tag: TK_INT32,
data: AnnotationParameterValueData {
int32_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_UINT32" => {
let value = ::serde_json::from_value::<u32>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_UINT32`: {err}"
),
))?;
Ok(Self {
tag: TK_UINT32,
data: AnnotationParameterValueData {
uint32_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_INT64" => {
let value = ::serde_json::from_value::<i64>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_INT64`: {err}"
),
))?;
Ok(Self {
tag: TK_INT64,
data: AnnotationParameterValueData {
int64_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_UINT64" => {
let value = ::serde_json::from_value::<u64>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_UINT64`: {err}"
),
))?;
Ok(Self {
tag: TK_UINT64,
data: AnnotationParameterValueData {
uint64_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_FLOAT32" => {
let value = ::serde_json::from_value::<f64>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_FLOAT32`: {err}"
),
))?;
Ok(Self {
tag: TK_FLOAT32,
data: AnnotationParameterValueData {
float32_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_FLOAT64" => {
let value = ::serde_json::from_value::<f64>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_FLOAT64`: {err}"
),
))?;
Ok(Self {
tag: TK_FLOAT64,
data: AnnotationParameterValueData {
float64_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_FLOAT128" => {
let value = ::serde_json::from_value::<f64>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_FLOAT128`: {err}"
),
))?;
Ok(Self {
tag: TK_FLOAT128,
data: AnnotationParameterValueData {
float128_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_CHAR8" => {
let value = ::serde_json::from_value::<char>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_CHAR8`: {err}"
),
))?;
Ok(Self {
tag: TK_CHAR8,
data: AnnotationParameterValueData {
char_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_CHAR16" => {
let value = ::serde_json::from_value::<char>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_CHAR16`: {err}"
),
))?;
Ok(Self {
tag: TK_CHAR16,
data: AnnotationParameterValueData {
wchar_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_ENUM" => {
let value = ::serde_json::from_value::<i32>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_ENUM`: {err}"
),
))?;
Ok(Self {
tag: TK_ENUM,
data: AnnotationParameterValueData {
enumerated_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_STRING8" => {
let value = ::serde_json::from_value::<String>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_STRING8`: {err}"
),
))?;
Ok(Self {
tag: TK_STRING8,
data: AnnotationParameterValueData {
string8_value: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_STRING16" => {
let value = ::serde_json::from_value::<String>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `TK_STRING16`: {err}"
),
))?;
Ok(Self {
tag: TK_STRING16,
data: AnnotationParameterValueData {
string16_value: core::mem::ManuallyDrop::new(value),
},
})
}
"default" => {
let value = ::serde_json::from_value::<
ExtendedAnnotationParameterValue,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union AnnotationParameterValue payload decode failed for tag `default`: {err}"
),
))?;
Ok(Self {
tag: u8::default(),
data: AnnotationParameterValueData {
extended_value: core::mem::ManuallyDrop::new(value),
},
})
}
_ => Err(serde::de::Error::custom(format!(
"union AnnotationParameterValue tag/data mismatch for tag `{}`",
helper.tag
))),
}
}
}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct AppliedAnnotationParameter {
pub paramname_hash: NameHash,
pub value: AnnotationParameterValue,
}
impl AppliedAnnotationParameter {}
pub type AppliedAnnotationParameterSeq = Vec<AppliedAnnotationParameter>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct AppliedAnnotation {
pub annotation_typeid: TypeIdentifier,
pub param_seq: Option<AppliedAnnotationParameterSeq>,
}
impl AppliedAnnotation {}
pub type AppliedAnnotationSeq = Vec<AppliedAnnotation>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct AppliedVerbatimAnnotation {
pub placement: String,
pub language: String,
pub text: String,
}
impl AppliedVerbatimAnnotation {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct AppliedBuiltinMemberAnnotations {
pub unit: Option<String>,
pub min: Option<AnnotationParameterValue>,
pub max: Option<AnnotationParameterValue>,
pub hash_id: Option<String>,
}
impl AppliedBuiltinMemberAnnotations {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonStructMember {
pub member_id: MemberId,
pub member_flags: StructMemberFlag,
pub member_type_id: TypeIdentifier,
}
impl CommonStructMember {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteMemberDetail {
pub name: MemberName,
pub ann_builtin: Option<AppliedBuiltinMemberAnnotations>,
pub ann_custom: Option<AppliedAnnotationSeq>,
}
impl CompleteMemberDetail {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalMemberDetail {
pub name_hash: NameHash,
}
impl MinimalMemberDetail {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteStructMember {
pub common: CommonStructMember,
pub detail: CompleteMemberDetail,
}
impl CompleteStructMember {}
pub type CompleteStructMemberSeq = Vec<CompleteStructMember>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalStructMember {
pub common: CommonStructMember,
pub detail: MinimalMemberDetail,
}
impl MinimalStructMember {}
pub type MinimalStructMemberSeq = Vec<MinimalStructMember>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct AppliedBuiltinTypeAnnotations {
pub verbatim: Option<AppliedVerbatimAnnotation>,
}
impl AppliedBuiltinTypeAnnotations {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalTypeDetail {}
impl MinimalTypeDetail {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteTypeDetail {
pub ann_builtin: Option<AppliedBuiltinTypeAnnotations>,
pub ann_custom: Option<AppliedAnnotationSeq>,
pub type_name: QualifiedTypeName,
}
impl CompleteTypeDetail {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteStructHeader {
pub base_type: TypeIdentifier,
pub detail: CompleteTypeDetail,
}
impl CompleteStructHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalStructHeader {
pub base_type: TypeIdentifier,
pub detail: MinimalTypeDetail,
}
impl MinimalStructHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteStructType {
pub struct_flags: StructTypeFlag,
pub header: CompleteStructHeader,
pub member_seq: CompleteStructMemberSeq,
}
impl CompleteStructType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalStructType {
pub struct_flags: StructTypeFlag,
pub header: MinimalStructHeader,
pub member_seq: MinimalStructMemberSeq,
}
impl MinimalStructType {}
pub type UnionCaseLabelSeq = Vec<i32>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonUnionMember {
pub member_id: MemberId,
pub member_flags: UnionMemberFlag,
pub type_id: TypeIdentifier,
pub label_seq: UnionCaseLabelSeq,
}
impl CommonUnionMember {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteUnionMember {
pub common: CommonUnionMember,
pub detail: CompleteMemberDetail,
}
impl CompleteUnionMember {}
pub type CompleteUnionMemberSeq = Vec<CompleteUnionMember>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalUnionMember {
pub common: CommonUnionMember,
pub detail: MinimalMemberDetail,
}
impl MinimalUnionMember {}
pub type MinimalUnionMemberSeq = Vec<MinimalUnionMember>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonDiscriminatorMember {
pub member_flags: UnionDiscriminatorFlag,
pub type_id: TypeIdentifier,
}
impl CommonDiscriminatorMember {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteDiscriminatorMember {
pub common: CommonDiscriminatorMember,
pub ann_builtin: Option<AppliedBuiltinTypeAnnotations>,
pub ann_custom: Option<AppliedAnnotationSeq>,
}
impl CompleteDiscriminatorMember {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalDiscriminatorMember {
pub common: CommonDiscriminatorMember,
}
impl MinimalDiscriminatorMember {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteUnionHeader {
pub detail: CompleteTypeDetail,
}
impl CompleteUnionHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalUnionHeader {
pub detail: MinimalTypeDetail,
}
impl MinimalUnionHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteUnionType {
pub union_flags: UnionTypeFlag,
pub header: CompleteUnionHeader,
pub discriminator: CompleteDiscriminatorMember,
pub member_seq: CompleteUnionMemberSeq,
}
impl CompleteUnionType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalUnionType {
pub union_flags: UnionTypeFlag,
pub header: MinimalUnionHeader,
pub discriminator: MinimalDiscriminatorMember,
pub member_seq: MinimalUnionMemberSeq,
}
impl MinimalUnionType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonAnnotationParameter {
pub member_flags: AnnotationParameterFlag,
pub member_type_id: TypeIdentifier,
}
impl CommonAnnotationParameter {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteAnnotationParameter {
pub common: CommonAnnotationParameter,
pub name: MemberName,
pub default_value: AnnotationParameterValue,
}
impl CompleteAnnotationParameter {}
pub type CompleteAnnotationParameterSeq = Vec<CompleteAnnotationParameter>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalAnnotationParameter {
pub common: CommonAnnotationParameter,
pub name_hash: NameHash,
pub default_value: AnnotationParameterValue,
}
impl MinimalAnnotationParameter {}
pub type MinimalAnnotationParameterSeq = Vec<MinimalAnnotationParameter>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteAnnotationHeader {
pub annotation_name: QualifiedTypeName,
}
impl CompleteAnnotationHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalAnnotationHeader {}
impl MinimalAnnotationHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteAnnotationType {
pub annotation_flag: AnnotationTypeFlag,
pub header: CompleteAnnotationHeader,
pub member_seq: CompleteAnnotationParameterSeq,
}
impl CompleteAnnotationType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalAnnotationType {
pub annotation_flag: AnnotationTypeFlag,
pub header: MinimalAnnotationHeader,
pub member_seq: MinimalAnnotationParameterSeq,
}
impl MinimalAnnotationType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonAliasBody {
pub related_flags: AliasMemberFlag,
pub related_type: TypeIdentifier,
}
impl CommonAliasBody {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteAliasBody {
pub common: CommonAliasBody,
pub ann_builtin: Option<AppliedBuiltinMemberAnnotations>,
pub ann_custom: Option<AppliedAnnotationSeq>,
}
impl CompleteAliasBody {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalAliasBody {
pub common: CommonAliasBody,
}
impl MinimalAliasBody {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteAliasHeader {
pub detail: CompleteTypeDetail,
}
impl CompleteAliasHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalAliasHeader {}
impl MinimalAliasHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteAliasType {
pub alias_flags: AliasTypeFlag,
pub header: CompleteAliasHeader,
pub body: CompleteAliasBody,
}
impl CompleteAliasType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalAliasType {
pub alias_flags: AliasTypeFlag,
pub header: MinimalAliasHeader,
pub body: MinimalAliasBody,
}
impl MinimalAliasType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteElementDetail {
pub ann_builtin: Option<AppliedBuiltinMemberAnnotations>,
pub ann_custom: Option<AppliedAnnotationSeq>,
}
impl CompleteElementDetail {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonCollectionElement {
pub element_flags: CollectionElementFlag,
pub r#type: TypeIdentifier,
}
impl CommonCollectionElement {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteCollectionElement {
pub common: CommonCollectionElement,
pub detail: CompleteElementDetail,
}
impl CompleteCollectionElement {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalCollectionElement {
pub common: CommonCollectionElement,
}
impl MinimalCollectionElement {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonCollectionHeader {
pub bound: LBound,
}
impl CommonCollectionHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteCollectionHeader {
pub common: CommonCollectionHeader,
pub detail: Option<CompleteTypeDetail>,
}
impl CompleteCollectionHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalCollectionHeader {
pub common: CommonCollectionHeader,
}
impl MinimalCollectionHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteSequenceType {
pub collection_flag: CollectionTypeFlag,
pub header: CompleteCollectionHeader,
pub element: CompleteCollectionElement,
}
impl CompleteSequenceType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalSequenceType {
pub collection_flag: CollectionTypeFlag,
pub header: MinimalCollectionHeader,
pub element: MinimalCollectionElement,
}
impl MinimalSequenceType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonArrayHeader {
pub bound_seq: LBoundSeq,
}
impl CommonArrayHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteArrayHeader {
pub common: CommonArrayHeader,
pub detail: CompleteTypeDetail,
}
impl CompleteArrayHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalArrayHeader {
pub common: CommonArrayHeader,
}
impl MinimalArrayHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteArrayType {
pub collection_flag: CollectionTypeFlag,
pub header: CompleteArrayHeader,
pub element: CompleteCollectionElement,
}
impl CompleteArrayType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalArrayType {
pub collection_flag: CollectionTypeFlag,
pub header: MinimalArrayHeader,
pub element: MinimalCollectionElement,
}
impl MinimalArrayType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteMapType {
pub collection_flag: CollectionTypeFlag,
pub header: CompleteCollectionHeader,
pub key: CompleteCollectionElement,
pub element: CompleteCollectionElement,
}
impl CompleteMapType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalMapType {
pub collection_flag: CollectionTypeFlag,
pub header: MinimalCollectionHeader,
pub key: MinimalCollectionElement,
pub element: MinimalCollectionElement,
}
impl MinimalMapType {}
pub type BitBound = u16;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonEnumeratedLiteral {
pub value: i32,
pub flags: EnumeratedLiteralFlag,
}
impl CommonEnumeratedLiteral {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteEnumeratedLiteral {
pub common: CommonEnumeratedLiteral,
pub detail: CompleteMemberDetail,
}
impl CompleteEnumeratedLiteral {}
pub type CompleteEnumeratedLiteralSeq = Vec<CompleteEnumeratedLiteral>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalEnumeratedLiteral {
pub common: CommonEnumeratedLiteral,
pub detail: MinimalMemberDetail,
}
impl MinimalEnumeratedLiteral {}
pub type MinimalEnumeratedLiteralSeq = Vec<MinimalEnumeratedLiteral>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonEnumeratedHeader {
pub bit_bound: BitBound,
}
impl CommonEnumeratedHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteEnumeratedHeader {
pub common: CommonEnumeratedHeader,
pub detail: CompleteTypeDetail,
}
impl CompleteEnumeratedHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalEnumeratedHeader {
pub common: CommonEnumeratedHeader,
}
impl MinimalEnumeratedHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteEnumeratedType {
pub enum_flags: EnumTypeFlag,
pub header: CompleteEnumeratedHeader,
pub literal_seq: CompleteEnumeratedLiteralSeq,
}
impl CompleteEnumeratedType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalEnumeratedType {
pub enum_flags: EnumTypeFlag,
pub header: MinimalEnumeratedHeader,
pub literal_seq: MinimalEnumeratedLiteralSeq,
}
impl MinimalEnumeratedType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonBitflag {
pub position: u16,
pub flags: BitflagFlag,
}
impl CommonBitflag {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteBitflag {
pub common: CommonBitflag,
pub detail: CompleteMemberDetail,
}
impl CompleteBitflag {}
pub type CompleteBitflagSeq = Vec<CompleteBitflag>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalBitflag {
pub common: CommonBitflag,
pub detail: MinimalMemberDetail,
}
impl MinimalBitflag {}
pub type MinimalBitflagSeq = Vec<MinimalBitflag>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonBitmaskHeader {
pub bit_bound: BitBound,
}
impl CommonBitmaskHeader {}
pub type CompleteBitmaskHeader = CompleteEnumeratedHeader;
pub type MinimalBitmaskHeader = MinimalEnumeratedHeader;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteBitmaskType {
pub bitmask_flags: BitmaskTypeFlag,
pub header: CompleteBitmaskHeader,
pub flag_seq: CompleteBitflagSeq,
}
impl CompleteBitmaskType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalBitmaskType {
pub bitmask_flags: BitmaskTypeFlag,
pub header: MinimalBitmaskHeader,
pub flag_seq: MinimalBitflagSeq,
}
impl MinimalBitmaskType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CommonBitfield {
pub position: u16,
pub flags: BitsetMemberFlag,
pub bitcount: u8,
pub holder_type: TypeKind,
}
impl CommonBitfield {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteBitfield {
pub common: CommonBitfield,
pub detail: CompleteMemberDetail,
}
impl CompleteBitfield {}
pub type CompleteBitfieldSeq = Vec<CompleteBitfield>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalBitfield {
pub common: CommonBitfield,
pub name_hash: NameHash,
}
impl MinimalBitfield {}
pub type MinimalBitfieldSeq = Vec<MinimalBitfield>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteBitsetHeader {
pub detail: CompleteTypeDetail,
}
impl CompleteBitsetHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalBitsetHeader {}
impl MinimalBitsetHeader {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteBitsetType {
pub bitset_flags: BitsetTypeFlag,
pub header: CompleteBitsetHeader,
pub field_seq: CompleteBitfieldSeq,
}
impl CompleteBitsetType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalBitsetType {
pub bitset_flags: BitsetTypeFlag,
pub header: MinimalBitsetHeader,
pub field_seq: MinimalBitfieldSeq,
}
impl MinimalBitsetType {}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct CompleteExtendedType {}
impl CompleteExtendedType {}
pub struct CompleteTypeObject {
tag: u8,
data: CompleteTypeObjectData,
}
union CompleteTypeObjectData {
alias_type: core::mem::ManuallyDrop<CompleteAliasType>,
annotation_type: core::mem::ManuallyDrop<CompleteAnnotationType>,
struct_type: core::mem::ManuallyDrop<CompleteStructType>,
union_type: core::mem::ManuallyDrop<CompleteUnionType>,
bitset_type: core::mem::ManuallyDrop<CompleteBitsetType>,
sequence_type: core::mem::ManuallyDrop<CompleteSequenceType>,
array_type: core::mem::ManuallyDrop<CompleteArrayType>,
map_type: core::mem::ManuallyDrop<CompleteMapType>,
enumerated_type: core::mem::ManuallyDrop<CompleteEnumeratedType>,
bitmask_type: core::mem::ManuallyDrop<CompleteBitmaskType>,
extended_type: core::mem::ManuallyDrop<CompleteExtendedType>,
}
impl Drop for CompleteTypeObject {
#[allow(unreachable_patterns)]
fn drop(&mut self) {
if matches!(self.tag, TK_ALIAS) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.alias_type);
}
} else if matches!(self.tag, TK_ANNOTATION) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.annotation_type);
}
} else if matches!(self.tag, TK_STRUCTURE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.struct_type);
}
} else if matches!(self.tag, TK_UNION) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.union_type);
}
} else if matches!(self.tag, TK_BITSET) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.bitset_type);
}
} else if matches!(self.tag, TK_SEQUENCE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.sequence_type);
}
} else if matches!(self.tag, TK_ARRAY) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.array_type);
}
} else if matches!(self.tag, TK_MAP) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.map_type);
}
} else if matches!(self.tag, TK_ENUM) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.enumerated_type);
}
} else if matches!(self.tag, TK_BITMASK) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.bitmask_type);
}
} else {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.extended_type);
}
}
}
}
impl Clone for CompleteTypeObject {
#[allow(clippy::clone_on_copy)]
#[allow(unreachable_patterns)]
fn clone(&self) -> Self {
if matches!(self.tag, TK_ALIAS) {
Self::new_alias_type(self.as_alias_type().clone())
} else if matches!(self.tag, TK_ANNOTATION) {
Self::new_annotation_type(self.as_annotation_type().clone())
} else if matches!(self.tag, TK_STRUCTURE) {
Self::new_struct_type(self.as_struct_type().clone())
} else if matches!(self.tag, TK_UNION) {
Self::new_union_type(self.as_union_type().clone())
} else if matches!(self.tag, TK_BITSET) {
Self::new_bitset_type(self.as_bitset_type().clone())
} else if matches!(self.tag, TK_SEQUENCE) {
Self::new_sequence_type(self.as_sequence_type().clone())
} else if matches!(self.tag, TK_ARRAY) {
Self::new_array_type(self.as_array_type().clone())
} else if matches!(self.tag, TK_MAP) {
Self::new_map_type(self.as_map_type().clone())
} else if matches!(self.tag, TK_ENUM) {
Self::new_enumerated_type(self.as_enumerated_type().clone())
} else if matches!(self.tag, TK_BITMASK) {
Self::new_bitmask_type(self.as_bitmask_type().clone())
} else {
Self::new_extended_type(self.as_extended_type().clone())
}
}
}
impl core::fmt::Debug for CompleteTypeObject {
#[allow(unreachable_patterns)]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut d = f.debug_struct("CompleteTypeObject");
d.field("tag", &self.tag);
if matches!(self.tag, TK_ALIAS) {
d.field("alias_type", self.as_alias_type());
} else if matches!(self.tag, TK_ANNOTATION) {
d.field("annotation_type", self.as_annotation_type());
} else if matches!(self.tag, TK_STRUCTURE) {
d.field("struct_type", self.as_struct_type());
} else if matches!(self.tag, TK_UNION) {
d.field("union_type", self.as_union_type());
} else if matches!(self.tag, TK_BITSET) {
d.field("bitset_type", self.as_bitset_type());
} else if matches!(self.tag, TK_SEQUENCE) {
d.field("sequence_type", self.as_sequence_type());
} else if matches!(self.tag, TK_ARRAY) {
d.field("array_type", self.as_array_type());
} else if matches!(self.tag, TK_MAP) {
d.field("map_type", self.as_map_type());
} else if matches!(self.tag, TK_ENUM) {
d.field("enumerated_type", self.as_enumerated_type());
} else if matches!(self.tag, TK_BITMASK) {
d.field("bitmask_type", self.as_bitmask_type());
} else {
d.field("extended_type", self.as_extended_type());
}
d.finish()
}
}
impl PartialEq for CompleteTypeObject {
#[allow(unreachable_patterns)]
fn eq(&self, other: &Self) -> bool {
if self.tag != other.tag {
return false;
}
if matches!(self.tag, TK_ALIAS) {
self.as_alias_type() == other.as_alias_type()
} else if matches!(self.tag, TK_ANNOTATION) {
self.as_annotation_type() == other.as_annotation_type()
} else if matches!(self.tag, TK_STRUCTURE) {
self.as_struct_type() == other.as_struct_type()
} else if matches!(self.tag, TK_UNION) {
self.as_union_type() == other.as_union_type()
} else if matches!(self.tag, TK_BITSET) {
self.as_bitset_type() == other.as_bitset_type()
} else if matches!(self.tag, TK_SEQUENCE) {
self.as_sequence_type() == other.as_sequence_type()
} else if matches!(self.tag, TK_ARRAY) {
self.as_array_type() == other.as_array_type()
} else if matches!(self.tag, TK_MAP) {
self.as_map_type() == other.as_map_type()
} else if matches!(self.tag, TK_ENUM) {
self.as_enumerated_type() == other.as_enumerated_type()
} else if matches!(self.tag, TK_BITMASK) {
self.as_bitmask_type() == other.as_bitmask_type()
} else {
self.as_extended_type() == other.as_extended_type()
}
}
}
impl CompleteTypeObject {
pub fn new_alias_type(value: CompleteAliasType) -> Self {
Self {
tag: TK_ALIAS,
data: CompleteTypeObjectData {
alias_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_alias_type(&self) -> bool {
matches!(self.tag, TK_ALIAS)
}
#[allow(clippy::borrowed_box)]
pub fn as_alias_type(&self) -> &CompleteAliasType {
debug_assert!(self.is_alias_type());
unsafe { &self.data.alias_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_alias_type_mut(&mut self) -> &mut CompleteAliasType {
debug_assert!(self.is_alias_type());
unsafe { &mut self.data.alias_type }
}
pub fn into_alias_type(self) -> CompleteAliasType {
debug_assert!(self.is_alias_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.alias_type)
}
}
pub fn new_annotation_type(value: CompleteAnnotationType) -> Self {
Self {
tag: TK_ANNOTATION,
data: CompleteTypeObjectData {
annotation_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_annotation_type(&self) -> bool {
matches!(self.tag, TK_ANNOTATION)
}
#[allow(clippy::borrowed_box)]
pub fn as_annotation_type(&self) -> &CompleteAnnotationType {
debug_assert!(self.is_annotation_type());
unsafe { &self.data.annotation_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_annotation_type_mut(&mut self) -> &mut CompleteAnnotationType {
debug_assert!(self.is_annotation_type());
unsafe { &mut self.data.annotation_type }
}
pub fn into_annotation_type(self) -> CompleteAnnotationType {
debug_assert!(self.is_annotation_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.annotation_type)
}
}
pub fn new_struct_type(value: CompleteStructType) -> Self {
Self {
tag: TK_STRUCTURE,
data: CompleteTypeObjectData {
struct_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_struct_type(&self) -> bool {
matches!(self.tag, TK_STRUCTURE)
}
#[allow(clippy::borrowed_box)]
pub fn as_struct_type(&self) -> &CompleteStructType {
debug_assert!(self.is_struct_type());
unsafe { &self.data.struct_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_struct_type_mut(&mut self) -> &mut CompleteStructType {
debug_assert!(self.is_struct_type());
unsafe { &mut self.data.struct_type }
}
pub fn into_struct_type(self) -> CompleteStructType {
debug_assert!(self.is_struct_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.struct_type)
}
}
pub fn new_union_type(value: CompleteUnionType) -> Self {
Self {
tag: TK_UNION,
data: CompleteTypeObjectData {
union_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_union_type(&self) -> bool {
matches!(self.tag, TK_UNION)
}
#[allow(clippy::borrowed_box)]
pub fn as_union_type(&self) -> &CompleteUnionType {
debug_assert!(self.is_union_type());
unsafe { &self.data.union_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_union_type_mut(&mut self) -> &mut CompleteUnionType {
debug_assert!(self.is_union_type());
unsafe { &mut self.data.union_type }
}
pub fn into_union_type(self) -> CompleteUnionType {
debug_assert!(self.is_union_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.union_type)
}
}
pub fn new_bitset_type(value: CompleteBitsetType) -> Self {
Self {
tag: TK_BITSET,
data: CompleteTypeObjectData {
bitset_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_bitset_type(&self) -> bool {
matches!(self.tag, TK_BITSET)
}
#[allow(clippy::borrowed_box)]
pub fn as_bitset_type(&self) -> &CompleteBitsetType {
debug_assert!(self.is_bitset_type());
unsafe { &self.data.bitset_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_bitset_type_mut(&mut self) -> &mut CompleteBitsetType {
debug_assert!(self.is_bitset_type());
unsafe { &mut self.data.bitset_type }
}
pub fn into_bitset_type(self) -> CompleteBitsetType {
debug_assert!(self.is_bitset_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.bitset_type)
}
}
pub fn new_sequence_type(value: CompleteSequenceType) -> Self {
Self {
tag: TK_SEQUENCE,
data: CompleteTypeObjectData {
sequence_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_sequence_type(&self) -> bool {
matches!(self.tag, TK_SEQUENCE)
}
#[allow(clippy::borrowed_box)]
pub fn as_sequence_type(&self) -> &CompleteSequenceType {
debug_assert!(self.is_sequence_type());
unsafe { &self.data.sequence_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_sequence_type_mut(&mut self) -> &mut CompleteSequenceType {
debug_assert!(self.is_sequence_type());
unsafe { &mut self.data.sequence_type }
}
pub fn into_sequence_type(self) -> CompleteSequenceType {
debug_assert!(self.is_sequence_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.sequence_type)
}
}
pub fn new_array_type(value: CompleteArrayType) -> Self {
Self {
tag: TK_ARRAY,
data: CompleteTypeObjectData {
array_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_array_type(&self) -> bool {
matches!(self.tag, TK_ARRAY)
}
#[allow(clippy::borrowed_box)]
pub fn as_array_type(&self) -> &CompleteArrayType {
debug_assert!(self.is_array_type());
unsafe { &self.data.array_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_array_type_mut(&mut self) -> &mut CompleteArrayType {
debug_assert!(self.is_array_type());
unsafe { &mut self.data.array_type }
}
pub fn into_array_type(self) -> CompleteArrayType {
debug_assert!(self.is_array_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.array_type)
}
}
pub fn new_map_type(value: CompleteMapType) -> Self {
Self {
tag: TK_MAP,
data: CompleteTypeObjectData {
map_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_map_type(&self) -> bool {
matches!(self.tag, TK_MAP)
}
#[allow(clippy::borrowed_box)]
pub fn as_map_type(&self) -> &CompleteMapType {
debug_assert!(self.is_map_type());
unsafe { &self.data.map_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_map_type_mut(&mut self) -> &mut CompleteMapType {
debug_assert!(self.is_map_type());
unsafe { &mut self.data.map_type }
}
pub fn into_map_type(self) -> CompleteMapType {
debug_assert!(self.is_map_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.map_type)
}
}
pub fn new_enumerated_type(value: CompleteEnumeratedType) -> Self {
Self {
tag: TK_ENUM,
data: CompleteTypeObjectData {
enumerated_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_enumerated_type(&self) -> bool {
matches!(self.tag, TK_ENUM)
}
#[allow(clippy::borrowed_box)]
pub fn as_enumerated_type(&self) -> &CompleteEnumeratedType {
debug_assert!(self.is_enumerated_type());
unsafe { &self.data.enumerated_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_enumerated_type_mut(&mut self) -> &mut CompleteEnumeratedType {
debug_assert!(self.is_enumerated_type());
unsafe { &mut self.data.enumerated_type }
}
pub fn into_enumerated_type(self) -> CompleteEnumeratedType {
debug_assert!(self.is_enumerated_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.enumerated_type)
}
}
pub fn new_bitmask_type(value: CompleteBitmaskType) -> Self {
Self {
tag: TK_BITMASK,
data: CompleteTypeObjectData {
bitmask_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_bitmask_type(&self) -> bool {
matches!(self.tag, TK_BITMASK)
}
#[allow(clippy::borrowed_box)]
pub fn as_bitmask_type(&self) -> &CompleteBitmaskType {
debug_assert!(self.is_bitmask_type());
unsafe { &self.data.bitmask_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_bitmask_type_mut(&mut self) -> &mut CompleteBitmaskType {
debug_assert!(self.is_bitmask_type());
unsafe { &mut self.data.bitmask_type }
}
pub fn into_bitmask_type(self) -> CompleteBitmaskType {
debug_assert!(self.is_bitmask_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.bitmask_type)
}
}
pub fn new_extended_type(value: CompleteExtendedType) -> Self {
Self {
tag: u8::default(),
data: CompleteTypeObjectData {
extended_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_extended_type(&self) -> bool {
matches!(self.tag, _)
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_type(&self) -> &CompleteExtendedType {
debug_assert!(self.is_extended_type());
unsafe { &self.data.extended_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_type_mut(&mut self) -> &mut CompleteExtendedType {
debug_assert!(self.is_extended_type());
unsafe { &mut self.data.extended_type }
}
pub fn into_extended_type(self) -> CompleteExtendedType {
debug_assert!(self.is_extended_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.extended_type)
}
}
pub fn tag(&self) -> &u8 {
&self.tag
}
}
impl Default for CompleteTypeObject {
fn default() -> Self {
Self {
tag: u8::default(),
data: CompleteTypeObjectData {
extended_type: core::mem::ManuallyDrop::new(CompleteExtendedType::default()),
},
}
}
}
#[derive(::serde::Serialize)]
struct CompleteTypeObjectSerdeRef<'__a> {
tag: &'__a str,
data: CompleteTypeObjectSerdeRefData<'__a>,
}
#[allow(clippy::borrowed_box)]
#[derive(::serde::Serialize)]
#[serde(untagged)]
enum CompleteTypeObjectSerdeRefData<'__a> {
Case0(&'__a CompleteAliasType),
Case1(&'__a CompleteAnnotationType),
Case2(&'__a CompleteStructType),
Case3(&'__a CompleteUnionType),
Case4(&'__a CompleteBitsetType),
Case5(&'__a CompleteSequenceType),
Case6(&'__a CompleteArrayType),
Case7(&'__a CompleteMapType),
Case8(&'__a CompleteEnumeratedType),
Case9(&'__a CompleteBitmaskType),
Case10(&'__a CompleteExtendedType),
}
impl serde::Serialize for CompleteTypeObject {
#[allow(unreachable_patterns)]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
__S: serde::Serializer,
{
let helper = if matches!(self.tag, TK_ALIAS) {
let tag = "TK_ALIAS";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case0(self.as_alias_type()),
}
} else if matches!(self.tag, TK_ANNOTATION) {
let tag = "TK_ANNOTATION";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case1(self.as_annotation_type()),
}
} else if matches!(self.tag, TK_STRUCTURE) {
let tag = "TK_STRUCTURE";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case2(self.as_struct_type()),
}
} else if matches!(self.tag, TK_UNION) {
let tag = "TK_UNION";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case3(self.as_union_type()),
}
} else if matches!(self.tag, TK_BITSET) {
let tag = "TK_BITSET";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case4(self.as_bitset_type()),
}
} else if matches!(self.tag, TK_SEQUENCE) {
let tag = "TK_SEQUENCE";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case5(self.as_sequence_type()),
}
} else if matches!(self.tag, TK_ARRAY) {
let tag = "TK_ARRAY";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case6(self.as_array_type()),
}
} else if matches!(self.tag, TK_MAP) {
let tag = "TK_MAP";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case7(self.as_map_type()),
}
} else if matches!(self.tag, TK_ENUM) {
let tag = "TK_ENUM";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case8(self.as_enumerated_type()),
}
} else if matches!(self.tag, TK_BITMASK) {
let tag = "TK_BITMASK";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case9(self.as_bitmask_type()),
}
} else {
let tag = "default";
CompleteTypeObjectSerdeRef {
tag,
data: CompleteTypeObjectSerdeRefData::Case10(self.as_extended_type()),
}
};
helper.serialize(__serializer)
}
}
#[derive(::serde::Deserialize)]
struct CompleteTypeObjectSerdeOwned {
tag: String,
data: ::serde_json::Value,
}
impl<'de> serde::Deserialize<'de> for CompleteTypeObject {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let helper = CompleteTypeObjectSerdeOwned::deserialize(deserializer)?;
match helper.tag.as_str() {
"TK_ALIAS" => {
let value = ::serde_json::from_value::<
CompleteAliasType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_ALIAS`: {err}"
),
))?;
Ok(Self {
tag: TK_ALIAS,
data: CompleteTypeObjectData {
alias_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_ANNOTATION" => {
let value = ::serde_json::from_value::<
CompleteAnnotationType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_ANNOTATION`: {err}"
),
))?;
Ok(Self {
tag: TK_ANNOTATION,
data: CompleteTypeObjectData {
annotation_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_STRUCTURE" => {
let value = ::serde_json::from_value::<
CompleteStructType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_STRUCTURE`: {err}"
),
))?;
Ok(Self {
tag: TK_STRUCTURE,
data: CompleteTypeObjectData {
struct_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_UNION" => {
let value = ::serde_json::from_value::<
CompleteUnionType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_UNION`: {err}"
),
))?;
Ok(Self {
tag: TK_UNION,
data: CompleteTypeObjectData {
union_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_BITSET" => {
let value = ::serde_json::from_value::<
CompleteBitsetType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_BITSET`: {err}"
),
))?;
Ok(Self {
tag: TK_BITSET,
data: CompleteTypeObjectData {
bitset_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_SEQUENCE" => {
let value = ::serde_json::from_value::<
CompleteSequenceType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_SEQUENCE`: {err}"
),
))?;
Ok(Self {
tag: TK_SEQUENCE,
data: CompleteTypeObjectData {
sequence_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_ARRAY" => {
let value = ::serde_json::from_value::<
CompleteArrayType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_ARRAY`: {err}"
),
))?;
Ok(Self {
tag: TK_ARRAY,
data: CompleteTypeObjectData {
array_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_MAP" => {
let value = ::serde_json::from_value::<
CompleteMapType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_MAP`: {err}"
),
))?;
Ok(Self {
tag: TK_MAP,
data: CompleteTypeObjectData {
map_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_ENUM" => {
let value = ::serde_json::from_value::<
CompleteEnumeratedType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_ENUM`: {err}"
),
))?;
Ok(Self {
tag: TK_ENUM,
data: CompleteTypeObjectData {
enumerated_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_BITMASK" => {
let value = ::serde_json::from_value::<
CompleteBitmaskType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `TK_BITMASK`: {err}"
),
))?;
Ok(Self {
tag: TK_BITMASK,
data: CompleteTypeObjectData {
bitmask_type: core::mem::ManuallyDrop::new(value),
},
})
}
"default" => {
let value = ::serde_json::from_value::<
CompleteExtendedType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union CompleteTypeObject payload decode failed for tag `default`: {err}"
),
))?;
Ok(Self {
tag: u8::default(),
data: CompleteTypeObjectData {
extended_type: core::mem::ManuallyDrop::new(value),
},
})
}
_ => Err(serde::de::Error::custom(format!(
"union CompleteTypeObject tag/data mismatch for tag `{}`",
helper.tag
))),
}
}
}
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct MinimalExtendedType {}
impl MinimalExtendedType {}
pub struct MinimalTypeObject {
tag: u8,
data: MinimalTypeObjectData,
}
union MinimalTypeObjectData {
alias_type: core::mem::ManuallyDrop<MinimalAliasType>,
annotation_type: core::mem::ManuallyDrop<MinimalAnnotationType>,
struct_type: core::mem::ManuallyDrop<MinimalStructType>,
union_type: core::mem::ManuallyDrop<MinimalUnionType>,
bitset_type: core::mem::ManuallyDrop<MinimalBitsetType>,
sequence_type: core::mem::ManuallyDrop<MinimalSequenceType>,
array_type: core::mem::ManuallyDrop<MinimalArrayType>,
map_type: core::mem::ManuallyDrop<MinimalMapType>,
enumerated_type: core::mem::ManuallyDrop<MinimalEnumeratedType>,
bitmask_type: core::mem::ManuallyDrop<MinimalBitmaskType>,
extended_type: core::mem::ManuallyDrop<MinimalExtendedType>,
}
impl Drop for MinimalTypeObject {
#[allow(unreachable_patterns)]
fn drop(&mut self) {
if matches!(self.tag, TK_ALIAS) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.alias_type);
}
} else if matches!(self.tag, TK_ANNOTATION) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.annotation_type);
}
} else if matches!(self.tag, TK_STRUCTURE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.struct_type);
}
} else if matches!(self.tag, TK_UNION) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.union_type);
}
} else if matches!(self.tag, TK_BITSET) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.bitset_type);
}
} else if matches!(self.tag, TK_SEQUENCE) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.sequence_type);
}
} else if matches!(self.tag, TK_ARRAY) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.array_type);
}
} else if matches!(self.tag, TK_MAP) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.map_type);
}
} else if matches!(self.tag, TK_ENUM) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.enumerated_type);
}
} else if matches!(self.tag, TK_BITMASK) {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.bitmask_type);
}
} else {
unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.extended_type);
}
}
}
}
impl Clone for MinimalTypeObject {
#[allow(clippy::clone_on_copy)]
#[allow(unreachable_patterns)]
fn clone(&self) -> Self {
if matches!(self.tag, TK_ALIAS) {
Self::new_alias_type(self.as_alias_type().clone())
} else if matches!(self.tag, TK_ANNOTATION) {
Self::new_annotation_type(self.as_annotation_type().clone())
} else if matches!(self.tag, TK_STRUCTURE) {
Self::new_struct_type(self.as_struct_type().clone())
} else if matches!(self.tag, TK_UNION) {
Self::new_union_type(self.as_union_type().clone())
} else if matches!(self.tag, TK_BITSET) {
Self::new_bitset_type(self.as_bitset_type().clone())
} else if matches!(self.tag, TK_SEQUENCE) {
Self::new_sequence_type(self.as_sequence_type().clone())
} else if matches!(self.tag, TK_ARRAY) {
Self::new_array_type(self.as_array_type().clone())
} else if matches!(self.tag, TK_MAP) {
Self::new_map_type(self.as_map_type().clone())
} else if matches!(self.tag, TK_ENUM) {
Self::new_enumerated_type(self.as_enumerated_type().clone())
} else if matches!(self.tag, TK_BITMASK) {
Self::new_bitmask_type(self.as_bitmask_type().clone())
} else {
Self::new_extended_type(self.as_extended_type().clone())
}
}
}
impl core::fmt::Debug for MinimalTypeObject {
#[allow(unreachable_patterns)]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut d = f.debug_struct("MinimalTypeObject");
d.field("tag", &self.tag);
if matches!(self.tag, TK_ALIAS) {
d.field("alias_type", self.as_alias_type());
} else if matches!(self.tag, TK_ANNOTATION) {
d.field("annotation_type", self.as_annotation_type());
} else if matches!(self.tag, TK_STRUCTURE) {
d.field("struct_type", self.as_struct_type());
} else if matches!(self.tag, TK_UNION) {
d.field("union_type", self.as_union_type());
} else if matches!(self.tag, TK_BITSET) {
d.field("bitset_type", self.as_bitset_type());
} else if matches!(self.tag, TK_SEQUENCE) {
d.field("sequence_type", self.as_sequence_type());
} else if matches!(self.tag, TK_ARRAY) {
d.field("array_type", self.as_array_type());
} else if matches!(self.tag, TK_MAP) {
d.field("map_type", self.as_map_type());
} else if matches!(self.tag, TK_ENUM) {
d.field("enumerated_type", self.as_enumerated_type());
} else if matches!(self.tag, TK_BITMASK) {
d.field("bitmask_type", self.as_bitmask_type());
} else {
d.field("extended_type", self.as_extended_type());
}
d.finish()
}
}
impl PartialEq for MinimalTypeObject {
#[allow(unreachable_patterns)]
fn eq(&self, other: &Self) -> bool {
if self.tag != other.tag {
return false;
}
if matches!(self.tag, TK_ALIAS) {
self.as_alias_type() == other.as_alias_type()
} else if matches!(self.tag, TK_ANNOTATION) {
self.as_annotation_type() == other.as_annotation_type()
} else if matches!(self.tag, TK_STRUCTURE) {
self.as_struct_type() == other.as_struct_type()
} else if matches!(self.tag, TK_UNION) {
self.as_union_type() == other.as_union_type()
} else if matches!(self.tag, TK_BITSET) {
self.as_bitset_type() == other.as_bitset_type()
} else if matches!(self.tag, TK_SEQUENCE) {
self.as_sequence_type() == other.as_sequence_type()
} else if matches!(self.tag, TK_ARRAY) {
self.as_array_type() == other.as_array_type()
} else if matches!(self.tag, TK_MAP) {
self.as_map_type() == other.as_map_type()
} else if matches!(self.tag, TK_ENUM) {
self.as_enumerated_type() == other.as_enumerated_type()
} else if matches!(self.tag, TK_BITMASK) {
self.as_bitmask_type() == other.as_bitmask_type()
} else {
self.as_extended_type() == other.as_extended_type()
}
}
}
impl MinimalTypeObject {
pub fn new_alias_type(value: MinimalAliasType) -> Self {
Self {
tag: TK_ALIAS,
data: MinimalTypeObjectData {
alias_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_alias_type(&self) -> bool {
matches!(self.tag, TK_ALIAS)
}
#[allow(clippy::borrowed_box)]
pub fn as_alias_type(&self) -> &MinimalAliasType {
debug_assert!(self.is_alias_type());
unsafe { &self.data.alias_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_alias_type_mut(&mut self) -> &mut MinimalAliasType {
debug_assert!(self.is_alias_type());
unsafe { &mut self.data.alias_type }
}
pub fn into_alias_type(self) -> MinimalAliasType {
debug_assert!(self.is_alias_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.alias_type)
}
}
pub fn new_annotation_type(value: MinimalAnnotationType) -> Self {
Self {
tag: TK_ANNOTATION,
data: MinimalTypeObjectData {
annotation_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_annotation_type(&self) -> bool {
matches!(self.tag, TK_ANNOTATION)
}
#[allow(clippy::borrowed_box)]
pub fn as_annotation_type(&self) -> &MinimalAnnotationType {
debug_assert!(self.is_annotation_type());
unsafe { &self.data.annotation_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_annotation_type_mut(&mut self) -> &mut MinimalAnnotationType {
debug_assert!(self.is_annotation_type());
unsafe { &mut self.data.annotation_type }
}
pub fn into_annotation_type(self) -> MinimalAnnotationType {
debug_assert!(self.is_annotation_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.annotation_type)
}
}
pub fn new_struct_type(value: MinimalStructType) -> Self {
Self {
tag: TK_STRUCTURE,
data: MinimalTypeObjectData {
struct_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_struct_type(&self) -> bool {
matches!(self.tag, TK_STRUCTURE)
}
#[allow(clippy::borrowed_box)]
pub fn as_struct_type(&self) -> &MinimalStructType {
debug_assert!(self.is_struct_type());
unsafe { &self.data.struct_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_struct_type_mut(&mut self) -> &mut MinimalStructType {
debug_assert!(self.is_struct_type());
unsafe { &mut self.data.struct_type }
}
pub fn into_struct_type(self) -> MinimalStructType {
debug_assert!(self.is_struct_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.struct_type)
}
}
pub fn new_union_type(value: MinimalUnionType) -> Self {
Self {
tag: TK_UNION,
data: MinimalTypeObjectData {
union_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_union_type(&self) -> bool {
matches!(self.tag, TK_UNION)
}
#[allow(clippy::borrowed_box)]
pub fn as_union_type(&self) -> &MinimalUnionType {
debug_assert!(self.is_union_type());
unsafe { &self.data.union_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_union_type_mut(&mut self) -> &mut MinimalUnionType {
debug_assert!(self.is_union_type());
unsafe { &mut self.data.union_type }
}
pub fn into_union_type(self) -> MinimalUnionType {
debug_assert!(self.is_union_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.union_type)
}
}
pub fn new_bitset_type(value: MinimalBitsetType) -> Self {
Self {
tag: TK_BITSET,
data: MinimalTypeObjectData {
bitset_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_bitset_type(&self) -> bool {
matches!(self.tag, TK_BITSET)
}
#[allow(clippy::borrowed_box)]
pub fn as_bitset_type(&self) -> &MinimalBitsetType {
debug_assert!(self.is_bitset_type());
unsafe { &self.data.bitset_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_bitset_type_mut(&mut self) -> &mut MinimalBitsetType {
debug_assert!(self.is_bitset_type());
unsafe { &mut self.data.bitset_type }
}
pub fn into_bitset_type(self) -> MinimalBitsetType {
debug_assert!(self.is_bitset_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.bitset_type)
}
}
pub fn new_sequence_type(value: MinimalSequenceType) -> Self {
Self {
tag: TK_SEQUENCE,
data: MinimalTypeObjectData {
sequence_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_sequence_type(&self) -> bool {
matches!(self.tag, TK_SEQUENCE)
}
#[allow(clippy::borrowed_box)]
pub fn as_sequence_type(&self) -> &MinimalSequenceType {
debug_assert!(self.is_sequence_type());
unsafe { &self.data.sequence_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_sequence_type_mut(&mut self) -> &mut MinimalSequenceType {
debug_assert!(self.is_sequence_type());
unsafe { &mut self.data.sequence_type }
}
pub fn into_sequence_type(self) -> MinimalSequenceType {
debug_assert!(self.is_sequence_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.sequence_type)
}
}
pub fn new_array_type(value: MinimalArrayType) -> Self {
Self {
tag: TK_ARRAY,
data: MinimalTypeObjectData {
array_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_array_type(&self) -> bool {
matches!(self.tag, TK_ARRAY)
}
#[allow(clippy::borrowed_box)]
pub fn as_array_type(&self) -> &MinimalArrayType {
debug_assert!(self.is_array_type());
unsafe { &self.data.array_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_array_type_mut(&mut self) -> &mut MinimalArrayType {
debug_assert!(self.is_array_type());
unsafe { &mut self.data.array_type }
}
pub fn into_array_type(self) -> MinimalArrayType {
debug_assert!(self.is_array_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.array_type)
}
}
pub fn new_map_type(value: MinimalMapType) -> Self {
Self {
tag: TK_MAP,
data: MinimalTypeObjectData {
map_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_map_type(&self) -> bool {
matches!(self.tag, TK_MAP)
}
#[allow(clippy::borrowed_box)]
pub fn as_map_type(&self) -> &MinimalMapType {
debug_assert!(self.is_map_type());
unsafe { &self.data.map_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_map_type_mut(&mut self) -> &mut MinimalMapType {
debug_assert!(self.is_map_type());
unsafe { &mut self.data.map_type }
}
pub fn into_map_type(self) -> MinimalMapType {
debug_assert!(self.is_map_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.map_type)
}
}
pub fn new_enumerated_type(value: MinimalEnumeratedType) -> Self {
Self {
tag: TK_ENUM,
data: MinimalTypeObjectData {
enumerated_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_enumerated_type(&self) -> bool {
matches!(self.tag, TK_ENUM)
}
#[allow(clippy::borrowed_box)]
pub fn as_enumerated_type(&self) -> &MinimalEnumeratedType {
debug_assert!(self.is_enumerated_type());
unsafe { &self.data.enumerated_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_enumerated_type_mut(&mut self) -> &mut MinimalEnumeratedType {
debug_assert!(self.is_enumerated_type());
unsafe { &mut self.data.enumerated_type }
}
pub fn into_enumerated_type(self) -> MinimalEnumeratedType {
debug_assert!(self.is_enumerated_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.enumerated_type)
}
}
pub fn new_bitmask_type(value: MinimalBitmaskType) -> Self {
Self {
tag: TK_BITMASK,
data: MinimalTypeObjectData {
bitmask_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_bitmask_type(&self) -> bool {
matches!(self.tag, TK_BITMASK)
}
#[allow(clippy::borrowed_box)]
pub fn as_bitmask_type(&self) -> &MinimalBitmaskType {
debug_assert!(self.is_bitmask_type());
unsafe { &self.data.bitmask_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_bitmask_type_mut(&mut self) -> &mut MinimalBitmaskType {
debug_assert!(self.is_bitmask_type());
unsafe { &mut self.data.bitmask_type }
}
pub fn into_bitmask_type(self) -> MinimalBitmaskType {
debug_assert!(self.is_bitmask_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.bitmask_type)
}
}
pub fn new_extended_type(value: MinimalExtendedType) -> Self {
Self {
tag: u8::default(),
data: MinimalTypeObjectData {
extended_type: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_extended_type(&self) -> bool {
matches!(self.tag, _)
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_type(&self) -> &MinimalExtendedType {
debug_assert!(self.is_extended_type());
unsafe { &self.data.extended_type }
}
#[allow(clippy::borrowed_box)]
pub fn as_extended_type_mut(&mut self) -> &mut MinimalExtendedType {
debug_assert!(self.is_extended_type());
unsafe { &mut self.data.extended_type }
}
pub fn into_extended_type(self) -> MinimalExtendedType {
debug_assert!(self.is_extended_type());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.extended_type)
}
}
pub fn tag(&self) -> &u8 {
&self.tag
}
}
impl Default for MinimalTypeObject {
fn default() -> Self {
Self {
tag: u8::default(),
data: MinimalTypeObjectData {
extended_type: core::mem::ManuallyDrop::new(MinimalExtendedType::default()),
},
}
}
}
#[derive(::serde::Serialize)]
struct MinimalTypeObjectSerdeRef<'__a> {
tag: &'__a str,
data: MinimalTypeObjectSerdeRefData<'__a>,
}
#[allow(clippy::borrowed_box)]
#[derive(::serde::Serialize)]
#[serde(untagged)]
enum MinimalTypeObjectSerdeRefData<'__a> {
Case0(&'__a MinimalAliasType),
Case1(&'__a MinimalAnnotationType),
Case2(&'__a MinimalStructType),
Case3(&'__a MinimalUnionType),
Case4(&'__a MinimalBitsetType),
Case5(&'__a MinimalSequenceType),
Case6(&'__a MinimalArrayType),
Case7(&'__a MinimalMapType),
Case8(&'__a MinimalEnumeratedType),
Case9(&'__a MinimalBitmaskType),
Case10(&'__a MinimalExtendedType),
}
impl serde::Serialize for MinimalTypeObject {
#[allow(unreachable_patterns)]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
__S: serde::Serializer,
{
let helper = if matches!(self.tag, TK_ALIAS) {
let tag = "TK_ALIAS";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case0(self.as_alias_type()),
}
} else if matches!(self.tag, TK_ANNOTATION) {
let tag = "TK_ANNOTATION";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case1(self.as_annotation_type()),
}
} else if matches!(self.tag, TK_STRUCTURE) {
let tag = "TK_STRUCTURE";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case2(self.as_struct_type()),
}
} else if matches!(self.tag, TK_UNION) {
let tag = "TK_UNION";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case3(self.as_union_type()),
}
} else if matches!(self.tag, TK_BITSET) {
let tag = "TK_BITSET";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case4(self.as_bitset_type()),
}
} else if matches!(self.tag, TK_SEQUENCE) {
let tag = "TK_SEQUENCE";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case5(self.as_sequence_type()),
}
} else if matches!(self.tag, TK_ARRAY) {
let tag = "TK_ARRAY";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case6(self.as_array_type()),
}
} else if matches!(self.tag, TK_MAP) {
let tag = "TK_MAP";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case7(self.as_map_type()),
}
} else if matches!(self.tag, TK_ENUM) {
let tag = "TK_ENUM";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case8(self.as_enumerated_type()),
}
} else if matches!(self.tag, TK_BITMASK) {
let tag = "TK_BITMASK";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case9(self.as_bitmask_type()),
}
} else {
let tag = "default";
MinimalTypeObjectSerdeRef {
tag,
data: MinimalTypeObjectSerdeRefData::Case10(self.as_extended_type()),
}
};
helper.serialize(__serializer)
}
}
#[derive(::serde::Deserialize)]
struct MinimalTypeObjectSerdeOwned {
tag: String,
data: ::serde_json::Value,
}
impl<'de> serde::Deserialize<'de> for MinimalTypeObject {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let helper = MinimalTypeObjectSerdeOwned::deserialize(deserializer)?;
match helper.tag.as_str() {
"TK_ALIAS" => {
let value = ::serde_json::from_value::<
MinimalAliasType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_ALIAS`: {err}"
),
))?;
Ok(Self {
tag: TK_ALIAS,
data: MinimalTypeObjectData {
alias_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_ANNOTATION" => {
let value = ::serde_json::from_value::<
MinimalAnnotationType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_ANNOTATION`: {err}"
),
))?;
Ok(Self {
tag: TK_ANNOTATION,
data: MinimalTypeObjectData {
annotation_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_STRUCTURE" => {
let value = ::serde_json::from_value::<
MinimalStructType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_STRUCTURE`: {err}"
),
))?;
Ok(Self {
tag: TK_STRUCTURE,
data: MinimalTypeObjectData {
struct_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_UNION" => {
let value = ::serde_json::from_value::<
MinimalUnionType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_UNION`: {err}"
),
))?;
Ok(Self {
tag: TK_UNION,
data: MinimalTypeObjectData {
union_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_BITSET" => {
let value = ::serde_json::from_value::<
MinimalBitsetType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_BITSET`: {err}"
),
))?;
Ok(Self {
tag: TK_BITSET,
data: MinimalTypeObjectData {
bitset_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_SEQUENCE" => {
let value = ::serde_json::from_value::<
MinimalSequenceType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_SEQUENCE`: {err}"
),
))?;
Ok(Self {
tag: TK_SEQUENCE,
data: MinimalTypeObjectData {
sequence_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_ARRAY" => {
let value = ::serde_json::from_value::<
MinimalArrayType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_ARRAY`: {err}"
),
))?;
Ok(Self {
tag: TK_ARRAY,
data: MinimalTypeObjectData {
array_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_MAP" => {
let value = ::serde_json::from_value::<
MinimalMapType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_MAP`: {err}"
),
))?;
Ok(Self {
tag: TK_MAP,
data: MinimalTypeObjectData {
map_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_ENUM" => {
let value = ::serde_json::from_value::<
MinimalEnumeratedType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_ENUM`: {err}"
),
))?;
Ok(Self {
tag: TK_ENUM,
data: MinimalTypeObjectData {
enumerated_type: core::mem::ManuallyDrop::new(value),
},
})
}
"TK_BITMASK" => {
let value = ::serde_json::from_value::<
MinimalBitmaskType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `TK_BITMASK`: {err}"
),
))?;
Ok(Self {
tag: TK_BITMASK,
data: MinimalTypeObjectData {
bitmask_type: core::mem::ManuallyDrop::new(value),
},
})
}
"default" => {
let value = ::serde_json::from_value::<
MinimalExtendedType,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union MinimalTypeObject payload decode failed for tag `default`: {err}"
),
))?;
Ok(Self {
tag: u8::default(),
data: MinimalTypeObjectData {
extended_type: core::mem::ManuallyDrop::new(value),
},
})
}
_ => Err(serde::de::Error::custom(format!(
"union MinimalTypeObject tag/data mismatch for tag `{}`",
helper.tag
))),
}
}
}
pub struct TypeObject {
tag: u8,
data: TypeObjectData,
}
union TypeObjectData {
complete: core::mem::ManuallyDrop<CompleteTypeObject>,
minimal: core::mem::ManuallyDrop<MinimalTypeObject>,
}
impl Drop for TypeObject {
#[allow(unreachable_patterns)]
fn drop(&mut self) {
match self.tag {
EK_COMPLETE => unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.complete);
},
EK_MINIMAL => unsafe {
core::mem::ManuallyDrop::drop(&mut self.data.minimal);
},
_ => {}
}
}
}
impl Clone for TypeObject {
#[allow(clippy::clone_on_copy)]
#[allow(unreachable_patterns)]
fn clone(&self) -> Self {
match self.tag {
EK_COMPLETE => Self::new_complete(self.as_complete().clone()),
EK_MINIMAL => Self::new_minimal(self.as_minimal().clone()),
_ => unreachable!(),
}
}
}
impl core::fmt::Debug for TypeObject {
#[allow(unreachable_patterns)]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut d = f.debug_struct("TypeObject");
d.field("tag", &self.tag);
match self.tag {
EK_COMPLETE => {
d.field("complete", self.as_complete());
}
EK_MINIMAL => {
d.field("minimal", self.as_minimal());
}
_ => {}
}
d.finish()
}
}
impl PartialEq for TypeObject {
#[allow(unreachable_patterns)]
fn eq(&self, other: &Self) -> bool {
if self.tag != other.tag {
return false;
}
match self.tag {
EK_COMPLETE => self.as_complete() == other.as_complete(),
EK_MINIMAL => self.as_minimal() == other.as_minimal(),
_ => false,
}
}
}
impl TypeObject {
pub fn new_complete(value: CompleteTypeObject) -> Self {
Self {
tag: EK_COMPLETE,
data: TypeObjectData {
complete: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_complete(&self) -> bool {
matches!(self.tag, EK_COMPLETE)
}
#[allow(clippy::borrowed_box)]
pub fn as_complete(&self) -> &CompleteTypeObject {
debug_assert!(self.is_complete());
unsafe { &self.data.complete }
}
#[allow(clippy::borrowed_box)]
pub fn as_complete_mut(&mut self) -> &mut CompleteTypeObject {
debug_assert!(self.is_complete());
unsafe { &mut self.data.complete }
}
pub fn into_complete(self) -> CompleteTypeObject {
debug_assert!(self.is_complete());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.complete)
}
}
pub fn new_minimal(value: MinimalTypeObject) -> Self {
Self {
tag: EK_MINIMAL,
data: TypeObjectData {
minimal: core::mem::ManuallyDrop::new(value),
},
}
}
pub fn is_minimal(&self) -> bool {
matches!(self.tag, EK_MINIMAL)
}
#[allow(clippy::borrowed_box)]
pub fn as_minimal(&self) -> &MinimalTypeObject {
debug_assert!(self.is_minimal());
unsafe { &self.data.minimal }
}
#[allow(clippy::borrowed_box)]
pub fn as_minimal_mut(&mut self) -> &mut MinimalTypeObject {
debug_assert!(self.is_minimal());
unsafe { &mut self.data.minimal }
}
pub fn into_minimal(self) -> MinimalTypeObject {
debug_assert!(self.is_minimal());
unsafe {
let mut forget = core::mem::ManuallyDrop::new(self);
core::mem::ManuallyDrop::take(&mut forget.data.minimal)
}
}
pub fn tag(&self) -> &u8 {
&self.tag
}
}
impl Default for TypeObject {
fn default() -> Self {
Self {
tag: EK_COMPLETE,
data: TypeObjectData {
complete: core::mem::ManuallyDrop::new(CompleteTypeObject::default()),
},
}
}
}
#[derive(::serde::Serialize)]
struct TypeObjectSerdeRef<'__a> {
tag: &'__a str,
data: TypeObjectSerdeRefData<'__a>,
}
#[allow(clippy::borrowed_box)]
#[derive(::serde::Serialize)]
#[serde(untagged)]
enum TypeObjectSerdeRefData<'__a> {
Case0(&'__a CompleteTypeObject),
Case1(&'__a MinimalTypeObject),
}
impl serde::Serialize for TypeObject {
#[allow(unreachable_patterns)]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where
__S: serde::Serializer,
{
let helper = match self.tag {
EK_COMPLETE => {
let tag = "EK_COMPLETE";
TypeObjectSerdeRef {
tag,
data: TypeObjectSerdeRefData::Case0(self.as_complete()),
}
}
EK_MINIMAL => {
let tag = "EK_MINIMAL";
TypeObjectSerdeRef {
tag,
data: TypeObjectSerdeRefData::Case1(self.as_minimal()),
}
}
_ => unreachable!(),
};
helper.serialize(__serializer)
}
}
#[derive(::serde::Deserialize)]
struct TypeObjectSerdeOwned {
tag: String,
data: ::serde_json::Value,
}
impl<'de> serde::Deserialize<'de> for TypeObject {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let helper = TypeObjectSerdeOwned::deserialize(deserializer)?;
match helper.tag.as_str() {
"EK_COMPLETE" => {
let value = ::serde_json::from_value::<
CompleteTypeObject,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeObject payload decode failed for tag `EK_COMPLETE`: {err}"
),
))?;
Ok(Self {
tag: EK_COMPLETE,
data: TypeObjectData {
complete: core::mem::ManuallyDrop::new(value),
},
})
}
"EK_MINIMAL" => {
let value = ::serde_json::from_value::<
MinimalTypeObject,
>(helper.data)
.map_err(|err| serde::de::Error::custom(
format!(
"union TypeObject payload decode failed for tag `EK_MINIMAL`: {err}"
),
))?;
Ok(Self {
tag: EK_MINIMAL,
data: TypeObjectData {
minimal: core::mem::ManuallyDrop::new(value),
},
})
}
_ => Err(serde::de::Error::custom(format!(
"union TypeObject tag/data mismatch for tag `{}`",
helper.tag
))),
}
}
}
pub type TypeObjectSeq = Vec<TypeObject>;
pub type StronglyConnectedComponent = TypeObjectSeq;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct TypeIdentifierTypeObjectPair {
pub type_identifier: TypeIdentifier,
pub type_object: TypeObject,
}
impl TypeIdentifierTypeObjectPair {}
pub type TypeIdentifierTypeObjectPairSeq = Vec<TypeIdentifierTypeObjectPair>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct TypeIdentifierPair {
pub type_identifier1: TypeIdentifier,
pub type_identifier2: TypeIdentifier,
}
impl TypeIdentifierPair {}
pub type TypeIdentifierPairSeq = Vec<TypeIdentifierPair>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct TypeIdentifierWithSize {
pub type_id: TypeIdentifier,
pub typeobject_serialized_size: u32,
}
impl TypeIdentifierWithSize {}
pub type TypeIdentifierWithSizeSeq = Vec<TypeIdentifierWithSize>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct TypeIdentifierWithDependencies {
pub typeid_with_size: TypeIdentifierWithSize,
pub dependent_typeid_count: i32,
pub dependent_typeids: Vec<TypeIdentifierWithSize>,
}
impl TypeIdentifierWithDependencies {}
pub type TypeIdentifierWithDependenciesSeq = Vec<TypeIdentifierWithDependencies>;
#[derive(Debug, Clone, PartialEq, ::serde::Serialize, ::serde::Deserialize, Default)]
pub struct TypeInformation {
pub minimal: TypeIdentifierWithDependencies,
pub complete: TypeIdentifierWithDependencies,
}
impl TypeInformation {}
pub type TypeInformationSeq = Vec<TypeInformation>;
}
}