Inspired by pipeline.rs by Johann Hoffmann (@johannhof).