pub struct RenameContext<'a> {
pub renamed: &'a DirEntryHandle,
pub replaced: Option<&'a DirEntryHandle>,
/* private fields */
}Expand description
A context that holds the locked children and info of the parents during a rename operation.
The context is constructed by locking the parent directories
(old_parent, new_parent) for write. These parent locks are held for
the duration of the context’s lifetime, preventing concurrent
modifications to the parents.
Child nodes (renamed and replaced) are not locked upon
construction. To query properties of the children (like whether they are
directories) without risking deadlocks, use the provided helper methods
(renamed_is_dir, replaced_is_dir) instead of locking them directly.
Fields§
§renamed: &'a DirEntryHandle§replaced: Option<&'a DirEntryHandle>Implementations§
Source§impl<'a> RenameContext<'a>
impl<'a> RenameContext<'a>
Sourcepub fn renamed_is_dir(&self) -> bool
pub fn renamed_is_dir(&self) -> bool
Returns whether the renamed child node is a directory.
This method safely handles child info locking under the parent locks.
If the renamed node is same as a parent (which is already locked),
it uses the parent’s guard to avoid self-deadlock. Otherwise, it
locks the child info using allow_subclass.
Sourcepub fn replaced_is_dir(&self) -> bool
pub fn replaced_is_dir(&self) -> bool
Returns whether the replaced child node is a directory.
Returns false if replaced is None.
This method safely handles child info locking under the parent locks.
If the replaced node is same as a parent (which is already locked),
it uses the parent’s guard to avoid self-deadlock. Otherwise, it
locks the child info using allow_subclass.
Sourcepub fn old_parent(&self) -> &DirEntryHandle
pub fn old_parent(&self) -> &DirEntryHandle
Returns the old parent directory entry handle.
The old parent’s child list is write-locked for the lifetime of the context.
Sourcepub fn new_parent(&self) -> &DirEntryHandle
pub fn new_parent(&self) -> &DirEntryHandle
Returns the new parent directory entry handle.
The new parent’s child list is write-locked for the lifetime of the context.
Sourcepub fn parent_infos_mut(&mut self) -> (&mut FsNodeInfo, Option<&mut FsNodeInfo>)
pub fn parent_infos_mut(&mut self) -> (&mut FsNodeInfo, Option<&mut FsNodeInfo>)
Returns mutable references to the FsNodeInfo of both parent
directories.
The references are returned as a tuple to allow them to be borrowed mutably at the same time (e.g., to update link counts in both).
If new_parent is the same as old_parent, the second element of the
tuple will be None to prevent mutable aliasing of the same guard.
Sourcepub fn old_parent_info(&self) -> &FsNodeInfo
pub fn old_parent_info(&self) -> &FsNodeInfo
Returns a shared reference to the FsNodeInfo of the old parent
directory.
Sourcepub fn new_parent_info(&self) -> Option<&FsNodeInfo>
pub fn new_parent_info(&self) -> Option<&FsNodeInfo>
Returns a shared reference to the FsNodeInfo of the new parent
directory.
Returns None if new_parent is the same as old_parent.
Auto Trait Implementations§
impl<'a> Freeze for RenameContext<'a>
impl<'a> !RefUnwindSafe for RenameContext<'a>
impl<'a> !Send for RenameContext<'a>
impl<'a> Sync for RenameContext<'a>
impl<'a> Unpin for RenameContext<'a>
impl<'a> UnsafeUnpin for RenameContext<'a>
impl<'a> !UnwindSafe for RenameContext<'a>
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, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more