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