| 6 | use tokio; |
| 7 | #[tokio::main] |
| 8 | async fn main() -> Result<(), anyhow::Error> { |
| 9 | let state = (); |
| 10 | |
| 11 | if let Some(plugin) = Builder::new(tokio::io::stdin(), tokio::io::stdout()) |
| 12 | .option(options::ConfigOption::new( |
| 13 | "test-option", |
| 14 | options::Value::Integer(42), |
| 15 | "a test-option with default 42", |
| 16 | )) |
| 17 | .rpcmethod("testmethod", "This is a test", testmethod) |
| 18 | .subscribe("connect", connect_handler) |
| 19 | .hook("peer_connected", peer_connected_handler) |
| 20 | .start(state) |
| 21 | .await? |
| 22 | { |
| 23 | plugin.join().await |
| 24 | } else { |
| 25 | Ok(()) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | async fn testmethod(_p: Plugin<()>, _v: serde_json::Value) -> Result<serde_json::Value, Error> { |
| 30 | Ok(json!("Hello")) |