Function srgn::apply

source ·
pub fn apply<'viewee>(
    input: &'viewee str,
    scopers: &[Box<dyn ScopedViewBuildStep>],
    actions: &[Box<dyn Action>]
) -> Result<String, ApplicationError<'viewee>>
Expand description

Apply the list of actions to a source, writing results to the given destination.

The actions will be applied in the order given. The source is expected to be UTF-8-encoded text, and will be read [line-by-line][BufRead::read_line]. Each processed line will be written to the destination immediately.

Example: Using a single action (German)

See also crate::actions::German.

use srgn::{apply, scoping::{ScopedViewBuildStep, regex::Regex}, actions::{Action, German}};

let actions: &[Box<dyn Action>] = &[Box::new(German::default())];
let scopers: &[Box<dyn ScopedViewBuildStep>] = &[Box::new(Regex::default())];

let mut input = "Gruess Gott!\n";

let result = apply(input, &scopers, &actions).unwrap();
assert_eq!(result, "Grüß Gott!\n");

Errors

Refer to ApplicationError.