-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move From impls from hashing to bazel_protos (#5706)
hashing should be a nice quick/easy/small thing to compile, which shouldn't rely on protocol buffer compilation because it just has a couple of value types in. bazel_protos already needs to depend on protocol buffer compilation.
- Loading branch information
1 parent
326da57
commit b9d3ef7
Showing
7 changed files
with
61 additions
and
53 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
src/*.rs | ||
!src/conversions.rs | ||
!src/lib.rs | ||
!src/verification.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/rust/engine/process_execution/bazel_protos/src/conversions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use hashing; | ||
|
||
impl<'a> From<&'a hashing::Digest> for super::remote_execution::Digest { | ||
fn from(d: &hashing::Digest) -> Self { | ||
let mut digest = super::remote_execution::Digest::new(); | ||
digest.set_hash(d.0.to_hex()); | ||
digest.set_size_bytes(d.1 as i64); | ||
digest | ||
} | ||
} | ||
|
||
impl<'a> From<&'a super::remote_execution::Digest> for hashing::Digest { | ||
fn from(d: &super::remote_execution::Digest) -> Self { | ||
hashing::Digest( | ||
hashing::Fingerprint::from_hex_string(d.get_hash()).expect("Bad fingerprint in Digest"), | ||
d.get_size_bytes() as usize, | ||
) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use hashing; | ||
|
||
#[test] | ||
fn from_our_digest() { | ||
let our_digest = &hashing::Digest( | ||
hashing::Fingerprint::from_hex_string( | ||
"0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff", | ||
).unwrap(), | ||
10, | ||
); | ||
let converted: super::super::remote_execution::Digest = our_digest.into(); | ||
let mut want = super::super::remote_execution::Digest::new(); | ||
want.set_hash("0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff".to_owned()); | ||
want.set_size_bytes(10); | ||
assert_eq!(converted, want); | ||
} | ||
|
||
#[test] | ||
fn from_bazel_digest() { | ||
let mut bazel_digest = super::super::remote_execution::Digest::new(); | ||
bazel_digest | ||
.set_hash("0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff".to_owned()); | ||
bazel_digest.set_size_bytes(10); | ||
let converted: hashing::Digest = (&bazel_digest).into(); | ||
let want = hashing::Digest( | ||
hashing::Fingerprint::from_hex_string( | ||
"0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff", | ||
).unwrap(), | ||
10, | ||
); | ||
assert_eq!(converted, want); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters