返回 CodeWhale
background.rs
根目录 / crates / command-contract / src / facets / background.rs
1 use std::path::PathBuf;
2 use std::sync::Arc;
3 use std::sync::atomic::AtomicBool;
4
5 use crate::outcome::BackgroundCommandResult;
6
7 #[derive(Debug, Clone, Default, PartialEq, Eq)]
8 pub struct BackgroundRequest {
9 pub workspace: PathBuf,
10 pub language: String,
11 pub updater: PathBuf,
12 pub argument: String,
13 }
14
15 pub type BackgroundCancel = Arc<AtomicBool>;
16
17 pub type BackgroundJob = fn(BackgroundRequest, BackgroundCancel) -> BackgroundCommandResult;
18
19 pub trait CommandBackgroundContext {
20 fn start(
21 &mut self,
22 command: &'static str,
23 job: BackgroundJob,
24 request: BackgroundRequest,
25 ) -> Result<String, String>;
26
27 fn cancel(&mut self, command: &'static str) -> Result<String, String>;
28 }
29
29 lines RUST