pub struct Permission {
inner: PermissionPriv,
}
Expand description
Public interface to the state machine that controls read-write permissions.
This is the “private enum
” pattern.
Fields§
§inner: PermissionPriv
Implementations§
source§impl Permission
impl Permission
sourcepub fn short_name(self) -> &'static str
pub fn short_name(self) -> &'static str
Abbreviated name of the permission (uniformly 3 letters for nice alignment).
source§impl Permission
impl Permission
sourcepub fn is_initial(&self) -> bool
pub fn is_initial(&self) -> bool
Check if self
can be the initial state of a pointer.
sourcepub fn is_disabled(&self) -> bool
pub fn is_disabled(&self) -> bool
Check if self
is the terminal state of a pointer (is Disabled
).
sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Check if self
is the post-child-write state of a pointer (is Active
).
sourcepub fn new_active() -> Self
pub fn new_active() -> Self
Default initial permission of the root of a new tree at inbounds positions. Must only be used for the root, this is not in general an “initial” permission!
sourcefn new_reserved_frz() -> Self
fn new_reserved_frz() -> Self
Default initial permission of a reborrowed mutable reference that is either protected or not interior mutable.
sourcefn new_reserved_im() -> Self
fn new_reserved_im() -> Self
Default initial permission of an unprotected interior mutable reference.
sourcepub fn new_reserved(ty_is_freeze: bool, protected: bool) -> Self
pub fn new_reserved(ty_is_freeze: bool, protected: bool) -> Self
Wrapper around new_reserved_frz
and new_reserved_im
that decides
which to call based on the interior mutability and the retag kind (whether there
is a protector is relevant because being protected takes priority over being
interior mutable)
sourcepub fn new_frozen() -> Self
pub fn new_frozen() -> Self
Default initial permission of a reborrowed shared reference.
sourcepub fn new_disabled() -> Self
pub fn new_disabled() -> Self
Default initial permission of the root of a new tree at out-of-bounds positions. Must only be used for the root, this is not in general an “initial” permission!
sourcepub fn compatible_with_protector(&self) -> bool
pub fn compatible_with_protector(&self) -> bool
Reject ReservedIM
that cannot exist in the presence of a protector.
sourcepub fn perform_access(
kind: AccessKind,
rel_pos: AccessRelatedness,
old_perm: Self,
protected: bool,
) -> Option<PermTransition>
pub fn perform_access( kind: AccessKind, rel_pos: AccessRelatedness, old_perm: Self, protected: bool, ) -> Option<PermTransition>
Apply the transition to the inner PermissionPriv.
sourcepub fn can_be_replaced_by_child(self, child: Self) -> bool
pub fn can_be_replaced_by_child(self, child: Self) -> bool
During a provenance GC, we want to compact the tree.
For this, we want to merge nodes upwards if they have a singleton parent.
But we need to be careful: If the parent is Frozen, and the child is Reserved,
we can not do such a merge. In general, such a merge is possible if the parent
allows similar accesses, and in particular if the parent never causes UB on its
own. This is enforced by a test, namely tree_compacting_is_sound
. See that
test for more information.
This method is only sound if the parent is not protected. We never attempt to
remove protected parents.
Trait Implementations§
source§impl Clone for Permission
impl Clone for Permission
source§fn clone(&self) -> Permission
fn clone(&self) -> Permission
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Permission
impl Debug for Permission
source§impl Display for Permission
impl Display for Permission
source§impl Hash for Permission
impl Hash for Permission
source§impl PartialEq for Permission
impl PartialEq for Permission
source§impl PartialOrd for Permission
impl PartialOrd for Permission
impl Copy for Permission
impl Eq for Permission
impl StructuralPartialEq for Permission
Auto Trait Implementations§
impl Freeze for Permission
impl RefUnwindSafe for Permission
impl Send for Permission
impl Sync for Permission
impl Unpin for Permission
impl UnwindSafe for Permission
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte