1use twizzler_abi::thread::ThreadRepr;
4
5#[rustc_on_unimplemented(
13 message = "`{Self}` is not safe to be stored in an object",
14 label = "`{Self}` is not safe to be stored in an object"
15)]
16pub unsafe trait Invariant {}
17
18unsafe impl Invariant for u8 {}
19unsafe impl Invariant for u16 {}
20unsafe impl Invariant for u32 {}
21unsafe impl Invariant for u64 {}
22unsafe impl Invariant for bool {}
23unsafe impl Invariant for i8 {}
24unsafe impl Invariant for i16 {}
25unsafe impl Invariant for i32 {}
26unsafe impl Invariant for i64 {}
27
28unsafe impl Invariant for f64 {}
29unsafe impl Invariant for f32 {}
30
31unsafe impl Invariant for () {}
32
33unsafe impl<T: Invariant, const N: usize> Invariant for [T; N] {}
34
35unsafe impl<T: Invariant> Invariant for (T,) {}
36unsafe impl<A: Invariant, B: Invariant> Invariant for (A, B) {}
37
38unsafe impl<T: Invariant> Invariant for Option<T> {}
39unsafe impl<R: Invariant, E: Invariant> Invariant for Result<R, E> {}
40
41pub unsafe auto trait StoreCopy {}
51
52#[derive(Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, Debug)]
55pub struct PhantomStoreEffect;
56
57impl !StoreCopy for PhantomStoreEffect {}
58impl !Unpin for PhantomStoreEffect {}
59#[rustc_on_unimplemented(
60 message = "`{Self}` is not safe to be stored as an object's base",
61 label = "`{Self}` is not safe to be stored as an object's base"
62)]
63pub trait BaseType {
64 fn fingerprint() -> u64 {
66 0
67 }
68}
69
70impl BaseType for () {}
71impl BaseType for u8 {}
72impl BaseType for u16 {}
73impl BaseType for u32 {}
74impl BaseType for u64 {}
75
76impl BaseType for ThreadRepr {}