Function loe::process

source · []
pub fn process<I, O, E, T>(
    input: &mut I,
    output: &mut O,
    config: Config<E, T>
) -> Result<(), ParseError> where
    I: Read,
    O: Write,
    E: Into<Box<dyn EncodingChecker>> + Display,
    T: Into<Box<dyn Transform>>, 
Expand description

The entry point of loe. It processes the given input and write the result into the given output. Its behavior is dependent on given config.

Examples

Basic usage:

use std::io::Cursor;

use loe::{process, Config};

let mut input = Cursor::new("hello\r\nworld!\r\n");
let expected = "hello\nworld!\n";
let mut output = Cursor::new(Vec::new());

process(&mut input, &mut output, Config::default());
let actual = String::from_utf8(output.into_inner()).unwrap();
assert_eq!(actual, expected);

Wrapping the function to convert string to string:

use std::io::Cursor;

use loe::{process, Config};

fn convert(input: String) -> String {
    let mut input = Cursor::new(input);
    let mut output = Cursor::new(Vec::new());

    process(&mut input, &mut output, Config::default());
    String::from_utf8(output.into_inner()).unwrap()
}

assert_eq!(convert("hello\r\nworld!\r\n".to_string()), "hello\nworld!\n".to_string());