Skip to main content

CostProvider

Trait CostProvider 

Source
pub trait CostProvider {
    type Error;

    // Required method
    fn compute<'img>(
        &self,
        image: &'img ImageBuffer,
    ) -> Result<CostMap<'img>, Self::Error>;
}
Expand description

A model that assigns an embedding cost to every pixel of a container image.

The trait exists so that the pipeline can be generic over the cost model: hill::HillCostProvider is the only implementation today, but the layers above never name it.

Required Associated Types§

Source

type Error

How this model reports an image it refuses to work with.

Required Methods§

Source

fn compute<'img>( &self, image: &'img ImageBuffer, ) -> Result<CostMap<'img>, Self::Error>

Computes the cost map of image.

The returned map borrows image for 'img, which freezes its samples until the map is dropped; see CostMap.

§Errors

Returns Self::Error when the image is unsuitable as a container. A cost model is entitled to refuse an image outright: producing a map for a container that cannot hide anything safely would only move the failure downstream, past the point where it can still be explained to the user.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§