Skip to main content

amethystate_core/
access.rs

1pub trait AccessMode: Send + Sync + 'static {}
2
3pub struct ReadOnlyMode;
4
5impl AccessMode for ReadOnlyMode {}
6
7pub struct WritableMode;
8
9impl AccessMode for WritableMode {}
10
11pub struct ReadOnly<T>(std::marker::PhantomData<T>);
12
13pub struct Writable<T>(std::marker::PhantomData<T>);
14
15impl<T> std::ops::Deref for ReadOnly<T> {
16    type Target = T;
17    fn deref(&self) -> &Self::Target {
18        unreachable!("Type-level token only")
19    }
20}
21
22impl<T> std::ops::Deref for Writable<T> {
23    type Target = T;
24    fn deref(&self) -> &Self::Target {
25        unreachable!("Type-level token only")
26    }
27}