Skip to content
Merged
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
57 changes: 28 additions & 29 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/plotnik-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rowan = "0.16.1"
rustc-hash = "2"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
sha2 = "0.10.9"
sha2 = "0.11.0"
thiserror = "2.0.17"
topological-sort = "0.2"
tree-sitter = { version = "0.26.10", optional = true }
Expand Down
10 changes: 9 additions & 1 deletion crates/plotnik-lib/src/core/grammar/identity.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Provenance for one exact `grammar.json` artifact.

use std::fmt::Write as _;

use sha2::{Digest, Sha256};

/// Exact grammar artifact used to bind a query.
Expand All @@ -19,9 +21,15 @@ impl GrammarIdentity {
grammar_json: &[u8],
source: impl Into<String>,
) -> Self {
let digest = Sha256::digest(grammar_json);
let mut sha256 = String::with_capacity(digest.len() * 2);
for byte in digest {
write!(&mut sha256, "{byte:02x}").expect("writing to a String cannot fail");
}

Self {
name: name.into(),
sha256: format!("{:x}", Sha256::digest(grammar_json)),
sha256,
source: source.into(),
}
}
Expand Down
57 changes: 28 additions & 29 deletions examples/arborium/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading