pub enum EngineError {
ModelNotFound {
dir: String,
},
TokenizerLoad(String),
SessionInit(String),
InferRun(String),
DecodeShape(String),
Internal(String),
}Expand description
引擎私有诊断错误。
6 变体覆盖从模型加载到张量解码的全链路失败模式;绝不持有 ort::Error
本身(rc.12 该类型非 Send + Sync,会污染 trait object 边界)。所有 ort/tokenizer
错误一律 e.to_string() 后塞进 String 字段。
caller 拿到的不是这个类型 —— From<EngineError> for ScanError 把 6 变体
全塌缩到 ScanError::InferenceFailed,只暴露统一的 reason。
Variants§
ModelNotFound
指定 dir 下缺少模型文件(tokenizer.json / config.json / model_q4f16.onnx
三件齐全才算就绪)或 VIGIL_PRIVACY_FILTER_MODEL_DIR 未设置。
TokenizerLoad(String)
tokenizers::Tokenizer::from_file 失败。内部串来自 tokenizers crate。
SessionInit(String)
ORT Session::builder / commit_from_file / 优化等级设置等 init 阶段失败。
InferRun(String)
推理执行阶段失败(tokenizer.encode / session.run)。
DecodeShape(String)
输出张量 shape 不符预期或 try_extract_tensor::<f32> 失败。
Internal(String)
其它内部错误(config.json 解析 / Mutex poisoned 等),用兜底变体避免新增 variant 立刻冲击 caller。
Trait Implementations§
Source§impl Debug for EngineError
impl Debug for EngineError
Source§impl Display for EngineError
impl Display for EngineError
Source§impl Error for EngineError
impl Error for EngineError
1.30.0 · 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()
Source§impl From<EngineError> for ScanError
impl From<EngineError> for ScanError
Source§fn from(e: EngineError) -> Self
fn from(e: EngineError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for EngineError
impl RefUnwindSafe for EngineError
impl Send for EngineError
impl Sync for EngineError
impl Unpin for EngineError
impl UnsafeUnpin for EngineError
impl UnwindSafe for EngineError
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