Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ js-sys = { version = "0.3.82", path = "./wasm-bindgen/crates/js-sys" }
serde = { version = "1.0.164", features = ["derive"] }
serde_json = "1.0.140"
serde-wasm-bindgen = "0.6.5"
wasm-bindgen = { version = "0.2.105", path = "./wasm-bindgen" }
wasm-bindgen = { version = "0.2.105", path = "./wasm-bindgen", features = ["unsafe-single-threaded-traits"] }
wasm-bindgen-cli-support = { version = "0.2.105", path = "./wasm-bindgen/crates/cli-support" }
wasm-bindgen-futures = { version = "0.4.54", path = "./wasm-bindgen/crates/futures" }
wasm-bindgen-futures = { version = "0.4.54", path = "./wasm-bindgen/crates/futures", features = ["unsafe-single-threaded-traits"] }
wasm-bindgen-macro-support = { version = "0.2.105", path = "./wasm-bindgen/crates/macro-support" }
wasm-bindgen-shared = { version = "0.2.105", path = "./wasm-bindgen/crates/shared" }
wasm-bindgen-test = { version = "0.3.50", path = "./wasm-bindgen/crates/test" }
Expand Down
8 changes: 3 additions & 5 deletions examples/rpc-client/src/calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ mod sys {
pub trait Calculator {
async fn add(&self, a: u32, b: u32) -> ::worker::Result<u64>;
}
pub struct CalculatorService(::worker::send::SendWrapper<sys::CalculatorSys>);
pub struct CalculatorService(sys::CalculatorSys);
#[async_trait::async_trait]
impl Calculator for CalculatorService {
async fn add(&self, a: u32, b: u32) -> ::worker::Result<u32> {
let promise = self.0.add(a, b)?;
let fut = ::worker::send::SendFuture::new(
::worker::wasm_bindgen_futures::JsFuture::from(promise),
);
let fut = ::worker::wasm_bindgen_futures::JsFuture::from(promise);
let output = fut.await?;
Ok(::serde_wasm_bindgen::from_value(output)?)
}
}
impl From<::worker::Fetcher> for CalculatorService {
fn from(fetcher: ::worker::Fetcher) -> Self {
Self(::worker::send::SendWrapper::new(fetcher.into_rpc()))
Self(fetcher.into_rpc())
}
}
1 change: 0 additions & 1 deletion test/src/alarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl DurableObject for AlarmObject {
}
}

#[worker::send]
pub async fn handle_alarm(_req: Request, env: Env, _data: SomeSharedData) -> Result<Response> {
let namespace = env.durable_object("ALARM")?;
let stub = namespace.id_from_name("alarm")?.get_stub()?;
Expand Down
3 changes: 1 addition & 2 deletions test/src/analytics_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::SomeSharedData;
use uuid::Uuid;
use worker::{AnalyticsEngineDataPointBuilder, Env, Request, Response, Result};

#[worker::send]
pub async fn handle_analytics_event(
req: Request,
env: Env,
Expand Down Expand Up @@ -31,5 +30,5 @@ pub async fn handle_analytics_event(
.add_double(200)
.write_to(&dataset)?;

return Response::ok("Events sent");
Response::ok("Events sent")
}
1 change: 0 additions & 1 deletion test/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub async fn handle_asset(
}

#[cfg(feature = "http")]
#[worker::send]
pub async fn handle_asset(
req: worker::Request,
env: worker::Env,
Expand Down
1 change: 0 additions & 1 deletion test/src/auto_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl DurableObject for AutoResponseObject {
}

// Route handler to exercise the Durable Object from tests.
#[worker::send]
pub async fn handle_auto_response(
_req: Request,
env: Env,
Expand Down
11 changes: 4 additions & 7 deletions test/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ fn key(req: &Request) -> Result<Option<String>> {
Ok(segments.nth(2).map(ToOwned::to_owned))
}

#[worker::send]
pub async fn handle_cache_example(
req: Request,
_env: Env,
Expand All @@ -34,7 +33,6 @@ pub async fn handle_cache_example(
}
}

#[worker::send]
pub async fn handle_cache_api_get(
req: Request,
_env: Env,
Expand All @@ -50,7 +48,6 @@ pub async fn handle_cache_api_get(
Response::error("key missing", 400)
}

#[worker::send]
pub async fn handle_cache_api_put(
req: Request,
_env: Env,
Expand All @@ -69,7 +66,6 @@ pub async fn handle_cache_api_put(
Response::error("key missing", 400)
}

#[worker::send]
pub async fn handle_cache_api_delete(
req: Request,
_env: Env,
Expand All @@ -84,7 +80,6 @@ pub async fn handle_cache_api_delete(
Response::error("key missing", 400)
}

#[worker::send]
pub async fn handle_cache_stream(
req: Request,
_env: Env,
Expand All @@ -98,8 +93,10 @@ pub async fn handle_cache_stream(
Ok(resp)
} else {
console_log!("Cache MISS!");
let mut rng = rand::rng();
let count = rng.random_range(0..10);
let count = {
let mut rng = rand::rng();
rng.random_range(0..10)
};
let stream = futures_util::stream::repeat("Hello, world!\n")
.take(count)
.then(|text| async move {
Expand Down
1 change: 0 additions & 1 deletion test/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ impl DurableObject for EchoContainer {

const CONTAINER_NAME: &str = "my-container";

#[worker::send]
pub async fn handle_container(
mut req: Request,
env: Env,
Expand Down
2 changes: 0 additions & 2 deletions test/src/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ impl DurableObject for Counter {
}
}

#[worker::send]
pub async fn handle_id(req: Request, env: Env, _data: SomeSharedData) -> Result<Response> {
let durable_object_name = if req.path().contains("shared") {
"SHARED_COUNTER"
Expand All @@ -110,7 +109,6 @@ pub async fn handle_id(req: Request, env: Env, _data: SomeSharedData) -> Result<
stub.fetch_with_str("https://fake-host/").await
}

#[worker::send]
pub async fn handle_websocket(req: Request, env: Env, _data: SomeSharedData) -> Result<Response> {
let durable_object_name = if req.path().contains("shared") {
"SHARED_COUNTER"
Expand Down
14 changes: 0 additions & 14 deletions test/src/d1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ struct Person {
age: u32,
}

#[worker::send]
pub async fn prepared_statement(
_req: Request,
env: Env,
Expand Down Expand Up @@ -68,7 +67,6 @@ pub async fn prepared_statement(
Response::ok("ok")
}

#[worker::send]
pub async fn batch(_req: Request, env: Env, _data: SomeSharedData) -> Result<Response> {
let db = env.d1("DB")?;
let mut results = db
Expand All @@ -93,7 +91,6 @@ pub async fn batch(_req: Request, env: Env, _data: SomeSharedData) -> Result<Res
Response::ok("ok")
}

#[worker::send]
pub async fn exec(mut req: Request, env: Env, _data: SomeSharedData) -> Result<Response> {
let db = env.d1("DB")?;
let result = db
Expand All @@ -104,14 +101,12 @@ pub async fn exec(mut req: Request, env: Env, _data: SomeSharedData) -> Result<R
Response::ok(result.count()?.unwrap_or_default().to_string())
}

#[worker::send]
pub async fn dump(_req: Request, env: Env, _data: SomeSharedData) -> Result<Response> {
let db = env.d1("DB")?;
let bytes = db.dump().await?;
Response::from_bytes(bytes)
}

#[worker::send]
pub async fn error(_req: Request, env: Env, _data: SomeSharedData) -> Result<Response> {
let db = env.d1("DB")?;
let error = db
Expand All @@ -138,7 +133,6 @@ struct NullablePerson {
age: Option<u32>,
}

#[worker::send]
pub async fn jsvalue_null_is_null(
_req: Request,
_env: Env,
Expand All @@ -149,7 +143,6 @@ pub async fn jsvalue_null_is_null(
Response::ok("ok")
}

#[worker::send]
pub async fn serialize_optional_none(
_req: Request,
_env: Env,
Expand All @@ -164,7 +157,6 @@ pub async fn serialize_optional_none(
Response::ok("ok")
}

#[worker::send]
pub async fn serialize_optional_some(
_req: Request,
_env: Env,
Expand All @@ -179,7 +171,6 @@ pub async fn serialize_optional_some(
Response::ok("ok")
}

#[worker::send]
pub async fn deserialize_optional_none(
_req: Request,
_env: Env,
Expand All @@ -201,7 +192,6 @@ pub async fn deserialize_optional_none(
Response::ok("ok")
}

#[worker::send]
pub async fn insert_and_retrieve_optional_none(
_req: Request,
env: Env,
Expand All @@ -227,7 +217,6 @@ pub async fn insert_and_retrieve_optional_none(
Response::ok("ok")
}

#[worker::send]
pub async fn insert_and_retrieve_optional_some(
_req: Request,
env: Env,
Expand All @@ -252,7 +241,6 @@ pub async fn insert_and_retrieve_optional_some(
Response::ok("ok")
}

#[worker::send]
pub async fn retrieve_optional_none(
_req: Request,
env: Env,
Expand All @@ -269,7 +257,6 @@ pub async fn retrieve_optional_none(
Response::ok("ok")
}

#[worker::send]
pub async fn retrieve_optional_some(
_req: Request,
env: Env,
Expand All @@ -286,7 +273,6 @@ pub async fn retrieve_optional_some(
Response::ok("ok")
}

#[worker::send]
pub async fn retrive_first_none(
_req: Request,
env: Env,
Expand Down
6 changes: 0 additions & 6 deletions test/src/durable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ impl DurableObject for MyClass {
}

// Route handlers to exercise the Durable Object from tests.
#[worker::send]
pub async fn handle_hello(
_req: Request,
env: Env,
Expand All @@ -190,7 +189,6 @@ pub async fn handle_hello(
.await
}

#[worker::send]
pub async fn handle_hello_unique(
_req: Request,
env: Env,
Expand All @@ -204,7 +202,6 @@ pub async fn handle_hello_unique(
.await
}

#[worker::send]
pub async fn handle_storage(
_req: Request,
env: Env,
Expand All @@ -215,7 +212,6 @@ pub async fn handle_storage(
stub.fetch_with_str("https://fake-host/storage").await
}

#[worker::send]
pub async fn handle_basic_test(
_req: Request,
env: Env,
Expand Down Expand Up @@ -290,7 +286,6 @@ pub async fn handle_basic_test(
Response::ok("ok")
}

#[worker::send]
pub async fn handle_get_by_name(
_req: Request,
env: Env,
Expand All @@ -308,7 +303,6 @@ pub async fn handle_get_by_name(
.await
}

#[worker::send]
pub async fn handle_get_by_name_with_location_hint(
_req: Request,
env: Env,
Expand Down
9 changes: 0 additions & 9 deletions test/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use worker::{
RequestInit, Response, Result,
};

#[worker::send]
pub async fn handle_fetch(_req: Request, _env: Env, _data: SomeSharedData) -> Result<Response> {
let req = Request::new("https://example.com", Method::Post)?;
let resp = Fetch::Request(req).send().await?;
Expand All @@ -19,7 +18,6 @@ pub async fn handle_fetch(_req: Request, _env: Env, _data: SomeSharedData) -> Re
))
}

#[worker::send]
pub async fn handle_fetch_json(
_req: Request,
_env: Env,
Expand All @@ -40,7 +38,6 @@ pub async fn handle_fetch_json(
))
}

#[worker::send]
pub async fn handle_proxy_request(
req: Request,
_env: Env,
Expand All @@ -57,7 +54,6 @@ pub async fn handle_proxy_request(
Fetch::Url(url.parse()?).send().await
}

#[worker::send]
pub async fn handle_request_init_fetch(
_req: Request,
_env: Env,
Expand All @@ -69,7 +65,6 @@ pub async fn handle_request_init_fetch(
.await
}

#[worker::send]
pub async fn handle_request_init_fetch_post(
_req: Request,
_env: Env,
Expand All @@ -82,7 +77,6 @@ pub async fn handle_request_init_fetch_post(
.await
}

#[worker::send]
pub async fn handle_cancelled_fetch(
_req: Request,
_env: Env,
Expand Down Expand Up @@ -115,7 +109,6 @@ pub async fn handle_cancelled_fetch(
Ok(res)
}

#[worker::send]
pub async fn handle_fetch_timeout(
_req: Request,
_env: Env,
Expand Down Expand Up @@ -158,7 +151,6 @@ pub async fn handle_fetch_timeout(
}
}

#[worker::send]
pub async fn handle_cloned_fetch(
_req: Request,
_env: Env,
Expand All @@ -179,7 +171,6 @@ pub async fn handle_cloned_fetch(
Response::ok((left == right).to_string())
}

#[worker::send]
pub async fn handle_cloned_response_attributes(
_req: Request,
_env: Env,
Expand Down
Loading
Loading