implement FileHandle

This commit is contained in:
Oleg Sobolev 2024-04-01 09:06:48 +07:00
parent 959f954d9d
commit b278a6aa52
2 changed files with 22 additions and 0 deletions

21
src/file.rs Normal file
View file

@ -0,0 +1,21 @@
use std::path::{Path, PathBuf};
use std::fs;
#[derive(Debug, Clone)]
pub struct FileHandle {
path: PathBuf,
}
impl FileHandle {
pub fn new(path: &Path) -> FileHandle {
FileHandle {
path: PathBuf::from(path),
}
}
}
impl Drop for FileHandle {
fn drop(&mut self) {
let _ = fs::remove_file(self.path.clone());
}
}

View file

@ -1,5 +1,6 @@
pub mod channel;
pub mod download;
pub mod file;
pub mod player;
pub mod telegram;
mod track;