Skip to main content

max / makenotwork

1.4 KB · 60 lines History Blame Raw
1 //! Bringing a catalog in from somewhere else: where it came from and how far
2 //! the job got.
3
4 use super::str_enum::impl_str_enum;
5 use serde::{Deserialize, Serialize};
6
7 // --- Import System ---
8
9 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
10 #[serde(rename_all = "snake_case")]
11 pub enum ImportSource {
12 GenericCsv,
13 Substack,
14 Ghost,
15 Gumroad,
16 Bandcamp,
17 LemonSqueezy,
18 Patreon,
19 }
20
21 impl_str_enum!(ImportSource {
22 GenericCsv => "generic_csv",
23 Substack => "substack",
24 Ghost => "ghost",
25 Gumroad => "gumroad",
26 Bandcamp => "bandcamp",
27 LemonSqueezy => "lemon_squeezy",
28 Patreon => "patreon",
29 });
30
31 #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
32 #[serde(rename_all = "lowercase")]
33 pub enum ImportJobStatus {
34 Pending,
35 Processing,
36 Completed,
37 Failed,
38 }
39
40 impl_str_enum!(ImportJobStatus {
41 Pending => "pending",
42 Processing => "processing",
43 Completed => "completed",
44 Failed => "failed",
45 });
46
47 impl ImportJobStatus {
48 /// Badge vocabulary (charter: `docs/design-system.md`).
49 pub fn badge_status(self) -> crate::types::BadgeStatus {
50 use crate::types::BadgeStatus;
51 match self {
52 Self::Completed => BadgeStatus::Live,
53 Self::Pending | Self::Processing => BadgeStatus::Pending,
54 Self::Failed => BadgeStatus::Failed,
55 }
56 }
57 }
58
59 // Moderation action types
60