near_structs_checker_core/
lib.rs1use std::any::TypeId;
2
3pub type FieldName = &'static str;
4pub type EnumVariant = Option<&'static [(FieldName, TypeId)]>;
5
6#[derive(Copy, Clone)]
7pub enum ProtocolStructInfo {
8 Struct { name: FieldName, type_id: TypeId, fields: &'static [(FieldName, TypeId)] },
9 Enum { name: FieldName, type_id: TypeId, variants: &'static [(FieldName, EnumVariant)] },
10}
11
12impl ProtocolStructInfo {
13 pub fn type_id(&self) -> TypeId {
14 match self {
15 ProtocolStructInfo::Struct { type_id, .. } => *type_id,
16 ProtocolStructInfo::Enum { type_id, .. } => *type_id,
17 }
18 }
19
20 pub fn name(&self) -> &'static str {
21 match self {
22 ProtocolStructInfo::Struct { name, .. } => name,
23 ProtocolStructInfo::Enum { name, .. } => name,
24 }
25 }
26}
27
28#[cfg(feature = "protocol_schema")]
29inventory::collect!(ProtocolStructInfo);
30
31pub trait ProtocolStruct {}