pub struct Environment { /* private fields */ }Expand description
Represents a single data pipeline configuration environment to run
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn from_config(config: &str) -> Result<Self, Error>
pub fn from_config(config: &str) -> Result<Self, Error>
The function takes the raw configuration of the data pipeline and registers built-in plugins, validates the configuration and returns the Environment to run.
use fiddler::Environment;
let conf_str = r#"input:
stdin: {}
pipeline:
processors:
- label: my_cool_mapping
noop: {}
output:
stdout: {}"#;
let env = Environment::from_config(conf_str).unwrap();Sourcepub fn set_label(&mut self, label: Option<String>) -> Result<(), Error>
pub fn set_label(&mut self, label: Option<String>) -> Result<(), Error>
The function sets the data pipeline with a label.
env.set_label(Some("MyPipeline".into())).unwrap();or to remove a given label:
env.set_label(None).unwrap();Sourcepub fn get_label(&self) -> Option<String>
pub fn get_label(&self) -> Option<String>
The function returns the currect label assigned to the pipeline
assert_eq!(env.get_label().unwrap(), "MyPipeline".to_string());Sourcepub fn set_input(&mut self, input: &HashMap<String, Value>) -> Result<(), Error>
pub fn set_input(&mut self, input: &HashMap<String, Value>) -> Result<(), Error>
The function replaces the existing input configuration with the provided input.
use serde_yaml::Value;
let conf_str = r#"file:
filename: tests/data/input.txt
codec: ToEnd"#;
let parsed_input: HashMap<String, Value> = serde_yaml::from_str(conf_str).unwrap();
env.set_input(&parsed_input).unwrap()Sourcepub fn set_output(
&mut self,
output: &HashMap<String, Value>,
) -> Result<(), Error>
pub fn set_output( &mut self, output: &HashMap<String, Value>, ) -> Result<(), Error>
The function replaces the existing output configuration with the provided output.
use serde_yaml::Value;
let conf_str = r#"stdout: {}"#;
let parsed_output: HashMap<String, Value> = serde_yaml::from_str(conf_str).unwrap();
env.set_output(&parsed_output).unwrap()Auto Trait Implementations§
impl Freeze for Environment
impl !RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl !UnwindSafe for Environment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more