chore: replace async-std with tokio (#813)

Signed-off-by: Zomatree <me@zomatree.live>
This commit is contained in:
Zomatree
2026-06-24 13:38:20 +01:00
committed by GitHub
parent a15a542f43
commit 01c7d925b0
35 changed files with 703 additions and 1150 deletions

View File

@@ -25,8 +25,8 @@ pub use mongodb;
#[macro_use]
extern crate bson;
#[cfg(not(feature = "async-std-runtime"))]
compile_error!("async-std-runtime feature must be enabled.");
#[cfg(not(feature = "tokio-runtime"))]
compile_error!("tokio-runtime feature must be enabled.");
#[macro_export]
#[cfg(debug_assertions)]

View File

@@ -11,7 +11,7 @@ auto_derived!(
#[cfg(test)]
mod tests {
#[async_std::test]
#[tokio::test]
async fn migrate() {
database_test!(|db| async move {
// Initialise the database

View File

@@ -452,7 +452,7 @@ pub async fn run_migrations(db: &MongoDb, revision: i32) -> i32 {
warn!("This is a destructive operation and will wipe existing permission data (excl. defaults for SendMessage).");
warn!("Taking a backup is advised.");
warn!("Continuing in 10 seconds...");
async_std::task::sleep(Duration::from_secs(10)).await;
tokio::time::sleep(Duration::from_secs(10)).await;
let servers = db.col::<Document>("servers");
let mut cursor = servers.find(doc! {}).await.unwrap();

View File

@@ -164,7 +164,7 @@ impl Bot {
mod tests {
use crate::{Bot, FieldsBot, PartialBot, User};
#[async_std::test]
#[tokio::test]
async fn crud() {
database_test!(|db| async move {
let owner = User::create(&db, "Owner".to_string(), None, None)

View File

@@ -128,7 +128,7 @@ impl Webhook {
mod tests {
use crate::{FieldsWebhook, PartialWebhook, Webhook};
#[async_std::test]
#[tokio::test]
async fn crud() {
database_test!(|db| async move {
let webhook_id = "webhook";

View File

@@ -787,7 +787,7 @@ mod tests {
use crate::{fixture, util::permissions::DatabasePermissionQuery};
#[async_std::test]
#[tokio::test]
async fn permissions_group_channel() {
database_test!(|db| async move {
fixture!(db, "group_with_members",
@@ -813,7 +813,7 @@ mod tests {
});
}
#[async_std::test]
#[tokio::test]
async fn permissions_text_channel() {
database_test!(|db| async move {
fixture!(db, "server_with_roles",

View File

@@ -320,7 +320,7 @@ mod tests {
use crate::{Member, PartialMember, RemovalIntention, Server, User};
#[async_std::test]
#[tokio::test]
async fn muted_member_rejoin() {
database_test!(|db| async move {
match db {

View File

@@ -420,7 +420,7 @@ mod tests {
use crate::{fixture, util::permissions::DatabasePermissionQuery};
#[async_std::test]
#[tokio::test]
async fn permissions() {
database_test!(|db| async move {
fixture!(db, "server_with_roles",

View File

@@ -926,7 +926,7 @@ mod tests {
assert!(User::validate_username(username_https).is_err());
}
#[async_std::test]
#[tokio::test]
async fn username_sanitisation_clean() {
let username_clean = "Test";
@@ -936,7 +936,7 @@ mod tests {
assert_eq!(username_clean, username_clean_sanitised.unwrap());
}
#[async_std::test]
#[tokio::test]
async fn username_sanitisation_homoglyphs() {
let username_homoglyphs = "𝔽𝕌Ňℕy";
@@ -947,7 +947,7 @@ mod tests {
assert_eq!("funny", username_homoglyphs_sanitised);
}
#[async_std::test]
#[tokio::test]
async fn username_sanitisation_padding() {
let username_padding = "a";
@@ -956,7 +956,7 @@ mod tests {
assert_eq!("a_", username);
}
#[async_std::test]
#[tokio::test]
async fn create_user() {
use revolt_result::Result;

View File

@@ -305,6 +305,6 @@ pub async fn worker(db: Database, amqp: AMQP) {
}
// Sleep for an arbitrary amount of time.
async_std::task::sleep(Duration::from_secs(1)).await;
tokio::time::sleep(Duration::from_secs(1)).await;
}
}

View File

@@ -82,6 +82,6 @@ pub async fn worker(db: Database) {
}
// Sleep for an arbitrary amount of time.
async_std::task::sleep(Duration::from_secs(1)).await;
tokio::time::sleep(Duration::from_secs(1)).await;
}
}

View File

@@ -2,7 +2,7 @@
use crate::{Database, AMQP};
use async_std::task;
use tokio::task;
use std::time::Instant;
const WORKER_COUNT: usize = 5;

View File

@@ -7,11 +7,11 @@ use revolt_config::config;
use revolt_result::Result;
use async_lock::Semaphore;
use async_std::task::spawn;
use deadqueue::limited::Queue;
use once_cell::sync::Lazy;
use revolt_models::v0::Embed;
use std::{collections::HashSet, sync::Arc};
use tokio::task::spawn;
use isahc::prelude::*;
@@ -159,6 +159,7 @@ pub async fn generate(
.await
.into_iter()
.flatten()
.flatten()
.collect::<Vec<Embed>>();
// Prevent database update when no embeds are found.

View File

@@ -5,7 +5,7 @@ use revolt_result::{create_error, Result};
#[cfg(feature = "rocket-impl")]
use revolt_result::Error;
use async_std::sync::Mutex;
use tokio::sync::Mutex;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};