pub trait Provider {
    fn provide<'a>(&'a self, demand: &mut Demand<'a>);
}
Available on nightly only.
Expand description

Trait implemented by a type which can dynamically provide values based on type.

Required Methods

Data providers should implement this method to provide all values they are able to provide by using demand.

Examples

Provides a reference to a field with type String as a &str.

use error_stack::provider::{Demand, Provider};

impl Provider for SomeConcreteType {
    fn provide<'a>(&'a self, demand: &mut Demand<'a>) {
        demand.provide_ref::<str>(&self.field);
    }
}

Implementors