Skip to main content

Snapshot

Struct Snapshot 

Source
pub struct Snapshot;
Expand description

Snapshot comparison utilities.

Implementations§

Source§

impl Snapshot

Source

pub fn assert_match(name: &str, actual: &Image, threshold: f64)

Compare an actual image against a baseline snapshot.

§Panics

Panics if the difference exceeds the threshold.

Source

pub fn diff(a: &Image, b: &Image) -> f64

Calculate difference ratio between two images (byte-level).

Source

pub fn perceptual_diff(a: &Image, b: &Image) -> f64

Calculate perceptual difference (color distance per pixel). Returns mean squared error normalized to 0.0-1.0.

Source

pub fn generate_diff_image(a: &Image, b: &Image) -> Image

Generate a difference image highlighting changed pixels.

Source

pub fn compare(a: &Image, b: &Image) -> ComparisonResult

Perform a comprehensive comparison between two images.

Source

pub fn count_changed_pixels(a: &Image, b: &Image) -> u64

Count the number of pixels that differ between two images.

Source

pub fn ssim(a: &Image, b: &Image) -> f64

Calculate Structural Similarity Index (SSIM).

Simplified implementation of SSIM that considers luminance similarity. Returns 1.0 for identical images, 0.0 for completely different.

Source

pub fn compare_region( a: &Image, b: &Image, x: u32, y: u32, width: u32, height: u32, ) -> ComparisonResult

Compare a region of two images.

Source

pub fn assert_region_match( name: &str, actual: &Image, baseline: &Image, x: u32, y: u32, width: u32, height: u32, threshold: f64, )

Assert that a region matches within threshold.

§Panics

Panics if the region difference exceeds the threshold.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.