Trait LayerResolver

Source
pub trait LayerResolver {
    type Error;

    // Required method
    fn load(&mut self, key: &str) -> Result<Option<Vec<u8>>, Self::Error>;

    // Provided method
    fn key(
        &mut self,
        uri: &str,
        importer: Option<&str>,
    ) -> Result<String, Self::Error> { ... }
}
Expand description

Finds and loads layers for a LayerStackBuilder.

Resolution happens in two steps so that a layer imported from several places loads once: key turns an import uri into a key that identifies the layer, and load returns the bytes for a key that is not loaded yet. Integrity is checked against exactly these bytes.

Required Associated Types§

Source

type Error

Failure other than a missing layer, such as an I/O error.

Required Methods§

Source

fn load(&mut self, key: &str) -> Result<Option<Vec<u8>>, Self::Error>

Returns the bytes of the layer with this key, or Ok(None) when there is no such layer.

Provided Methods§

Source

fn key( &mut self, uri: &str, importer: Option<&str>, ) -> Result<String, Self::Error>

Identifies the layer that uri names. importer is the key of the layer whose imports list uri, or None for the main layer, so relative references can resolve against it.

The default uses uri unchanged, as upstream’s providers do.

Implementations on Foreign Types§

Source§

impl<R: LayerResolver + ?Sized> LayerResolver for &mut R

Source§

type Error = <R as LayerResolver>::Error

Source§

fn key( &mut self, uri: &str, importer: Option<&str>, ) -> Result<String, Self::Error>

Source§

fn load(&mut self, key: &str) -> Result<Option<Vec<u8>>, Self::Error>

Implementors§