trash
trash moves path to the platform trash/recycle bin, recoverable, unlike deleting it outright.
Signature
trash(path: string): Result<void, OsError>tyrus
import { OsError, trash } from "tyrus:os";
match (trash("./stale-report.txt")) {
Ok() => print("File moved to trash"); // File moved to trash
Err(error) => printError(`${error.code}: ${error.message}`); // ERR_OS_TRASH_FAILED: path does not exist, or the trash service is unavailable
}Returns Err(OsError) (code: "ERR_OS_TRASH_FAILED") if path does not exist or cannot be moved to the trash.
OsError Fields
| Field | Type | Meaning |
|---|---|---|
code | string | A stable, machine-readable identifier (e.g. "ERR_OS_TRASH_FAILED"). |
message | string | A human-readable description of what went wrong. |
