pub enum Error {
Io(Error),
Zip(ZipError),
Xml(String),
Opc(String),
Oxml(String),
NotFound(String),
IndexOutOfRange(usize),
NotImplemented(&'static str),
Encryption(String),
Ppt97(String),
Other(String),
}Expand description
库错误。所有外部接口(除特别声明外)均返回 Result<T>。
变体按“来源“分类,调用方可以基于 match 决定重试 / 跳过 / 报告策略。
错误消息遵循 小写开头、句末无标点 的 Rust 标准库风格。
Variants§
Io(Error)
I/O 错误:文件不存在、读取失败、写入失败、权限拒绝等。
由 #[from] io::Error 自动派生,调用方可用 ? 直接把任意
std::io::Error 提升为本变体。
Zip(ZipError)
zip 压缩包错误:CRC 校验失败、条目不存在、解压错误等。
由 #[from] zip::result::ZipError 派生,封装 zip crate 的全部错误。
Xml(String)
XML 解析或序列化错误。
字符串内容应包含 出错元素名 + 上下文路径,例如
"slide layout1.xml parse: unexpected end of <p:sld> at line 42"。
Opc(String)
OPC 包结构错误。
典型场景:
- 缺少必要的 part(如
word/document.xml缺失); - 关系链断裂(
r:id指向不存在的 target); [Content_Types].xml中缺失 Override / Default。
Oxml(String)
OOXML 模型错误。
典型场景:
- 缺失必要字段(如
slideLayout必须有cSld); - 命名空间不匹配;
- 序列化时违反 OOXML 元素顺序约束(CT_* schema 严格顺序)。
NotFound(String)
元素未找到:按 Id / Name / Type 查找时未命中。
IndexOutOfRange(usize)
索引越界:访问 Slides / Shapes 等集合时 idx >= len。
NotImplemented(&'static str)
不支持的功能(路线图中)。
携带 &'static str 描述功能名,便于编译期收集未实现项清单。
Encryption(String)
加密/解密错误。
典型场景:
- 密码不匹配;
- 加密算法不支持;
- AES 密钥/IV 长度不正确;
- 加密文件格式损坏。
Ppt97(String)
.ppt(PowerPoint 97-2003 二进制格式)处理错误。
典型场景:
- OLE2/CFB 容器结构损坏;
- PPT record 树解析失败(record header / recLen 异常);
- 找不到必要 stream(PowerPoint Document / Current User);
- PersistDirectoryAtom 解析失败;
- 水印注入失败(找不到 MainMaster / PPDrawing / SpgrContainer);
- persist 对象重排失败。
与 Error::Encryption 的区别:本变体专指 .ppt 二进制格式的
结构性错误;而 Encryption 侧重密钥/算法层面的失败。
Other(String)
其它错误。
仅 用于临时过渡;正式错误请扩展 enum Error 的具体变体。
Implementations§
Source§impl Error
impl Error
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for Error
impl !UnwindSafe for Error
impl Freeze for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
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