Skip to main content

rumtk_pipeline_run

Macro rumtk_pipeline_run 

Source
macro_rules! rumtk_pipeline_run {
    ( $pipeline:expr ) => { ... };
    ( $pipeline:expr, $data:expr ) => { ... };
}
Expand description

This macro is similar to rumtk_pipeline_quick_run. The difference here is that the function takes a pipeline structure (RUMCommandLine) In other words, this macro simply runs an already defined pipeline.

§Example

§Run the pipeline

use rumtk_core::{rumtk_pipeline_command, rumtk_pipeline_run, rumtk_resolve_task, rumtk_init_threads};
use rumtk_core::base::{RUMResult};
use rumtk_core::strings::RUMStringConversions;
use rumtk_core::buffers::*;

let f = || -> RUMResult<RUMBuffer> {
    let pipeline = vec![
        rumtk_pipeline_command!("ls"),
        rumtk_pipeline_command!("wc")
    ];
 
    rumtk_pipeline_run!(&pipeline)
};
 
f().unwrap();

§Pipe Buffer to Pipeline

use rumtk_core::{rumtk_pipeline_command, rumtk_pipeline_run};
use rumtk_core::base::RUMResult;
use rumtk_core::buffers::*;
use rumtk_core::strings::{string_to_buffer};
use rumtk_core::buffers::{buffer_to_string};

const data: &str = "Hello World!";
const expected: &str = "      0       2      12\n";


let f = |input: &RUMBuffer| -> RUMResult<RUMBuffer> {
    let mut pipeline = vec![
        rumtk_pipeline_command!("wc")
    ];

    rumtk_pipeline_run!(&pipeline, &input)
};
let result = buffer_to_string(&f(&string_to_buffer(data)).unwrap()).unwrap();

assert_eq!(result, expected, "Buffer correctly piped into pipeline!");

§Pipe String to Pipeline

use rumtk_core::{rumtk_pipeline_command, rumtk_pipeline_run};
use rumtk_core::base::RUMResult;
use rumtk_core::strings::{string_to_buffer};
use rumtk_core::buffers::{buffer_to_string};
use rumtk_core::buffers::*;

const data: &str = "Hello World!";
const expected: &str = "      0       2      12\n";


let f = |input: &str| -> RUMResult<RUMBuffer> {
    let mut pipeline = vec![
        rumtk_pipeline_command!("wc")
    ];

    rumtk_pipeline_run!(&pipeline, &string_to_buffer(input))
};
let result = buffer_to_string(&f(data).unwrap()).unwrap();

assert_eq!(result, expected, "String correctly piped into pipeline!");