[][src]Module ashpd::desktop::trash

Move a file to the trash.

Examples

use zbus;
use zvariant::Fd;
use ashpd::desktop::trash::{TrashProxy, TrashStatus};
use zbus::fdo::Result;
use std::fs::File;
use std::os::unix::io::AsRawFd;


fn main() -> Result<()> {
    let connection = zbus::Connection::new_session()?;
    let proxy = TrashProxy::new(&connection)?;

    let file = File::open("/home/bilelmoussaoui/Downloads/adwaita-night.jpg").unwrap();

    match proxy.trash_file(Fd::from(file.as_raw_fd()))? {
        TrashStatus::Succeeded => println!("the file was removed!"),
        TrashStatus::Failed => println!("oof, couldn't remove the file"),
        _ => println!("something else happened"),
    };

    Ok(())
}

Structs

TrashProxy

The interface lets sandboxed applications send files to the trashcan.

Enums

TrashStatus

The status of moving a file to the trash.