-
Notifications
You must be signed in to change notification settings - Fork 122
Expand file tree
/
Copy pathmod.rs
More file actions
46 lines (36 loc) · 921 Bytes
/
mod.rs
File metadata and controls
46 lines (36 loc) · 921 Bytes
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
45
46
use std::sync::Arc;
use async_trait::async_trait;
use ruma::UserId;
use tuwunel_core::{Result, log::capture::EventData};
pub mod complete;
pub mod run;
pub mod run_matrix;
pub struct CommandResult {
pub output: String,
pub logs: Vec<EventData>,
pub err: bool,
}
pub struct CompletionTree {
pub name: String,
pub nodes: Vec<Self>,
}
#[async_trait]
pub trait CommandSystem: Send + Sync {
fn parse(&self, command_line: &str) -> Vec<String>;
fn get_completion_tree(&self) -> CompletionTree;
async fn process(
&self,
command_line: &[&str],
input: &str,
sender: Option<&UserId>,
) -> Result<String>;
}
pub struct Service {
services: Arc<crate::services::OnceServices>,
}
impl crate::Service for Service {
fn build(args: &crate::Args<'_>) -> Result<Arc<Self>> {
Ok(Arc::new(Self { services: args.services.clone() }))
}
fn name(&self) -> &str { crate::service::make_name(std::module_path!()) }
}