qualia_core_db/q42/asset_import/
status.rs1use super::error::ImportError;
4use std::path::PathBuf;
5
6#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum ImportStatus {
9 Running,
10 Cancelled,
11 Failed(String),
12 Succeeded {
13 bytes_read: u64,
14 accepted: u64,
15 quarantined: u64,
16 output_bytes: u64,
17 },
18}
19
20impl ImportStatus {
21 pub fn is_succeeded(&self) -> bool {
23 matches!(self, Self::Succeeded { .. })
24 }
25}
26
27#[derive(Debug, Clone, Copy, PartialEq, Eq)]
29pub struct FeedProgress {
30 pub bytes_this_chunk: u64,
32 pub bytes_read_total: u64,
34 pub eof: bool,
36}
37
38#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
40pub struct ChunkOutcome {
41 pub accepted: u64,
42 pub quarantined: u64,
43}
44
45#[derive(Debug, Clone, PartialEq, Eq)]
47pub struct PromotedArtifact {
48 pub path: PathBuf,
49 pub sha256: [u8; 32],
50 pub bytes: u64,
51 pub accepted: u64,
52 pub quarantined: u64,
53}
54
55impl ImportStatus {
56 pub(crate) fn require_succeeded(&self) -> Result<(u64, u64, u64, u64), ImportError> {
58 match self {
59 Self::Succeeded {
60 bytes_read,
61 accepted,
62 quarantined,
63 output_bytes,
64 } => Ok((*bytes_read, *accepted, *quarantined, *output_bytes)),
65 Self::Cancelled => Err(ImportError::Cancelled),
66 _ => Err(ImportError::NotSucceeded),
67 }
68 }
69}