|
@ -100,15 +100,51 @@ impl<'a, R> SymbolRunner for ReportingSymbolRunner<'a, R> where R: SymbolRunner |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub struct RequirementsResolvingSymbolRunner<'s, R: 's + SymbolRunner, G: 's + SymbolRepository<'s>>(&'s R, &'s G);
|
|
|
|
|
|
|
|
|
use std::cell::RefCell;
|
|
|
|
|
|
use std::collections::HashSet;
|
|
|
|
|
|
use resources::Resource;
|
|
|
|
|
|
|
|
|
|
|
|
pub struct NonRepeatingSymbolRunner<'a, R> where R: 'a + SymbolRunner {
|
|
|
|
|
|
upstream: &'a R,
|
|
|
|
|
|
done: RefCell<HashSet<Resource>>
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<'a, R> NonRepeatingSymbolRunner<'a, R> where R: SymbolRunner {
|
|
|
|
|
|
pub fn new(symbol_runner: &'a R) -> Self {
|
|
|
|
|
|
NonRepeatingSymbolRunner{ upstream: symbol_runner, done: RefCell::new(HashSet::new()) }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<'a, R> SymbolRunner for NonRepeatingSymbolRunner<'a, R> where R: SymbolRunner {
|
|
|
|
|
|
fn run_symbol<S: ?Sized + Symbol + fmt::Display>(&self, logger: &mut Logger, symbol: &S) -> Result<(), Box<Error>>
|
|
|
|
|
|
{
|
|
|
|
|
|
if let Some(resources) = symbol.provides() {
|
|
|
|
|
|
let mut done = self.done.borrow_mut();
|
|
|
|
|
|
let mut has_to_run = false;
|
|
|
|
|
|
for resource in resources {
|
|
|
|
|
|
if !done.contains(&resource) {
|
|
|
|
|
|
has_to_run = true;
|
|
|
|
|
|
done.insert(resource.clone());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if !has_to_run {
|
|
|
|
|
|
return Ok(());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
self.upstream.run_symbol(logger, &*symbol)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
use std::marker::PhantomData;
|
|
|
|
|
|
|
|
|
|
|
|
pub struct RequirementsResolvingSymbolRunner<'a, 's, R: 'a + SymbolRunner, G: 'a + SymbolRepository<'s>>(&'a R, &'a G, PhantomData<Box<Symbol + 's>>);
|
|
|
|
|
|
|
|
|
impl<'s, R, G> RequirementsResolvingSymbolRunner<'s, R, G> where R: SymbolRunner, G: SymbolRepository<'s> {
|
|
|
|
|
|
pub fn new(symbol_runner: &'s R, symbol_repo: &'s G) -> Self {
|
|
|
|
|
|
RequirementsResolvingSymbolRunner(symbol_runner, symbol_repo)
|
|
|
|
|
|
|
|
|
impl<'a, 's, R, G> RequirementsResolvingSymbolRunner<'a, 's, R, G> where R: SymbolRunner, G: SymbolRepository<'s> {
|
|
|
|
|
|
pub fn new(symbol_runner: &'a R, symbol_repo: &'a G) -> Self {
|
|
|
|
|
|
RequirementsResolvingSymbolRunner(symbol_runner, symbol_repo, PhantomData)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<'s, R, G> SymbolRunner for RequirementsResolvingSymbolRunner<'s, R, G> where R: SymbolRunner, G: SymbolRepository<'s> {
|
|
|
|
|
|
|
|
|
impl<'a, 's, R, G> SymbolRunner for RequirementsResolvingSymbolRunner<'a, 's, R, G> where R: SymbolRunner, G: SymbolRepository<'s> {
|
|
|
fn run_symbol<S: ?Sized + Symbol + fmt::Display>(&self, logger: &mut Logger, symbol: &S) -> Result<(), Box<Error>>
|
|
|
fn run_symbol<S: ?Sized + Symbol + fmt::Display>(&self, logger: &mut Logger, symbol: &S) -> Result<(), Box<Error>>
|
|
|
{
|
|
|
{
|
|
|
for resource in symbol.get_prerequisites() {
|
|
|
for resource in symbol.get_prerequisites() {
|
|
|