twizzler_abi/
marker.rs

1//! Marker traits used to indicate safety for storing data in objects and using a struct as a base
2//! type.
3
4use core::{
5    cell::UnsafeCell,
6    sync::atomic::{
7        AtomicBool, AtomicI16, AtomicI32, AtomicI64, AtomicI8, AtomicIsize, AtomicU16, AtomicU32,
8        AtomicU64, AtomicU8, AtomicUsize,
9    },
10};
11
12/// This auto trait specifies that some type is "safe" to to store inside an object. This means that
13/// the type contains no non-invariant references nor any unsafe interior mutability not implemented
14/// via twizzler-nando.
15///
16/// # Safety
17/// Manually marking type as safe requires that the programmer adhere to the rules set above.
18
19pub unsafe auto trait ObjSafe {}
20
21impl<T> !ObjSafe for *const T {}
22impl<T> !ObjSafe for *mut T {}
23impl<T> !ObjSafe for &T {}
24impl<T> !ObjSafe for &mut T {}
25impl<T: ?Sized> !ObjSafe for UnsafeCell<T> {}
26unsafe impl ObjSafe for AtomicBool {}
27unsafe impl ObjSafe for AtomicU16 {}
28unsafe impl ObjSafe for AtomicU32 {}
29unsafe impl ObjSafe for AtomicU64 {}
30unsafe impl ObjSafe for AtomicU8 {}
31unsafe impl ObjSafe for AtomicUsize {}
32unsafe impl ObjSafe for AtomicI16 {}
33unsafe impl ObjSafe for AtomicI32 {}
34unsafe impl ObjSafe for AtomicI64 {}
35unsafe impl ObjSafe for AtomicI8 {}
36unsafe impl ObjSafe for AtomicIsize {}