logo
pub trait PathBound {
    fn open_resource(&self, resource: &str) -> File;
}
Expand description

Path bound trait.

Required Methods

Opens a resource from the root path folder. Consider the following folder structure:

/myapp.rs
/user.sql
/templates
    /index.html

If you want to open the user.sql file you should do the following:

use std::io::Read;

use sharp_pencil::PathBound;


fn main() {
    let app = sharp_pencil::Pencil::new("/web/demo");
    let mut file = app.open_resource("user.sql");
    let mut content = String::from("");
    file.read_to_string(&mut content).unwrap();
}

Implementors