expose more internals for external use
This commit is contained in:
parent
5ec9bd59ec
commit
243006ceff
10
src/dict.rs
10
src/dict.rs
|
@ -60,9 +60,7 @@ impl Paths {
|
|||
}
|
||||
|
||||
pub(crate) fn key_path(&self) -> PathBuf {
|
||||
let mut pb = PathBuf::from(&self.base_path);
|
||||
pb.push("Contents");
|
||||
pb.push(&self.contents_dir);
|
||||
let mut pb = self.contents_path();
|
||||
pb.push("key");
|
||||
pb
|
||||
}
|
||||
|
@ -74,9 +72,7 @@ impl Paths {
|
|||
}
|
||||
|
||||
pub(crate) fn headline_path(&self) -> PathBuf {
|
||||
let mut pb = PathBuf::from(&self.base_path);
|
||||
pb.push("Contents");
|
||||
pb.push(&self.contents_dir);
|
||||
let mut pb = self.contents_path();
|
||||
pb.push("headline");
|
||||
pb
|
||||
}
|
||||
|
@ -136,7 +132,7 @@ impl MonokakidoDict {
|
|||
};
|
||||
let pages = Pages::new(&paths)?;
|
||||
let audio = Audio::new(&paths)?;
|
||||
let keys = Keys::new(&paths)?;
|
||||
let keys = Keys::new(paths.key_headword_path())?;
|
||||
|
||||
Ok(MonokakidoDict {
|
||||
paths,
|
||||
|
|
|
@ -2,6 +2,7 @@ use std::{
|
|||
borrow::Cow,
|
||||
cmp::Ordering,
|
||||
fs::File,
|
||||
path::Path,
|
||||
io::{Read, Seek},
|
||||
mem::size_of,
|
||||
str::from_utf8,
|
||||
|
@ -9,7 +10,6 @@ use std::{
|
|||
|
||||
use crate::{
|
||||
abi_utils::{TransmuteSafe, LE32, read_vec},
|
||||
dict::Paths,
|
||||
Error,
|
||||
};
|
||||
|
||||
|
@ -119,8 +119,8 @@ impl Keys {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn new(paths: &Paths) -> Result<Keys, Error> {
|
||||
let mut file = File::open(paths.key_headword_path())?;
|
||||
pub fn new<P: AsRef<Path>>(path: P) -> Result<Keys, Error> {
|
||||
let mut file = File::open(path)?;
|
||||
let file_size = file.metadata()?.len() as usize;
|
||||
let mut hdr = FileHeader::default();
|
||||
file.read_exact(hdr.as_bytes_mut())?;
|
||||
|
|
|
@ -4,7 +4,7 @@ mod dict;
|
|||
mod error;
|
||||
mod key;
|
||||
mod pages;
|
||||
mod resource;
|
||||
pub mod resource;
|
||||
mod headline;
|
||||
|
||||
pub use audio::Audio;
|
||||
|
|
|
@ -210,7 +210,7 @@ impl Nrsc {
|
|||
Ok(files)
|
||||
}
|
||||
|
||||
pub(crate) fn new(path: &Path) -> Result<Self, Error> {
|
||||
pub fn new(path: &Path) -> Result<Self, Error> {
|
||||
let files = Nrsc::files(path)?;
|
||||
let index = NrscIndex::new(path)?;
|
||||
Ok(Nrsc {
|
||||
|
|
|
@ -280,7 +280,7 @@ impl Rsc {
|
|||
Ok(files)
|
||||
}
|
||||
|
||||
pub(crate) fn new(path: &Path, rsc_name: &str) -> Result<Self, Error> {
|
||||
pub fn new(path: &Path, rsc_name: &str) -> Result<Self, Error> {
|
||||
let files = Rsc::files(path, rsc_name)?;
|
||||
let index = RscIndex::new(path, rsc_name)?;
|
||||
Ok(Self {
|
||||
|
|
Loading…
Reference in a new issue