Fixed all documentation errors.

Renamed some errors to their function's name.
This commit is contained in:
2021-04-10 05:41:58 +01:00
parent 64aacedaf6
commit 991fa6ecce
20 changed files with 42 additions and 38 deletions

View File

@@ -7,7 +7,7 @@ pub mod error;
use dcb_iso9660::entry::FileReader;
// Exports
pub use error::{NewError, ReadFileError};
pub use error::{NewError, ReadDrvError};
// Imports
use dcb_cdrom_xa::CdRomReader;
@@ -44,17 +44,17 @@ impl<'a, R> GameFile<'a, R> {
impl<'a, R: io::Read + io::Seek> GameFile<'a, R> {
/// Reads a game file
pub fn read_drv<'b>(&'b mut self, name: &str) -> Result<FileReader<'b, R>, ReadFileError>
pub fn read_drv<'b>(&'b mut self, name: &str) -> Result<FileReader<'b, R>, ReadDrvError>
where
'a: 'b,
{
// Read the root directory
let root_dir = self.filesystem.root_dir().read_dir(self.cdrom).map_err(ReadFileError::ReadRoot)?;
let root_dir = self.filesystem.root_dir().read_dir(self.cdrom).map_err(ReadDrvError::ReadRoot)?;
// Get the file
let entry = root_dir.find(name).ok_or(ReadFileError::FindFile)?;
let entry = root_dir.find(name).ok_or(ReadDrvError::FindFile)?;
// And read it
entry.read_file(self.cdrom).map_err(ReadFileError::ReadFile)
entry.read_file(self.cdrom).map_err(ReadDrvError::ReadFile)
}
}

View File

@@ -8,9 +8,9 @@ pub enum NewError {
ParseFilesystem(#[source] dcb_iso9660::NewError),
}
/// Error for [`GameFile::read_file`](super::GameFile::read_file)
/// Error for [`GameFile::read_drv`](super::GameFile::read_drv)
#[derive(Debug, thiserror::Error)]
pub enum ReadFileError {
pub enum ReadDrvError {
/// Unable to read filesystem root
#[error("Unable to read filesystem root")]
ReadRoot(#[source] dcb_iso9660::entry::ReadDirError),