From 73e56413dee0060414c3e4c0bd536031cb15eb48 Mon Sep 17 00:00:00 2001 From: V0ldek Date: Sun, 22 Dec 2024 23:51:43 +0100 Subject: [PATCH] release/v0.9.2 (#619) release v0.9.2 --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 +- CHANGELOG.md | 28 ++ Cargo.lock | 10 +- Cargo.toml | 63 ++- Justfile | 12 +- README.md | 444 ++++++++++++------ book/src/user/installation.md | 2 +- crates/rsonpath-benchmarks/Cargo.toml | 4 +- crates/rsonpath-lib/Cargo.toml | 17 +- crates/rsonpath-lib/README.md | 11 +- .../examples/approx_spans_usage.rs | 1 + crates/rsonpath-lib/src/lib.rs | 53 +-- .../tests/input_implementation_tests.rs | 93 ++-- crates/rsonpath-syntax/CHANGELOG.md | 9 + crates/rsonpath-syntax/Cargo.toml | 14 +- crates/rsonpath-syntax/src/lib.rs | 64 +-- .../tests/query_parser_tests.rs | 6 +- crates/rsonpath-test-codegen/Cargo.lock | 2 +- crates/rsonpath-test-codegen/Cargo.toml | 2 +- crates/rsonpath-test/Cargo.toml | 11 +- crates/rsonpath/Cargo.toml | 17 +- crates/rsonpath/src/args.rs | 6 +- crates/rsonpath/src/error.rs | 77 +-- crates/rsonpath/src/input.rs | 26 +- crates/rsonpath/src/logger.rs | 2 +- crates/rsonpath/src/runner.rs | 42 +- crates/rsonpath/src/version.rs | 2 +- fuzz/Cargo.lock | 8 +- fuzz/Cargo.toml | 2 +- 29 files changed, 569 insertions(+), 462 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index ae29080e..a25b0d34 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -71,7 +71,8 @@ body: attributes: label: Version of the release options: - # + # + - v0.9.2 - v0.9.1 - v0.9.0 - v0.8.7 diff --git a/CHANGELOG.md b/CHANGELOG.md index a4c7c9f3..2a1ac35e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,34 @@ All notable changes to this project will be documented in this file. +## [0.9.2] - 2024-12-22 + +### Library + +- Added `StringPattern` and made `Automaton` no longer borrow the query. ([#117](https://github.com/V0ldek/rsonpath/issues/117)[#613](https://github.com/V0ldek/rsonpath/issues/613)) + + - The `Automaton` struct borrowed the source query, which also caused the Engine to carry the query's lifetime with it. + The actual data being borrowed were the `JsonString` values for member transitions. + In preparation for [#117](https://github.com/V0ldek/rsonpath/issues/117)we remove the borrowed `JsonString` and replace it + with `StringPattern`. For UTF-8 the `StringPattern` will be a more complex struct that precomputes some stuff for efficient matching later. + For now, it's a thin wrapper over a `JsonString`. + - During construction we may create many transitions over the same pattern. + To reduce the size of the automaton we cache the patterns and put them into an `Rc`. + This may get optimised later to instead use some kind of inline storage, but it's unlike to actually matter. + I ran the benchmarks and saw no measurable difference between the previous version and this one. + +### Dependencies + +- Bump arbitrary from 1.3.1 to 1.4.1 +- Bump clap from 4.5.2 to 4.5.23 +- Bump color-eyre from 0.6.2 to 0.6.3 +- Bump log from 0.4.21 to 0.4.22 +- Bump memmap2 from 0.9.4 to 0.9.5 +- Bump simple_logger from 4.3.3 to 5.0.0 +- Bump smallvec from 1.13.1 to 1.13.2 +- Bump thiserror from 1.0.58 to 2.0.9 (#617). ([#617](https://github.com/V0ldek/rsonpath/issues/617)) +- Remove `nom` as a direct dependency of `rsonpath-lib` + ## [0.9.1] - 2024-04-03 ### Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index 5bebfd32..e0586f24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1188,7 +1188,7 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rsonpath" -version = "0.9.1" +version = "0.9.2" dependencies = [ "clap", "color-eyre", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "rsonpath-lib" -version = "0.9.1" +version = "0.9.2" dependencies = [ "arbitrary", "cfg-if", @@ -1225,7 +1225,7 @@ dependencies = [ [[package]] name = "rsonpath-syntax" -version = "0.3.1" +version = "0.3.2" dependencies = [ "arbitrary", "insta", @@ -1240,7 +1240,7 @@ dependencies = [ [[package]] name = "rsonpath-test" -version = "0.9.1" +version = "0.9.2" dependencies = [ "eyre", "glob", @@ -1255,7 +1255,7 @@ dependencies = [ [[package]] name = "rsonpath-test-codegen" -version = "0.9.1" +version = "0.9.2" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 40a42334..a942ca56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,19 @@ exclude = ["crates/rsonpath-benchmarks", "crates/rsonpath-test-codegen"] resolver = "2" +[workspace.package] +version = "0.9.2" +authors = ["Mateusz Gienieczko "] +readme = "README.md" +license = "MIT" +repository = "https://github.com/rsonquery/rsonpath" +homepage = "https://rsonquery.github.io/rsonpath/" +edition = "2021" + [workspace.dependencies] # Project crates -rsonpath-lib = { version = "0.9.1", path = "./crates/rsonpath-lib", package = "rsonpath-lib", default-features = false } -rsonpath-syntax = { version = "0.3.1", path = "./crates/rsonpath-syntax" } +rsonpath-lib = { version = "0.9.2", path = "./crates/rsonpath-lib", package = "rsonpath-lib", default-features = false } +rsonpath-syntax = { version = "0.3.2", path = "./crates/rsonpath-syntax" } # Main dependencies arbitrary = { version = "1.4.1" } cfg-if = "1.0.0" @@ -26,6 +35,56 @@ pretty_assertions = "1.4.1" proptest = "1.5.0" test-case = "3.3.1" +[workspace.lints.rust] +explicit_outlives_requirements = "warn" +semicolon_in_expressions_from_macros = "warn" +unreachable_pub = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" + +[workspace.lints.clippy] +allow_attributes_without_reason = "warn" +cargo_common_metadata = "warn" +cast_lossless = "warn" +cloned_instead_of_copied = "warn" +empty_drop = "warn" +empty_line_after_outer_attr = "warn" +equatable_if_let = "warn" +expl_impl_clone_on_copy = "warn" +explicit_deref_methods = "warn" +explicit_into_iter_loop = "warn" +explicit_iter_loop = "warn" +fallible_impl_from = "warn" +flat_map_option = "warn" +if_then_some_else_none = "warn" +inconsistent_struct_constructor = "warn" +large_digit_groups = "warn" +let_underscore_must_use = "warn" +manual_ok_or = "warn" +map_err_ignore = "warn" +map_unwrap_or = "warn" +match_same_arms = "warn" +match_wildcard_for_single_variants = "warn" +missing_inline_in_public_items = "warn" +mod_module_files = "warn" +must_use_candidate = "warn" +needless_continue = "warn" +needless_for_each = "warn" +needless_pass_by_value = "warn" +ptr_as_ptr = "warn" +redundant_closure_for_method_calls = "warn" +ref_binding_to_reference = "warn" +ref_option_ref = "warn" +rest_pat_in_fully_bound_structs = "warn" +undocumented_unsafe_blocks = "warn" +unneeded_field_pattern = "warn" +unseparated_literal_suffix = "warn" +unreadable_literal = "warn" +unused_self = "warn" +use_self = "warn" +# Panic-free lints +exit = "warn" + [profile.dev] lto = false diff --git a/Justfile b/Justfile index d82960b7..085f86d0 100644 --- a/Justfile +++ b/Justfile @@ -276,13 +276,19 @@ release ver: cargo build cargo +nightly fuzz build +# Execute prerequisits for a release of `rsonpath-syntax` for the given version. +release-syntax ver: + #!/usr/bin/env nu + let ver = "{{ver}}"; + sed -i $'s/^version = "[^"]*"/version = "($ver)"/' "./crates/rsonpath-syntax/Cargo.toml" + sed -i $'s/^rsonpath-syntax = { version = "[^"]*"/rsonpath-syntax = { version = "($ver)"/' "./Cargo.toml" + [private] release-patch ver: #!/usr/bin/env nu let ver = "{{ver}}"; - let crates = ["rsonpath", "rsonpath-lib", "rsonpath-benchmarks", "rsonpath-test", "rsonpath-test-codegen"]; - $crates | each { |cr| - let path = $"./crates/($cr)/Cargo.toml"; + let paths = ["./Cargo.toml", "./crates/rsonpath-benchmarks/Cargo.toml", "./crates/rsonpath-test-codegen/Cargo.toml"]; + $paths | each { |path| sed -i $'s/^version = "[^"]*"/version = "($ver)"/;s/^rsonpath-lib = { version = "[^"]*"/rsonpath-lib = { version = "($ver)"/;s/rsonpath-test-codegen = { version = "[^"]*"/rsonpath-test-codegen = { version = "($ver)"/' $path; }; diff --git a/README.md b/README.md index 0fc546c9..8f32b455 100644 --- a/README.md +++ b/README.md @@ -216,17 +216,21 @@ cargo tree --package rsonpath --edges normal --depth 1 ```ini -rsonpath v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath) -├── clap v4.5.4 +rsonpath v0.9.2 (/home/mat/src/rsonpath/crates/rsonpath) +├── clap v4.5.23 ├── color-eyre v0.6.3 ├── eyre v0.6.12 -├── log v0.4.21 -├── rsonpath-lib v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath-lib) +├── log v0.4.22 +├── rsonpath-lib v0.9.2 (/home/mat/src/rsonpath/crates/rsonpath-lib) ├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax) -└── simple_logger v4.3.3 +└── simple_logger v5.0.0 [build-dependencies] -├── rustflags v0.1.5 -└── vergen v8.3.1 +├── rustflags v0.1.6 +├── vergen v9.0.2 +│ [build-dependencies] +├── vergen-git2 v1.0.2 +│ [build-dependencies] +└── vergen-gitcl v1.0.2 [build-dependencies] ``` @@ -237,16 +241,15 @@ cargo tree --package rsonpath-lib --edges normal --depth 1 ```ini -rsonpath-lib v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath-lib) -├── arbitrary v1.3.2 +rsonpath-lib v0.9.2 (/home/mat/src/rsonpath/crates/rsonpath-lib) +├── arbitrary v1.4.1 ├── cfg-if v1.0.0 -├── log v0.4.21 -├── memmap2 v0.9.4 -├── nom v7.1.3 +├── log v0.4.22 +├── memmap2 v0.9.5 ├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax) ├── smallvec v1.13.2 ├── static_assertions v1.1.0 -├── thiserror v1.0.58 +├── thiserror v2.0.9 └── vector-map v1.0.1 ``` @@ -272,183 +275,328 @@ cargo tree --package rsonpath --edges normal ```ini -rsonpath v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath) -├── clap v4.5.4 -│ ├── clap_builder v4.5.2 -│ │ ├── anstream v0.6.13 -│ │ │ ├── anstyle v1.0.6 -│ │ │ ├── anstyle-parse v0.2.3 -│ │ │ │ └── utf8parse v0.2.1 -│ │ │ ├── anstyle-query v1.0.2 -│ │ │ │ └── windows-sys v0.52.0 -│ │ │ │ └── windows-targets v0.52.4 -│ │ │ │ ├── windows_aarch64_gnullvm v0.52.4 -│ │ │ │ ├── windows_aarch64_msvc v0.52.4 -│ │ │ │ ├── windows_i686_gnu v0.52.4 -│ │ │ │ ├── windows_i686_msvc v0.52.4 -│ │ │ │ ├── windows_x86_64_gnu v0.52.4 -│ │ │ │ ├── windows_x86_64_gnullvm v0.52.4 -│ │ │ │ └── windows_x86_64_msvc v0.52.4 -│ │ │ ├── anstyle-wincon v3.0.2 -│ │ │ │ ├── anstyle v1.0.6 -│ │ │ │ └── windows-sys v0.52.0 (*) -│ │ │ ├── colorchoice v1.0.0 -│ │ │ └── utf8parse v0.2.1 -│ │ ├── anstyle v1.0.6 -│ │ ├── clap_lex v0.7.0 +rsonpath v0.9.2 (/home/mat/src/rsonpath/crates/rsonpath) +├── clap v4.5.23 +│ ├── clap_builder v4.5.23 +│ │ ├── anstream v0.6.18 +│ │ │ ├── anstyle v1.0.10 +│ │ │ ├── anstyle-parse v0.2.6 +│ │ │ │ └── utf8parse v0.2.2 +│ │ │ ├── anstyle-query v1.1.2 +│ │ │ │ └── windows-sys v0.59.0 +│ │ │ │ └── windows-targets v0.52.6 +│ │ │ │ ├── windows_aarch64_gnullvm v0.52.6 +│ │ │ │ ├── windows_aarch64_msvc v0.52.6 +│ │ │ │ ├── windows_i686_gnu v0.52.6 +│ │ │ │ ├── windows_i686_gnullvm v0.52.6 +│ │ │ │ ├── windows_i686_msvc v0.52.6 +│ │ │ │ ├── windows_x86_64_gnu v0.52.6 +│ │ │ │ ├── windows_x86_64_gnullvm v0.52.6 +│ │ │ │ └── windows_x86_64_msvc v0.52.6 +│ │ │ ├── anstyle-wincon v3.0.6 +│ │ │ │ ├── anstyle v1.0.10 +│ │ │ │ └── windows-sys v0.59.0 (*) +│ │ │ ├── colorchoice v1.0.3 +│ │ │ ├── is_terminal_polyfill v1.70.1 +│ │ │ └── utf8parse v0.2.2 +│ │ ├── anstyle v1.0.10 +│ │ ├── clap_lex v0.7.4 │ │ ├── strsim v0.11.1 -│ │ └── terminal_size v0.3.0 -│ │ ├── rustix v0.38.32 -│ │ │ ├── bitflags v2.5.0 -│ │ │ ├── errno v0.3.8 -│ │ │ │ ├── libc v0.2.153 -│ │ │ │ └── windows-sys v0.52.0 (*) -│ │ │ ├── libc v0.2.153 -│ │ │ ├── linux-raw-sys v0.4.13 -│ │ │ └── windows-sys v0.52.0 (*) -│ │ └── windows-sys v0.48.0 -│ │ └── windows-targets v0.48.5 -│ │ ├── windows_aarch64_gnullvm v0.48.5 -│ │ ├── windows_aarch64_msvc v0.48.5 -│ │ ├── windows_i686_gnu v0.48.5 -│ │ ├── windows_i686_msvc v0.48.5 -│ │ ├── windows_x86_64_gnu v0.48.5 -│ │ ├── windows_x86_64_gnullvm v0.48.5 -│ │ └── windows_x86_64_msvc v0.48.5 -│ └── clap_derive v4.5.4 (proc-macro) +│ │ └── terminal_size v0.4.1 +│ │ ├── rustix v0.38.42 +│ │ │ ├── bitflags v2.6.0 +│ │ │ ├── errno v0.3.10 +│ │ │ │ ├── libc v0.2.169 +│ │ │ │ └── windows-sys v0.59.0 (*) +│ │ │ ├── libc v0.2.169 +│ │ │ ├── linux-raw-sys v0.4.14 +│ │ │ └── windows-sys v0.59.0 (*) +│ │ └── windows-sys v0.59.0 (*) +│ └── clap_derive v4.5.18 (proc-macro) │ ├── heck v0.5.0 -│ ├── proc-macro2 v1.0.79 -│ │ └── unicode-ident v1.0.12 -│ ├── quote v1.0.35 -│ │ └── proc-macro2 v1.0.79 (*) -│ └── syn v2.0.58 -│ ├── proc-macro2 v1.0.79 (*) -│ ├── quote v1.0.35 (*) -│ └── unicode-ident v1.0.12 +│ ├── proc-macro2 v1.0.92 +│ │ └── unicode-ident v1.0.14 +│ ├── quote v1.0.37 +│ │ └── proc-macro2 v1.0.92 (*) +│ └── syn v2.0.91 +│ ├── proc-macro2 v1.0.92 (*) +│ ├── quote v1.0.37 (*) +│ └── unicode-ident v1.0.14 ├── color-eyre v0.6.3 │ ├── backtrace v0.3.71 │ │ ├── addr2line v0.21.0 │ │ │ └── gimli v0.28.1 │ │ ├── cfg-if v1.0.0 -│ │ ├── libc v0.2.153 -│ │ ├── miniz_oxide v0.7.2 +│ │ ├── libc v0.2.169 +│ │ ├── miniz_oxide v0.7.4 │ │ │ └── adler v1.0.2 │ │ ├── object v0.32.2 -│ │ │ └── memchr v2.7.2 -│ │ └── rustc-demangle v0.1.23 +│ │ │ └── memchr v2.7.4 +│ │ └── rustc-demangle v0.1.24 │ │ [build-dependencies] -│ │ └── cc v1.0.90 +│ │ └── cc v1.2.5 +│ │ ├── jobserver v0.1.32 +│ │ │ └── libc v0.2.169 +│ │ ├── libc v0.2.169 +│ │ └── shlex v1.3.0 │ ├── eyre v0.6.12 │ │ ├── indenter v0.3.3 -│ │ └── once_cell v1.19.0 +│ │ └── once_cell v1.20.2 │ ├── indenter v0.3.3 -│ ├── once_cell v1.19.0 +│ ├── once_cell v1.20.2 │ └── owo-colors v3.5.0 ├── eyre v0.6.12 (*) -├── log v0.4.21 -├── rsonpath-lib v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath-lib) +├── log v0.4.22 +├── rsonpath-lib v0.9.2 (/home/mat/src/rsonpath/crates/rsonpath-lib) │ ├── cfg-if v1.0.0 -│ ├── log v0.4.21 -│ ├── memmap2 v0.9.4 -│ │ └── libc v0.2.153 -│ ├── nom v7.1.3 -│ │ ├── memchr v2.7.2 -│ │ └── minimal-lexical v0.2.1 +│ ├── log v0.4.22 +│ ├── memmap2 v0.9.5 +│ │ └── libc v0.2.169 │ ├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax) -│ │ ├── nom v7.1.3 (*) -│ │ ├── owo-colors v4.0.0 -│ │ ├── thiserror v1.0.58 -│ │ │ └── thiserror-impl v1.0.58 (proc-macro) -│ │ │ ├── proc-macro2 v1.0.79 (*) -│ │ │ ├── quote v1.0.35 (*) -│ │ │ └── syn v2.0.58 (*) -│ │ └── unicode-width v0.1.11 +│ │ ├── nom v7.1.3 +│ │ │ ├── memchr v2.7.4 +│ │ │ └── minimal-lexical v0.2.1 +│ │ ├── owo-colors v4.1.0 +│ │ ├── thiserror v2.0.9 +│ │ │ └── thiserror-impl v2.0.9 (proc-macro) +│ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ ├── quote v1.0.37 (*) +│ │ │ └── syn v2.0.91 (*) +│ │ └── unicode-width v0.2.0 │ ├── smallvec v1.13.2 │ ├── static_assertions v1.1.0 -│ ├── thiserror v1.0.58 (*) +│ ├── thiserror v2.0.9 (*) │ └── vector-map v1.0.1 │ ├── contracts v0.4.0 (proc-macro) -│ │ ├── proc-macro2 v1.0.79 (*) -│ │ ├── quote v1.0.35 (*) +│ │ ├── proc-macro2 v1.0.92 (*) +│ │ ├── quote v1.0.37 (*) │ │ └── syn v1.0.109 -│ │ ├── proc-macro2 v1.0.79 (*) -│ │ ├── quote v1.0.35 (*) -│ │ └── unicode-ident v1.0.12 +│ │ ├── proc-macro2 v1.0.92 (*) +│ │ ├── quote v1.0.37 (*) +│ │ └── unicode-ident v1.0.14 │ └── rand v0.7.3 │ ├── getrandom v0.1.16 │ │ ├── cfg-if v1.0.0 -│ │ ├── libc v0.2.153 +│ │ ├── libc v0.2.169 │ │ └── wasi v0.9.0+wasi-snapshot-preview1 -│ ├── libc v0.2.153 +│ ├── libc v0.2.169 │ ├── rand_chacha v0.2.2 -│ │ ├── ppv-lite86 v0.2.17 +│ │ ├── ppv-lite86 v0.2.20 +│ │ │ └── zerocopy v0.7.35 +│ │ │ ├── byteorder v1.5.0 +│ │ │ └── zerocopy-derive v0.7.35 (proc-macro) +│ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ ├── quote v1.0.37 (*) +│ │ │ └── syn v2.0.91 (*) │ │ └── rand_core v0.5.1 │ │ └── getrandom v0.1.16 (*) │ ├── rand_core v0.5.1 (*) │ └── rand_hc v0.2.0 │ └── rand_core v0.5.1 (*) ├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax) (*) -└── simple_logger v4.3.3 - ├── colored v2.1.0 - │ ├── lazy_static v1.4.0 - │ └── windows-sys v0.48.0 (*) - ├── log v0.4.21 - ├── time v0.3.34 +└── simple_logger v5.0.0 + ├── colored v2.2.0 + │ ├── lazy_static v1.5.0 + │ └── windows-sys v0.59.0 (*) + ├── log v0.4.22 + ├── time v0.3.37 │ ├── deranged v0.3.11 │ │ └── powerfmt v0.2.0 - │ ├── itoa v1.0.11 - │ ├── libc v0.2.153 + │ ├── itoa v1.0.14 + │ ├── libc v0.2.169 │ ├── num-conv v0.1.0 │ ├── num_threads v0.1.7 - │ │ └── libc v0.2.153 + │ │ └── libc v0.2.169 │ ├── powerfmt v0.2.0 │ ├── time-core v0.1.2 - │ └── time-macros v0.2.17 (proc-macro) + │ └── time-macros v0.2.19 (proc-macro) │ ├── num-conv v0.1.0 │ └── time-core v0.1.2 - └── windows-sys v0.48.0 (*) + └── windows-sys v0.48.0 + └── windows-targets v0.48.5 + ├── windows_aarch64_gnullvm v0.48.5 + ├── windows_aarch64_msvc v0.48.5 + ├── windows_i686_gnu v0.48.5 + ├── windows_i686_msvc v0.48.5 + ├── windows_x86_64_gnu v0.48.5 + ├── windows_x86_64_gnullvm v0.48.5 + └── windows_x86_64_msvc v0.48.5 [build-dependencies] -├── rustflags v0.1.5 -└── vergen v8.3.1 - ├── anyhow v1.0.81 - ├── cargo_metadata v0.18.1 - │ ├── camino v1.1.6 - │ │ └── serde v1.0.197 - │ │ └── serde_derive v1.0.197 (proc-macro) - │ │ ├── proc-macro2 v1.0.79 (*) - │ │ ├── quote v1.0.35 (*) - │ │ └── syn v2.0.58 (*) - │ ├── cargo-platform v0.1.8 - │ │ └── serde v1.0.197 (*) - │ ├── semver v1.0.22 - │ │ └── serde v1.0.197 (*) - │ ├── serde v1.0.197 (*) - │ ├── serde_json v1.0.115 - │ │ ├── itoa v1.0.11 - │ │ ├── ryu v1.0.17 - │ │ └── serde v1.0.197 (*) - │ └── thiserror v1.0.58 (*) - ├── cfg-if v1.0.0 - ├── regex v1.10.4 - │ ├── aho-corasick v1.1.3 - │ │ └── memchr v2.7.2 - │ ├── memchr v2.7.2 - │ ├── regex-automata v0.4.6 - │ │ ├── aho-corasick v1.1.3 (*) - │ │ ├── memchr v2.7.2 - │ │ └── regex-syntax v0.8.3 - │ └── regex-syntax v0.8.3 - ├── rustc_version v0.4.0 - │ └── semver v1.0.22 (*) - └── time v0.3.34 - ├── deranged v0.3.11 (*) - ├── itoa v1.0.11 - ├── libc v0.2.153 - ├── num-conv v0.1.0 - ├── num_threads v0.1.7 (*) - ├── powerfmt v0.2.0 - └── time-core v0.1.2 +├── rustflags v0.1.6 +├── vergen v9.0.2 +│ ├── anyhow v1.0.95 +│ ├── cargo_metadata v0.19.1 +│ │ ├── camino v1.1.9 +│ │ │ └── serde v1.0.216 +│ │ │ └── serde_derive v1.0.216 (proc-macro) +│ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ ├── quote v1.0.37 (*) +│ │ │ └── syn v2.0.91 (*) +│ │ ├── cargo-platform v0.1.9 +│ │ │ └── serde v1.0.216 (*) +│ │ ├── semver v1.0.24 +│ │ │ └── serde v1.0.216 (*) +│ │ ├── serde v1.0.216 (*) +│ │ ├── serde_json v1.0.134 +│ │ │ ├── itoa v1.0.14 +│ │ │ ├── memchr v2.7.4 +│ │ │ ├── ryu v1.0.18 +│ │ │ └── serde v1.0.216 (*) +│ │ └── thiserror v2.0.9 (*) +│ ├── derive_builder v0.20.2 +│ │ └── derive_builder_macro v0.20.2 (proc-macro) +│ │ ├── derive_builder_core v0.20.2 +│ │ │ ├── darling v0.20.10 +│ │ │ │ ├── darling_core v0.20.10 +│ │ │ │ │ ├── fnv v1.0.7 +│ │ │ │ │ ├── ident_case v1.0.1 +│ │ │ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ │ ├── strsim v0.11.1 +│ │ │ │ │ └── syn v2.0.91 (*) +│ │ │ │ └── darling_macro v0.20.10 (proc-macro) +│ │ │ │ ├── darling_core v0.20.10 (*) +│ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ └── syn v2.0.91 (*) +│ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ ├── quote v1.0.37 (*) +│ │ │ └── syn v2.0.91 (*) +│ │ └── syn v2.0.91 (*) +│ ├── regex v1.11.1 +│ │ ├── aho-corasick v1.1.3 +│ │ │ └── memchr v2.7.4 +│ │ ├── memchr v2.7.4 +│ │ ├── regex-automata v0.4.9 +│ │ │ ├── aho-corasick v1.1.3 (*) +│ │ │ ├── memchr v2.7.4 +│ │ │ └── regex-syntax v0.8.5 +│ │ └── regex-syntax v0.8.5 +│ ├── rustc_version v0.4.1 +│ │ └── semver v1.0.24 (*) +│ └── vergen-lib v0.1.5 +│ ├── anyhow v1.0.95 +│ └── derive_builder v0.20.2 (*) +│ [build-dependencies] +│ └── rustversion v1.0.18 (proc-macro) +│ [build-dependencies] +│ └── rustversion v1.0.18 (proc-macro) +├── vergen-git2 v1.0.2 +│ ├── anyhow v1.0.95 +│ ├── derive_builder v0.20.2 (*) +│ ├── git2 v0.19.0 +│ │ ├── bitflags v2.6.0 +│ │ ├── libc v0.2.169 +│ │ ├── libgit2-sys v0.17.0+1.8.1 +│ │ │ ├── libc v0.2.169 +│ │ │ └── libz-sys v1.1.20 +│ │ │ └── libc v0.2.169 +│ │ │ [build-dependencies] +│ │ │ ├── cc v1.2.5 (*) +│ │ │ ├── pkg-config v0.3.31 +│ │ │ └── vcpkg v0.2.15 +│ │ │ [build-dependencies] +│ │ │ ├── cc v1.2.5 (*) +│ │ │ └── pkg-config v0.3.31 +│ │ ├── log v0.4.22 +│ │ └── url v2.5.4 +│ │ ├── form_urlencoded v1.2.1 +│ │ │ └── percent-encoding v2.3.1 +│ │ ├── idna v1.0.3 +│ │ │ ├── idna_adapter v1.2.0 +│ │ │ │ ├── icu_normalizer v1.5.0 +│ │ │ │ │ ├── displaydoc v0.2.5 (proc-macro) +│ │ │ │ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ │ │ └── syn v2.0.91 (*) +│ │ │ │ │ ├── icu_collections v1.5.0 +│ │ │ │ │ │ ├── displaydoc v0.2.5 (proc-macro) (*) +│ │ │ │ │ │ ├── yoke v0.7.5 +│ │ │ │ │ │ │ ├── stable_deref_trait v1.2.0 +│ │ │ │ │ │ │ ├── yoke-derive v0.7.5 (proc-macro) +│ │ │ │ │ │ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ │ │ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ │ │ │ │ ├── syn v2.0.91 (*) +│ │ │ │ │ │ │ │ └── synstructure v0.13.1 +│ │ │ │ │ │ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ │ │ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ │ │ │ │ └── syn v2.0.91 (*) +│ │ │ │ │ │ │ └── zerofrom v0.1.5 +│ │ │ │ │ │ │ └── zerofrom-derive v0.1.5 (proc-macro) +│ │ │ │ │ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ │ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ │ │ │ ├── syn v2.0.91 (*) +│ │ │ │ │ │ │ └── synstructure v0.13.1 (*) +│ │ │ │ │ │ ├── zerofrom v0.1.5 (*) +│ │ │ │ │ │ └── zerovec v0.10.4 +│ │ │ │ │ │ ├── yoke v0.7.5 (*) +│ │ │ │ │ │ ├── zerofrom v0.1.5 (*) +│ │ │ │ │ │ └── zerovec-derive v0.10.3 (proc-macro) +│ │ │ │ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ │ │ └── syn v2.0.91 (*) +│ │ │ │ │ ├── icu_normalizer_data v1.5.0 +│ │ │ │ │ ├── icu_properties v1.5.1 +│ │ │ │ │ │ ├── displaydoc v0.2.5 (proc-macro) (*) +│ │ │ │ │ │ ├── icu_collections v1.5.0 (*) +│ │ │ │ │ │ ├── icu_locid_transform v1.5.0 +│ │ │ │ │ │ │ ├── displaydoc v0.2.5 (proc-macro) (*) +│ │ │ │ │ │ │ ├── icu_locid v1.5.0 +│ │ │ │ │ │ │ │ ├── displaydoc v0.2.5 (proc-macro) (*) +│ │ │ │ │ │ │ │ ├── litemap v0.7.4 +│ │ │ │ │ │ │ │ ├── tinystr v0.7.6 +│ │ │ │ │ │ │ │ │ ├── displaydoc v0.2.5 (proc-macro) (*) +│ │ │ │ │ │ │ │ │ └── zerovec v0.10.4 (*) +│ │ │ │ │ │ │ │ ├── writeable v0.5.5 +│ │ │ │ │ │ │ │ └── zerovec v0.10.4 (*) +│ │ │ │ │ │ │ ├── icu_locid_transform_data v1.5.0 +│ │ │ │ │ │ │ ├── icu_provider v1.5.0 +│ │ │ │ │ │ │ │ ├── displaydoc v0.2.5 (proc-macro) (*) +│ │ │ │ │ │ │ │ ├── icu_locid v1.5.0 (*) +│ │ │ │ │ │ │ │ ├── icu_provider_macros v1.5.0 (proc-macro) +│ │ │ │ │ │ │ │ │ ├── proc-macro2 v1.0.92 (*) +│ │ │ │ │ │ │ │ │ ├── quote v1.0.37 (*) +│ │ │ │ │ │ │ │ │ └── syn v2.0.91 (*) +│ │ │ │ │ │ │ │ ├── stable_deref_trait v1.2.0 +│ │ │ │ │ │ │ │ ├── tinystr v0.7.6 (*) +│ │ │ │ │ │ │ │ ├── writeable v0.5.5 +│ │ │ │ │ │ │ │ ├── yoke v0.7.5 (*) +│ │ │ │ │ │ │ │ ├── zerofrom v0.1.5 (*) +│ │ │ │ │ │ │ │ └── zerovec v0.10.4 (*) +│ │ │ │ │ │ │ ├── tinystr v0.7.6 (*) +│ │ │ │ │ │ │ └── zerovec v0.10.4 (*) +│ │ │ │ │ │ ├── icu_properties_data v1.5.0 +│ │ │ │ │ │ ├── icu_provider v1.5.0 (*) +│ │ │ │ │ │ ├── tinystr v0.7.6 (*) +│ │ │ │ │ │ └── zerovec v0.10.4 (*) +│ │ │ │ │ ├── icu_provider v1.5.0 (*) +│ │ │ │ │ ├── smallvec v1.13.2 +│ │ │ │ │ ├── utf16_iter v1.0.5 +│ │ │ │ │ ├── utf8_iter v1.0.4 +│ │ │ │ │ ├── write16 v1.0.0 +│ │ │ │ │ └── zerovec v0.10.4 (*) +│ │ │ │ └── icu_properties v1.5.1 (*) +│ │ │ ├── smallvec v1.13.2 +│ │ │ └── utf8_iter v1.0.4 +│ │ └── percent-encoding v2.3.1 +│ ├── time v0.3.37 +│ │ ├── deranged v0.3.11 (*) +│ │ ├── itoa v1.0.14 +│ │ ├── libc v0.2.169 +│ │ ├── num-conv v0.1.0 +│ │ ├── num_threads v0.1.7 (*) +│ │ ├── powerfmt v0.2.0 +│ │ └── time-core v0.1.2 +│ ├── vergen v9.0.2 (*) +│ └── vergen-lib v0.1.5 (*) +│ [build-dependencies] +│ └── rustversion v1.0.18 (proc-macro) +└── vergen-gitcl v1.0.2 + ├── anyhow v1.0.95 + ├── derive_builder v0.20.2 (*) + ├── time v0.3.37 (*) + ├── vergen v9.0.2 (*) + └── vergen-lib v0.1.5 (*) [build-dependencies] - └── rustversion v1.0.14 (proc-macro) + └── rustversion v1.0.18 (proc-macro) ``` diff --git a/book/src/user/installation.md b/book/src/user/installation.md index dc792864..8358b65d 100644 --- a/book/src/user/installation.md +++ b/book/src/user/installation.md @@ -35,7 +35,7 @@ To verify it works, check if `rq` is available from your command line: ```console $ rq -V -rq 0.9.1 +rq 0.9.2 ``` diff --git a/crates/rsonpath-benchmarks/Cargo.toml b/crates/rsonpath-benchmarks/Cargo.toml index 2482614a..e5488007 100644 --- a/crates/rsonpath-benchmarks/Cargo.toml +++ b/crates/rsonpath-benchmarks/Cargo.toml @@ -4,7 +4,7 @@ authors = [ "Mateusz Gienieczko ", "Charles Paperman ", ] -version = "0.9.1" +version = "0.9.2" edition = "2021" description = "Benchmark suite for the `rsonpath` project." readme = "./README.md" @@ -34,7 +34,7 @@ lazy_static = "1.5.0" serde_json = "1.0.134" sha2 = "0.10.8" reqwest = { version = "0.12.9", features = ["blocking"] } -rsonpath-lib = { version = "0.9.1", default-features = false } +rsonpath-lib = { version = "0.9.2", default-features = false } rsonpath-syntax = { version = "0.3.1", default-features = false } serde_json_path = "0.7.1" tar = "0.4.43" diff --git a/crates/rsonpath-lib/Cargo.toml b/crates/rsonpath-lib/Cargo.toml index a3f3ae1d..f8115b58 100644 --- a/crates/rsonpath-lib/Cargo.toml +++ b/crates/rsonpath-lib/Cargo.toml @@ -1,10 +1,13 @@ [package] +version = { workspace = true } +authors = { workspace = true } +readme = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +edition = { workspace = true } name = "rsonpath-lib" -version = "0.9.1" -authors = ["Mateusz Gienieczko "] description = "Blazing fast JSONPath query engine powered by SIMD. Core library of `rsonpath`." -readme = "README.md" -license = "MIT" keywords = ["json", "jsonpath", "query", "search", "simd"] exclude = [ "/tests", @@ -13,9 +16,6 @@ exclude = [ "/src/classification/classifier_correctness_tests.proptest-regressions", ] categories = ["text-processing"] -repository = "https://github.com/V0ldek/rsonpath" -homepage = "https://v0ldek.github.io/rsonpath/" -edition = "2021" rust-version = "1.67.1" [lib] @@ -52,3 +52,6 @@ simd = [] name = "approx_spans_usage" path = "examples/approx_spans_usage.rs" doc-scrape-examples = true + +[lints] +workspace = true \ No newline at end of file diff --git a/crates/rsonpath-lib/README.md b/crates/rsonpath-lib/README.md index 3b1dca24..ccdb8c47 100644 --- a/crates/rsonpath-lib/README.md +++ b/crates/rsonpath-lib/README.md @@ -60,16 +60,15 @@ cargo tree --package rsonpath-lib --edges normal --depth 1 ```ini -rsonpath-lib v0.9.1 (/home/mat/src/rsonpath/crates/rsonpath-lib) -├── arbitrary v1.3.2 +rsonpath-lib v0.9.2 (/home/mat/src/rsonpath/crates/rsonpath-lib) +├── arbitrary v1.4.1 ├── cfg-if v1.0.0 -├── log v0.4.21 -├── memmap2 v0.9.4 -├── nom v7.1.3 +├── log v0.4.22 +├── memmap2 v0.9.5 ├── rsonpath-syntax v0.3.1 (/home/mat/src/rsonpath/crates/rsonpath-syntax) ├── smallvec v1.13.2 ├── static_assertions v1.1.0 -├── thiserror v1.0.58 +├── thiserror v2.0.9 └── vector-map v1.0.1 ``` diff --git a/crates/rsonpath-lib/examples/approx_spans_usage.rs b/crates/rsonpath-lib/examples/approx_spans_usage.rs index abbce0d0..4d1877bd 100644 --- a/crates/rsonpath-lib/examples/approx_spans_usage.rs +++ b/crates/rsonpath-lib/examples/approx_spans_usage.rs @@ -18,6 +18,7 @@ fn main() -> Result> { let query = rsonpath_syntax::parse(query_arg)?; let file = fs::File::open(file_path)?; + // SAFETY: File is kept open until end of the run. let input = unsafe { MmapInput::map_file(&file)? }; let stdout_lock = io::stdout().lock(); let mut sink = MatchWriter::from(stdout_lock); diff --git a/crates/rsonpath-lib/src/lib.rs b/crates/rsonpath-lib/src/lib.rs index 0b7538b6..396199cb 100644 --- a/crates/rsonpath-lib/src/lib.rs +++ b/crates/rsonpath-lib/src/lib.rs @@ -129,58 +129,6 @@ warn(missing_docs, clippy::missing_errors_doc, clippy::missing_panics_doc,) )] #![cfg_attr(not(debug_assertions), warn(rustdoc::missing_crate_level_docs))] -// Generic pedantic lints. -#![warn( - explicit_outlives_requirements, - semicolon_in_expressions_from_macros, - unreachable_pub, - unused_import_braces, - unused_lifetimes -)] -// Clippy pedantic lints. -#![warn( - clippy::allow_attributes_without_reason, - clippy::cargo_common_metadata, - clippy::cast_lossless, - clippy::cloned_instead_of_copied, - clippy::empty_drop, - clippy::empty_line_after_outer_attr, - clippy::equatable_if_let, - clippy::expl_impl_clone_on_copy, - clippy::explicit_deref_methods, - clippy::explicit_into_iter_loop, - clippy::explicit_iter_loop, - clippy::fallible_impl_from, - clippy::flat_map_option, - clippy::if_then_some_else_none, - clippy::inconsistent_struct_constructor, - clippy::large_digit_groups, - clippy::let_underscore_must_use, - clippy::manual_ok_or, - clippy::map_err_ignore, - clippy::map_unwrap_or, - clippy::match_same_arms, - clippy::match_wildcard_for_single_variants, - clippy::missing_inline_in_public_items, - clippy::mod_module_files, - clippy::must_use_candidate, - clippy::needless_continue, - clippy::needless_for_each, - clippy::needless_pass_by_value, - clippy::ptr_as_ptr, - clippy::redundant_closure_for_method_calls, - clippy::ref_binding_to_reference, - clippy::ref_option_ref, - clippy::rest_pat_in_fully_bound_structs, - clippy::undocumented_unsafe_blocks, - clippy::unneeded_field_pattern, - clippy::unseparated_literal_suffix, - clippy::unreadable_literal, - clippy::unused_self, - clippy::use_self -)] -// Panic-free lint. -#![warn(clippy::exit)] // Panic-free lints (disabled for tests). #![cfg_attr(not(test), warn(clippy::panic, clippy::panic_in_result_fn, clippy::unwrap_used))] // IO hygiene, only on --release. @@ -188,6 +136,7 @@ not(debug_assertions), warn(clippy::print_stderr, clippy::print_stdout, clippy::todo) )] +// Docs.rs config. #![cfg_attr(docsrs, feature(doc_cfg))] pub mod automaton; diff --git a/crates/rsonpath-lib/tests/input_implementation_tests.rs b/crates/rsonpath-lib/tests/input_implementation_tests.rs index 308426c4..2a57bb45 100644 --- a/crates/rsonpath-lib/tests/input_implementation_tests.rs +++ b/crates/rsonpath-lib/tests/input_implementation_tests.rs @@ -50,9 +50,9 @@ impl FileTestInput { fn test_on_file(&self, path: &str) { match self { - FileTestInput::Buffered => Self::test_buffered(path), - FileTestInput::Mmap => Self::test_mmap(path), - FileTestInput::Borrowed => Self::test_borrowed(path), + Self::Buffered => Self::test_buffered(path), + Self::Mmap => Self::test_mmap(path), + Self::Borrowed => Self::test_borrowed(path), } } @@ -65,7 +65,7 @@ impl FileTestInput { let file = Self::get_file(path); let input = BufferedInput::new(file); - test_equivalence(&buf, input); + test_equivalence(&buf, &input); } fn test_mmap(path: &str) { @@ -75,9 +75,10 @@ impl FileTestInput { drop(file); let file = Self::get_file(path); + // SAFETY: We keep the file open until end of this function. let input = unsafe { MmapInput::map_file(&file) }.unwrap(); - test_equivalence(&buf, input); + test_equivalence(&buf, &input); } fn test_borrowed(path: &str) { @@ -86,68 +87,56 @@ impl FileTestInput { file.read_to_end(&mut buf).unwrap(); let input = BorrowedBytes::new(&buf); - test_equivalence(&buf, input); + test_equivalence(&buf, &input); } } impl InMemoryTestInput { fn test_padding(&self, bytes: &[u8]) { match self { - InMemoryTestInput::Buffered => Self::test_padding_buffered(bytes), - InMemoryTestInput::Borrowed => Self::test_padding_borrowed(bytes), - InMemoryTestInput::Owned => Self::test_padding_owned(bytes), + Self::Buffered => Self::test_padding_buffered(bytes), + Self::Borrowed => Self::test_padding_borrowed(bytes), + Self::Owned => Self::test_padding_owned(bytes), } } fn test_seek_forward(&self, bytes: &[u8], from: usize, needle: u8, expected: usize) { match self { - InMemoryTestInput::Buffered => Self::test_seek_forward_buffered(bytes, from, needle, expected), - InMemoryTestInput::Borrowed => Self::test_seek_forward_borrowed(bytes, from, needle, expected), - InMemoryTestInput::Owned => Self::test_seek_forward_owned(bytes, from, needle, expected), + Self::Buffered => Self::test_seek_forward_buffered(bytes, from, needle, expected), + Self::Borrowed => Self::test_seek_forward_borrowed(bytes, from, needle, expected), + Self::Owned => Self::test_seek_forward_owned(bytes, from, needle, expected), } } fn test_seek_non_whitespace_forward(&self, bytes: &[u8], from: usize, expected: usize, expected_byte: u8) { match self { - InMemoryTestInput::Buffered => { - Self::test_seek_non_whitespace_forward_buffered(bytes, from, expected, expected_byte) - } - InMemoryTestInput::Borrowed => { - Self::test_seek_non_whitespace_forward_borrowed(bytes, from, expected, expected_byte) - } - InMemoryTestInput::Owned => { - Self::test_seek_non_whitespace_forward_owned(bytes, from, expected, expected_byte) - } + Self::Buffered => Self::test_seek_non_whitespace_forward_buffered(bytes, from, expected, expected_byte), + Self::Borrowed => Self::test_seek_non_whitespace_forward_borrowed(bytes, from, expected, expected_byte), + Self::Owned => Self::test_seek_non_whitespace_forward_owned(bytes, from, expected, expected_byte), } } fn test_seek_backward(&self, bytes: &[u8], from: usize, needle: u8, expected: usize) { match self { - InMemoryTestInput::Buffered => Self::test_seek_backward_buffered(bytes, from, needle, expected), - InMemoryTestInput::Borrowed => Self::test_seek_backward_borrowed(bytes, from, needle, expected), - InMemoryTestInput::Owned => Self::test_seek_backward_owned(bytes, from, needle, expected), + Self::Buffered => Self::test_seek_backward_buffered(bytes, from, needle, expected), + Self::Borrowed => Self::test_seek_backward_borrowed(bytes, from, needle, expected), + Self::Owned => Self::test_seek_backward_owned(bytes, from, needle, expected), } } fn test_seek_non_whitespace_backward(&self, bytes: &[u8], from: usize, expected: usize, expected_byte: u8) { match self { - InMemoryTestInput::Buffered => { - Self::test_seek_non_whitespace_backward_buffered(bytes, from, expected, expected_byte) - } - InMemoryTestInput::Borrowed => { - Self::test_seek_non_whitespace_backward_borrowed(bytes, from, expected, expected_byte) - } - InMemoryTestInput::Owned => { - Self::test_seek_non_whitespace_backward_owned(bytes, from, expected, expected_byte) - } + Self::Buffered => Self::test_seek_non_whitespace_backward_buffered(bytes, from, expected, expected_byte), + Self::Borrowed => Self::test_seek_non_whitespace_backward_borrowed(bytes, from, expected, expected_byte), + Self::Owned => Self::test_seek_non_whitespace_backward_owned(bytes, from, expected, expected_byte), } } - fn test_positive_is_member_match(&self, bytes: &[u8], from: usize, to: usize, json_string: StringPattern) { + fn test_positive_is_member_match(&self, bytes: &[u8], from: usize, to: usize, json_string: &StringPattern) { match self { - InMemoryTestInput::Buffered => Self::test_positive_is_member_match_buffered(bytes, from, to, json_string), - InMemoryTestInput::Borrowed => Self::test_positive_is_member_match_borrowed(bytes, from, to, json_string), - InMemoryTestInput::Owned => Self::test_positive_is_member_match_owned(bytes, from, to, json_string), + Self::Buffered => Self::test_positive_is_member_match_buffered(bytes, from, to, json_string), + Self::Borrowed => Self::test_positive_is_member_match_borrowed(bytes, from, to, json_string), + Self::Owned => Self::test_positive_is_member_match_owned(bytes, from, to, json_string), } } @@ -269,50 +258,50 @@ impl InMemoryTestInput { assert_eq!(result, Some((expected, expected_byte))); } - fn test_positive_is_member_match_buffered(bytes: &[u8], from: usize, to: usize, json_string: StringPattern) { + fn test_positive_is_member_match_buffered(bytes: &[u8], from: usize, to: usize, json_string: &StringPattern) { let input = create_buffered(bytes); - let result = input.is_member_match(from, to, &json_string).expect("match succeeds"); + let result = input.is_member_match(from, to, json_string).expect("match succeeds"); // Buffered is never padded from the start. assert!(result); } - fn test_positive_is_member_match_borrowed(bytes: &[u8], from: usize, to: usize, json_string: StringPattern) { + fn test_positive_is_member_match_borrowed(bytes: &[u8], from: usize, to: usize, json_string: &StringPattern) { let input = BorrowedBytes::new(bytes); // Need to take padding into account. let from = from + input.leading_padding_len(); let to = to + input.leading_padding_len(); - let result = input.is_member_match(from, to, &json_string).expect("match succeeds"); + let result = input.is_member_match(from, to, json_string).expect("match succeeds"); assert!(result); } - fn test_positive_is_member_match_owned(bytes: &[u8], from: usize, to: usize, json_string: StringPattern) { + fn test_positive_is_member_match_owned(bytes: &[u8], from: usize, to: usize, json_string: &StringPattern) { let input = OwnedBytes::new(bytes); // Need to take padding into account. let from = from + input.leading_padding_len(); let to = to + input.leading_padding_len(); - let result = input.is_member_match(from, to, &json_string).expect("match succeeds"); + let result = input.is_member_match(from, to, json_string).expect("match succeeds"); assert!(result); } fn test_padding_buffered(bytes: &[u8]) { let input = create_buffered(bytes); - test_equivalence(bytes, input); + test_equivalence(bytes, &input); } fn test_padding_borrowed(bytes: &[u8]) { let input = BorrowedBytes::new(bytes); - test_equivalence(bytes, input); + test_equivalence(bytes, &input); } fn test_padding_owned(bytes: &[u8]) { let input = OwnedBytes::new(bytes); - test_equivalence(bytes, input); + test_equivalence(bytes, &input); } } @@ -321,7 +310,7 @@ fn create_buffered(bytes: &[u8]) -> BufferedInput { BufferedInput::new(read) } -fn test_equivalence(original_contents: &[u8], input: I) { +fn test_equivalence(original_contents: &[u8], input: &I) { let original_length = original_contents.len(); let mut input_contents = read_input_to_end(input).unwrap(); @@ -330,11 +319,11 @@ fn test_equivalence(original_contents: &[u8], input: I) { buffered_assert_eq(&input_contents.data, original_contents); } -fn read_input_to_end(input: I) -> Result { +fn read_input_to_end(input: &I) -> Result { let mut result: Vec = vec![]; let mut iter = input.iter_blocks::<_, BLOCK_SIZE>(&EmptyRecorder); - while let Some(block) = iter.next().map_err(|x| x.into())? { + while let Some(block) = iter.next().map_err(std::convert::Into::into)? { result.extend_from_slice(&block) } @@ -503,17 +492,17 @@ mod in_memory_proptests { #[test] fn buffered_input_is_member_match_should_be_true((input, from, to, member) in positive_is_member_match_strategy()) { - InMemoryTestInput::Buffered.test_positive_is_member_match(&input, from, to, member) + InMemoryTestInput::Buffered.test_positive_is_member_match(&input, from, to, &member) } #[test] fn borrowed_input_is_member_match_should_be_true((input, from, to, member) in positive_is_member_match_strategy()) { - InMemoryTestInput::Borrowed.test_positive_is_member_match(&input, from, to, member) + InMemoryTestInput::Borrowed.test_positive_is_member_match(&input, from, to, &member) } #[test] fn owned_input_is_member_match_should_be_true((input, from, to, member) in positive_is_member_match_strategy()) { - InMemoryTestInput::Owned.test_positive_is_member_match(&input, from, to, member) + InMemoryTestInput::Owned.test_positive_is_member_match(&input, from, to, &member) } } diff --git a/crates/rsonpath-syntax/CHANGELOG.md b/crates/rsonpath-syntax/CHANGELOG.md index 8116f74f..6b346c6d 100644 --- a/crates/rsonpath-syntax/CHANGELOG.md +++ b/crates/rsonpath-syntax/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. +## [0.3.2] - 2024-12-22 + +### Dependencies + +- Bump arbitrary from 1.3.1 to 1.3.2 +- Bump owo-colors from 4.0.0 to 4.1.0 +- Bump thiserror from 1.0.57 to 2.0.9 (#617). ([#617](https://github.com/V0ldek/rsonpath/issues/617)) +- Bump unicode-width from 0.1.11 to 0.2.0 + ## [0.3.1] - 2024-03-28 ### Features diff --git a/crates/rsonpath-syntax/Cargo.toml b/crates/rsonpath-syntax/Cargo.toml index 61d9a20c..899e05c4 100644 --- a/crates/rsonpath-syntax/Cargo.toml +++ b/crates/rsonpath-syntax/Cargo.toml @@ -1,15 +1,16 @@ [package] +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +edition = { workspace = true } name = "rsonpath-syntax" -version = "0.3.1" -authors = ["Mateusz Gienieczko "] +version = "0.3.2" description = "A JSONPath parser." readme = "README.md" -license = "MIT" keywords = ["json", "jsonpath", "query", "search", "parser"] exclude = ["tests", "src/cli.rs"] categories = ["parser-implementations", "text-processing"] -repository = "https://github.com/V0ldek/rsonpath" -edition = "2021" rust-version = "1.67.1" [package.metadata.docs.rs] @@ -33,3 +34,6 @@ test-case = { workspace = true } default = [] arbitrary = ["dep:arbitrary"] color = ["dep:owo-colors"] + +[lints] +workspace = true \ No newline at end of file diff --git a/crates/rsonpath-syntax/src/lib.rs b/crates/rsonpath-syntax/src/lib.rs index cda70a08..e5c43fd5 100644 --- a/crates/rsonpath-syntax/src/lib.rs +++ b/crates/rsonpath-syntax/src/lib.rs @@ -96,58 +96,13 @@ //! see [`ParseError::colored`](error::ParseError::colored). #![forbid(unsafe_code)] -// Generic pedantic lints. -#![warn( - explicit_outlives_requirements, - semicolon_in_expressions_from_macros, - unreachable_pub, - unused_import_braces, - unused_lifetimes -)] -// Clippy pedantic lints. -#![warn( - clippy::allow_attributes_without_reason, - clippy::cargo_common_metadata, - clippy::cast_lossless, - clippy::cloned_instead_of_copied, - clippy::empty_drop, - clippy::empty_line_after_outer_attr, - clippy::equatable_if_let, - clippy::expl_impl_clone_on_copy, - clippy::explicit_deref_methods, - clippy::explicit_into_iter_loop, - clippy::explicit_iter_loop, - clippy::fallible_impl_from, - clippy::flat_map_option, - clippy::if_then_some_else_none, - clippy::inconsistent_struct_constructor, - clippy::large_digit_groups, - clippy::let_underscore_must_use, - clippy::manual_ok_or, - clippy::map_err_ignore, - clippy::map_unwrap_or, - clippy::match_same_arms, - clippy::match_wildcard_for_single_variants, - clippy::missing_inline_in_public_items, - clippy::mod_module_files, - clippy::must_use_candidate, - clippy::needless_continue, - clippy::needless_for_each, - clippy::needless_pass_by_value, - clippy::ptr_as_ptr, - clippy::redundant_closure_for_method_calls, - clippy::ref_binding_to_reference, - clippy::ref_option_ref, - clippy::rest_pat_in_fully_bound_structs, - clippy::undocumented_unsafe_blocks, - clippy::unneeded_field_pattern, - clippy::unseparated_literal_suffix, - clippy::unreadable_literal, - clippy::unused_self, - clippy::use_self +#![doc(html_logo_url = "https://raw.githubusercontent.com/V0ldek/rsonpath/main/img/rsonquery-logo.svg")] +// Documentation lints, enabled only on --release. +#![cfg_attr( + not(debug_assertions), + warn(missing_docs, clippy::missing_errors_doc, clippy::missing_panics_doc,) )] -// Panic-free lint. -#![warn(clippy::exit)] +#![cfg_attr(not(debug_assertions), warn(rustdoc::missing_crate_level_docs))] // Panic-free lints (disabled for tests). #![cfg_attr(not(test), warn(clippy::unwrap_used))] // IO hygiene, only on --release. @@ -155,15 +110,8 @@ not(debug_assertions), warn(clippy::print_stderr, clippy::print_stdout, clippy::todo) )] -// Documentation lints, enabled only on --release. -#![cfg_attr( - not(debug_assertions), - warn(missing_docs, clippy::missing_errors_doc, clippy::missing_panics_doc,) -)] -#![cfg_attr(not(debug_assertions), warn(rustdoc::missing_crate_level_docs))] // Docs.rs config. #![cfg_attr(docsrs, feature(doc_cfg))] -#![doc(html_logo_url = "https://raw.githubusercontent.com/V0ldek/rsonpath/main/img/rsonquery-logo.svg")] pub mod builder; pub mod error; diff --git a/crates/rsonpath-syntax/tests/query_parser_tests.rs b/crates/rsonpath-syntax/tests/query_parser_tests.rs index b2e92dc9..1f48e456 100644 --- a/crates/rsonpath-syntax/tests/query_parser_tests.rs +++ b/crates/rsonpath-syntax/tests/query_parser_tests.rs @@ -467,7 +467,7 @@ mod proptests { } } - pub fn any_json_string() -> impl Strategy { + pub(super) fn any_json_string() -> impl Strategy { prop_oneof![ Just(JsonStringTokenEncodingMode::SingleQuoted), Just(JsonStringTokenEncodingMode::DoubleQuoted) @@ -509,7 +509,7 @@ mod proptests { SingularSegment, TestExpr, }; - pub fn any_logical_expr( + pub(super) fn any_logical_expr( test_query_strategy: Option>, ) -> impl Strategy { any_atomic_logical_expr(test_query_strategy).prop_recursive(8, 32, 2, |inner| { @@ -659,7 +659,7 @@ mod proptests { ]; fn any_float() -> impl Strategy { - prop_oneof![num::f64::NORMAL, num::f64::NORMAL.prop_map(|f| f.trunc())] + prop_oneof![num::f64::NORMAL, num::f64::NORMAL.prop_map(f64::trunc)] } fn arbitrary_exp_repr(f: f64) -> impl Strategy { diff --git a/crates/rsonpath-test-codegen/Cargo.lock b/crates/rsonpath-test-codegen/Cargo.lock index 0f4a74e3..6848d2cd 100644 --- a/crates/rsonpath-test-codegen/Cargo.lock +++ b/crates/rsonpath-test-codegen/Cargo.lock @@ -72,7 +72,7 @@ dependencies = [ [[package]] name = "rsonpath-test-codegen" -version = "0.9.1" +version = "0.9.2" dependencies = [ "heck", "pretty_assertions", diff --git a/crates/rsonpath-test-codegen/Cargo.toml b/crates/rsonpath-test-codegen/Cargo.toml index 414b09f6..1516b78a 100644 --- a/crates/rsonpath-test-codegen/Cargo.toml +++ b/crates/rsonpath-test-codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rsonpath-test-codegen" -version = "0.9.1" +version = "0.9.2" authors = ["Mateusz Gienieczko "] description = "TOML-based test codegen for rsonpath-lib." readme = "README.md" diff --git a/crates/rsonpath-test/Cargo.toml b/crates/rsonpath-test/Cargo.toml index 595e4ef3..944dd1b7 100644 --- a/crates/rsonpath-test/Cargo.toml +++ b/crates/rsonpath-test/Cargo.toml @@ -1,14 +1,15 @@ [package] +version = { workspace = true } +authors = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +edition = { workspace = true } name = "rsonpath-test" -version = "0.9.1" -authors = ["Mateusz Gienieczko "] description = "Just a build script for the auto test generation." readme = "README.md" -license = "MIT" keywords = ["json", "jsonpath", "query", "simd", "parser"] categories = ["text-processing"] -repository = "https://github.com/V0ldek/rsonpath" -edition = "2021" rust-version = "1.70.0" publish = false diff --git a/crates/rsonpath/Cargo.toml b/crates/rsonpath/Cargo.toml index 1c919682..45b6ad7c 100644 --- a/crates/rsonpath/Cargo.toml +++ b/crates/rsonpath/Cargo.toml @@ -1,21 +1,21 @@ [package] +version = { workspace = true } +authors = { workspace = true } +readme = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +homepage = { workspace = true } +edition = { workspace = true } name = "rsonpath" -version = "0.9.1" -authors = ["Mateusz Gienieczko "] description = "Blazing fast JSONPath CLI tool powered by SIMD" -readme = "../../README.md" -license = "MIT" keywords = ["json", "jsonpath", "query", "search", "cli"] categories = [ "command-line-utilities", "text-processing", "parser-implementations", ] -repository = "https://github.com/V0ldek/rsonpath" -homepage = "https://v0ldek.github.io/rsonpath/" build = "build.rs" workspace = "../.." -edition = "2021" rust-version = "1.78.0" [[bin]] @@ -44,3 +44,6 @@ trycmd = "0.15.8" [features] default = ["simd"] simd = ["rsonpath-lib/simd"] + +[lints] +workspace = true \ No newline at end of file diff --git a/crates/rsonpath/src/args.rs b/crates/rsonpath/src/args.rs index 3eff6119..e5f801a6 100644 --- a/crates/rsonpath/src/args.rs +++ b/crates/rsonpath/src/args.rs @@ -7,7 +7,7 @@ use clap::{Parser, ValueEnum}; /// Blazing fast JSONPath CLI tool powered by SIMD. /// /// A usage guide is available at . -pub struct Args { +pub(super) struct Args { /// JSONPath query to run against the input JSON. pub query: String, /// Input JSON file to query. @@ -41,7 +41,7 @@ pub struct Args { } #[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq)] -pub enum ResultArg { +pub(super) enum ResultArg { /// Return only the number of matches. Count, /// Return a list of all bytes at which a match occurred. @@ -51,7 +51,7 @@ pub enum ResultArg { } #[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq)] -pub enum InputArg { +pub(super) enum InputArg { /// Use a memory map over a file. /// /// This is preferred by default, if available on a given platform. diff --git a/crates/rsonpath/src/error.rs b/crates/rsonpath/src/error.rs index e68cfe42..ce7b22a1 100644 --- a/crates/rsonpath/src/error.rs +++ b/crates/rsonpath/src/error.rs @@ -6,14 +6,14 @@ use rsonpath_syntax::{error::ParseError, JsonPathQuery}; const FEATURE_REQUEST_URL: &str = "https://github.com/V0ldek/rsonpath/issues/new?template=feature_request.md"; /// Turn a [`ParseError`] into a user-friendly eyre Report. -pub fn report_parser_error(error: ParseError) -> eyre::Report { +pub(super) fn report_parser_error(error: ParseError) -> eyre::Report { eyre!("One or more syntax errors occurred.").section(error.colored().header("Parse error:")) } /// Turn a [`CompilerError`] into a user-friendly eyre Report. -pub fn report_compiler_error(query: &JsonPathQuery, error: CompilerError) -> eyre::Report { +pub(super) fn report_compiler_error(query: &JsonPathQuery, error: CompilerError) -> eyre::Report { match error { - CompilerError::NotSupported(unsupported) => report_unsupported_error(unsupported), + CompilerError::NotSupported(unsupported) => report_unsupported_error(&unsupported), CompilerError::QueryTooComplex(_) => { let mut report = eyre::Report::new(error); if query.segments().iter().any(|segment| { @@ -27,73 +27,30 @@ pub fn report_compiler_error(query: &JsonPathQuery, error: CompilerError) -> eyr Consider reformulating the query using descendant selectors to replace sequences of wildcards.", ); } - add_unsupported_context(report, UnsupportedFeatureError::large_automaton_queries()) + add_unsupported_context(report, &UnsupportedFeatureError::large_automaton_queries()) } } } /// Turn a [`EngineError`] into a user-friendly eyre Report. -pub fn report_engine_error(error: EngineError) -> eyre::Report { +pub(super) fn report_engine_error(error: EngineError) -> eyre::Report { match error { - EngineError::DepthBelowZero(_, _) => eyre::Report::new(error), EngineError::DepthAboveLimit(_, _) => { - add_unsupported_context(eyre::Report::new(error), UnsupportedFeatureError::large_json_depths()) + add_unsupported_context(eyre::Report::new(error), &UnsupportedFeatureError::large_json_depths()) } - EngineError::MissingClosingCharacter() => eyre::Report::new(error), - EngineError::MissingOpeningCharacter() => eyre::Report::new(error), - EngineError::MissingItem() => eyre::Report::new(error), - EngineError::MalformedStringQuotes(_) => eyre::Report::new(error), - EngineError::NotSupported(unsupported) => report_unsupported_error(unsupported), - EngineError::InternalError(_) => eyre::Report::new(error), - EngineError::InputError(_) => eyre::Report::new(error), - EngineError::SinkError(_) => eyre::Report::new(error), + EngineError::NotSupported(unsupported) => report_unsupported_error(&unsupported), + EngineError::DepthBelowZero(_, _) + | EngineError::InputError(_) + | EngineError::InternalError(_) + | EngineError::MalformedStringQuotes(_) + | EngineError::MissingClosingCharacter() + | EngineError::MissingItem() + | EngineError::MissingOpeningCharacter() + | EngineError::SinkError(_) => eyre::Report::new(error), } } -/*fn report_query_syntax_error(query_string: &str, report: ParseErrorReport) -> eyre::Report { - let mut eyre = eyre!("One or more syntax errors occurred."); - - for error in report.errors() { - use color_eyre::owo_colors::OwoColorize; - use std::{cmp, iter}; - const MAX_DISPLAY_LENGTH: usize = 80; - - let display_start_idx = if error.start_idx > MAX_DISPLAY_LENGTH { - error.start_idx - MAX_DISPLAY_LENGTH - } else { - 0 - }; - let display_length = cmp::min(error.len + MAX_DISPLAY_LENGTH, query_string.len() - display_start_idx); - let error_slice = &query_string[error.start_idx..error.start_idx + error.len]; - let slice = &query_string[display_start_idx..display_start_idx + display_length]; - let error_idx = error.start_idx - display_start_idx; - let underline: String = iter::repeat(' ') - .take(error_idx) - .chain(iter::repeat('^').take(error.len)) - .collect(); - let display_string = format!("{}\n{}", slice, (underline + " invalid tokens").bright_red()); - - eyre = eyre.section(display_string.header("Parse error:")); - - if error.start_idx == 0 { - eyre = eyre.suggestion(format!( - "Queries should start with the root selector '{}'.", - "$".dimmed() - )); - } - - if error_slice.contains('$') { - eyre = eyre.suggestion(format!( - "The '{}' character is reserved for the root selector and may appear only at the start.", - "$".dimmed() - )); - } - } - - eyre -}*/ - -fn report_unsupported_error(unsupported: UnsupportedFeatureError) -> eyre::Report { +fn report_unsupported_error(unsupported: &UnsupportedFeatureError) -> eyre::Report { use color_eyre::owo_colors::OwoColorize; let feature = unsupported.feature(); let base_report = if unsupported.is_planned() { @@ -106,7 +63,7 @@ fn report_unsupported_error(unsupported: UnsupportedFeatureError) -> eyre::Repor add_unsupported_context(base_report, unsupported) } -fn add_unsupported_context(report: eyre::Report, unsupported: UnsupportedFeatureError) -> eyre::Report { +fn add_unsupported_context(report: eyre::Report, unsupported: &UnsupportedFeatureError) -> eyre::Report { use color_eyre::owo_colors::OwoColorize; let feature = unsupported.feature(); if let Some(issue) = unsupported.issue() { diff --git a/crates/rsonpath/src/input.rs b/crates/rsonpath/src/input.rs index 9d754a80..73f96e7a 100644 --- a/crates/rsonpath/src/input.rs +++ b/crates/rsonpath/src/input.rs @@ -8,18 +8,18 @@ use std::{ const MAX_EAGER_LEN: u64 = 1 << 20; -pub enum JsonSource { +pub(super) enum JsonSource { File(fs::File), Stdin(io::Stdin), Inline(S), } -pub enum JsonSourceRead<'a> { +pub(super) enum JsonSourceRead<'a> { File(&'a mut fs::File), Stdin(&'a mut io::Stdin), } -pub enum ResolvedInputKind { +pub(super) enum ResolvedInputKind { Mmap, Owned, Buffered, @@ -31,9 +31,9 @@ impl JsonSource { use std::os::fd::AsRawFd; match self { - JsonSource::File(f) => Some(f.as_raw_fd()), - JsonSource::Stdin(s) => Some(s.as_raw_fd()), - JsonSource::Inline(_) => None, + Self::File(f) => Some(f.as_raw_fd()), + Self::Stdin(s) => Some(s.as_raw_fd()), + Self::Inline(_) => None, } } @@ -42,17 +42,17 @@ impl JsonSource { use os::windows::io::AsRawHandle; match self { - JsonSource::File(f) => Some(f.as_raw_handle()), - JsonSource::Stdin(s) => Some(s.as_raw_handle()), - JsonSource::Inline(_) => None, + Self::File(f) => Some(f.as_raw_handle()), + Self::Stdin(s) => Some(s.as_raw_handle()), + Self::Inline(_) => None, } } pub(crate) fn try_as_read(&mut self) -> Option { match self { - JsonSource::File(f) => Some(JsonSourceRead::File(f)), - JsonSource::Stdin(s) => Some(JsonSourceRead::Stdin(s)), - JsonSource::Inline(_) => None, + Self::File(f) => Some(JsonSourceRead::File(f)), + Self::Stdin(s) => Some(JsonSourceRead::Stdin(s)), + Self::Inline(_) => None, } } } @@ -66,7 +66,7 @@ impl Read for JsonSourceRead<'_> { } } -pub fn decide_input_strategy( +pub(super) fn decide_input_strategy( source: &JsonSource, force_input: Option<&InputArg>, ) -> Result<(ResolvedInputKind, Option)> { diff --git a/crates/rsonpath/src/logger.rs b/crates/rsonpath/src/logger.rs index 1afc4a19..aa90dc3a 100644 --- a/crates/rsonpath/src/logger.rs +++ b/crates/rsonpath/src/logger.rs @@ -2,7 +2,7 @@ use color_eyre::eyre::{Result, WrapErr}; use log::LevelFilter; use simple_logger::SimpleLogger; -pub fn configure(verbose: bool) -> Result<()> { +pub(super) fn configure(verbose: bool) -> Result<()> { SimpleLogger::new() .with_level(if verbose { LevelFilter::Trace } else { LevelFilter::Warn }) .init() diff --git a/crates/rsonpath/src/runner.rs b/crates/rsonpath/src/runner.rs index 1330ccbb..cae2edb6 100644 --- a/crates/rsonpath/src/runner.rs +++ b/crates/rsonpath/src/runner.rs @@ -17,7 +17,7 @@ use std::{ path::Path, }; -pub struct Runner { +pub(super) struct Runner { pub with_compiled_query: Automaton, pub with_engine: ResolvedEngine, pub with_input: ResolvedInput, @@ -25,7 +25,7 @@ pub struct Runner { } impl> Runner { - pub fn run(self) -> Result<()> { + pub(super) fn run(self) -> Result<()> { match self.with_engine { ResolvedEngine::Main => { let engine = MainEngine::from_compiled_query(self.with_compiled_query); @@ -37,7 +37,7 @@ impl> Runner { } } -pub fn resolve_input, S: AsRef>( +pub(super) fn resolve_input, S: AsRef>( file_path: Option

, inline_json: Option, force_input: Option<&InputArg>, @@ -58,7 +58,7 @@ pub fn resolve_input, S: AsRef>( }) } -pub fn resolve_output(result_arg: ResultArg) -> ResolvedOutput { +pub(super) fn resolve_output(result_arg: ResultArg) -> ResolvedOutput { match result_arg { ResultArg::Indices => ResolvedOutput::Index, ResultArg::Count => ResolvedOutput::Count, @@ -66,21 +66,21 @@ pub fn resolve_output(result_arg: ResultArg) -> ResolvedOutput { } } -pub fn resolve_engine() -> ResolvedEngine { +pub(super) fn resolve_engine() -> ResolvedEngine { ResolvedEngine::Main } -pub enum ResolvedEngine { +pub(super) enum ResolvedEngine { Main, } -pub struct ResolvedInput { +pub(super) struct ResolvedInput { file: JsonSource, kind: ResolvedInputKind, fallback_kind: Option, } -pub enum ResolvedOutput { +pub(super) enum ResolvedOutput { Count, Index, Nodes, @@ -94,17 +94,19 @@ impl> ResolvedInput { .file .try_as_raw_desc() .ok_or_else(|| eyre::eyre!("Attempt to create a memory map on inline JSON input."))?; + // SAFETY: The file is open for at least as long as self exists, so the fd should remain valid + // throughout this function. let mmap_result = unsafe { MmapInput::map_file(raw_desc) }; match mmap_result { - Ok(input) => with_output.run_and_output(engine, input), + Ok(input) => with_output.run_and_output(&engine, &input), Err(err) => match self.fallback_kind { Some(fallback_kind) => { warn!( "Creating a memory map failed: '{}'. Falling back to a slower input strategy.", err ); - let new_input = ResolvedInput { + let new_input = Self { kind: fallback_kind, fallback_kind: None, file: self.file, @@ -120,16 +122,16 @@ impl> ResolvedInput { JsonSource::File(f) => { let contents = get_contents(f)?; let input = OwnedBytes::new(contents.into_bytes()); - with_output.run_and_output(engine, input) + with_output.run_and_output(&engine, &input) } JsonSource::Stdin(s) => { let contents = get_contents(s)?; let input = OwnedBytes::new(contents.into_bytes()); - with_output.run_and_output(engine, input) + with_output.run_and_output(&engine, &input) } JsonSource::Inline(j) => { let input = BorrowedBytes::new(j.as_ref().as_bytes()); - with_output.run_and_output(engine, input) + with_output.run_and_output(&engine, &input) } }, ResolvedInputKind::Buffered => { @@ -138,34 +140,34 @@ impl> ResolvedInput { .try_as_read() .ok_or_else(|| eyre::eyre!("Attempt to buffer reads on inline JSON input."))?; let input = BufferedInput::new(read); - with_output.run_and_output(engine, input) + with_output.run_and_output(&engine, &input) } } } } impl ResolvedOutput { - fn run_and_output(self, engine: E, input: I) -> Result<()> { - fn run_impl(out: ResolvedOutput, engine: E, input: I) -> Result<(), EngineError> { + fn run_and_output(self, engine: &E, input: &I) -> Result<()> { + fn run_impl(out: &ResolvedOutput, engine: &E, input: &I) -> Result<(), EngineError> { match out { ResolvedOutput::Count => { - let result = engine.count(&input)?; + let result = engine.count(input)?; print!("{result}"); } ResolvedOutput::Index => { let mut sink = MatchWriter::from(io::stdout().lock()); - engine.indices(&input, &mut sink)?; + engine.indices(input, &mut sink)?; } ResolvedOutput::Nodes => { let mut sink = MatchWriter::from(io::stdout().lock()); - engine.matches(&input, &mut sink)?; + engine.matches(input, &mut sink)?; } } Ok(()) } - run_impl(self, engine, input).map_err(|err| report_engine_error(err).wrap_err("Error executing the query.")) + run_impl(&self, engine, input).map_err(|err| report_engine_error(err).wrap_err("Error executing the query.")) } } diff --git a/crates/rsonpath/src/version.rs b/crates/rsonpath/src/version.rs index 4d475b8e..1ae91726 100644 --- a/crates/rsonpath/src/version.rs +++ b/crates/rsonpath/src/version.rs @@ -2,7 +2,7 @@ use std::sync::OnceLock; static LONG_VERSION: OnceLock = OnceLock::new(); -pub fn get_long_version() -> &'static str { +pub(super) fn get_long_version() -> &'static str { LONG_VERSION.get_or_init(|| { let mut res = env!("CARGO_PKG_VERSION").to_owned(); let simd = rsonpath_lib::classification::describe_simd(); diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 8667c2bc..6f2525f1 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -205,7 +205,7 @@ dependencies = [ [[package]] name = "rsonpath-lib" -version = "0.9.1" +version = "0.9.2" dependencies = [ "arbitrary", "cfg-if", @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "rsonpath-syntax" -version = "0.3.1" +version = "0.3.2" dependencies = [ "arbitrary", "nom", @@ -268,9 +268,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" dependencies = [ "itoa", "memchr", diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index f6027a98..22a7390b 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -11,7 +11,7 @@ cargo-fuzz = true arbitrary = { version = "1.4.*", features = ["derive"] } libfuzzer-sys = { version = "0.4.8" } serde = "1.0.216" -serde_json = "1.0.133" +serde_json = "1.0.134" [dependencies.rsonpath-lib] path = "../crates/rsonpath-lib"