feat(memory): 添加记忆系统模块

This commit is contained in:
徐涛
2026-06-08 08:42:43 +08:00
parent 1fe7f02281
commit 2ecc0b4001
9 changed files with 1244 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
//! 记忆系统错误类型。
use thiserror::Error;
/// 记忆系统错误枚举。
#[derive(Debug, Error)]
pub enum MemoryError {
#[error("Item not found: {0}")]
NotFound(String),
#[error("Storage error: {0}")]
Storage(String),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("Retrieval error: {0}")]
RetrievalError(String),
}
impl MemoryError {
/// 是否为可恢复错误(调用方可重试或调整参数)。
pub fn is_recoverable(&self) -> bool {
matches!(self, Self::NotFound(_) | Self::RetrievalError(_))
}
}