serialtui 0.1.0

A TUI environment specific to serial connections
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub(crate) mod command_manager;

use crate::hint::default_hint::DefaultHint;
use async_trait::async_trait;

#[async_trait]
pub trait Command {
    fn get_command(&self) -> &'static str;

    fn hint(&self, tokens: &Vec<&str>, pos: usize) -> Option<DefaultHint>;

    fn validate(&self, tokens: &Vec<&str>) -> bool {
        tokens.len() == 1 && tokens.last().unwrap() == &self.get_command()
    }

    async fn run(&self, args: Vec<String>) -> Vec<u8>;
}