feat(info): Add new functions

version - send info about rclone version
stats - check info about operation
This commit is contained in:
Black_Raven committed 2026-03-27 12:08:39 +03:00
1 parent 559af7d594
commit 3bcfbe573e
1 file changed
+26
+26
View File
@@ -0,0 +1,26 @@
use super::*;
use crate::rclone_install::RcloneApp;
use serde_json::Value;
use std::collections::HashMap;
/// Получить версию в удобочитаемом формате
pub fn version(app: &RcloneApp) -> Result<HashMap<String, String>, String> {
let output = app.run_command(&["version"])?;
let mut version_info = HashMap::new();
for line in output.lines() {
if let Some((key, value)) = line.split_once(':') {
version_info.insert(key.trim().to_string(), value.trim().to_string());
}
}
Ok(version_info)
}
/// Получить статистику текущих операций
pub fn stats(app: &RcloneApp) -> Result<Value, String> {
let output = app.run_command(&["core", "stats"])?;
let stats: Value =
serde_json::from_str(&output).map_err(|e| format!("Ошибка парсинга статистики: {}", e))?;
Ok(stats)
}