Skip to content

Commit 9110a7a

Browse files
committed
pass 2
1 parent 664c186 commit 9110a7a

File tree

6 files changed

+28
-25
lines changed

6 files changed

+28
-25
lines changed

demo/cloudflare-backend/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::await_holding_refcell_ref)]
2+
13
use std::cell::RefCell;
24

35
use coordinator::Coordinator;
@@ -70,6 +72,7 @@ impl DurableObject for DocumentCoordinator {
7072
spawn_local(task.into_task());
7173
*self.coordinator.borrow_mut() = Some(coordinator);
7274
}
75+
7376
let mut borrow = self.coordinator.borrow_mut();
7477
let coordinator = borrow.as_mut().unwrap();
7578

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ test:
2121
build-wasm:
2222
just run-with-prefix 'wasm-'
2323

24+
package:
25+
just run-with-prefix 'package-'
26+
2427
run-with-prefix prefix:
2528
#!/usr/bin/env bash
2629
set -euo pipefail

lib/sqlsync-reducer/examples/host.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn main() -> anyhow::Result<()> {
5656
log::info!("received query request: {} {:?}", sql, params);
5757
let ptr = ffi.encode(
5858
&mut store,
59-
&Ok::<_, ErrorResponse>(QueryResponse {
59+
Ok::<_, ErrorResponse>(QueryResponse {
6060
columns: vec!["foo".into(), "bar".into()],
6161
rows: vec![vec!["baz".into(), "qux".into()].into()],
6262
}),
@@ -68,7 +68,7 @@ fn main() -> anyhow::Result<()> {
6868
if sql == "FAIL" {
6969
let ptr = ffi.encode(
7070
&mut store,
71-
&Err::<ExecResponse, _>(ErrorResponse::SqliteError {
71+
Err::<ExecResponse, _>(ErrorResponse::SqliteError {
7272
code: 1,
7373
message: "error".to_string(),
7474
}),
@@ -77,7 +77,7 @@ fn main() -> anyhow::Result<()> {
7777
} else {
7878
let ptr = ffi.encode(
7979
&mut store,
80-
&Ok::<_, ErrorResponse>(ExecResponse { changes: 1 }),
80+
Ok::<_, ErrorResponse>(ExecResponse { changes: 1 }),
8181
)?;
8282
responses.insert(id, ptr);
8383
}

lib/sqlsync-worker/sqlsync-wasm/src/utils.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub async fn fetch_reducer(reducer_url: &str) -> Result<(WasmReducer, Vec<u8>),
112112
)));
113113
}
114114

115-
let mut reducer_wasm_bytes = resp.binary().await?;
115+
let reducer_wasm_bytes = resp.binary().await?;
116116

117117
let global = js_sys::global()
118118
.dyn_into::<js_sys::Object>()
@@ -130,10 +130,9 @@ pub async fn fetch_reducer(reducer_url: &str) -> Result<(WasmReducer, Vec<u8>),
130130
// sha256 sum the data
131131
// TODO: it would be much better to stream the data through the hash function
132132
// but afaik that's not doable with the crypto.subtle api
133-
let digest = JsFuture::from(
134-
subtle.digest_with_str_and_u8_array("SHA-256", &mut reducer_wasm_bytes)?,
135-
)
136-
.await?;
133+
let digest =
134+
JsFuture::from(subtle.digest_with_str_and_u8_array("SHA-256", &reducer_wasm_bytes)?)
135+
.await?;
137136
Uint8Array::new(&digest).to_vec()
138137
};
139138

lib/sqlsync/examples/end-to-end-local-net.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ use sqlsync::WasmReducer;
2222
use serde::{Deserialize, Serialize};
2323
use sqlsync::{coordinator::CoordinatorDocument, MemoryJournal};
2424

25-
fn serialize_into<W, T: ?Sized>(writer: W, value: &T) -> io::Result<()>
25+
fn serialize_into<W, T>(writer: W, value: &T) -> io::Result<()>
2626
where
2727
W: std::io::Write,
28-
T: serde::Serialize,
28+
T: serde::Serialize + ?Sized,
2929
{
3030
match bincode::serialize_into(writer, value) {
3131
Ok(_) => Ok(()),
3232
Err(err) => match err.as_ref() {
3333
ErrorKind::Io(err) => Err(err.kind().into()),
34-
_ => Err(io::Error::new(io::ErrorKind::Other, err)),
34+
_ => Err(io::Error::other(err)),
3535
},
3636
}
3737
}
@@ -45,7 +45,7 @@ where
4545
Ok(v) => Ok(v),
4646
Err(err) => match err.as_ref() {
4747
ErrorKind::Io(err) => Err(err.kind().into()),
48-
_ => Err(io::Error::new(io::ErrorKind::Other, err)),
48+
_ => Err(io::Error::other(err)),
4949
},
5050
}
5151
}

lib/sqlsync/src/positioned_io.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
use std::io::{self, Read, Seek, SeekFrom, Write};
1+
//! The traits in this file copy certain methods and docstrings from the position-io module
2+
//! https://crates.io/crates/positioned-io
3+
//! postioned-io is under the MIT license
4+
//!
5+
//! They are copied here as the positioned-io crate takes a lot of dependencies
6+
//! on std::File which we don't need or want due to Wasm limitations.
27
3-
/**
4-
* The traits in this file copy certain methods and docstrings from the position-io module
5-
* https://crates.io/crates/positioned-io
6-
* postioned-io is under the MIT license
7-
*
8-
* They are copied here as the positioned-io crate takes a lot of dependencies
9-
* on std::File which we don't need or want due to Wasm limitations.
10-
*/
8+
use std::io::{self, Read, Seek, SeekFrom, Write};
119

1210
pub trait PositionedReader {
1311
/// Reads bytes from an offset in this source into a buffer, returning how
@@ -120,7 +118,7 @@ impl PositionedReader for Vec<u8> {
120118
}
121119
}
122120

123-
impl<'a> PositionedReader for &'a [u8] {
121+
impl PositionedReader for &[u8] {
124122
fn read_at(&self, pos: usize, buf: &mut [u8]) -> io::Result<usize> {
125123
if pos >= self.len() {
126124
return Ok(0);
@@ -195,7 +193,7 @@ impl<I: PositionedReader> Seek for PositionedCursor<I> {
195193

196194
// Ref implementations
197195

198-
impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a T {
196+
impl<T: ?Sized + PositionedReader> PositionedReader for &T {
199197
fn read_at(&self, pos: usize, buf: &mut [u8]) -> io::Result<usize> {
200198
T::read_at(self, pos, buf)
201199
}
@@ -205,7 +203,7 @@ impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a T {
205203
}
206204
}
207205

208-
impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a mut T {
206+
impl<T: ?Sized + PositionedReader> PositionedReader for &mut T {
209207
fn read_at(&self, pos: usize, buf: &mut [u8]) -> io::Result<usize> {
210208
T::read_at(self, pos, buf)
211209
}
@@ -215,7 +213,7 @@ impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a mut T {
215213
}
216214
}
217215

218-
impl<'a, T: ?Sized + PositionedWriter> PositionedWriter for &'a mut T {
216+
impl<T: ?Sized + PositionedWriter> PositionedWriter for &mut T {
219217
fn write_at(&mut self, pos: usize, buf: &[u8]) -> io::Result<usize> {
220218
T::write_at(self, pos, buf)
221219
}

0 commit comments

Comments
 (0)