Skip to content

Commit 5707925

Browse files
committed
Add missing default annotations
1 parent 7d2d4da commit 5707925

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

crates/core/build.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use std::process::Command;
22
fn main() {
33
// note: add error checking yourself.
4-
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
4+
let output = Command::new("git")
5+
.args(&["rev-parse", "HEAD"])
6+
.output()
7+
.unwrap();
58
let git_hash = String::from_utf8(output.stdout).unwrap();
69
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
710
}

crates/core/src/ext.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use sqlite_nostd::{Connection, Destructor, ManagedStmt, ResultCode, sqlite3};
1+
use sqlite_nostd::{sqlite3, Connection, Destructor, ManagedStmt, ResultCode};
22

33
pub trait SafeManagedStmt {
44
fn exec(&self) -> Result<(), ResultCode>;
@@ -23,7 +23,6 @@ impl SafeManagedStmt for ManagedStmt {
2323
}
2424
}
2525

26-
2726
pub trait ExtendedDatabase {
2827
fn exec_text(&self, sql: &str, param: &str) -> Result<(), ResultCode>;
2928
}

crates/core/src/sync/line.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub struct CheckpointDiff<'a> {
5454
pub updated_buckets: Vec<BucketChecksum<'a>>,
5555
#[serde(borrow)]
5656
pub removed_buckets: Vec<&'a str>,
57+
#[serde(default)]
5758
#[serde(deserialize_with = "deserialize_optional_string_to_i64")]
5859
pub write_checkpoint: Option<i64>,
5960
}
@@ -75,11 +76,13 @@ pub struct CheckpointPartiallyComplete {
7576
pub struct BucketChecksum<'a> {
7677
pub bucket: &'a str,
7778
pub checksum: Checksum,
79+
#[serde(default)]
7880
pub priority: Option<BucketPriority>,
81+
#[serde(default)]
7982
pub count: Option<i64>,
80-
// #[serde(default)]
81-
// #[serde(deserialize_with = "deserialize_optional_string_to_i64")]
82-
// pub last_op_id: Option<i64>,
83+
// #[serde(default)]
84+
// #[serde(deserialize_with = "deserialize_optional_string_to_i64")]
85+
// pub last_op_id: Option<i64>,
8386
}
8487

8588
#[derive(Deserialize, Debug)]
@@ -364,15 +367,23 @@ mod tests {
364367
assert_eq!(diff.removed_buckets.len(), 0);
365368
}
366369

370+
#[test]
371+
fn parse_checkpoint_diff_no_write_checkpoint() {
372+
let SyncLine::CheckpointDiff(diff) = deserialize(
373+
r#"{"checkpoint_diff":{"last_op_id":"12","updated_buckets":[{"bucket":"a","count":12,"checksum":0,"priority":3}],"removed_buckets":[]}}"#,
374+
) else {
375+
panic!("Expected checkpoint diff")
376+
};
377+
}
378+
367379
#[test]
368380
fn parse_checkpoint_complete() {
369381
assert_matches!(
370382
deserialize(r#"{"checkpoint_complete": {"last_op_id": "10"}}"#),
371-
SyncLine::CheckpointComplete(CheckpointComplete {
372-
//last_op_id: 10
373-
})
383+
SyncLine::CheckpointComplete(CheckpointComplete {
384+
// last_op_id: 10
385+
})
374386
);
375-
376387
}
377388

378389
#[test]

0 commit comments

Comments
 (0)