Skip to content
Closed
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
File renamed without changes.
790 changes: 572 additions & 218 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
resolver = "2"

members = [
"lib/sqlsync",
"lib/sqlsync-worker/sqlsync-wasm",
"lib/sqlsync-reducer",
"lib/sqlite-vfs",
"lib/testutil",
"lib/sqlsync",
"lib/sqlsync-worker/sqlsync-wasm",
"lib/sqlsync-reducer",
"lib/sqlite-vfs",
"lib/testutil",

"examples/reducer-guestbook",
"examples/reducer-guestbook",

"demo/demo-reducer",
"demo/cloudflare-backend",
"demo/demo-reducer",
"demo/cloudflare-backend",
]

[workspace.package]
Expand Down
6 changes: 3 additions & 3 deletions lib/sqlsync-reducer/examples/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() -> anyhow::Result<()> {
log::info!("received query request: {} {:?}", sql, params);
let ptr = ffi.encode(
&mut store,
&Ok::<_, ErrorResponse>(QueryResponse {
Ok::<_, ErrorResponse>(QueryResponse {
columns: vec!["foo".into(), "bar".into()],
rows: vec![vec!["baz".into(), "qux".into()].into()],
}),
Expand All @@ -68,7 +68,7 @@ fn main() -> anyhow::Result<()> {
if sql == "FAIL" {
let ptr = ffi.encode(
&mut store,
&Err::<ExecResponse, _>(ErrorResponse::SqliteError {
Err::<ExecResponse, _>(ErrorResponse::SqliteError {
code: 1,
message: "error".to_string(),
}),
Expand All @@ -77,7 +77,7 @@ fn main() -> anyhow::Result<()> {
} else {
let ptr = ffi.encode(
&mut store,
&Ok::<_, ErrorResponse>(ExecResponse { changes: 1 }),
Ok::<_, ErrorResponse>(ExecResponse { changes: 1 }),
)?;
responses.insert(id, ptr);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/sqlsync-reducer/src/guest_ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub fn fbm() -> &'static mut FFIBufManager {
unsafe {
ONCE.call_once(|| {
let singleton = FFIBufManager::default();
#[allow(static_mut_refs)]
SINGLETON.write(singleton);
});
#[allow(static_mut_refs)]
SINGLETON.assume_init_mut()
}
}
Expand Down Expand Up @@ -138,7 +140,7 @@ pub fn install_panic_hook() {
});
}

fn panic_hook(info: &panic::PanicInfo) {
fn panic_hook(info: &panic::PanicHookInfo) {
let record: LogRecord = info.into();
let record_ptr = fbm().encode(&record).unwrap();
unsafe { host_log(record_ptr) }
Expand Down
2 changes: 2 additions & 0 deletions lib/sqlsync-reducer/src/guest_reactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ pub fn reactor() -> &'static mut Reactor {
unsafe {
ONCE.call_once(|| {
let singleton = Reactor::new();
#[allow(static_mut_refs)]
SINGLETON.write(singleton);
});
#[allow(static_mut_refs)]
SINGLETON.assume_init_mut()
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/sqlsync-reducer/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ pub struct LogRecord {
line: Option<u32>,
}

impl From<&panic::PanicInfo<'_>> for LogRecord {
fn from(info: &panic::PanicInfo) -> Self {
impl From<&panic::PanicHookInfo<'_>> for LogRecord {
fn from(info: &panic::PanicHookInfo) -> Self {
let loc = info.location();
LogRecord {
level: log::Level::Error.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlsync-worker/sqlsync-wasm/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'de> Deserialize<'de> for SqlValue {
{
struct SqlValueVisitor;

impl<'de> Visitor<'de> for SqlValueVisitor {
impl Visitor<'_> for SqlValueVisitor {
type Value = SqlValue;

fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlsync/src/journal/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'a, S: Scannable, I: DoubleEndedIterator<Item = Lsn>> Cursor<'a, S, I> {
}
}

impl<'a, S: Scannable, I> PositionedReader for Cursor<'a, S, I> {
impl<S: Scannable, I> PositionedReader for Cursor<'_, S, I> {
fn read_at(&self, pos: usize, buf: &mut [u8]) -> io::Result<usize> {
match self.state {
None => Ok(0),
Expand Down
9 changes: 4 additions & 5 deletions lib/sqlsync/src/positioned_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::io::{self, Read, Seek, SeekFrom, Write};
* They are copied here as the positioned-io crate takes a lot of dependencies
* on std::File which we don't need or want due to Wasm limitations.
*/

pub trait PositionedReader {
/// Reads bytes from an offset in this source into a buffer, returning how
/// many bytes were read.
Expand Down Expand Up @@ -120,7 +119,7 @@ impl PositionedReader for Vec<u8> {
}
}

impl<'a> PositionedReader for &'a [u8] {
impl PositionedReader for &[u8] {
fn read_at(&self, pos: usize, buf: &mut [u8]) -> io::Result<usize> {
if pos >= self.len() {
return Ok(0);
Expand Down Expand Up @@ -195,7 +194,7 @@ impl<I: PositionedReader> Seek for PositionedCursor<I> {

// Ref implementations

impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a T {
impl<T: ?Sized + PositionedReader> PositionedReader for &T {
fn read_at(&self, pos: usize, buf: &mut [u8]) -> io::Result<usize> {
T::read_at(self, pos, buf)
}
Expand All @@ -205,7 +204,7 @@ impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a T {
}
}

impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a mut T {
impl<T: ?Sized + PositionedReader> PositionedReader for &mut T {
fn read_at(&self, pos: usize, buf: &mut [u8]) -> io::Result<usize> {
T::read_at(self, pos, buf)
}
Expand All @@ -215,7 +214,7 @@ impl<'a, T: ?Sized + PositionedReader> PositionedReader for &'a mut T {
}
}

impl<'a, T: ?Sized + PositionedWriter> PositionedWriter for &'a mut T {
impl<T: ?Sized + PositionedWriter> PositionedWriter for &mut T {
fn write_at(&mut self, pos: usize, buf: &[u8]) -> io::Result<usize> {
T::write_at(self, pos, buf)
}
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlsync/src/replication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ struct LimitedReader<'a, R: io::Read> {
inner: &'a mut R,
}

impl<'a, R: io::Read> io::Read for LimitedReader<'a, R> {
impl<R: io::Read> io::Read for LimitedReader<'_, R> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
if self.limit == 0 {
return Ok(0);
Expand Down
Loading