spacetimedb_sats/
algebraic_type_ref.rs1use crate::impl_st;
2use crate::{algebraic_type::AlgebraicType, impl_deserialize, impl_serialize, meta_type::MetaType};
3use std::fmt::Display;
4
5#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
10pub struct AlgebraicTypeRef(
11 pub u32,
13);
14
15impl AlgebraicTypeRef {
16 pub const fn idx(self) -> usize {
18 self.0 as usize
19 }
20}
21
22impl_serialize!([] AlgebraicTypeRef, (self, ser) => self.0.serialize(ser));
23impl_deserialize!([] AlgebraicTypeRef, de => u32::deserialize(de).map(Self));
24impl_st!([] AlgebraicTypeRef, AlgebraicType::U32);
25
26impl Display for AlgebraicTypeRef {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 write!(f, "&{}", self.0)
30 }
31}
32
33impl MetaType for AlgebraicTypeRef {
34 fn meta_type() -> AlgebraicType {
35 AlgebraicType::U32
36 }
37}