cloud_disk_sync/utils/
path.rs

1pub fn parse_account_path(path_str: &str) -> Result<(String, String), Box<dyn std::error::Error>> {
2    // 格式: account_name:/path/to/folder
3    let parts: Vec<&str> = path_str.splitn(2, ':').collect();
4    if parts.len() != 2 {
5        return Err(format!(
6            "无效的路径格式,应为 account_name:/path/to/folder,实际: {}",
7            path_str
8        )
9        .into());
10    }
11
12    let account = parts[0].trim().to_string();
13    let path = parts[1].trim().to_string();
14
15    if account.is_empty() || path.is_empty() {
16        return Err("账户名或路径不能为空".into());
17    }
18
19    Ok((account, path))
20}