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
impl RestoreReport
Sourcepub fn note_unsupported_n(&mut self, kind: UnsupportedKind, n: usize)
pub fn note_unsupported_n(&mut self, kind: UnsupportedKind, n: usize)
一次记入 n 项平台不支持。
供 crate::unpack 汇报符号链接:链接是在元数据还原之前创建的
(目标类型判断依赖文件已落盘),所以那边先自己计数,再合并到本
报告里,而不是每建一个链接就回调一次。
n 为 0 时不产生任何条目——否则报告里会出现「0 个链接不支持」
这种让人以为出了问题的空条目。
Sourcepub fn push_failure(&mut self, path: String, item: &'static str, reason: String)
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
impl Clone for RestoreReport
Source§impl Debug for RestoreReport
impl Debug for RestoreReport
Auto Trait Implementations§
impl Forget for RestoreReport
impl Freeze for RestoreReport
impl RefUnwindSafe for RestoreReport
impl Send for RestoreReport
impl Sync for RestoreReport
impl Unpin for RestoreReport
impl UnsafeUnpin for RestoreReport
impl UnwindSafe for RestoreReport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more