Skip to main content

egui_winit/
dropped_file.rs

1use std::path::{Path, PathBuf};
2
3#[derive(Debug)]
4pub(crate) struct NativeFile {
5    path: PathBuf,
6}
7
8impl From<PathBuf> for NativeFile {
9    fn from(path: PathBuf) -> Self {
10        Self { path }
11    }
12}
13
14impl egui::DroppedFile for NativeFile {
15    fn path(&self) -> &Path {
16        &self.path
17    }
18
19    fn bytes(&self) -> Result<Vec<u8>, String> {
20        std::fs::read(&self.path).map_err(|err| err.to_string())
21    }
22}