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,) {}
36
37unsafe impl<T: Invariant> Invariant for Option<T> {}
38unsafe impl<R: Invariant, E: Invariant> Invariant for Result<R, E> {}
39
40pub unsafe auto trait StoreCopy {}
50
51#[derive(Copy, Clone, PartialEq, PartialOrd, Ord, Eq, Hash, Debug)]
54pub struct PhantomStoreEffect;
55
56impl !StoreCopy for PhantomStoreEffect {}
57impl !Unpin for PhantomStoreEffect {}
58#[rustc_on_unimplemented(
59 message = "`{Self}` is not safe to be stored as an object's base",
60 label = "`{Self}` is not safe to be stored as an object's base"
61)]
62pub trait BaseType {
63 fn fingerprint() -> u64 {
65 0
66 }
67}
68
69impl BaseType for () {}
70impl BaseType for u8 {}
71impl BaseType for u16 {}
72impl BaseType for u32 {}
73impl BaseType for u64 {}
74
75impl BaseType for ThreadRepr {}