From f24d478454b12c14d06eb70d7c82fa0490474101 Mon Sep 17 00:00:00 2001 From: Martin Loffler <me@fatalerrorcoded.eu> Date: Mon, 4 Jan 2021 14:59:25 +0100 Subject: [PATCH] async_std main attribute Closes #1 --- Cargo.lock | 11 +++++++++++ Cargo.toml | 2 +- src/main.rs | 8 ++------ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5e1586f..b24b97f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,16 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "async-attributes" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423" +dependencies = [ + "quote 1.0.8", + "syn 1.0.56", +] + [[package]] name = "async-channel" version = "1.5.1" @@ -110,6 +120,7 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f9f84f1280a2b436a2c77c2582602732b6c2f4321d5494d6e799e6c367859a8" dependencies = [ + "async-attributes", "async-channel", "async-global-executor", "async-io", diff --git a/Cargo.toml b/Cargo.toml index 1a48cf2..2ede2e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ impl_ops = "0.1.1" ctrlc = { version = "3.0", features = ["termination"] } async-tungstenite = { version = "0.10.0", features = ["async-std-runtime"] } rauth = { git = "https://gitlab.insrt.uk/insert/rauth" } -async-std = { version = "1.8.0", features = ["tokio02"] } +async-std = { version = "1.8.0", features = ["tokio02", "attributes"] } hive_pubsub = { version = "0.4.3", features = ["mongo"] } rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" } diff --git a/src/main.rs b/src/main.rs index 8c55f5b..e0f1d12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,17 +18,13 @@ pub mod notifications; pub mod routes; pub mod util; -use async_std::task; use futures::join; use log::info; use rauth; use rocket_cors::AllowedOrigins; -fn main() { - task::block_on(entry()) -} - -async fn entry() { +#[async_std::main] +async fn main() { dotenv::dotenv().ok(); env_logger::init_from_env(env_logger::Env::default().filter_or("RUST_LOG", "info")); -- GitLab