Skip to main content

WalkItem

Struct WalkItem 

Source
pub struct WalkItem {
    pub path: PathBuf,
    pub comps: Vec<String>,
    pub is_dir: bool,
    pub meta: EntryMeta,
    pub link_target: Option<String>,
}
Expand description

遍历时交给回调的一个条目。

抽出这个类型是为了让容器模式与树形模式共用同一套遍历判定: 按名字稳定排序、用 symlink_metadata 而不是 metadata、跳过符号链接 与非普通文件、深度上限。各写一份的话,哪天给容器模式修了「跳过 socket 文件」,树形模式还在按老样子处理,同一个目录用两种模式加密会得到不同的 内容集合。

Fields§

§path: PathBuf

绝对路径。

§comps: Vec<String>

相对根目录的路径组件。

§is_dir: bool

是否是目录。

§meta: EntryMeta

文件系统元数据,供调用方提取 mtime 等。

§link_target: Option<String>

符号链接的目标;非链接时为 None。

由 walk_dir 交给调用方而不是自行跳过,是因为两种加密模式对链接 的处理能力不同:容器模式有索引可以存目标,树形模式把每个条目落成 独立 .omy 文件、没有地方记这个字段。让 walk_dir 只负责「如实 报告这是个链接」,各模式自己决定存还是跳过——遍历判定规则仍然只有 一处,符合本模块与 tree 共用 walk_dir 的约定。

Trait Implementations§

Source§

impl Debug for WalkItem

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.