Use Rust native async traits

This commit is contained in:
mdecimus 2024-01-09 18:11:26 +01:00
parent 407c051e93
commit 633181a80c
5 changed files with 5 additions and 11 deletions

View file

@ -31,7 +31,7 @@ use crate::{Principal, QueryBy, Type};
use super::{manage::ManageDirectory, PrincipalIdType};
#[async_trait::async_trait]
#[allow(async_fn_in_trait)]
pub trait DirectoryStore: Sync + Send {
async fn query(
&self,
@ -46,7 +46,6 @@ pub trait DirectoryStore: Sync + Send {
async fn expn(&self, address: &str) -> crate::Result<Vec<String>>;
}
#[async_trait::async_trait]
impl DirectoryStore for Store {
async fn query(
&self,

View file

@ -39,7 +39,7 @@ use super::{
PrincipalValue,
};
#[async_trait::async_trait]
#[allow(async_fn_in_trait)]
pub trait ManageDirectory: Sized {
async fn get_account_id(&self, name: &str) -> crate::Result<Option<u32>>;
async fn get_or_create_account_id(&self, name: &str) -> crate::Result<u32>;
@ -75,7 +75,6 @@ pub trait ManageDirectory: Sized {
async fn init(self) -> crate::Result<Self>;
}
#[async_trait::async_trait]
impl ManageDirectory for Store {
async fn get_account_name(&self, account_id: u32) -> crate::Result<Option<String>> {
self.get_value::<Principal<u32>>(ValueKey::from(ValueClass::Directory(

View file

@ -45,7 +45,7 @@ use crate::{
use super::cache::CachedDirectory;
#[async_trait::async_trait]
#[allow(async_fn_in_trait)]
pub trait ConfigDirectory {
async fn parse_directory(
&self,
@ -54,7 +54,6 @@ pub trait ConfigDirectory {
) -> utils::config::Result<Directories>;
}
#[async_trait::async_trait]
impl ConfigDirectory for Config {
async fn parse_directory(
&self,

View file

@ -23,7 +23,6 @@
use std::sync::Arc;
use async_trait::async_trait;
use utils::config::{cron::SimpleCron, Config};
use crate::{
@ -56,7 +55,7 @@ use crate::backend::elastic::ElasticSearchStore;
#[cfg(feature = "redis")]
use crate::backend::redis::RedisStore;
#[async_trait]
#[allow(async_fn_in_trait)]
pub trait ConfigStore {
async fn parse_stores(&self) -> utils::config::Result<Stores>;
async fn parse_purge_schedules(
@ -67,7 +66,6 @@ pub trait ConfigStore {
) -> utils::config::Result<Vec<PurgeSchedule>>;
}
#[async_trait]
impl ConfigStore for Config {
#[allow(unused_variables)]
#[allow(unreachable_code)]

View file

@ -97,7 +97,7 @@ impl SessionStream for DummyIo {
impl Unpin for DummyIo {}
#[async_trait::async_trait]
#[allow(async_fn_in_trait)]
pub trait TestSession {
fn test(core: impl Into<Arc<SMTP>>) -> Self;
fn test_with_shutdown(core: impl Into<Arc<SMTP>>, shutdown_rx: watch::Receiver<bool>) -> Self;
@ -113,7 +113,6 @@ pub trait TestSession {
async fn test_builder(&self);
}
#[async_trait::async_trait]
impl TestSession for Session<DummyIo> {
fn test_with_shutdown(core: impl Into<Arc<SMTP>>, shutdown_rx: watch::Receiver<bool>) -> Self {
Self {