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