blob: af028e89d20ad1dd80376b75d420801f219104ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
use std::any::TypeId;
pub mod types {
use crate::Object;
use std::any::TypeId;
pub const OBJECT: TypeId = TypeId::of::<Object>();
pub const STR: TypeId = TypeId::of::<&str>();
pub const BINARY: TypeId = TypeId::of::<&[u8]>();
pub const U32: TypeId = TypeId::of::<u32>();
pub const U64: TypeId = TypeId::of::<u64>();
pub const I64: TypeId = TypeId::of::<i64>();
pub const F64: TypeId = TypeId::of::<f64>();
}
#[derive(Clone)]
pub struct TagInfo {
pub name: &'static str,
pub r#type: Option<TypeId>,
}
#[macro_export]
macro_rules! fields {
($($id:ident: $type:ty = $tag:literal;)*) => {
$(pub const $id: $crate::TypedTag<$type> = $crate::TypedTag($crate::Tag::new($tag), std::marker::PhantomData);)*
};
}
#[macro_export]
macro_rules! enums {
($($id:ident = $tag:literal;)*) => {
$(pub const $id: $crate::Tag = $crate::Tag::new($tag);)*
};
}
|