Formatting

This commit is contained in:
Antoine Gersant 2016-08-28 17:43:15 -07:00
parent f7726c0ad9
commit 16c609cd20
3 changed files with 33 additions and 48 deletions

View file

@ -120,7 +120,7 @@ fn serve(request: &mut Request, collection: &mut Collection) -> IronResult<Respo
_ => status::InternalServerError,
};
return Err(IronError::new(e, status));
},
}
};
if !metadata.is_file() {

View file

@ -37,9 +37,7 @@ pub struct Directory {
}
impl Directory {
pub fn read(collection: &Collection,
path: &Path)
-> Result<Directory, PError> {
pub fn read(collection: &Collection, path: &Path) -> Result<Directory, PError> {
let virtual_path = try!(collection.vfs.real_to_virtual(path));
let path_string = try!(virtual_path.to_str().ok_or(PError::PathDecoding));
@ -64,17 +62,16 @@ pub struct Collection {
vfs: Vfs,
}
const CONFIG_MOUNT_DIRS : &'static str = "mount_dirs";
const CONFIG_MOUNT_DIR_NAME : &'static str = "name";
const CONFIG_MOUNT_DIR_SOURCE : &'static str = "source";
const CONFIG_MOUNT_DIRS: &'static str = "mount_dirs";
const CONFIG_MOUNT_DIR_NAME: &'static str = "name";
const CONFIG_MOUNT_DIR_SOURCE: &'static str = "source";
impl Collection {
pub fn new() -> Collection {
Collection { vfs: Vfs::new() }
}
pub fn load_config(&mut self, config_path: &Path) -> Result<(), PError>
{
pub fn load_config(&mut self, config_path: &Path) -> Result<(), PError> {
// Open
let mut config_file = match File::open(config_path) {
Ok(c) => c,

View file

@ -58,24 +58,12 @@ impl fmt::Display for PError {
match *self {
PError::Io(ref err) => write!(f, "IO error: {}", err),
PError::PathDecoding => write!(f, "Path decoding error"),
PError::ConflictingMount => {
write!(f, "Mount point already has a target directory")
}
PError::PathNotInVfs => {
write!(f, "Requested path does not index a mount point")
}
PError::CannotServeDirectory => {
write!(f, "Only individual files can be served")
}
PError::ConfigFileOpenError => {
write!(f, "Could not open config file")
}
PError::ConfigFileReadError => {
write!(f, "Could not read config file")
}
PError::ConfigFileParseError => {
write!(f, "Could not parse config file")
}
PError::ConflictingMount => write!(f, "Mount point already has a target directory"),
PError::PathNotInVfs => write!(f, "Requested path does not index a mount point"),
PError::CannotServeDirectory => write!(f, "Only individual files can be served"),
PError::ConfigFileOpenError => write!(f, "Could not open config file"),
PError::ConfigFileReadError => write!(f, "Could not read config file"),
PError::ConfigFileParseError => write!(f, "Could not parse config file"),
PError::ConfigMountDirsParseError => {
write!(f, "Could not parse mount directories in config file")
}