跳到主要内容

ReadDir

搜索

结构体 ReadDir 

Source
pub struct ReadDir(/* private fields */);
展开描述

读取目录中的条目。

此结构体 由本模块的 read_dir 函数返回, 它会产生 DirEntry 实例。 通过 DirEntry, 可以 了解诸如 条目路径 及可能的 其他元数据 等信息。

可以通过 ReadDirStream 将 ReadDir 转换为 Stream。

§Errors

如果在迭代过程中 出现某种间歇性 IO 错误, 则此流将返回 Err。

实现§

Source§

impl ReadDir

Source

pub async fn next_entry(&mut self) -> Result<Option<DirEntry>>

返回目录流中的下一个条目。

§Cancel safety

此方法是可取消安全的。

Source

pub fn poll_next_entry( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<Option<DirEntry>>>

轮询流中的下一个目录条目。

此方法返回:

  • Poll::Pending if the next directory entry is not yet available.
  • Poll::Ready(Ok(Some(entry))) if the next directory entry is available.
  • Poll::Ready(Ok(None)) if there are no more directory entries in this stream.
  • Poll::Ready(Err(err)) if an IO error occurred while reading the next directory entry.

当方法返回 Poll::Pending 时,提供的 Context 中的 Waker 会被安排为在底层 IO 资源上 可获取下一个目录条目时收到唤醒。

请注意,在多次调用 poll_next_entry 时,只有 传递给最近一次调用的 Context 中的 Waker 会被安排 接收唤醒。

Trait 实现§

Source§

impl Debug for ReadDir

Source§

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

使用给定的格式化器格式化此值。 更多信息

自动 Trait 实现§

Blanket 实现§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 更多信息
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. 更多信息
Source§

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

Source§

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

Mutably borrows from an owned value. 更多信息
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

原样返回传入的参数。

Source§

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

Source§

fn into(self) -> U

调用 U::from(self)。

也就是说,此转换的具体行为取决于 From<T> for U 的实现方式。

Source§

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

Source§

type Error = Infallible

转换出错时返回的类型。
Source§

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

执行转换。
Source§

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

Source§

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

转换出错时返回的类型。
Source§

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

执行转换。