Trait spirit::fragment::Extractor[][src]

pub trait Extractor<'a, O, C> {
    type Fragment: Fragment + 'a;
    fn extract(&mut self, opts: &'a O, config: &'a C) -> Self::Fragment;
}
Expand description

A trait describing something that extracts a fragment from configuration and command line options.

The extractor is used every time a Pipeline is triggered, to get the fragment out.

Usually, an extractor is a closure, but something else can implement the trait too.

Users usually don’t need to interact with this trait directly.

Note that the extractor is lifetime-parametric. Usually the real extractor implements the trait for all lifetimes (and it is not useful otherwise). This allows returning references into the configuration, the Pipeline is able to work with that (given new enough rustc ‒ there were some bugs preventing it from working; if that’s the case, you can clone and return owned values).

Associated Types

The fragment being extracted.

Required methods

The actual call of the extractor.

The extractor is allowed to either reference into the configuration (or command line options) or create something new out of it (including structures containing references there).

It is not uncommon to combine information from both to form a fragment.

Implementors