Skip to content

Commit

Permalink
remove: remove async_trait crate due to increased MSRV (#234)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
oestradiol and sugyan authored Sep 20, 2024
1 parent 3ca9c1a commit 245d61f
Show file tree
Hide file tree
Showing 21 changed files with 159 additions and 168 deletions.
43 changes: 14 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ atrium-xrpc = { version = "0.11.4", path = "atrium-xrpc" }
atrium-xrpc-client = { version = "0.5.7", path = "atrium-xrpc-client" }
bsky-sdk = { version = "0.1.10", path = "bsky-sdk" }

# async in traits
# Can be removed once MSRV is at least 1.75.0.
async-trait = "0.1.80"

# DAG-CBOR codec
ipld-core = { version = "0.4.1", default-features = false, features = ["std"] }
serde_ipld_dagcbor = { version = "0.6.0", default-features = false, features = ["std"] }
Expand Down Expand Up @@ -76,3 +72,6 @@ mockito = "1.4"
# WebAssembly
wasm-bindgen-test = "0.3.41"
bumpalo = "~3.14.0"

# Code generation
trait-variant = "0.1.2"
2 changes: 1 addition & 1 deletion atrium-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ keywords.workspace = true

[dependencies]
atrium-xrpc.workspace = true
async-trait.workspace = true
chrono = { workspace = true, features = ["serde"] }
http.workspace = true
ipld-core = { workspace = true, features = ["serde"] }
Expand All @@ -24,6 +23,7 @@ serde_bytes.workspace = true
serde_json.workspace = true
thiserror.workspace = true
tokio = { workspace = true, optional = true }
trait-variant.workspace = true

[features]
default = ["agent", "bluesky"]
Expand Down
3 changes: 0 additions & 3 deletions atrium-api/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ mod tests {
use crate::com::atproto::server::create_session::OutputData;
use crate::did_doc::{DidDocument, Service, VerificationMethod};
use crate::types::TryIntoUnknown;
use async_trait::async_trait;
use atrium_xrpc::HttpClient;
use http::{HeaderMap, HeaderName, HeaderValue, Request, Response};
use std::collections::HashMap;
Expand All @@ -189,8 +188,6 @@ mod tests {
headers: Arc<RwLock<Vec<HeaderMap<HeaderValue>>>>,
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl HttpClient for MockClient {
async fn send_http(
&self,
Expand Down
11 changes: 0 additions & 11 deletions atrium-api/src/agent/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::{Session, SessionStore};
use crate::did_doc::DidDocument;
use crate::types::string::Did;
use crate::types::TryFromUnknown;
use async_trait::async_trait;
use atrium_xrpc::error::{Error, Result, XrpcErrorKind};
use atrium_xrpc::{HttpClient, OutputDataOrBytes, XrpcClient, XrpcRequest};
use http::{Method, Request, Response, Uri};
Expand Down Expand Up @@ -51,8 +50,6 @@ impl<S, T> Clone for WrapperClient<S, T> {
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<S, T> HttpClient for WrapperClient<S, T>
where
S: Send + Sync,
Expand All @@ -67,8 +64,6 @@ where
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<S, T> XrpcClient for WrapperClient<S, T>
where
S: SessionStore + Send + Sync,
Expand Down Expand Up @@ -231,8 +226,6 @@ where
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<S, T> HttpClient for Client<S, T>
where
S: Send + Sync,
Expand All @@ -247,8 +240,6 @@ where
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<S, T> XrpcClient for Client<S, T>
where
S: SessionStore + Send + Sync,
Expand Down Expand Up @@ -321,8 +312,6 @@ impl<S> Store<S> {
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl<S> SessionStore for Store<S>
where
S: SessionStore + Send + Sync,
Expand Down
12 changes: 6 additions & 6 deletions atrium-api/src/agent/store.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
mod memory;

use std::future::Future;

pub use self::memory::MemorySessionStore;
pub(crate) use super::Session;
use async_trait::async_trait;

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(not(target_arch = "wasm32"), trait_variant::make(Send))]
pub trait SessionStore {
#[must_use]
async fn get_session(&self) -> Option<Session>;
fn get_session(&self) -> impl Future<Output = Option<Session>>;
#[must_use]
async fn set_session(&self, session: Session);
fn set_session(&self, session: Session) -> impl Future<Output = ()>;
#[must_use]
async fn clear_session(&self);
fn clear_session(&self) -> impl Future<Output = ()>;
}
3 changes: 0 additions & 3 deletions atrium-api/src/agent/store/memory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::{Session, SessionStore};
use async_trait::async_trait;
use std::sync::Arc;
use tokio::sync::RwLock;

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

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl SessionStore for MemorySessionStore {
async fn get_session(&self) -> Option<Session> {
self.session.read().await.clone()
Expand Down
1 change: 0 additions & 1 deletion atrium-xrpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ license.workspace = true
keywords.workspace = true

[dependencies]
async-trait.workspace = true
atrium-xrpc.workspace = true
isahc = { workspace = true, optional = true }
reqwest = { workspace = true, optional = true }
Expand Down
2 changes: 0 additions & 2 deletions atrium-xrpc-client/src/isahc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![doc = "XrpcClient implementation for [isahc]"]
use async_trait::async_trait;
use atrium_xrpc::http::{Request, Response};
use atrium_xrpc::{HttpClient, XrpcClient};
use isahc::{AsyncReadResponseExt, HttpClient as Client};
Expand Down Expand Up @@ -52,7 +51,6 @@ impl IsahcClientBuilder {
}
}

#[async_trait]
impl HttpClient for IsahcClient {
async fn send_http(
&self,
Expand Down
3 changes: 0 additions & 3 deletions atrium-xrpc-client/src/reqwest.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![doc = "XrpcClient implementation for [reqwest]"]
use async_trait::async_trait;
use atrium_xrpc::http::{Request, Response};
use atrium_xrpc::{HttpClient, XrpcClient};
use reqwest::Client;
Expand Down Expand Up @@ -48,8 +47,6 @@ impl ReqwestClientBuilder {
}
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl HttpClient for ReqwestClient {
async fn send_http(
&self,
Expand Down
2 changes: 1 addition & 1 deletion atrium-xrpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ license.workspace = true
keywords.workspace = true

[dependencies]
async-trait.workspace = true
http.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_html_form.workspace = true
serde_json.workspace = true
thiserror.workspace = true
trait-variant.workspace = true

[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt"] }
Expand Down
3 changes: 0 additions & 3 deletions atrium-xrpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mod tests {
use super::*;
use crate::error::{XrpcError, XrpcErrorKind};
use crate::{HttpClient, XrpcClient};
use async_trait::async_trait;
use http::{Request, Response};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
Expand All @@ -24,8 +23,6 @@ mod tests {
body: Vec<u8>,
}

#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
impl HttpClient for DummyClient {
async fn send_http(
&self,
Expand Down
Loading

0 comments on commit 245d61f

Please sign in to comment.