diff --git a/worker-sandbox/src/lib.rs b/worker-sandbox/src/lib.rs index 834ee885..3e04f2bd 100644 --- a/worker-sandbox/src/lib.rs +++ b/worker-sandbox/src/lib.rs @@ -10,7 +10,11 @@ use std::{ use router_service::unsync::Router; use serde::{Deserialize, Serialize}; use tower::Service; -use worker::{body::Body, http::{Response, HttpClone, RequestRedirect}, *}; +use worker::{ + body::Body, + http::{HttpClone, RequestRedirect, Response}, + *, +}; mod alarm; mod counter; diff --git a/worker-sys/Cargo.toml b/worker-sys/Cargo.toml index 44654f68..fb897475 100644 --- a/worker-sys/Cargo.toml +++ b/worker-sys/Cargo.toml @@ -10,7 +10,7 @@ description = "Low-level extern definitions / FFI bindings to the Cloudflare Wor [dependencies] cfg-if = "1.0.0" js-sys = "0.3.63" -wasm-bindgen = "=0.2.87" +wasm-bindgen = {workspace=true} [dependencies.web-sys] version = "0.3.63" diff --git a/worker/src/body/body.rs b/worker/src/body/body.rs index fc675974..9b9edddb 100644 --- a/worker/src/body/body.rs +++ b/worker/src/body/body.rs @@ -3,16 +3,16 @@ use std::{ task::{Context, Poll}, }; -use bytes::Bytes; -use futures_util::{AsyncRead, Stream}; -use http::HeaderMap; -use serde::de::DeserializeOwned; use crate::console_log; use crate::{ body::{wasm::WasmStreamBody, HttpBody}, futures::SendJsFuture, Error, }; +use bytes::Bytes; +use futures_util::{AsyncRead, Stream}; +use http::HeaderMap; +use serde::de::DeserializeOwned; type BoxBody = http_body::combinators::UnsyncBoxBody; @@ -189,11 +189,13 @@ impl Body { match self.into_inner() { crate::body::BodyInner::Request(req) => req.body(), crate::body::BodyInner::Response(res) => res.body(), - crate::body::BodyInner::Regular(s) => { - Some( - wasm_streams::ReadableStream::from_async_read(crate::body::BoxBodyReader::new(s), 1024).into_raw() + crate::body::BodyInner::Regular(s) => Some( + wasm_streams::ReadableStream::from_async_read( + crate::body::BoxBodyReader::new(s), + 1024, ) - } + .into_raw(), + ), crate::body::BodyInner::None => None, _ => panic!("unexpected body inner"), } @@ -302,14 +304,14 @@ impl HttpBody for Body { pub struct BoxBodyReader { inner: BoxBody, - store: Vec + store: Vec, } impl BoxBodyReader { pub fn new(inner: BoxBody) -> Self { BoxBodyReader { inner, - store: Vec::new() + store: Vec::new(), } } } @@ -319,7 +321,7 @@ impl AsyncRead for BoxBodyReader { fn poll_read( mut self: Pin<&mut Self>, cx: &mut Context<'_>, - buf: &mut [u8] + buf: &mut [u8], ) -> Poll> { if self.store.len() > 0 { let size = self.store.len().min(buf.len()); @@ -338,13 +340,13 @@ impl AsyncRead for BoxBodyReader { buf[..size].clone_from_slice(&self.store[..size]); self.store = self.store.split_off(size); Poll::Ready(Ok(size)) - }, + } Err(e) => { Poll::Ready(Err(std::io::Error::new(std::io::ErrorKind::Other, e))) } }, - None => Poll::Ready(Ok(0)) // Not sure about this - } + None => Poll::Ready(Ok(0)), // Not sure about this + }, } } } diff --git a/worker/src/durable.rs b/worker/src/durable.rs index 1c628617..9a2ef4eb 100644 --- a/worker/src/durable.rs +++ b/worker/src/durable.rs @@ -28,12 +28,12 @@ use futures_util::Future; use js_sys::{Map, Number, Object}; use serde::{de::DeserializeOwned, Serialize}; use wasm_bindgen::{prelude::*, JsCast}; +use wasm_bindgen_futures::future_to_promise; use worker_sys::{ DurableObject as EdgeDurableObject, DurableObjectId, DurableObjectNamespace as EdgeObjectNamespace, DurableObjectState, DurableObjectStorage, DurableObjectTransaction, }; -use wasm_bindgen_futures::future_to_promise; /// A Durable Object stub is a client object used to send requests to a remote Durable Object. pub struct Stub {