Function open::with

source ·
pub fn with<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> Result<()>
Expand description

Open path with the given application.

This function may block if the application doesn’t detach itself. In that case, consider using with_in_background().

Examples

let path = "http://rust-lang.org";
let app = "firefox";

match open::with(path, app) {
    Ok(()) => println!("Opened '{}' successfully.", path),
    Err(err) => panic!("An error occurred when opening '{}': {}", path, err),
}

Errors

A std::io::Error is returned on failure. Because different operating systems handle errors differently it is recommend to not match on a certain error.