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
40
41
42
43
44
45
46
47
48
49
50
51
52
use std::alloc::Layout;
mod cast;
pub mod diff;
pub mod gc;
pub mod mapping;
pub mod prelude {
pub use crate::diff::{diff, Diff, FieldDiff, FieldEditKind};
pub use crate::mapping::{Action, FieldMapping};
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum TypeGroup {
Primitive,
Struct,
}
impl<'t> From<&'t abi::TypeInfoData> for TypeGroup {
fn from(data: &'t abi::TypeInfoData) -> Self {
match data {
abi::TypeInfoData::Primitive => TypeGroup::Primitive,
abi::TypeInfoData::Struct(_) => TypeGroup::Struct,
}
}
}
pub trait TypeDesc: Send + Sync {
fn name(&self) -> &str;
fn guid(&self) -> &abi::Guid;
fn group(&self) -> TypeGroup;
}
pub trait TypeMemory: Send + Sync {
fn layout(&self) -> Layout;
fn is_stack_allocated(&self) -> bool;
}
pub trait TypeFields<T>: Send + Sync {
fn fields(&self) -> Vec<(&str, T)>;
fn offsets(&self) -> &[u16];
}