Function kripher::utils::read_from [] [src]

pub fn read_from<P>(file: Option<P>) -> ReadResult where
    P: AsRef<Path>, 

Reads from a file or from stdin.

If file is Some, then use it as a filename to read from, Otherwise, read from the standard input.

If any error is found, return an Err.

Examples

use kripher::utils::read_from;

// Read from standard input.
match read_from::<String>(None) {
    Ok(_) => println!("Read correctly!"),
    Err(_) => println!("Oops!"),
}