summaryrefslogtreecommitdiffstats
path: root/src/loader.rs
blob: 9aae9c80dd8472f678f1c5222abe048f8e3c81fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/// Helper trait to load something and then postprocess it
///
/// the load() function might fail, but the PostProcessor::postprocess() function should never fail.
pub trait Loader {
    type Output: Sized;
    type Error: Sized;
    type PostProcessedOutput: Sized;
    type PostProcessor: PostProcessor<Self::Output, Output = Self::PostProcessedOutput>;

    fn load(self) -> Result<Self::Output, Self::Error>;
    fn postprocessor(&self, load_name: String) -> Self::PostProcessor;
}

pub trait PostProcessor<Object: Sized> {
    type Output: Sized;

    fn postprocess(&self, o: Object) -> Self::Output;
}