diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..65d9de7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,78 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in library 'rga'", + "cargo": { + "args": ["test", "--no-run", "--lib", "--package=rga"], + "filter": { + "name": "rga", + "kind": "lib" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'rga'", + "cargo": { + "args": ["build", "--bin=rga", "--package=rga"], + "filter": { + "name": "rga", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'rga'", + "cargo": { + "args": ["test", "--no-run", "--bin=rga", "--package=rga"], + "filter": { + "name": "rga", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'rga-preproc'", + "cargo": { + "args": ["build", "--bin=rga-preproc", "--package=rga"], + "filter": { + "name": "rga-preproc", + "kind": "bin" + } + }, + "args": ["exampledir/short.pdf"], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'rga-preproc'", + "cargo": { + "args": ["test", "--no-run", "--bin=rga-preproc", "--package=rga"], + "filter": { + "name": "rga-preproc", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} diff --git a/src/adapters.rs b/src/adapters.rs index 7c614a0..7cc94e0 100644 --- a/src/adapters.rs +++ b/src/adapters.rs @@ -45,8 +45,11 @@ pub struct AdaptInfo<'a> { pub filepath_hint: &'a Path, /// true if filepath_hint is an actual file on the file system pub is_real_file: bool, + /// stream to read the file from. can be from a file or from some decoder pub inp: &'a mut dyn Read, + /// stream to write to. will be written to from a different thread pub oup: &'a mut (dyn Write + Send), + /// prefix every output line with this string to better indicate the file's location if it is in some archive pub line_prefix: &'a str, // pub adapt_subobject: &'a dyn Fn(AdaptInfo) -> Fallible<()>, } diff --git a/src/preproc.rs b/src/preproc.rs index 5057d25..d4b3f6b 100644 --- a/src/preproc.rs +++ b/src/preproc.rs @@ -7,6 +7,7 @@ use path_clean::PathClean; const MAX_DB_BLOB_LEN: usize = 2_000_000; const ZSTD_LEVEL: i32 = 12; +/// opens a LMDB cache pub fn open_cache_db() -> Result>, Error> { let app_cache = cachedir::CacheDirConfig::new("rga").get_cache_dir()?; @@ -30,6 +31,12 @@ pub fn open_cache_db() -> Result>, Er Ok(db_arc) } +/** + * preprocess a file as defined in `ai`. + * + * If a cache is passed, read/write to it. + * + */ pub fn rga_preproc<'a>( ai: AdaptInfo<'a>, mb_db_arc: Option>>,