Expand description
This crate provides functions that allow moving files to the operating system’s Recycle Bin or Trash, or the equivalent.
Furthermore on Linux and on Windows additional functions are available from the os_limited
module.
§Potential UB on Linux and FreeBSD
When querying information about mount points, non-threadsafe versions of libc::getmnt(info|ent)
are
used which can cause UB if another thread calls into the same function, probably only if the mountpoints
changed as well.
To neutralize the issue, the respective function in this crate has been made thread-safe with a Mutex.
If your crate calls into the aforementioned methods directly or indirectly from other threads, rather not use this crate.
As the handling of UB is clearly a trade-off and certainly goes against the zero-chance-of-UB goal of the Rust community, please interact with us in the tracking issue to help find a more permanent solution.
§Notes on the Linux implementation
This library implements version 1.0 of the Freedesktop.org Trash specification and aims to match the behaviour of Ubuntu 18.04 GNOME in cases of ambiguity. Most -if not all- Linux distributions that ship with a desktop environment follow this specification. For example GNOME, KDE, and XFCE all use this convention. This crate blindly assumes that the Linux distribution it runs on, follows this specification.
Modules§
- os_
limited - This module provides functionality which is only supported on Windows and Linux or other Freedesktop Trash compliant environment.
Structs§
- Trash
Context - A collection of preferences for trash operations.
- Trash
Item - This struct holds information about a single item within the trash.
- Trash
Item Metadata - Metadata about a
TrashItem
Enums§
- Error
- Provides information about an error.
- Trash
Item Size - Size of a
TrashItem
in bytes or entries
Constants§
Functions§
- delete
- Convenience method for
DEFAULT_TRASH_CTX.delete()
. - delete_
all - Convenience method for
DEFAULT_TRASH_CTX.delete_all()
. - into_
unknown