|
1 | 1 | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
|
2 | 2 | // Licensed under the Apache License, Version 2.0 (see LICENSE).
|
3 | 3 |
|
4 |
| -extern crate bazel_protos; |
5 | 4 | extern crate digest;
|
6 | 5 | extern crate hex;
|
7 | 6 | extern crate sha2;
|
@@ -79,24 +78,6 @@ impl AsRef<[u8]> for Fingerprint {
|
79 | 78 | #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
|
80 | 79 | pub struct Digest(pub Fingerprint, pub usize);
|
81 | 80 |
|
82 |
| -impl<'a> From<&'a Digest> for bazel_protos::remote_execution::Digest { |
83 |
| - fn from(d: &Digest) -> Self { |
84 |
| - let mut digest = bazel_protos::remote_execution::Digest::new(); |
85 |
| - digest.set_hash(d.0.to_hex()); |
86 |
| - digest.set_size_bytes(d.1 as i64); |
87 |
| - digest |
88 |
| - } |
89 |
| -} |
90 |
| - |
91 |
| -impl<'a> From<&'a bazel_protos::remote_execution::Digest> for Digest { |
92 |
| - fn from(d: &bazel_protos::remote_execution::Digest) -> Self { |
93 |
| - Digest( |
94 |
| - Fingerprint::from_hex_string(d.get_hash()).expect("Bad fingerprint in Digest"), |
95 |
| - d.get_size_bytes() as usize, |
96 |
| - ) |
97 |
| - } |
98 |
| -} |
99 |
| - |
100 | 81 | ///
|
101 | 82 | /// A Write instance that fingerprints all data that passes through it.
|
102 | 83 | ///
|
@@ -136,7 +117,7 @@ impl<W: Write> Write for WriterHasher<W> {
|
136 | 117 |
|
137 | 118 | #[cfg(test)]
|
138 | 119 | mod fingerprint_tests {
|
139 |
| - use super::{bazel_protos, Digest, Fingerprint}; |
| 120 | + use super::Fingerprint; |
140 | 121 |
|
141 | 122 | #[test]
|
142 | 123 | fn from_bytes_unsafe() {
|
@@ -204,35 +185,4 @@ mod fingerprint_tests {
|
204 | 185 | hex.to_lowercase()
|
205 | 186 | )
|
206 | 187 | }
|
207 |
| - |
208 |
| - #[test] |
209 |
| - fn from_our_digest() { |
210 |
| - let our_digest = &Digest( |
211 |
| - Fingerprint::from_hex_string( |
212 |
| - "0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff", |
213 |
| - ).unwrap(), |
214 |
| - 10, |
215 |
| - ); |
216 |
| - let converted: bazel_protos::remote_execution::Digest = our_digest.into(); |
217 |
| - let mut want = bazel_protos::remote_execution::Digest::new(); |
218 |
| - want.set_hash("0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff".to_owned()); |
219 |
| - want.set_size_bytes(10); |
220 |
| - assert_eq!(converted, want); |
221 |
| - } |
222 |
| - |
223 |
| - #[test] |
224 |
| - fn from_bazel_digest() { |
225 |
| - let mut bazel_digest = bazel_protos::remote_execution::Digest::new(); |
226 |
| - bazel_digest |
227 |
| - .set_hash("0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff".to_owned()); |
228 |
| - bazel_digest.set_size_bytes(10); |
229 |
| - let converted: Digest = (&bazel_digest).into(); |
230 |
| - let want = Digest( |
231 |
| - Fingerprint::from_hex_string( |
232 |
| - "0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff", |
233 |
| - ).unwrap(), |
234 |
| - 10, |
235 |
| - ); |
236 |
| - assert_eq!(converted, want); |
237 |
| - } |
238 | 188 | }
|
0 commit comments