Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

StructDirEntry

Source
pub struct DirEntry {/* private fields */ }
Expand description

A directory entry.

This is the type of value that is yielded from the iterators defined inthis crate.

On Unix systems, this type implements theDirEntryExt trait, whichprovides efficient access to the inode number of the directory entry.

§Differences withstd::fs::DirEntry

This type mostly mirrors the type by the same name instd::fs. Thereare some differences however:

  • All recursive directory iterators must inspect the entry’s type.Therefore, the value is stored and its access is guaranteed to be cheap andsuccessful.
  • path andfile_name return borrowed variants.
  • Iffollow_links was enabled on the originating iterator, then alloperations except forpath operate on the link target. Otherwise, alloperations operate on the symbolic link.

Implementations§

Source§

implDirEntry

Source

pub fnpath(&self) -> &Path

The full path that this entry represents.

The full path is created by joining the parents of this entry up to theroot initially given toWalkDir::new with the file name of thisentry.

Note that thisalways returns the path reported by the underlyingdirectory entry, even when symbolic links are followed. To get thetarget path, usepath_is_symlink to (cheaply) check if this entrycorresponds to a symbolic link, andstd::fs::read_link to resolvethe target.

Source

pub fninto_path(self) ->PathBuf

The full path that this entry represents.

Analogous topath, but moves ownership of the path.

Source

pub fnpath_is_symlink(&self) ->bool

Returnstrue if and only if this entry was created from a symboliclink. This is unaffected by thefollow_links setting.

Whentrue, the value returned by thepath method is asymbolic link name. To get the full target path, you must callstd::fs::read_link(entry.path()).

Source

pub fnmetadata(&self) ->Result<Metadata>

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

This will follow symbolic links if and only if theWalkDir valuehasfollow_links enabled.

§Platform behavior

This always callsstd::fs::symlink_metadata.

If this entry is a symbolic link andfollow_links is enabled, thenstd::fs::metadata is called instead.

§Errors

Similar tostd::fs::metadata, returns errors for path values thatthe program does not have permissions to access or if the path does notexist.

Source

pub fnfile_type(&self) ->FileType

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

If this is a symbolic link andfollow_links istrue, then thisreturns the type of the target.

This never makes any system calls.

Source

pub fnfile_name(&self) -> &OsStr

Return the file name of this entry.

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

Source

pub fndepth(&self) ->usize

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

The smallest depth is0 and always corresponds to the path givento thenew function onWalkDir. Its direct descendents have depth1, and their descendents have depth2, and so on.

Trait Implementations§

Source§

implClone forDirEntry

Source§

fnclone(&self) ->DirEntry

Returns a duplicate of the value.Read more
1.0.0 ·Source§

fnclone_from(&mut self, source: &Self)

Performs copy-assignment fromsource.Read more
Source§

implDebug forDirEntry

Source§

fnfmt(&self, f: &mutFormatter<'_>) ->Result

Formats the value using the given formatter.Read more
Source§

implDirEntryExt forDirEntry

Source§

fnino(&self) ->u64

Returns the underlyingd_ino field in the containeddirentstructure.

Auto Trait Implementations§

§

implFreeze forDirEntry

§

implRefUnwindSafe forDirEntry

§

implSend forDirEntry

§

implSync forDirEntry

§

implUnpin forDirEntry

§

implUnwindSafe forDirEntry

Blanket Implementations§

Source§

impl<T>Any for T
where T: 'static + ?Sized,

Source§

fntype_id(&self) ->TypeId

Gets theTypeId ofself.Read more
Source§

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

Source§

fnborrow(&self) ->&T

Immutably borrows from an owned value.Read more
Source§

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

Source§

fnborrow_mut(&mut self) ->&mut T

Mutably borrows from an owned value.Read more
Source§

impl<T>CloneToUninit for T
where T:Clone,

Source§

unsafe fnclone_to_uninit(&self, dest:*mutu8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment fromself todest.Read more
Source§

impl<T>From<T> for T

Source§

fnfrom(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fninto(self) -> U

CallsU::from(self).

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

Source§

impl<T>ToOwned for T
where T:Clone,

Source§

typeOwned = T

The resulting type after obtaining ownership.
Source§

fnto_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning.Read more
Source§

fnclone_into(&self, target:&mut T)

Uses borrowed data to replace owned data, usually by cloning.Read more
Source§

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

Source§

typeError =Infallible

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

fntry_from(value: U) ->Result<T, <T asTryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

typeError = <U asTryFrom<T>>::Error

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

fntry_into(self) ->Result<U, <U asTryFrom<T>>::Error>

Performs the conversion.

[8]ページ先頭

©2009-2025 Movatter.jp