macro_rules! rumtk_pipeline_run_async {
( $pipeline:expr ) => { ... };
( $pipeline:expr, $data:expr ) => { ... };
}Expand description
This macro is similar to rumtk_pipeline_quick_run_async. The difference here is that the function takes a pipeline structure (RUMCommandLine) In other words, this macro simply runs an already defined pipeline.
§Example
use rumtk_core::{rumtk_pipeline_command, rumtk_pipeline_run_async, rumtk_resolve_task, rumtk_init_threads};
use rumtk_core::base::{RUMResult};
use rumtk_core::strings::RUMStringConversions;
use rumtk_core::buffers::*;
let f = async || -> RUMResult<RUMBuffer> {
let pipeline = vec![
rumtk_pipeline_command!("ls"),
rumtk_pipeline_command!("wc")
];
rumtk_pipeline_run_async!(&pipeline).await
};
rumtk_resolve_task!(f()).unwrap();§Pipe Buffer to Pipeline
use rumtk_core::{rumtk_pipeline_command, rumtk_pipeline_run_async, rumtk_resolve_task, rumtk_spawn_task};
use rumtk_core::base::RUMResult;
use rumtk_core::buffers::*;
use rumtk_core::buffers::{buffer_to_string};
use rumtk_core::strings::{string_to_buffer};
const data: &str = "Hello World!";
const expected: &str = " 0 2 12\n";
let task = rumtk_spawn_task!(async {
let input = RUMBuffer::from("Hello World!");
let mut pipeline = vec![
rumtk_pipeline_command!("wc")
];
rumtk_pipeline_run_async!(&pipeline, &input).await
});
let result = buffer_to_string(&rumtk_resolve_task!(task).unwrap().unwrap()).unwrap();
assert_eq!(result, expected, "Buffer correctly piped into pipeline!");§Pipe String to Pipeline
use rumtk_core::{rumtk_pipeline_command, rumtk_pipeline_run_async, rumtk_resolve_task, rumtk_spawn_task};
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 task = rumtk_spawn_task!(async {
let input = string_to_buffer(data);
let mut pipeline = vec![
rumtk_pipeline_command!("wc")
];
rumtk_pipeline_run_async!(&pipeline, &input).await
});
let result = buffer_to_string(&rumtk_resolve_task!(task).unwrap().unwrap()).unwrap();
assert_eq!(result, expected, "String correctly piped into pipeline!");