pub struct BinaryGolden { /* private fields */ }Expand description
A binary-content snapshot bound to a path on disk.
Like Golden but for arbitrary byte content. Useful for verifying
generated images, archives, encoded protocol frames, etc.
On mismatch, the diff is reported as byte-length deltas and a hex preview of the first differing region — not a line-based diff, because binary content has no meaningful line structure.
Set the DEV_FIXTURES_UPDATE_GOLDEN environment variable to update
snapshots on intentional changes.
§Example
use dev_fixtures::golden::BinaryGolden;
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("snap.bin");
std::fs::write(&path, &[0u8, 1, 2, 3]).unwrap();
let g = BinaryGolden::new(&path);
let check = g.compare("frame", &[0u8, 1, 2, 3]);
assert!(matches!(check.verdict, dev_report::Verdict::Pass));Implementations§
Source§impl BinaryGolden
impl BinaryGolden
Sourcepub fn compare(&self, name: impl AsRef<str>, actual: &[u8]) -> CheckResult
pub fn compare(&self, name: impl AsRef<str>, actual: &[u8]) -> CheckResult
Compare actual against the stored snapshot and emit a
CheckResult tagged fixtures and golden.
Verdicts mirror Golden::compare:
- Match ->
Pass. - Missing ->
Skipwithcreatedtag (snapshot is written). - Mismatch +
DEV_FIXTURES_UPDATE_GOLDENset ->Skipwithupdated. - Mismatch ->
Fail (Error)withregressiontag, byte-length and first-diff-offset evidence.
Auto Trait Implementations§
impl Freeze for BinaryGolden
impl RefUnwindSafe for BinaryGolden
impl Send for BinaryGolden
impl Sync for BinaryGolden
impl Unpin for BinaryGolden
impl UnsafeUnpin for BinaryGolden
impl UnwindSafe for BinaryGolden
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more