Skip to main content

RestoreReport

Struct RestoreReport 

Source
pub struct RestoreReport {
    pub mtime_restored: usize,
    pub mode_restored: usize,
    pub unsupported: Vec<(UnsupportedKind, usize)>,
    pub failures: Vec<RestoreFailure>,
}
Expand description

还原报告。

§为什么把「平台不支持」和「尝试了但失败」分开

两者对用户的含义完全不同,合并会误导:

  • 不支持是平台的既有事实,换台 Linux 解开就能拿到,不是出错, 所以文档要求配一句「完整元数据仍保存在加密文件中」。
  • 失败是这次操作出了问题(文件被占用、权限不足、路径有问题), 同一台机器重试可能就好了,需要用户处理。

把前者报成错误会让人以为文件坏了;把后者报成“平台限制“会让人 放弃重试,白丢元数据。

Fields§

§mtime_restored: usize

成功还原修改时间的条目数。

§mode_restored: usize

成功还原权限位的条目数。

§unsupported: Vec<(UnsupportedKind, usize)>

当前平台不支持的项,及涉及的条目数。

用 Vec 而不是 HashMap:项数固定只有四个,顺序稳定便于测试 与展示,也免得引入哈希遍历顺序不定的问题。

§failures: Vec<RestoreFailure>

尝试过但失败的项。

Implementations§

Source§

impl RestoreReport

Source

pub fn has_notes(&self) -> bool

是否有任何需要告知用户的内容。

Source

pub fn note_unsupported_n(&mut self, kind: UnsupportedKind, n: usize)

一次记入 n 项平台不支持。

供 crate::unpack 汇报符号链接:链接是在元数据还原之前创建的 (目标类型判断依赖文件已落盘),所以那边先自己计数,再合并到本 报告里,而不是每建一个链接就回调一次。

n 为 0 时不产生任何条目——否则报告里会出现「0 个链接不支持」 这种让人以为出了问题的空条目。

Source

pub fn push_failure(&mut self, path: String, item: &'static str, reason: String)

追加一条还原失败记录。

同样供 crate::unpack 汇报链接创建失败,理由见 Self::note_unsupported_n。

Trait Implementations§

Source§

impl Clone for RestoreReport

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RestoreReport

Source§

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

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

impl Default for RestoreReport

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_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§

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.