pub trait Comparator:
Send
+ Sync
+ 'static {
// Required methods
fn matches(&self, reference: &Snapshot, test: &Snapshot) -> bool;
fn dyn_clone(&self) -> Box<dyn Comparator>;
// Provided method
fn matches_fully(&self, reference: &Snapshot, test: &Snapshot) -> bool { ... }
}Expand description
Allows specific behavior to be invoked when Snapshots are compared.
This is intended for when custom Snapshot comparison behavior is
desired. For example, two binary files that contain the same logical data
but have different representations on disk (as might be the case with
compressed images) could be compared with a Comparator that decompresses
Snapshot data before comparing it.
To make a custom Comparator active, pass it to
crate::settings::Settings::set_comparator or call with_settings! and
provide an appropriate Comparator instance.
This trait requires 'static so that implementing structs can be stored in
crate::settings::Settings.
Required Methods§
Sourcefn matches(&self, reference: &Snapshot, test: &Snapshot) -> bool
fn matches(&self, reference: &Snapshot, test: &Snapshot) -> bool
Returns true if the contents of reference and test match.
This is the standard comparison used by assert_snapshot!.
Sourcefn dyn_clone(&self) -> Box<dyn Comparator>
fn dyn_clone(&self) -> Box<dyn Comparator>
Returns a type-erased clone of self.
This is needed so that crate::settings::Settings (which provides the
usual mechanism for setting a custom Comparator) can implement
Clone.