From fc55b641ca00aa47efa3ba1f768e0040613d5f0d Mon Sep 17 00:00:00 2001 From: Joshua Mo Date: Mon, 3 Nov 2025 10:51:18 +0000 Subject: [PATCH 1/5] refactor(rig-1031): remove worker::send from all providers --- rig-core/src/agent/prompt_request/streaming.rs | 1 - rig-core/src/providers/anthropic/client.rs | 1 - rig-core/src/providers/anthropic/completion.rs | 2 -- rig-core/src/providers/azure.rs | 7 ------- rig-core/src/providers/cohere/client.rs | 1 - rig-core/src/providers/cohere/completion.rs | 2 -- rig-core/src/providers/cohere/embeddings.rs | 1 - rig-core/src/providers/deepseek.rs | 3 --- rig-core/src/providers/galadriel.rs | 3 --- rig-core/src/providers/gemini/client.rs | 1 - rig-core/src/providers/gemini/completion.rs | 2 -- rig-core/src/providers/gemini/embedding.rs | 1 - rig-core/src/providers/gemini/transcription.rs | 1 - rig-core/src/providers/groq.rs | 4 ---- rig-core/src/providers/huggingface/client.rs | 1 - rig-core/src/providers/huggingface/completion.rs | 2 -- rig-core/src/providers/huggingface/image_generation.rs | 1 - rig-core/src/providers/huggingface/transcription.rs | 1 - rig-core/src/providers/hyperbolic.rs | 5 ----- rig-core/src/providers/mira.rs | 3 --- rig-core/src/providers/mistral/client.rs | 1 - rig-core/src/providers/mistral/completion.rs | 2 -- rig-core/src/providers/mistral/embedding.rs | 1 - rig-core/src/providers/moonshot.rs | 3 --- rig-core/src/providers/ollama.rs | 4 ---- rig-core/src/providers/openai/audio_generation.rs | 1 - rig-core/src/providers/openai/client.rs | 1 - rig-core/src/providers/openai/completion/mod.rs | 2 -- rig-core/src/providers/openai/embedding.rs | 1 - rig-core/src/providers/openai/image_generation.rs | 1 - rig-core/src/providers/openai/responses_api/mod.rs | 2 -- rig-core/src/providers/openai/transcription.rs | 1 - rig-core/src/providers/openrouter/client.rs | 1 - rig-core/src/providers/openrouter/completion.rs | 2 -- rig-core/src/providers/perplexity.rs | 3 --- rig-core/src/providers/together/client.rs | 1 - rig-core/src/providers/together/completion.rs | 2 -- rig-core/src/providers/together/embedding.rs | 1 - rig-core/src/providers/voyageai.rs | 2 -- rig-core/src/providers/xai/client.rs | 1 - rig-core/src/providers/xai/completion.rs | 2 -- 41 files changed, 78 deletions(-) diff --git a/rig-core/src/agent/prompt_request/streaming.rs b/rig-core/src/agent/prompt_request/streaming.rs index b1359acec..cc79faf32 100644 --- a/rig-core/src/agent/prompt_request/streaming.rs +++ b/rig-core/src/agent/prompt_request/streaming.rs @@ -153,7 +153,6 @@ where } } - #[cfg_attr(feature = "worker", worker::send)] async fn send(self) -> StreamingResult { let agent_span = if tracing::Span::current().is_disabled() { info_span!( diff --git a/rig-core/src/providers/anthropic/client.rs b/rig-core/src/providers/anthropic/client.rs index 86aa9ffbd..780619e5a 100644 --- a/rig-core/src/providers/anthropic/client.rs +++ b/rig-core/src/providers/anthropic/client.rs @@ -261,7 +261,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/v1/models") diff --git a/rig-core/src/providers/anthropic/completion.rs b/rig-core/src/providers/anthropic/completion.rs index dcc1cbd2b..aa229f3df 100644 --- a/rig-core/src/providers/anthropic/completion.rs +++ b/rig-core/src/providers/anthropic/completion.rs @@ -739,7 +739,6 @@ where type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: completion::CompletionRequest, @@ -887,7 +886,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/azure.rs b/rig-core/src/providers/azure.rs index f3b59defc..bf6624615 100644 --- a/rig-core/src/providers/azure.rs +++ b/rig-core/src/providers/azure.rs @@ -489,7 +489,6 @@ where self.ndims } - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator, @@ -656,7 +655,6 @@ where type Response = openai::CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -722,7 +720,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, @@ -797,7 +794,6 @@ where { type Response = TranscriptionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn transcription( &self, request: transcription::TranscriptionRequest, @@ -884,7 +880,6 @@ mod image_generation { { type Response = ImageGenerationResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn image_generation( &self, generation_request: ImageGenerationRequest, @@ -973,7 +968,6 @@ mod audio_generation { { type Response = Bytes; - #[cfg_attr(feature = "worker", worker::send)] async fn audio_generation( &self, request: AudioGenerationRequest, @@ -1031,7 +1025,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + Default + std::fmt::Debug + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { // There is currently no way to verify the Azure OpenAI API key or token without // consuming tokens diff --git a/rig-core/src/providers/cohere/client.rs b/rig-core/src/providers/cohere/client.rs index 27de8e601..a49d01c33 100644 --- a/rig-core/src/providers/cohere/client.rs +++ b/rig-core/src/providers/cohere/client.rs @@ -240,7 +240,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + WasmCompatSend + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/models")? diff --git a/rig-core/src/providers/cohere/completion.rs b/rig-core/src/providers/cohere/completion.rs index 9363997d0..d24bdf93e 100644 --- a/rig-core/src/providers/cohere/completion.rs +++ b/rig-core/src/providers/cohere/completion.rs @@ -587,7 +587,6 @@ where type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: completion::CompletionRequest, @@ -659,7 +658,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/cohere/embeddings.rs b/rig-core/src/providers/cohere/embeddings.rs index 0378fd0c4..793787a23 100644 --- a/rig-core/src/providers/cohere/embeddings.rs +++ b/rig-core/src/providers/cohere/embeddings.rs @@ -77,7 +77,6 @@ where self.ndims } - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator, diff --git a/rig-core/src/providers/deepseek.rs b/rig-core/src/providers/deepseek.rs index 9b20174bc..187b53cce 100644 --- a/rig-core/src/providers/deepseek.rs +++ b/rig-core/src/providers/deepseek.rs @@ -190,7 +190,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/user/balance")? @@ -629,7 +628,6 @@ where type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -703,7 +701,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, completion_request: CompletionRequest, diff --git a/rig-core/src/providers/galadriel.rs b/rig-core/src/providers/galadriel.rs index 1d09ff47a..2acdc292b 100644 --- a/rig-core/src/providers/galadriel.rs +++ b/rig-core/src/providers/galadriel.rs @@ -190,7 +190,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { // Could not find an API endpoint to verify the API key Ok(()) @@ -560,7 +559,6 @@ where type Response = CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -632,7 +630,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/gemini/client.rs b/rig-core/src/providers/gemini/client.rs index 8064649fa..a846206c0 100644 --- a/rig-core/src/providers/gemini/client.rs +++ b/rig-core/src/providers/gemini/client.rs @@ -309,7 +309,6 @@ where T: HttpClientExt + Clone + Debug + Default + WasmCompatSend + WasmCompatSync + 'static, Client: CompletionClient, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/v1beta/models") diff --git a/rig-core/src/providers/gemini/completion.rs b/rig-core/src/providers/gemini/completion.rs index 26fe1c2ed..284cff3db 100644 --- a/rig-core/src/providers/gemini/completion.rs +++ b/rig-core/src/providers/gemini/completion.rs @@ -75,7 +75,6 @@ where type Response = GenerateContentResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -162,7 +161,6 @@ where } } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/gemini/embedding.rs b/rig-core/src/providers/gemini/embedding.rs index 78132b772..6d84647fc 100644 --- a/rig-core/src/providers/gemini/embedding.rs +++ b/rig-core/src/providers/gemini/embedding.rs @@ -48,7 +48,6 @@ where } /// - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator + WasmCompatSend, diff --git a/rig-core/src/providers/gemini/transcription.rs b/rig-core/src/providers/gemini/transcription.rs index 3e64c8a3a..d814c25bd 100644 --- a/rig-core/src/providers/gemini/transcription.rs +++ b/rig-core/src/providers/gemini/transcription.rs @@ -44,7 +44,6 @@ where { type Response = GenerateContentResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn transcription( &self, request: transcription::TranscriptionRequest, diff --git a/rig-core/src/providers/groq.rs b/rig-core/src/providers/groq.rs index ed7327a82..d9d5f6d18 100644 --- a/rig-core/src/providers/groq.rs +++ b/rig-core/src/providers/groq.rs @@ -216,7 +216,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + Send + std::fmt::Debug + Default + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/models")? @@ -474,7 +473,6 @@ where type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -545,7 +543,6 @@ where tracing::Instrument::instrument(async_block, span).await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, @@ -624,7 +621,6 @@ where { type Response = TranscriptionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn transcription( &self, request: transcription::TranscriptionRequest, diff --git a/rig-core/src/providers/huggingface/client.rs b/rig-core/src/providers/huggingface/client.rs index 1ee1d4c73..43ec0d438 100644 --- a/rig-core/src/providers/huggingface/client.rs +++ b/rig-core/src/providers/huggingface/client.rs @@ -361,7 +361,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/api/whoami-v2")? diff --git a/rig-core/src/providers/huggingface/completion.rs b/rig-core/src/providers/huggingface/completion.rs index 8aba96bda..947acd3dd 100644 --- a/rig-core/src/providers/huggingface/completion.rs +++ b/rig-core/src/providers/huggingface/completion.rs @@ -683,7 +683,6 @@ where type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -757,7 +756,6 @@ where } } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/huggingface/image_generation.rs b/rig-core/src/providers/huggingface/image_generation.rs index 91dec7853..388cc7ae0 100644 --- a/rig-core/src/providers/huggingface/image_generation.rs +++ b/rig-core/src/providers/huggingface/image_generation.rs @@ -47,7 +47,6 @@ where { type Response = ImageGenerationResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn image_generation( &self, request: ImageGenerationRequest, diff --git a/rig-core/src/providers/huggingface/transcription.rs b/rig-core/src/providers/huggingface/transcription.rs index 28b97cdf0..3fe1c7bef 100644 --- a/rig-core/src/providers/huggingface/transcription.rs +++ b/rig-core/src/providers/huggingface/transcription.rs @@ -52,7 +52,6 @@ where { type Response = TranscriptionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn transcription( &self, request: transcription::TranscriptionRequest, diff --git a/rig-core/src/providers/hyperbolic.rs b/rig-core/src/providers/hyperbolic.rs index 8ca62e77b..7d2af712a 100644 --- a/rig-core/src/providers/hyperbolic.rs +++ b/rig-core/src/providers/hyperbolic.rs @@ -181,7 +181,6 @@ where } impl VerifyClient for Client { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/models")? @@ -436,7 +435,6 @@ where type Response = CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -499,7 +497,6 @@ where async_block.instrument(span).await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, completion_request: CompletionRequest, @@ -624,7 +621,6 @@ mod image_generation { { type Response = ImageGenerationResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn image_generation( &self, generation_request: ImageGenerationRequest, @@ -761,7 +757,6 @@ mod audio_generation { { type Response = AudioGenerationResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn audio_generation( &self, request: AudioGenerationRequest, diff --git a/rig-core/src/providers/mira.rs b/rig-core/src/providers/mira.rs index 64f3e9205..33d114f33 100644 --- a/rig-core/src/providers/mira.rs +++ b/rig-core/src/providers/mira.rs @@ -298,7 +298,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/user-credits")? @@ -438,7 +437,6 @@ where type Response = CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -533,7 +531,6 @@ where async_block.instrument(span).await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, completion_request: CompletionRequest, diff --git a/rig-core/src/providers/mistral/client.rs b/rig-core/src/providers/mistral/client.rs index 9284291ab..77d4cd9be 100644 --- a/rig-core/src/providers/mistral/client.rs +++ b/rig-core/src/providers/mistral/client.rs @@ -219,7 +219,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + Default + std::fmt::Debug + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/models")? diff --git a/rig-core/src/providers/mistral/completion.rs b/rig-core/src/providers/mistral/completion.rs index 1ebd2b53d..b0dd32380 100644 --- a/rig-core/src/providers/mistral/completion.rs +++ b/rig-core/src/providers/mistral/completion.rs @@ -494,7 +494,6 @@ where type Response = CompletionResponse; type StreamingResponse = CompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -553,7 +552,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/mistral/embedding.rs b/rig-core/src/providers/mistral/embedding.rs index 90c9fec2e..c7624669b 100644 --- a/rig-core/src/providers/mistral/embedding.rs +++ b/rig-core/src/providers/mistral/embedding.rs @@ -41,7 +41,6 @@ where self.ndims } - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator, diff --git a/rig-core/src/providers/moonshot.rs b/rig-core/src/providers/moonshot.rs index 5e6663d7e..60996973e 100644 --- a/rig-core/src/providers/moonshot.rs +++ b/rig-core/src/providers/moonshot.rs @@ -180,7 +180,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/models")? @@ -315,7 +314,6 @@ where type Response = openai::CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -395,7 +393,6 @@ where async_block.instrument(span).await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/ollama.rs b/rig-core/src/providers/ollama.rs index 3be39cd17..1b7b3c8e6 100644 --- a/rig-core/src/providers/ollama.rs +++ b/rig-core/src/providers/ollama.rs @@ -204,7 +204,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("api/tags") @@ -309,7 +308,6 @@ where fn ndims(&self) -> usize { self.ndims } - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator, @@ -565,7 +563,6 @@ where type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -639,7 +636,6 @@ where tracing::Instrument::instrument(async_block, span).await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/openai/audio_generation.rs b/rig-core/src/providers/openai/audio_generation.rs index 8424ab59d..72a2ad439 100644 --- a/rig-core/src/providers/openai/audio_generation.rs +++ b/rig-core/src/providers/openai/audio_generation.rs @@ -30,7 +30,6 @@ where { type Response = Bytes; - #[cfg_attr(feature = "worker", worker::send)] async fn audio_generation( &self, request: AudioGenerationRequest, diff --git a/rig-core/src/providers/openai/client.rs b/rig-core/src/providers/openai/client.rs index a73acf811..76448bef3 100644 --- a/rig-core/src/providers/openai/client.rs +++ b/rig-core/src/providers/openai/client.rs @@ -304,7 +304,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Send + Default + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/models")? diff --git a/rig-core/src/providers/openai/completion/mod.rs b/rig-core/src/providers/openai/completion/mod.rs index f4a920838..517d91112 100644 --- a/rig-core/src/providers/openai/completion/mod.rs +++ b/rig-core/src/providers/openai/completion/mod.rs @@ -928,7 +928,6 @@ impl completion::CompletionModel for CompletionModel { type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CoreCompletionRequest, @@ -991,7 +990,6 @@ impl completion::CompletionModel for CompletionModel { .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CoreCompletionRequest, diff --git a/rig-core/src/providers/openai/embedding.rs b/rig-core/src/providers/openai/embedding.rs index fa830d76b..9b0cfad4b 100644 --- a/rig-core/src/providers/openai/embedding.rs +++ b/rig-core/src/providers/openai/embedding.rs @@ -62,7 +62,6 @@ where self.ndims } - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator, diff --git a/rig-core/src/providers/openai/image_generation.rs b/rig-core/src/providers/openai/image_generation.rs index 581c3ec0a..9c3513de0 100644 --- a/rig-core/src/providers/openai/image_generation.rs +++ b/rig-core/src/providers/openai/image_generation.rs @@ -68,7 +68,6 @@ where { type Response = ImageGenerationResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn image_generation( &self, generation_request: ImageGenerationRequest, diff --git a/rig-core/src/providers/openai/responses_api/mod.rs b/rig-core/src/providers/openai/responses_api/mod.rs index 4a03d4ef2..52c646950 100644 --- a/rig-core/src/providers/openai/responses_api/mod.rs +++ b/rig-core/src/providers/openai/responses_api/mod.rs @@ -1043,7 +1043,6 @@ where type Response = CompletionResponse; type StreamingResponse = StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: crate::completion::CompletionRequest, @@ -1116,7 +1115,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: crate::completion::CompletionRequest, diff --git a/rig-core/src/providers/openai/transcription.rs b/rig-core/src/providers/openai/transcription.rs index 5c2b64f5c..c276d83ac 100644 --- a/rig-core/src/providers/openai/transcription.rs +++ b/rig-core/src/providers/openai/transcription.rs @@ -52,7 +52,6 @@ where { type Response = TranscriptionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn transcription( &self, request: transcription::TranscriptionRequest, diff --git a/rig-core/src/providers/openrouter/client.rs b/rig-core/src/providers/openrouter/client.rs index 1accedaf6..20bda38cb 100644 --- a/rig-core/src/providers/openrouter/client.rs +++ b/rig-core/src/providers/openrouter/client.rs @@ -176,7 +176,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/key")? diff --git a/rig-core/src/providers/openrouter/completion.rs b/rig-core/src/providers/openrouter/completion.rs index 1643c1798..e301dc3d3 100644 --- a/rig-core/src/providers/openrouter/completion.rs +++ b/rig-core/src/providers/openrouter/completion.rs @@ -248,7 +248,6 @@ where type Response = CompletionResponse; type StreamingResponse = FinalCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: CompletionRequest, @@ -313,7 +312,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, completion_request: CompletionRequest, diff --git a/rig-core/src/providers/perplexity.rs b/rig-core/src/providers/perplexity.rs index a79275f17..14e69e32f 100644 --- a/rig-core/src/providers/perplexity.rs +++ b/rig-core/src/providers/perplexity.rs @@ -167,7 +167,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { // No API endpoint to verify the API key Ok(()) @@ -417,7 +416,6 @@ where type Response = CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: completion::CompletionRequest, @@ -488,7 +486,6 @@ where async_block.instrument(span).await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, completion_request: completion::CompletionRequest, diff --git a/rig-core/src/providers/together/client.rs b/rig-core/src/providers/together/client.rs index 6f532ed68..7e6344e58 100644 --- a/rig-core/src/providers/together/client.rs +++ b/rig-core/src/providers/together/client.rs @@ -226,7 +226,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + Default + std::fmt::Debug + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self .get("/models")? diff --git a/rig-core/src/providers/together/completion.rs b/rig-core/src/providers/together/completion.rs index be38ba8b0..9aecd0b71 100644 --- a/rig-core/src/providers/together/completion.rs +++ b/rig-core/src/providers/together/completion.rs @@ -204,7 +204,6 @@ where type Response = openai::CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: completion::CompletionRequest, @@ -281,7 +280,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, diff --git a/rig-core/src/providers/together/embedding.rs b/rig-core/src/providers/together/embedding.rs index 2a7b9c155..0d27b50ad 100644 --- a/rig-core/src/providers/together/embedding.rs +++ b/rig-core/src/providers/together/embedding.rs @@ -82,7 +82,6 @@ where self.ndims } - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator, diff --git a/rig-core/src/providers/voyageai.rs b/rig-core/src/providers/voyageai.rs index 9dc707390..3c9ef34e8 100644 --- a/rig-core/src/providers/voyageai.rs +++ b/rig-core/src/providers/voyageai.rs @@ -112,7 +112,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + std::fmt::Debug + Default + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { // No API endpoint to verify the API key Ok(()) @@ -260,7 +259,6 @@ where self.ndims } - #[cfg_attr(feature = "worker", worker::send)] async fn embed_texts( &self, documents: impl IntoIterator, diff --git a/rig-core/src/providers/xai/client.rs b/rig-core/src/providers/xai/client.rs index a4c19f8de..2d7b545ef 100644 --- a/rig-core/src/providers/xai/client.rs +++ b/rig-core/src/providers/xai/client.rs @@ -177,7 +177,6 @@ impl VerifyClient for Client where T: HttpClientExt + Clone + Default + std::fmt::Debug + Send + 'static, { - #[cfg_attr(feature = "worker", worker::send)] async fn verify(&self) -> Result<(), VerifyError> { let req = self.get("/v1/api-key").unwrap().body(NoBody).unwrap(); diff --git a/rig-core/src/providers/xai/completion.rs b/rig-core/src/providers/xai/completion.rs index d5e440160..4b26affcb 100644 --- a/rig-core/src/providers/xai/completion.rs +++ b/rig-core/src/providers/xai/completion.rs @@ -119,7 +119,6 @@ where type Response = CompletionResponse; type StreamingResponse = openai::StreamingCompletionResponse; - #[cfg_attr(feature = "worker", worker::send)] async fn completion( &self, completion_request: completion::CompletionRequest, @@ -180,7 +179,6 @@ where .await } - #[cfg_attr(feature = "worker", worker::send)] async fn stream( &self, request: CompletionRequest, From 05b70bc71ee6727d06c8c4fc1d9b90aad5ba59b8 Mon Sep 17 00:00:00 2001 From: Joshua Mo Date: Mon, 3 Nov 2025 11:04:13 +0000 Subject: [PATCH 2/5] feat: update all references to conditional wasm compilation --- Cargo.lock | 1 - Cargo.toml | 1 - rig-core/Cargo.toml | 3 +- .../src/agent/prompt_request/streaming.rs | 4 +-- rig-core/src/completion/request.rs | 4 +-- rig-core/src/embeddings/embedding.rs | 4 +-- rig-core/src/http_client/mod.rs | 12 +++---- rig-core/src/http_client/sse.rs | 12 +++---- rig-core/src/streaming.rs | 8 ++--- rig-core/src/tool/mod.rs | 4 +-- rig-core/src/tool/server.rs | 4 +-- rig-core/src/transcription.rs | 4 +-- rig-core/src/vector_store/mod.rs | 4 +-- rig-core/src/wasm_compat.rs | 32 +++++++++---------- 14 files changed, 47 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6188017e..b905b0f27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9585,7 +9585,6 @@ dependencies = [ "tracing-subscriber", "url", "wasm-bindgen-futures", - "worker", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7042f8c37..c7d9461de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,6 @@ tokio-test = "0.4.4" tracing = "0.1.41" tracing-subscriber = "0.3.19" uuid = "1.17.0" -worker = "0.6" zerocopy = "0.8.26" [workspace.metadata.cargo-autoinherit] diff --git a/rig-core/Cargo.toml b/rig-core/Cargo.toml index a1c6e5e14..072a32190 100644 --- a/rig-core/Cargo.toml +++ b/rig-core/Cargo.toml @@ -37,7 +37,6 @@ serde_json = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } url = { workspace = true } -worker = { workspace = true, optional = true } rmcp = { version = "0.8", optional = true, features = ["client"] } tokio = { workspace = true, features = ["rt", "sync"] } http = "1.3.1" @@ -89,7 +88,7 @@ discord-bot = ["dep:serenity"] pdf = ["dep:lopdf"] epub = ["dep:epub", "dep:quick-xml"] rayon = ["dep:rayon"] -worker = ["dep:worker", "dep:wasm-bindgen-futures", "futures-timer/wasm-bindgen"] +wasm = ["dep:wasm-bindgen-futures", "futures-timer/wasm-bindgen"] rmcp = ["dep:rmcp"] socks = ["reqwest/socks"] reqwest-tls = ["reqwest/default"] diff --git a/rig-core/src/agent/prompt_request/streaming.rs b/rig-core/src/agent/prompt_request/streaming.rs index cc79faf32..8ff799bc5 100644 --- a/rig-core/src/agent/prompt_request/streaming.rs +++ b/rig-core/src/agent/prompt_request/streaming.rs @@ -20,11 +20,11 @@ use crate::{ tool::ToolSetError, }; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] pub type StreamingResult = Pin, StreamingError>> + Send>>; -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] pub type StreamingResult = Pin, StreamingError>>>>; diff --git a/rig-core/src/completion/request.rs b/rig-core/src/completion/request.rs index 9a100fb41..53f94d70c 100644 --- a/rig-core/src/completion/request.rs +++ b/rig-core/src/completion/request.rs @@ -98,12 +98,12 @@ pub enum CompletionError { #[error("UrlError: {0}")] UrlError(#[from] url::ParseError), - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] /// Error building the completion request #[error("RequestError: {0}")] RequestError(#[from] Box), - #[cfg(target_family = "wasm")] + #[cfg(feature = "wasm")] /// Error building the completion request #[error("RequestError: {0}")] RequestError(#[from] Box), diff --git a/rig-core/src/embeddings/embedding.rs b/rig-core/src/embeddings/embedding.rs index 2513d2495..d1438e434 100644 --- a/rig-core/src/embeddings/embedding.rs +++ b/rig-core/src/embeddings/embedding.rs @@ -23,12 +23,12 @@ pub enum EmbeddingError { #[error("UrlError: {0}")] UrlError(#[from] url::ParseError), - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] /// Error processing the document for embedding #[error("DocumentError: {0}")] DocumentError(Box), - #[cfg(target_family = "wasm")] + #[cfg(feature = "wasm")] /// Error processing the document for embedding #[error("DocumentError: {0}")] DocumentError(Box), diff --git a/rig-core/src/http_client/mod.rs b/rig-core/src/http_client/mod.rs index 4d8a04ea0..5f35d790e 100644 --- a/rig-core/src/http_client/mod.rs +++ b/rig-core/src/http_client/mod.rs @@ -23,23 +23,23 @@ pub enum Error { StreamEnded, #[error("Invalid content type was returned: {0:?}")] InvalidContentType(HeaderValue), - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] #[error("Http client error: {0}")] Instance(#[from] Box), - #[cfg(target_family = "wasm")] + #[cfg(feature = "wasm")] #[error("Http client error: {0}")] Instance(#[from] Box), } pub type Result = std::result::Result; -#[cfg(not(target_family = "wasm"))] +#[cfg(not(feature = "wasm"))] pub(crate) fn instance_error(error: E) -> Error { Error::Instance(error.into()) } -#[cfg(target_family = "wasm")] +#[cfg(feature = "wasm")] fn instance_error(error: E) -> Error { Error::Instance(error.into()) } @@ -221,12 +221,12 @@ impl HttpClientExt for reqwest::Client { )); } - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] let mut res = Response::builder() .status(response.status()) .version(response.version()); - #[cfg(target_family = "wasm")] + #[cfg(feature = "wasm")] let mut res = Response::builder().status(response.status()); if let Some(hs) = res.headers_mut() { diff --git a/rig-core/src/http_client/sse.rs b/rig-core/src/http_client/sse.rs index f9f963847..bda2990ec 100644 --- a/rig-core/src/http_client/sse.rs +++ b/rig-core/src/http_client/sse.rs @@ -12,9 +12,9 @@ use std::{ use bytes::Bytes; use eventsource_stream::{Event as MessageEvent, EventStreamError, Eventsource}; use futures::Stream; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] use futures::{future::BoxFuture, stream::BoxStream}; -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] use futures::{future::LocalBoxFuture, stream::LocalBoxStream}; use futures_timer::Delay; use http::Response; @@ -32,14 +32,14 @@ use crate::{ pub type BoxedStream = Pin>>>; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] type ResponseFuture = BoxFuture<'static, Result, super::Error>>; -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] type ResponseFuture = LocalBoxFuture<'static, Result, super::Error>>; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] type EventStream = BoxStream<'static, Result>>; -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] type EventStream = LocalBoxStream<'static, Result>>; type BoxedRetry = Box; diff --git a/rig-core/src/streaming.rs b/rig-core/src/streaming.rs index acca53d5c..cce3ca76e 100644 --- a/rig-core/src/streaming.rs +++ b/rig-core/src/streaming.rs @@ -91,11 +91,11 @@ where FinalResponse(R), } -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] pub type StreamingResult = Pin, CompletionError>> + Send>>; -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] pub type StreamingResult = Pin, CompletionError>>>>; @@ -477,9 +477,9 @@ mod tests { yield Ok(RawStreamingChoice::FinalResponse(MockResponse { token_count: 15 })); }; - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(feature = "wasm"))] let pinned_stream: StreamingResult = Box::pin(stream); - #[cfg(target_arch = "wasm32")] + #[cfg(feature = "wasm")] let pinned_stream: StreamingResult = Box::pin(stream); StreamingCompletionResponse::stream(pinned_stream) diff --git a/rig-core/src/tool/mod.rs b/rig-core/src/tool/mod.rs index 5331c5e4b..1db6c37eb 100644 --- a/rig-core/src/tool/mod.rs +++ b/rig-core/src/tool/mod.rs @@ -23,12 +23,12 @@ use crate::{ #[derive(Debug, thiserror::Error)] pub enum ToolError { - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] /// Error returned by the tool #[error("ToolCallError: {0}")] ToolCallError(#[from] Box), - #[cfg(target_family = "wasm")] + #[cfg(feature = "wasm")] /// Error returned by the tool #[error("ToolCallError: {0}")] ToolCallError(#[from] Box), diff --git a/rig-core/src/tool/server.rs b/rig-core/src/tool/server.rs index 62aee345b..d14f6b2ed 100644 --- a/rig-core/src/tool/server.rs +++ b/rig-core/src/tool/server.rs @@ -86,7 +86,7 @@ impl ToolServer { pub fn run(mut self) -> ToolServerHandle { let (tx, mut rx) = tokio::sync::mpsc::channel(1000); - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] tokio::spawn(async move { while let Some(message) = rx.recv().await { self.handle_message(message).await; @@ -95,7 +95,7 @@ impl ToolServer { // SAFETY: `rig` currently doesn't compile to WASM without the `worker` feature. // Therefore, we can safely assume that the user won't try to compile to wasm without the worker feature. - #[cfg(all(feature = "worker", target_family = "wasm"))] + #[cfg(feature = "wasm")] wasm_bindgen_futures::spawn_local(async move { while let Some(message) = rx.recv().await { self.handle_message(message).await; diff --git a/rig-core/src/transcription.rs b/rig-core/src/transcription.rs index 666972328..2c499b42b 100644 --- a/rig-core/src/transcription.rs +++ b/rig-core/src/transcription.rs @@ -21,12 +21,12 @@ pub enum TranscriptionError { #[error("JsonError: {0}")] JsonError(#[from] serde_json::Error), - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] /// Error building the transcription request #[error("RequestError: {0}")] RequestError(#[from] Box), - #[cfg(target_family = "wasm")] + #[cfg(feature = "wasm")] /// Error building the transcription request #[error("RequestError: {0}")] RequestError(#[from] Box), diff --git a/rig-core/src/vector_store/mod.rs b/rig-core/src/vector_store/mod.rs index 89c2e9432..b49748567 100644 --- a/rig-core/src/vector_store/mod.rs +++ b/rig-core/src/vector_store/mod.rs @@ -24,14 +24,14 @@ pub enum VectorStoreError { #[error("Json error: {0}")] JsonError(#[from] serde_json::Error), - #[cfg(not(target_family = "wasm"))] + #[cfg(not(feature = "wasm"))] #[error("Datastore error: {0}")] DatastoreError(#[from] Box), #[error("Filter error: {0}")] FilterError(#[from] FilterError), - #[cfg(target_family = "wasm")] + #[cfg(feature = "wasm")] #[error("Datastore error: {0}")] DatastoreError(#[from] Box), diff --git a/rig-core/src/wasm_compat.rs b/rig-core/src/wasm_compat.rs index 0e31134a4..a5124d09d 100644 --- a/rig-core/src/wasm_compat.rs +++ b/rig-core/src/wasm_compat.rs @@ -3,29 +3,29 @@ use std::pin::Pin; use futures::Stream; -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] pub trait WasmCompatSend: Send {} -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] pub trait WasmCompatSend {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] impl WasmCompatSend for T where T: Send {} -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] impl WasmCompatSend for T {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] pub trait WasmCompatSendStream: Stream> + Send { type InnerItem: Send; } -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] pub trait WasmCompatSendStream: Stream> { type InnerItem; } -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] impl WasmCompatSendStream for T where T: Stream> + Send, @@ -33,7 +33,7 @@ where type InnerItem = Result; } -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] impl WasmCompatSendStream for T where T: Stream>, @@ -41,26 +41,26 @@ where type InnerItem = Result; } -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] pub trait WasmCompatSync: Sync {} -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] pub trait WasmCompatSync {} -#[cfg(not(target_arch = "wasm32"))] +#[cfg(not(feature = "wasm"))] impl WasmCompatSync for T where T: Sync {} -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "wasm")] impl WasmCompatSync for T {} -#[cfg(not(target_family = "wasm"))] +#[cfg(not(feature = "wasm"))] pub type WasmBoxedFuture<'a, T> = Pin + Send + 'a>>; -#[cfg(target_family = "wasm")] +#[cfg(feature = "wasm")] pub type WasmBoxedFuture<'a, T> = Pin + 'a>>; #[macro_export] macro_rules! if_wasm { ($($tokens:tt)*) => { - #[cfg(target_arch = "wasm32")] + #[cfg(feature = "wasm")] $($tokens)* }; @@ -69,7 +69,7 @@ macro_rules! if_wasm { #[macro_export] macro_rules! if_not_wasm { ($($tokens:tt)*) => { - #[cfg(not(target_arch = "wasm32"))] + #[cfg(not(feature = "wasm"))] $($tokens)* }; From fedc3958c6234523613fa996b73e238de93deef5 Mon Sep 17 00:00:00 2001 From: Joshua Mo Date: Mon, 3 Nov 2025 11:05:00 +0000 Subject: [PATCH 3/5] refactor: update CI to wasm feature for wasm check --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ffdfa9107..110cc69eb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,7 +49,7 @@ jobs: toolchain: ${{ vars.RUST_VERSION }} - name: Run cargo check wasm target - run: cargo check --package rig-core --features worker --target wasm32-unknown-unknown + run: cargo check --package rig-core --features wasm --target wasm32-unknown-unknown clippy: name: stable / clippy From 4f21449905e1e552485c1ad5d305d8b9154f504a Mon Sep 17 00:00:00 2001 From: Joshua Mo Date: Mon, 3 Nov 2025 12:54:09 +0000 Subject: [PATCH 4/5] refactor: some updates --- rig-core/src/agent/builder.rs | 12 +++--- rig-core/src/agent/completion.rs | 10 +---- rig-core/src/audio_generation.rs | 12 ++++-- rig-core/src/evals.rs | 72 ++++++++++++++++++++++++-------- rig-core/src/tool/server.rs | 6 +-- 5 files changed, 74 insertions(+), 38 deletions(-) diff --git a/rig-core/src/agent/builder.rs b/rig-core/src/agent/builder.rs index 51c220c92..97f3c1c94 100644 --- a/rig-core/src/agent/builder.rs +++ b/rig-core/src/agent/builder.rs @@ -58,7 +58,7 @@ where /// Maximum number of tokens for the completion max_tokens: Option, /// List of vector store, with the sample number - dynamic_context: Vec<(usize, Box)>, + dynamic_context: Vec<(usize, Box)>, /// Temperature of the model temperature: Option, /// Tool server handle @@ -248,10 +248,10 @@ where pub fn dynamic_tools( self, sample: usize, - dynamic_tools: impl VectorStoreIndexDyn + Send + Sync + 'static, + dynamic_tools: impl VectorStoreIndexDyn + 'static, toolset: ToolSet, ) -> AgentBuilderSimple { - let thing: Box = Box::new(dynamic_tools); + let thing: Box = Box::new(dynamic_tools); let dynamic_tools = vec![(sample, thing)]; AgentBuilderSimple { @@ -355,9 +355,9 @@ where /// Maximum number of tokens for the completion max_tokens: Option, /// List of vector store, with the sample number - dynamic_context: Vec<(usize, Box)>, + dynamic_context: Vec<(usize, Box)>, /// Dynamic tools - dynamic_tools: Vec<(usize, Box)>, + dynamic_tools: Vec<(usize, Box)>, /// Temperature of the model temperature: Option, /// Actual tool implementations @@ -480,7 +480,7 @@ where pub fn dynamic_tools( mut self, sample: usize, - dynamic_tools: impl VectorStoreIndexDyn + Send + Sync + 'static, + dynamic_tools: impl VectorStoreIndexDyn + 'static, toolset: ToolSet, ) -> Self { self.dynamic_tools.push((sample, Box::new(dynamic_tools))); diff --git a/rig-core/src/agent/completion.rs b/rig-core/src/agent/completion.rs index e2ca2dc49..d9b785dae 100644 --- a/rig-core/src/agent/completion.rs +++ b/rig-core/src/agent/completion.rs @@ -17,14 +17,8 @@ use tokio::sync::RwLock; const UNKNOWN_AGENT_NAME: &str = "Unnamed Agent"; -pub type DynamicContextStore = Arc< - RwLock< - Vec<( - usize, - Box, - )>, - >, ->; +pub type DynamicContextStore = + Arc)>>>; /// Struct representing an LLM agent. An agent is an LLM model combined with a preamble /// (i.e.: system prompt) and a static set of context documents and tools. diff --git a/rig-core/src/audio_generation.rs b/rig-core/src/audio_generation.rs index 4e459b3e9..1c6dbcd05 100644 --- a/rig-core/src/audio_generation.rs +++ b/rig-core/src/audio_generation.rs @@ -1,6 +1,10 @@ //! Everything related to audio generation (ie, Text To Speech). //! Rig abstracts over a number of different providers using the [AudioGenerationModel] trait. -use crate::{client::audio_generation::AudioGenerationModelHandle, http_client}; +use crate::{ + client::audio_generation::AudioGenerationModelHandle, + http_client, + wasm_compat::{WasmCompatSend, WasmCompatSync}, +}; use futures::future::BoxFuture; use serde_json::Value; use std::sync::Arc; @@ -46,7 +50,7 @@ where voice: &str, ) -> impl std::future::Future< Output = Result, AudioGenerationError>, - > + Send; + > + WasmCompatSend; } pub struct AudioGenerationResponse { @@ -54,7 +58,7 @@ pub struct AudioGenerationResponse { pub response: T, } -pub trait AudioGenerationModel: Clone + Send + Sync { +pub trait AudioGenerationModel: Clone + WasmCompatSend + WasmCompatSync { type Response: Send + Sync; fn audio_generation( @@ -69,7 +73,7 @@ pub trait AudioGenerationModel: Clone + Send + Sync { } } -pub trait AudioGenerationModelDyn: Send + Sync { +pub trait AudioGenerationModelDyn: WasmCompatSend + WasmCompatSync { fn audio_generation( &self, request: AudioGenerationRequest, diff --git a/rig-core/src/evals.rs b/rig-core/src/evals.rs index 7895e94d4..b55ad61b8 100644 --- a/rig-core/src/evals.rs +++ b/rig-core/src/evals.rs @@ -9,6 +9,7 @@ use crate::{ completion::CompletionModel, embeddings::EmbeddingModel, extractor::{Extractor, ExtractorBuilder}, + wasm_compat::{WasmCompatSend, WasmCompatSync}, }; /// Evaluation errors. @@ -22,7 +23,7 @@ pub enum EvalError { Custom(String), } -/// The outcome of an evaluation (ie, sending an input to an LLM which then gets tested against a set of criteria). +/// The outcome of an evaluation (ie, WasmCompatSending an input to an LLM which then gets tested against a set of criteria). /// Invalid results due to things like functions returning errors should be encoded as invalid evaluation outcomes. #[derive(Deserialize, Serialize, Clone, Debug)] #[serde(tag = "outcome", content = "data")] @@ -58,20 +59,20 @@ impl EvalOutcome { /// - Invalid (the output was unable to be retrieved due to an external failure like an API call fail) pub trait Eval where - Output: for<'a> Deserialize<'a> + Serialize + Clone + Send + Sync, - Self: Sized + Send + Sync + 'static, + Output: for<'a> Deserialize<'a> + Serialize + Clone + WasmCompatSend + WasmCompatSync, + Self: Sized + WasmCompatSend + WasmCompatSync + 'static, { - fn eval(&self, input: String) -> impl Future> + Send; + fn eval(&self, input: String) -> impl Future> + WasmCompatSend; - /// Send a bunch of inputs to be evaluated all in one call. + /// WasmCompatSend a bunch of inputs to be evaluated all in one call. /// You can set the concurrency limit to help alleviate issues - /// with model provider API limits, as sending requests too quickly may + /// with model provider API limits, as WasmCompatSending requests too quickly may /// result in throttling or temporary request refusal. fn eval_batch( &self, input: Vec, concurrency_limit: usize, - ) -> impl Future>> + Send { + ) -> impl Future>> + WasmCompatSend { use futures::StreamExt; async move { let thing: Vec> = futures::stream::iter(input) @@ -203,7 +204,12 @@ where pub struct LlmJudgeMetric where M: CompletionModel, - T: Judgment + Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a>, + T: Judgment + + WasmCompatSend + + WasmCompatSync + + JsonSchema + + Serialize + + for<'a> Deserialize<'a>, { ext: Extractor, } @@ -213,16 +219,20 @@ where pub struct LlmJudgeMetricWithFn where M: CompletionModel, - T: Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a>, + T: WasmCompatSend + WasmCompatSync + JsonSchema + Serialize + for<'a> Deserialize<'a>, { ext: Extractor, + #[cfg(not(not(all(feature = "wasm", target_arch = "wasm32"))))] + evaluator: Box bool + Send + Sync>, + + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] evaluator: Box bool + Send + Sync>, } pub struct LlmJudgeBuilder where M: CompletionModel, - T: Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a> + 'static, + T: WasmCompatSend + WasmCompatSync + JsonSchema + Serialize + for<'a> Deserialize<'a> + 'static, { ext: ExtractorBuilder, } @@ -230,21 +240,25 @@ where pub struct LlmJudgeBuilderWithFn where M: CompletionModel, - T: Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a> + 'static, + T: WasmCompatSend + WasmCompatSync + JsonSchema + Serialize + for<'a> Deserialize<'a> + 'static, { ext: ExtractorBuilder, + #[cfg(not(feature = "wasm"))] + evaluator: Box bool + Send + Sync>, + #[cfg(feature = "wasm")] evaluator: Box bool + Send + Sync>, } impl LlmJudgeBuilder where M: CompletionModel, - T: Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a>, + T: WasmCompatSend + WasmCompatSync + JsonSchema + Serialize + for<'a> Deserialize<'a>, { pub fn new(ext: ExtractorBuilder) -> Self { Self { ext } } + #[cfg(not(feature = "wasm"))] pub fn with_fn(self, f: F) -> LlmJudgeBuilderWithFn where F: Fn(&T) -> bool + Send + Sync + 'static, @@ -255,6 +269,17 @@ where } } + #[cfg(feature = "wasm")] + pub fn with_fn(self, f: F) -> LlmJudgeBuilderWithFn + where + F: Fn(&T) -> bool + 'static, + { + LlmJudgeBuilderWithFn { + ext: self.ext, + evaluator: Box::new(f), + } + } + pub fn build(self) -> LlmJudgeMetric where T: Judgment + 'static, @@ -272,11 +297,11 @@ where impl LlmJudgeBuilderWithFn where M: CompletionModel, - T: Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a> + 'static, + T: WasmCompatSend + WasmCompatSync + JsonSchema + Serialize + for<'a> Deserialize<'a> + 'static, { pub fn with_fn(mut self, f: F2) -> Self where - F2: Fn(&T) -> bool + Send + Sync + 'static, + F2: Fn(&T) -> bool + WasmCompatSend + WasmCompatSync + 'static, { self.evaluator = Box::new(f); self @@ -306,7 +331,14 @@ pub trait Judgment { impl Eval for LlmJudgeMetric where M: CompletionModel + 'static, - T: Judgment + Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a> + Clone + 'static, + T: Judgment + + WasmCompatSend + + WasmCompatSync + + JsonSchema + + Serialize + + for<'a> Deserialize<'a> + + Clone + + 'static, { async fn eval(&self, input: String) -> EvalOutcome { match self.ext.extract(input).await { @@ -325,7 +357,13 @@ where impl Eval for LlmJudgeMetricWithFn where M: CompletionModel + 'static, - T: Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a> + Clone + 'static, + T: WasmCompatSend + + WasmCompatSync + + JsonSchema + + Serialize + + for<'a> Deserialize<'a> + + Clone + + 'static, { async fn eval(&self, input: String) -> EvalOutcome { match self.ext.extract(input).await { @@ -344,7 +382,7 @@ where impl From> for LlmJudgeBuilder where M: CompletionModel, - T: Send + Sync + JsonSchema + Serialize + for<'a> Deserialize<'a>, + T: WasmCompatSend + WasmCompatSync + JsonSchema + Serialize + for<'a> Deserialize<'a>, { fn from(ext: ExtractorBuilder) -> Self { Self::new(ext) diff --git a/rig-core/src/tool/server.rs b/rig-core/src/tool/server.rs index d14f6b2ed..3771603eb 100644 --- a/rig-core/src/tool/server.rs +++ b/rig-core/src/tool/server.rs @@ -12,7 +12,7 @@ pub struct ToolServer { /// These tools will always exist on the tool server for as long as they are not deleted. static_tool_names: Vec, /// Dynamic tools. These tools will be dynamically fetched from a given vector store. - dynamic_tools: Vec<(usize, Box)>, + dynamic_tools: Vec<(usize, Box)>, /// The toolset where tools are called (to be executed). toolset: ToolSet, } @@ -44,7 +44,7 @@ impl ToolServer { pub(crate) fn add_dynamic_tools( mut self, - dyn_tools: Vec<(usize, Box)>, + dyn_tools: Vec<(usize, Box)>, ) -> Self { self.dynamic_tools = dyn_tools; self @@ -75,7 +75,7 @@ impl ToolServer { pub fn dynamic_tools( mut self, sample: usize, - dynamic_tools: impl VectorStoreIndexDyn + Send + Sync + 'static, + dynamic_tools: impl VectorStoreIndexDyn + 'static, toolset: ToolSet, ) -> Self { self.dynamic_tools.push((sample, Box::new(dynamic_tools))); From e734b68ba64b85f4ca3afb3f2446cf8a46daba33 Mon Sep 17 00:00:00 2001 From: Joshua Mo Date: Mon, 3 Nov 2025 13:00:39 +0000 Subject: [PATCH 5/5] refactor: find and replace wasm feature to check for wasm32 target --- .../src/agent/prompt_request/streaming.rs | 4 +-- rig-core/src/completion/request.rs | 4 +-- rig-core/src/embeddings/embedding.rs | 4 +-- rig-core/src/evals.rs | 8 ++--- rig-core/src/http_client/mod.rs | 12 +++---- rig-core/src/http_client/sse.rs | 12 +++---- rig-core/src/streaming.rs | 8 ++--- rig-core/src/tool/mod.rs | 4 +-- rig-core/src/tool/server.rs | 4 +-- rig-core/src/transcription.rs | 4 +-- rig-core/src/vector_store/mod.rs | 4 +-- rig-core/src/wasm_compat.rs | 32 +++++++++---------- 12 files changed, 50 insertions(+), 50 deletions(-) diff --git a/rig-core/src/agent/prompt_request/streaming.rs b/rig-core/src/agent/prompt_request/streaming.rs index 8ff799bc5..99621206b 100644 --- a/rig-core/src/agent/prompt_request/streaming.rs +++ b/rig-core/src/agent/prompt_request/streaming.rs @@ -20,11 +20,11 @@ use crate::{ tool::ToolSetError, }; -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub type StreamingResult = Pin, StreamingError>> + Send>>; -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] pub type StreamingResult = Pin, StreamingError>>>>; diff --git a/rig-core/src/completion/request.rs b/rig-core/src/completion/request.rs index 53f94d70c..0e2ae7f9d 100644 --- a/rig-core/src/completion/request.rs +++ b/rig-core/src/completion/request.rs @@ -98,12 +98,12 @@ pub enum CompletionError { #[error("UrlError: {0}")] UrlError(#[from] url::ParseError), - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] /// Error building the completion request #[error("RequestError: {0}")] RequestError(#[from] Box), - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] /// Error building the completion request #[error("RequestError: {0}")] RequestError(#[from] Box), diff --git a/rig-core/src/embeddings/embedding.rs b/rig-core/src/embeddings/embedding.rs index d1438e434..4fdf4365f 100644 --- a/rig-core/src/embeddings/embedding.rs +++ b/rig-core/src/embeddings/embedding.rs @@ -23,12 +23,12 @@ pub enum EmbeddingError { #[error("UrlError: {0}")] UrlError(#[from] url::ParseError), - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] /// Error processing the document for embedding #[error("DocumentError: {0}")] DocumentError(Box), - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] /// Error processing the document for embedding #[error("DocumentError: {0}")] DocumentError(Box), diff --git a/rig-core/src/evals.rs b/rig-core/src/evals.rs index b55ad61b8..56805e78f 100644 --- a/rig-core/src/evals.rs +++ b/rig-core/src/evals.rs @@ -243,9 +243,9 @@ where T: WasmCompatSend + WasmCompatSync + JsonSchema + Serialize + for<'a> Deserialize<'a> + 'static, { ext: ExtractorBuilder, - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] evaluator: Box bool + Send + Sync>, - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] evaluator: Box bool + Send + Sync>, } @@ -258,7 +258,7 @@ where Self { ext } } - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub fn with_fn(self, f: F) -> LlmJudgeBuilderWithFn where F: Fn(&T) -> bool + Send + Sync + 'static, @@ -269,7 +269,7 @@ where } } - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] pub fn with_fn(self, f: F) -> LlmJudgeBuilderWithFn where F: Fn(&T) -> bool + 'static, diff --git a/rig-core/src/http_client/mod.rs b/rig-core/src/http_client/mod.rs index 5f35d790e..97a13421a 100644 --- a/rig-core/src/http_client/mod.rs +++ b/rig-core/src/http_client/mod.rs @@ -23,23 +23,23 @@ pub enum Error { StreamEnded, #[error("Invalid content type was returned: {0:?}")] InvalidContentType(HeaderValue), - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] #[error("Http client error: {0}")] Instance(#[from] Box), - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] #[error("Http client error: {0}")] Instance(#[from] Box), } pub type Result = std::result::Result; -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub(crate) fn instance_error(error: E) -> Error { Error::Instance(error.into()) } -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] fn instance_error(error: E) -> Error { Error::Instance(error.into()) } @@ -221,12 +221,12 @@ impl HttpClientExt for reqwest::Client { )); } - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] let mut res = Response::builder() .status(response.status()) .version(response.version()); - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] let mut res = Response::builder().status(response.status()); if let Some(hs) = res.headers_mut() { diff --git a/rig-core/src/http_client/sse.rs b/rig-core/src/http_client/sse.rs index bda2990ec..929d3bccd 100644 --- a/rig-core/src/http_client/sse.rs +++ b/rig-core/src/http_client/sse.rs @@ -12,9 +12,9 @@ use std::{ use bytes::Bytes; use eventsource_stream::{Event as MessageEvent, EventStreamError, Eventsource}; use futures::Stream; -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] use futures::{future::BoxFuture, stream::BoxStream}; -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] use futures::{future::LocalBoxFuture, stream::LocalBoxStream}; use futures_timer::Delay; use http::Response; @@ -32,14 +32,14 @@ use crate::{ pub type BoxedStream = Pin>>>; -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] type ResponseFuture = BoxFuture<'static, Result, super::Error>>; -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] type ResponseFuture = LocalBoxFuture<'static, Result, super::Error>>; -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] type EventStream = BoxStream<'static, Result>>; -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] type EventStream = LocalBoxStream<'static, Result>>; type BoxedRetry = Box; diff --git a/rig-core/src/streaming.rs b/rig-core/src/streaming.rs index cce3ca76e..f4e3e0c0b 100644 --- a/rig-core/src/streaming.rs +++ b/rig-core/src/streaming.rs @@ -91,11 +91,11 @@ where FinalResponse(R), } -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub type StreamingResult = Pin, CompletionError>> + Send>>; -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] pub type StreamingResult = Pin, CompletionError>>>>; @@ -477,9 +477,9 @@ mod tests { yield Ok(RawStreamingChoice::FinalResponse(MockResponse { token_count: 15 })); }; - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] let pinned_stream: StreamingResult = Box::pin(stream); - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] let pinned_stream: StreamingResult = Box::pin(stream); StreamingCompletionResponse::stream(pinned_stream) diff --git a/rig-core/src/tool/mod.rs b/rig-core/src/tool/mod.rs index 1db6c37eb..bd6fc6e2e 100644 --- a/rig-core/src/tool/mod.rs +++ b/rig-core/src/tool/mod.rs @@ -23,12 +23,12 @@ use crate::{ #[derive(Debug, thiserror::Error)] pub enum ToolError { - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] /// Error returned by the tool #[error("ToolCallError: {0}")] ToolCallError(#[from] Box), - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] /// Error returned by the tool #[error("ToolCallError: {0}")] ToolCallError(#[from] Box), diff --git a/rig-core/src/tool/server.rs b/rig-core/src/tool/server.rs index 3771603eb..1809e73fb 100644 --- a/rig-core/src/tool/server.rs +++ b/rig-core/src/tool/server.rs @@ -86,7 +86,7 @@ impl ToolServer { pub fn run(mut self) -> ToolServerHandle { let (tx, mut rx) = tokio::sync::mpsc::channel(1000); - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] tokio::spawn(async move { while let Some(message) = rx.recv().await { self.handle_message(message).await; @@ -95,7 +95,7 @@ impl ToolServer { // SAFETY: `rig` currently doesn't compile to WASM without the `worker` feature. // Therefore, we can safely assume that the user won't try to compile to wasm without the worker feature. - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] wasm_bindgen_futures::spawn_local(async move { while let Some(message) = rx.recv().await { self.handle_message(message).await; diff --git a/rig-core/src/transcription.rs b/rig-core/src/transcription.rs index 2c499b42b..402aaf022 100644 --- a/rig-core/src/transcription.rs +++ b/rig-core/src/transcription.rs @@ -21,12 +21,12 @@ pub enum TranscriptionError { #[error("JsonError: {0}")] JsonError(#[from] serde_json::Error), - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] /// Error building the transcription request #[error("RequestError: {0}")] RequestError(#[from] Box), - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] /// Error building the transcription request #[error("RequestError: {0}")] RequestError(#[from] Box), diff --git a/rig-core/src/vector_store/mod.rs b/rig-core/src/vector_store/mod.rs index b49748567..e9bb355ed 100644 --- a/rig-core/src/vector_store/mod.rs +++ b/rig-core/src/vector_store/mod.rs @@ -24,14 +24,14 @@ pub enum VectorStoreError { #[error("Json error: {0}")] JsonError(#[from] serde_json::Error), - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] #[error("Datastore error: {0}")] DatastoreError(#[from] Box), #[error("Filter error: {0}")] FilterError(#[from] FilterError), - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] #[error("Datastore error: {0}")] DatastoreError(#[from] Box), diff --git a/rig-core/src/wasm_compat.rs b/rig-core/src/wasm_compat.rs index a5124d09d..b228bb619 100644 --- a/rig-core/src/wasm_compat.rs +++ b/rig-core/src/wasm_compat.rs @@ -3,29 +3,29 @@ use std::pin::Pin; use futures::Stream; -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub trait WasmCompatSend: Send {} -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] pub trait WasmCompatSend {} -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] impl WasmCompatSend for T where T: Send {} -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] impl WasmCompatSend for T {} -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub trait WasmCompatSendStream: Stream> + Send { type InnerItem: Send; } -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] pub trait WasmCompatSendStream: Stream> { type InnerItem; } -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] impl WasmCompatSendStream for T where T: Stream> + Send, @@ -33,7 +33,7 @@ where type InnerItem = Result; } -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] impl WasmCompatSendStream for T where T: Stream>, @@ -41,26 +41,26 @@ where type InnerItem = Result; } -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub trait WasmCompatSync: Sync {} -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] pub trait WasmCompatSync {} -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] impl WasmCompatSync for T where T: Sync {} -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] impl WasmCompatSync for T {} -#[cfg(not(feature = "wasm"))] +#[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] pub type WasmBoxedFuture<'a, T> = Pin + Send + 'a>>; -#[cfg(feature = "wasm")] +#[cfg(all(feature = "wasm", target_arch = "wasm32"))] pub type WasmBoxedFuture<'a, T> = Pin + 'a>>; #[macro_export] macro_rules! if_wasm { ($($tokens:tt)*) => { - #[cfg(feature = "wasm")] + #[cfg(all(feature = "wasm", target_arch = "wasm32"))] $($tokens)* }; @@ -69,7 +69,7 @@ macro_rules! if_wasm { #[macro_export] macro_rules! if_not_wasm { ($($tokens:tt)*) => { - #[cfg(not(feature = "wasm"))] + #[cfg(not(all(feature = "wasm", target_arch = "wasm32")))] $($tokens)* };