Skip to content

Commit

Permalink
Improve readme. Add remove_all function to mac as unimplemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturKovacs committed Jul 13, 2019
1 parent a651d0f commit 2850270
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = "trash"
version = "0.1.0"
authors = ["Artur Kovacs <kovacs.artur.barnabas@gmail.com>"]
license = "MIT"
license-file = "LICENSE.TXT"
readme = "Readme.md"
description = "A Rust library for moving files to the Recycle Bin"
Expand Down
30 changes: 28 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@

[![Crates.io](https://img.shields.io/crates/v/trash.svg)](https://crates.io/crates/trash)

## About

Trash is a Rust library that provides functionality to move files to the operating system's Recycle Bin.
Trash is a Rust library that provides functionality to move files and folders to the operating system's Recycle Bin (or Trash or Rubbish Bin or what have you).

The library currently supports Windows and Linux. Contribution to MacOS support would be very much appretiated.

## Usage

```rust
extern crate trash;
use std::fs::File;

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

Note that this libaray is in early development. It is planned to be multi-platform but I only have a Windows and a Linux system, so creating a pull request with MacOS support would be very much appretiated.
// 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::remove_all(&the_others).unwrap();
for name in the_others.iter() {
assert!(File::open(name).is_err());
}
}
```
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum Error {
},
}

/// Removes a single file.
/// Removes a single file or directory.
///
/// # Example
///
Expand All @@ -49,7 +49,7 @@ pub fn remove<T: AsRef<Path>>(path: T) -> Result<(), Error> {
platform::remove(path)
}

/// Removes all files specified by the collection of paths provided as an argument.
/// Removes all files/directories specified by the collection of paths provided as an argument.
///
/// # Example
///
Expand Down
8 changes: 8 additions & 0 deletions src/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ pub fn is_implemented() -> bool {
false
}

pub fn remove_all<I, T>(paths: I) -> Result<(), Error>
where
I: IntoIterator<Item = T>,
T: AsRef<Path>,
{
unimplemented!();
}

pub fn remove<T: AsRef<Path>>(path: T) -> Result<(), Error> {
unimplemented!();
}

0 comments on commit 2850270

Please sign in to comment.