Skip to main content

RenameContext

Struct RenameContext 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn old_parent_info(&self) -> &FsNodeInfo

Returns a shared reference to the FsNodeInfo of the old parent directory.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<F, N> FidlIntoNative<Box<N>> for F
where F: FidlIntoNative<N>,

§

fn fidl_into_native(self) -> Box<N>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> Into32<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_32(self) -> U

Source§

impl<T, U> Into64<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_64(self) -> U

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
Source§

impl<T, U> IntoFidl<U> for T
where U: FromFidl<T>,

Source§

fn into_fidl(self) -> U

Source§

impl<T, U> MultiArchFrom<T> for U
where U: From<T>,

Source§

fn from_64(value: T) -> U

Source§

fn from_32(value: T) -> U

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

type Error = <U as TryFromExt<T>>::Error

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<St> WithTag for St

§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag
Source§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,

Source§

impl<B, A> LockEqualOrBefore<B> for A
where A: LockBefore<B>,

§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,