diff --git a/src/cli/javascript/request_filter.rs b/src/cli/javascript/request_filter.rs index 2c50d0b2a1..c40defca40 100644 --- a/src/cli/javascript/request_filter.rs +++ b/src/cli/javascript/request_filter.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use std::sync::Arc; use hyper::body::Bytes; @@ -53,7 +52,7 @@ impl RequestFilter { async fn on_request(&self, mut request: reqwest::Request) -> anyhow::Result> { let js_request = WorkerRequest::try_from(&request)?; let event = Event::Request(js_request); - let command = self.worker.call(Cow::Borrowed("onRequest"), event).await?; + let command = self.worker.call("onRequest", event).await?; match command { Some(command) => match command { Command::Request(js_request) => { diff --git a/src/cli/javascript/runtime.rs b/src/cli/javascript/runtime.rs index e76462279c..4f32e61dc6 100644 --- a/src/cli/javascript/runtime.rs +++ b/src/cli/javascript/runtime.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use std::cell::{OnceCell, RefCell}; use std::fmt::{Debug, Formatter}; use std::thread; @@ -83,13 +82,9 @@ impl Drop for Runtime { #[async_trait::async_trait] impl WorkerIO for Runtime { - async fn call( - &self, - name: Cow<'async_trait, str>, - event: Event, - ) -> anyhow::Result> { + async fn call(&self, name: &'async_trait str, event: Event) -> anyhow::Result> { let script = self.script.clone(); - let name = name.as_ref().to_string(); // TODO + let name = name.to_string(); // TODO if let Some(runtime) = &self.tokio_runtime { runtime .spawn(async move { @@ -107,11 +102,11 @@ impl WorkerIO for Runtime { impl WorkerIO for Runtime { async fn call( &self, - name: Cow<'async_trait, str>, + name: &'async_trait str, input: ConstValue, ) -> anyhow::Result> { let script = self.script.clone(); - let name = name.as_ref().to_string(); + let name = name.to_string(); if let Some(runtime) = &self.tokio_runtime { runtime .spawn(async move { diff --git a/src/core/lambda/io.rs b/src/core/lambda/io.rs index e007f77309..92de982470 100644 --- a/src/core/lambda/io.rs +++ b/src/core/lambda/io.rs @@ -1,5 +1,4 @@ use core::future::Future; -use std::borrow::Cow; use std::hash::{Hash, Hasher}; use std::pin::Pin; use std::sync::Arc; @@ -144,7 +143,7 @@ impl IO { .request_ctx .runtime .worker - .call(Cow::Borrowed(method), value) + .call(method, value) .await .map_err(EvaluationError::from)?; diff --git a/src/core/mod.rs b/src/core/mod.rs index 25a5d99dd4..c4d32bb90e 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -84,7 +84,7 @@ pub type EntityCache = dyn Cache; #[async_trait::async_trait] pub trait WorkerIO: Send + Sync + 'static { /// Calls a global JS function - async fn call(&self, name: Cow<'async_trait, str>, input: In) -> anyhow::Result>; + async fn call(&self, name: &'async_trait str, input: In) -> anyhow::Result>; } pub fn is_default(val: &T) -> bool { diff --git a/src/core/worker.rs b/src/core/worker.rs index 0a8a29c3c5..5c1c45d77a 100644 --- a/src/core/worker.rs +++ b/src/core/worker.rs @@ -1,4 +1,3 @@ -use std::borrow::Cow; use crate::core::{Response, WorkerIO}; @@ -6,7 +5,7 @@ pub struct DefaultJsRuntime; #[async_trait::async_trait] impl WorkerIO for DefaultJsRuntime { - async fn call(&self, _: Cow<'async_trait, str>, _: A) -> anyhow::Result> { + async fn call(&self, _: &'async_trait str, _: A) -> anyhow::Result> { anyhow::bail!("JavaScript runtime is not supported in this build") } }