use anyhow::{Context, Result};
use std::path::Path;
pub fn move_to_trash(paths: &[&Path]) -> Result<usize> {
let mut moved = 0;
for p in paths {
trash::delete(p).with_context(|| format!("failed to trash {}", p.display()))?;
moved += 1;
}
Ok(moved)
}
pub fn restore_from_trash(name_contains: &str) -> Result<usize> {
let items = trash::os_limited::list()?;
let matches: Vec<_> = items.into_iter()
.filter(|i| i.name.to_string_lossy().contains(name_contains))
.collect();
if matches.is_empty() {
return Ok(0);
}
trash::os_limited::restore_all(matches.clone())?;
Ok(matches.len())
}