Skip to content

Commit 245d61f

Browse files
oestradiolsugyan
andauthored
remove: remove async_trait crate due to increased MSRV (#234)
* chore: Bumping MSRV to 1.75 * Formatting * Bumping version on Cargo.toml * Configuring matrix workflow * Bringing back actions-rust-lang/setup-rust-toolchain@v1 * Removing "Install Rust Problem Matcher" * Removing dependency * Refactoring code * Relaxing back the Send trait on return types for wasm --------- Co-authored-by: Yoshihiro Sugi <[email protected]>
1 parent 3ca9c1a commit 245d61f

File tree

21 files changed

+159
-168
lines changed

21 files changed

+159
-168
lines changed

Cargo.lock

+14-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ atrium-xrpc = { version = "0.11.4", path = "atrium-xrpc" }
2828
atrium-xrpc-client = { version = "0.5.7", path = "atrium-xrpc-client" }
2929
bsky-sdk = { version = "0.1.10", path = "bsky-sdk" }
3030

31-
# async in traits
32-
# Can be removed once MSRV is at least 1.75.0.
33-
async-trait = "0.1.80"
34-
3531
# DAG-CBOR codec
3632
ipld-core = { version = "0.4.1", default-features = false, features = ["std"] }
3733
serde_ipld_dagcbor = { version = "0.6.0", default-features = false, features = ["std"] }
@@ -76,3 +72,6 @@ mockito = "1.4"
7672
# WebAssembly
7773
wasm-bindgen-test = "0.3.41"
7874
bumpalo = "~3.14.0"
75+
76+
# Code generation
77+
trait-variant = "0.1.2"

atrium-api/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ keywords.workspace = true
1313

1414
[dependencies]
1515
atrium-xrpc.workspace = true
16-
async-trait.workspace = true
1716
chrono = { workspace = true, features = ["serde"] }
1817
http.workspace = true
1918
ipld-core = { workspace = true, features = ["serde"] }
@@ -24,6 +23,7 @@ serde_bytes.workspace = true
2423
serde_json.workspace = true
2524
thiserror.workspace = true
2625
tokio = { workspace = true, optional = true }
26+
trait-variant.workspace = true
2727

2828
[features]
2929
default = ["agent", "bluesky"]

atrium-api/src/agent.rs

-3
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ mod tests {
168168
use crate::com::atproto::server::create_session::OutputData;
169169
use crate::did_doc::{DidDocument, Service, VerificationMethod};
170170
use crate::types::TryIntoUnknown;
171-
use async_trait::async_trait;
172171
use atrium_xrpc::HttpClient;
173172
use http::{HeaderMap, HeaderName, HeaderValue, Request, Response};
174173
use std::collections::HashMap;
@@ -189,8 +188,6 @@ mod tests {
189188
headers: Arc<RwLock<Vec<HeaderMap<HeaderValue>>>>,
190189
}
191190

192-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
193-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
194191
impl HttpClient for MockClient {
195192
async fn send_http(
196193
&self,

atrium-api/src/agent/inner.rs

-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::{Session, SessionStore};
22
use crate::did_doc::DidDocument;
33
use crate::types::string::Did;
44
use crate::types::TryFromUnknown;
5-
use async_trait::async_trait;
65
use atrium_xrpc::error::{Error, Result, XrpcErrorKind};
76
use atrium_xrpc::{HttpClient, OutputDataOrBytes, XrpcClient, XrpcRequest};
87
use http::{Method, Request, Response, Uri};
@@ -51,8 +50,6 @@ impl<S, T> Clone for WrapperClient<S, T> {
5150
}
5251
}
5352

54-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
55-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
5653
impl<S, T> HttpClient for WrapperClient<S, T>
5754
where
5855
S: Send + Sync,
@@ -67,8 +64,6 @@ where
6764
}
6865
}
6966

70-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
71-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
7267
impl<S, T> XrpcClient for WrapperClient<S, T>
7368
where
7469
S: SessionStore + Send + Sync,
@@ -231,8 +226,6 @@ where
231226
}
232227
}
233228

234-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
235-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
236229
impl<S, T> HttpClient for Client<S, T>
237230
where
238231
S: Send + Sync,
@@ -247,8 +240,6 @@ where
247240
}
248241
}
249242

250-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
251-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
252243
impl<S, T> XrpcClient for Client<S, T>
253244
where
254245
S: SessionStore + Send + Sync,
@@ -321,8 +312,6 @@ impl<S> Store<S> {
321312
}
322313
}
323314

324-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
325-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
326315
impl<S> SessionStore for Store<S>
327316
where
328317
S: SessionStore + Send + Sync,

atrium-api/src/agent/store.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
mod memory;
22

3+
use std::future::Future;
4+
35
pub use self::memory::MemorySessionStore;
46
pub(crate) use super::Session;
5-
use async_trait::async_trait;
67

7-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
8-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
8+
#[cfg_attr(not(target_arch = "wasm32"), trait_variant::make(Send))]
99
pub trait SessionStore {
1010
#[must_use]
11-
async fn get_session(&self) -> Option<Session>;
11+
fn get_session(&self) -> impl Future<Output = Option<Session>>;
1212
#[must_use]
13-
async fn set_session(&self, session: Session);
13+
fn set_session(&self, session: Session) -> impl Future<Output = ()>;
1414
#[must_use]
15-
async fn clear_session(&self);
15+
fn clear_session(&self) -> impl Future<Output = ()>;
1616
}

atrium-api/src/agent/store/memory.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use super::{Session, SessionStore};
2-
use async_trait::async_trait;
32
use std::sync::Arc;
43
use tokio::sync::RwLock;
54

@@ -8,8 +7,6 @@ pub struct MemorySessionStore {
87
session: Arc<RwLock<Option<Session>>>,
98
}
109

11-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
12-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
1310
impl SessionStore for MemorySessionStore {
1411
async fn get_session(&self) -> Option<Session> {
1512
self.session.read().await.clone()

atrium-xrpc-client/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ license.workspace = true
1212
keywords.workspace = true
1313

1414
[dependencies]
15-
async-trait.workspace = true
1615
atrium-xrpc.workspace = true
1716
isahc = { workspace = true, optional = true }
1817
reqwest = { workspace = true, optional = true }

atrium-xrpc-client/src/isahc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![doc = "XrpcClient implementation for [isahc]"]
2-
use async_trait::async_trait;
32
use atrium_xrpc::http::{Request, Response};
43
use atrium_xrpc::{HttpClient, XrpcClient};
54
use isahc::{AsyncReadResponseExt, HttpClient as Client};
@@ -52,7 +51,6 @@ impl IsahcClientBuilder {
5251
}
5352
}
5453

55-
#[async_trait]
5654
impl HttpClient for IsahcClient {
5755
async fn send_http(
5856
&self,

atrium-xrpc-client/src/reqwest.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![doc = "XrpcClient implementation for [reqwest]"]
2-
use async_trait::async_trait;
32
use atrium_xrpc::http::{Request, Response};
43
use atrium_xrpc::{HttpClient, XrpcClient};
54
use reqwest::Client;
@@ -48,8 +47,6 @@ impl ReqwestClientBuilder {
4847
}
4948
}
5049

51-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
52-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
5350
impl HttpClient for ReqwestClient {
5451
async fn send_http(
5552
&self,

atrium-xrpc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ license.workspace = true
1212
keywords.workspace = true
1313

1414
[dependencies]
15-
async-trait.workspace = true
1615
http.workspace = true
1716
serde = { workspace = true, features = ["derive"] }
1817
serde_html_form.workspace = true
1918
serde_json.workspace = true
2019
thiserror.workspace = true
20+
trait-variant.workspace = true
2121

2222
[dev-dependencies]
2323
tokio = { workspace = true, features = ["macros", "rt"] }

atrium-xrpc/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ mod tests {
1313
use super::*;
1414
use crate::error::{XrpcError, XrpcErrorKind};
1515
use crate::{HttpClient, XrpcClient};
16-
use async_trait::async_trait;
1716
use http::{Request, Response};
1817
#[cfg(target_arch = "wasm32")]
1918
use wasm_bindgen_test::*;
@@ -24,8 +23,6 @@ mod tests {
2423
body: Vec<u8>,
2524
}
2625

27-
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
28-
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
2926
impl HttpClient for DummyClient {
3027
async fn send_http(
3128
&self,

0 commit comments

Comments
 (0)