Skip to content

trash ​

trash moves path to the platform trash/recycle bin, recoverable, unlike deleting it outright.

Signaturetrash(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 ​

FieldTypeMeaning
codestringA stable, machine-readable identifier (e.g. "ERR_OS_TRASH_FAILED").
messagestringA human-readable description of what went wrong.