Mountain/IPC/WindServiceHandlers/FileSystem/Native/FileRenameNative.rs
1#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2
3//! Wire method `file:move` / `file:rename`.
4
5use serde_json::Value;
6
7use crate::IPC::WindServiceHandlers::Utilities::PathExtraction::extract_path_from_arg;
8
9pub async fn FileRenameNative(Arguments:Vec<Value>) -> Result<Value, String> {
10 let Source = extract_path_from_arg(Arguments.get(0).ok_or("Missing source path")?)?;
11 let Target = extract_path_from_arg(Arguments.get(1).ok_or("Missing target path")?)?;
12
13 tokio::fs::rename(&Source, &Target)
14 .await
15 .map_err(|E| format!("Failed to rename: {} -> {} ({})", Source, Target, E))?;
16
17 Ok(Value::Null)
18}