From fd8b50c56f7d753169e40134c6cbb257d5177bb9 Mon Sep 17 00:00:00 2001 From: FantasyPvP <80643031+FantasyPvP@users.noreply.github.com> Date: Mon, 13 Nov 2023 00:27:04 +0000 Subject: [PATCH] Updated Crystal API (markdown) --- Crystal-API.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Crystal-API.md b/Crystal-API.md index d4e3a77..aef8831 100644 --- a/Crystal-API.md +++ b/Crystal-API.md @@ -1,23 +1,22 @@ +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 ```rust -use async_trait::async_trait; -use alloc::{string::String, vec::Vec, boxed::Box}; - #[async_trait] pub trait Application { - fn new() -> Self; - - async fn run(&mut self, _: Vec) -> Result<(), Error> { - Ok(()) - } + fn new() -> Self; + async fn run(&mut self, _: Vec) -> Result<(), Error> { + Ok(()) + } } #[derive(Debug)] pub enum Error { - UnknownCommand(String), - CommandFailed(String), - ApplicationError(String), - EmptyCommand, + UnknownCommand(String), + CommandFailed(String), + ApplicationError(String), + EmptyCommand, } - ``` \ No newline at end of file