Trait pencil::helpers::PathBound
[−]
[src]
pub trait PathBound { fn open_resource(&self, resource: &str) -> File; }
Path bound trait.
Required Methods
fn open_resource(&self, resource: &str) -> File
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 pencil::PathBound; fn main() { let app = 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
impl PathBound for Pencil