Updated Crystal API (markdown)
+4
-5
@@ -1,12 +1,12 @@
|
|||||||
|
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
|
```rust
|
||||||
use async_trait::async_trait;
|
|
||||||
use alloc::{string::String, vec::Vec, boxed::Box};
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Application {
|
pub trait Application {
|
||||||
fn new() -> Self;
|
fn new() -> Self;
|
||||||
|
|
||||||
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
|
async fn run(&mut self, _: Vec<String>) -> Result<(), Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -19,5 +19,4 @@ pub enum Error {
|
|||||||
ApplicationError(String),
|
ApplicationError(String),
|
||||||
EmptyCommand,
|
EmptyCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user