diff --git a/Cargo.lock b/Cargo.lock index b3305769..0f2c87f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2312,7 +2312,7 @@ dependencies = [ [[package]] name = "jwst-codec-utils" -version = "0.1.0" +version = "0.0.1" dependencies = [ "arbitrary", "clap", diff --git a/libs/jwst-codec-utils/Cargo.toml b/libs/jwst-codec-utils/Cargo.toml index 6f0bdbaf..f9936f2c 100644 --- a/libs/jwst-codec-utils/Cargo.toml +++ b/libs/jwst-codec-utils/Cargo.toml @@ -1,7 +1,8 @@ [package] -name = "jwst-codec-utils" -version = "0.1.0" +authors = ["x1a0t <405028157@qq.com>", "DarkSky "] edition = "2021" +name = "jwst-codec-utils" +version = "0.0.1" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -16,7 +17,7 @@ arbitrary = { version = "1.3", features = ["derive"], optional = true } clap = { version = "4.4", features = ["derive"], optional = true } phf = { version = "0.11", features = ["macros"], optional = true } rand_chacha = "0.3" -regex = { version = "1.9", optional = true } +regex = { version = "1.10", optional = true } # ======= bench dependencies ======= lib0 = { version = "=0.16.5", features = ["lib0-serde"] } @@ -38,6 +39,10 @@ proptest-derive = "0.4" name = "bench_result_render" path = "bin/bench_result_render.rs" +[[bin]] +name = "doc_merger" +path = "bin/doc_merger.rs" + [[bin]] name = "memory_leak_test" path = "bin/memory_leak_test.rs" @@ -60,11 +65,11 @@ name = "text_ops_benchmarks" [[bench]] harness = false -name = "update_benchmarks" +name = "apply_benchmarks" [[bench]] harness = false -name = "apply_benchmarks" +name = "update_benchmarks" [lib] bench = true diff --git a/libs/jwst-codec-utils/fuzz/Cargo.toml b/libs/jwst-codec-utils/fuzz/Cargo.toml index 57980980..c96a18ee 100644 --- a/libs/jwst-codec-utils/fuzz/Cargo.toml +++ b/libs/jwst-codec-utils/fuzz/Cargo.toml @@ -1,16 +1,16 @@ [package] +edition = "2021" name = "jwst-codec-fuzz" -version = "0.0.0" publish = false -edition = "2021" +version = "0.0.0" [package.metadata] cargo-fuzz = true [dependencies] -rand = "0.8.5" -rand_chacha = "0.3.1" -libfuzzer-sys = "0.4.6" +rand = "0.8" +rand_chacha = "0.3" +libfuzzer-sys = "0.4" jwst-codec-utils = { path = "..", features = ["fuzz"] } lib0 = "0.16.5" @@ -27,65 +27,65 @@ members = ["."] debug = 1 [[bin]] +doc = false name = "codec_doc_any_struct" path = "fuzz_targets/codec_doc_any_struct.rs" test = false -doc = false [[bin]] +doc = false name = "codec_doc_any" path = "fuzz_targets/codec_doc_any.rs" test = false -doc = false [[bin]] +doc = false name = "decode_bytes" path = "fuzz_targets/decode_bytes.rs" test = false -doc = false [[bin]] +doc = false name = "ins_del_text" path = "fuzz_targets/ins_del_text.rs" test = false -doc = false [[bin]] +doc = false name = "sync_message" path = "fuzz_targets/sync_message.rs" test = false -doc = false [[bin]] +doc = false name = "i32_decode" path = "fuzz_targets/i32_decode.rs" test = false -doc = false [[bin]] +doc = false name = "i32_encode" path = "fuzz_targets/i32_encode.rs" test = false -doc = false [[bin]] +doc = false name = "u64_decode" path = "fuzz_targets/u64_decode.rs" test = false -doc = false [[bin]] +doc = false name = "u64_encode" path = "fuzz_targets/u64_encode.rs" test = false -doc = false [[bin]] +doc = false name = "apply_update" path = "fuzz_targets/apply_update.rs" test = false -doc = false [patch.crates-io] lib0 = { git = "https://github.com/toeverything/y-crdt", rev = "a700f09" } diff --git a/libs/jwst-codec-utils/src/doc_operation/yrs_op/mod.rs b/libs/jwst-codec-utils/src/doc_operation/yrs_op/mod.rs index dbb0c861..15b50393 100644 --- a/libs/jwst-codec-utils/src/doc_operation/yrs_op/mod.rs +++ b/libs/jwst-codec-utils/src/doc_operation/yrs_op/mod.rs @@ -161,7 +161,7 @@ mod tests { fn test_ops_registry_get_ops() { let ops_registry = OpsRegistry::new(); let ops = ops_registry.get_ops(&CRDTNestType::Array); - assert!(ops.len() > 0); + assert!(!ops.is_empty()); } #[test] @@ -170,6 +170,6 @@ mod tests { let array = doc.get_or_insert_array("array"); let ops_registry = OpsRegistry::new(); let ops = ops_registry.get_ops_from_yrs_nest_type(&YrsNestType::ArrayType(array)); - assert!(ops.len() > 0); + assert!(!ops.is_empty()); } } diff --git a/libs/jwst-codec/src/codec/buffer.rs b/libs/jwst-codec/src/codec/buffer.rs index ee296073..72d99f9e 100644 --- a/libs/jwst-codec/src/codec/buffer.rs +++ b/libs/jwst-codec/src/codec/buffer.rs @@ -73,6 +73,6 @@ mod tests { let mut buf = Vec::::new(); write_var_buffer(&mut buf, data).unwrap(); let result = read_var_buffer(buf.as_bytes()); - assert_eq!(result, Ok((&[][..], &data[..]))); + assert_eq!(result, Ok((&[][..], data))); } } diff --git a/libs/jwst-codec/src/doc/awareness.rs b/libs/jwst-codec/src/doc/awareness.rs index a4f8680f..b7f838f1 100644 --- a/libs/jwst-codec/src/doc/awareness.rs +++ b/libs/jwst-codec/src/doc/awareness.rs @@ -3,11 +3,11 @@ use std::{cmp::max, collections::hash_map::Entry}; use super::*; use crate::sync::Arc; -type AwarenessCallback = dyn Fn(&Awareness, AwarenessEvent) + Send + Sync + 'static; +pub type AwarenessCallback = Arc; pub struct Awareness { awareness: AwarenessStates, - callback: Option>, + callback: Option, local_id: u64, }