gix_features::fs::walkdir

Struct DirEntryGeneric

Source
pub struct DirEntryGeneric<C>
where C: ClientState,
{ pub depth: usize, pub file_name: OsString, pub file_type: FileType, pub client_state: <C as ClientState>::DirEntryState, pub parent_path: Arc<Path>, pub read_children_path: Option<Arc<Path>>, pub read_children_error: Option<Error>, /* private fields */ }
Available on crate feature fs-walkdir-parallel only.
Expand description

Representation of a file or directory.

This representation does not wrap a std::fs::DirEntry. Instead it copies file_name, file_type, and optionally metadata out of the underlying std::fs::DirEntry. This allows it to quickly drop the underlying file descriptor.

Fields§

§depth: usize

Depth of this entry relative to the root directory where the walk started.

§file_name: OsString

File name of this entry without leading path component.

§file_type: FileType

File type for the file/directory that this entry points at.

§client_state: <C as ClientState>::DirEntryState

Field where clients can store state from within the The process_read_dir callback.

§parent_path: Arc<Path>

Path used by this entry’s parent to read this entry.

§read_children_path: Option<Arc<Path>>

Path that will be used to read child entries. This is automatically set for directories. The process_read_dir callback may set this field to None to skip reading the contents of a particular directory.

§read_children_error: Option<Error>

If read_children_path is set and resulting fs::read_dir generates an error then that error is stored here.

Implementations§

Source§

impl<C> DirEntry<C>
where C: ClientState,

Source

pub fn file_type(&self) -> FileType

Return the file type for the file that this entry points to.

If this is a symbolic link and follow_links is true, then this returns the type of the target.

This never makes any system calls.

Source

pub fn file_name(&self) -> &OsStr

Return the file name of this entry.

If this entry has no file name (e.g., /), then the full path is returned.

Source

pub fn depth(&self) -> usize

Returns the depth at which this entry was created relative to the root.

The smallest depth is 0 and always corresponds to the path given to the new function on WalkDir. Its direct descendants have depth 1, and their descendants have depth 2, and so on.

Source

pub fn path(&self) -> PathBuf

Path to the file/directory represented by this entry.

The path is created by joining parent_path with file_name.

Returns true if and only if this entry was created from a symbolic link. This is unaffected by the follow_links setting.

When true, the value returned by the path method is a symbolic link name. To get the full target path, you must call std::fs::read_link(entry.path()).

Source

pub fn metadata(&self) -> Result<Metadata, Error>

Return the metadata for the file that this entry points to.

This will follow symbolic links if and only if the WalkDir value has follow_links enabled.

§Platform behavior

This always calls std::fs::symlink_metadata.

If this entry is a symbolic link and follow_links is enabled, then std::fs::metadata is called instead.

§Errors

Similar to std::fs::metadata, returns errors for path values that the program does not have permissions to access or if the path does not exist.

Source

pub fn parent_path(&self) -> &Path

Reference to the path of the directory containing this entry.

Trait Implementations§

Source§

impl<C> Debug for DirEntry<C>
where C: ClientState,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C> Freeze for DirEntry<C>

§

impl<C> !RefUnwindSafe for DirEntry<C>

§

impl<C> Send for DirEntry<C>

§

impl<C> Sync for DirEntry<C>

§

impl<C> Unpin for DirEntry<C>

§

impl<C> !UnwindSafe for DirEntry<C>

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

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.