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
|
// SPDX-License-Identifier: MIT
// Copyright (c) 2023 Robin Jarry
mod imap;
mod maildir;
mod mbox;
mod notmuch;
use tokio::sync::mpsc::{Receiver, Sender};
use crate::config::{AccountConfig, BackendType};
pub struct Worker {
config: AccountConfig,
backend: Box<dyn Backend>,
from_app: Receiver<WorkerMessage>,
to_app: Sender<WorkerMessage>,
}
impl Worker {
pub fn new(
config: AccountConfig,
from_app: Receiver<WorkerMessage>,
to_app: Sender<WorkerMessage>,
) -> Self {
let backend: Box<dyn Backend> = match config.backend {
BackendType::IMAP => Box::new(imap::new()),
BackendType::Maildir => Box::new(maildir::new()),
BackendType::Mbox => Box::new(mbox::new()),
BackendType::Notmuch => Box::new(notmuch::new()),
};
Worker {
config,
backend,
from_app,
to_app,
}
}
pub async fn run(self) {}
}
pub trait Backend: Send + Sync {}
pub struct WorkerMessage {}
|