#remove #trash #recycle #bin #rubbish

trash

A library for moving files and folders to the Recycle Bin

16 stable releases (3 major)

3.0.2 May 17, 2023
3.0.1 Jan 30, 2023
3.0.0 Nov 27, 2022
2.1.5 Jul 5, 2022
0.1.1 Jul 13, 2019

#53 in Filesystem

Download history 3986/week @ 2023-02-11 5650/week @ 2023-02-18 5118/week @ 2023-02-25 3824/week @ 2023-03-04 4511/week @ 2023-03-11 3145/week @ 2023-03-18 2415/week @ 2023-03-25 2458/week @ 2023-04-01 2457/week @ 2023-04-08 2367/week @ 2023-04-15 2312/week @ 2023-04-22 2898/week @ 2023-04-29 2509/week @ 2023-05-06 2716/week @ 2023-05-13 3332/week @ 2023-05-20 2939/week @ 2023-05-27

12,031 downloads per month
Used in 31 crates (27 directly)

MIT license

89KB
1.5K SLoC

Crates.io Docs.rs CI

About

The trash is a Rust library for moving files and folders to the operating system's Recycle Bin or Trash or Rubbish Bin or what have you :D

The library supports Windows, macOS, and all FreeDesktop Trash compliant environments (including GNOME, KDE, XFCE, and more). See more about the FreeDesktop Trash implementation in the freedesktop.rs file.

Usage

# In Cargo.toml
[dependencies]
trash = "2.0"
// In main.rs
use std::fs::File;
use trash;

fn main() {
    // Let's create and remove a single file
    File::create("remove-me").unwrap();
    trash::delete("remove-me").unwrap();
    assert!(File::open("remove-me").is_err());

    // Now let's remove multiple files at once
    let the_others = ["remove-me-too", "dont-forget-about-me-either"];
    for name in the_others.iter() {
        File::create(name).unwrap();
    }
    trash::delete_all(&the_others).unwrap();
    for name in the_others.iter() {
        assert!(File::open(name).is_err());
    }
}

Dependencies

~0–44MB
~727K SLoC