This commit is contained in:
shenjack-5600u 2025-04-09 12:35:27 +08:00
parent ad66657d37
commit 9e72c8a117
Signed by: shenjack
GPG Key ID: FDF9864E11C7E79F

View File

@ -48,27 +48,28 @@ impl ConfigStoragePy {
match kwargs { match kwargs {
Some(kwargs) => { Some(kwargs) => {
let mut keys = HashMap::new(); let mut keys = HashMap::new();
for (key, value) in kwargs.iter() { for (key, value) in kwargs.iter() {}
}
Ok(Self { keys }) Ok(Self { keys })
} }
None => Ok(Self { keys: HashMap::new() }), None => Ok(Self {
keys: HashMap::new(),
}),
} }
} }
#[getter] #[getter]
/// 获取最大允许的层级深度 /// 获取最大允许的层级深度
pub fn get_max_allowed_depth(&self) -> usize { pub fn get_max_allowed_depth(&self) -> usize { MAX_CFG_DEPTH }
MAX_CFG_DEPTH
}
} }
impl ConfigStoragePy { impl ConfigStoragePy {
/// 递归解析配置 /// 递归解析配置
/// ///
/// 用个 Result 来标记递归过深 /// 用个 Result 来标记递归过深
fn parse_init_key(map: &mut HashMap<String, ConfigItemPy>, current_deepth: usize) -> Result<(), usize>{ fn parse_init_key(
map: &mut HashMap<String, ConfigItemPy>,
current_deepth: usize,
) -> Result<(), usize> {
if current_deepth > MAX_CFG_DEPTH { if current_deepth > MAX_CFG_DEPTH {
Err(current_deepth) Err(current_deepth)
} else { } else {