1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use crate::services::Task;
use std::fmt;
cfg_if::cfg_if! {
if #[cfg(feature = "std_web")] {
mod std_web;
pub use std_web::*;
} else if #[cfg(feature = "web_sys")] {
mod web_sys;
pub use self::web_sys::*;
}
}
#[derive(Clone, Debug)]
pub struct FileData {
pub name: String,
pub content: Vec<u8>,
}
#[derive(Clone, Debug)]
pub enum FileChunk {
Started {
name: String,
},
DataChunk {
data: Vec<u8>,
progress: f32,
},
Finished,
}
#[derive(Default, Debug)]
pub struct ReaderService {}
impl fmt::Debug for ReaderTask {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("ReaderTask")
}
}
impl Drop for ReaderTask {
fn drop(&mut self) {
if self.is_active() {
self.file_reader.abort();
}
}
}