-
Notifications
You must be signed in to change notification settings - Fork 1
Crystal API
FantasyPvP edited this page Nov 13, 2023
·
3 revisions
trait for declaring an application, pretty much just create a struct and implement the trait, the main function should be async as in the trait.
- you will also need to import Box and async_trait for any struct implementing async trait to work otherwise you'll get a compile error
#[async_trait]
pub trait Application {
fn new() -> Self;
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
Ok(())
}
}
#[derive(Debug)]
pub enum Error {
UnknownCommand(String),
CommandFailed(String),
ApplicationError(String),
EmptyCommand,
}