cleanup warnings

This commit is contained in:
phiresky 2022-12-25 18:46:57 +01:00
parent 24e866a153
commit 0d70be4b74
5 changed files with 17 additions and 34 deletions

View File

@ -12,8 +12,8 @@ use std::sync::Arc;
// pub mod zip;
use crate::{adapted_iter::AdaptedFilesIterBox, config::RgaConfig, matching::*};
use anyhow::*;
use custom::builtin_spawning_adapters;
use custom::CustomAdapterConfig;
use custom::BUILTIN_SPAWNING_ADAPTERS;
use log::*;
use tokio::io::AsyncRead;
@ -23,7 +23,6 @@ use std::collections::HashMap;
use std::iter::Iterator;
use std::path::PathBuf;
use std::pin::Pin;
use std::rc::Rc;
use self::postproc::PostprocPageBreaks;
@ -129,7 +128,7 @@ pub fn get_all_adapters(custom_adapters: Option<Vec<CustomAdapterConfig>>) -> Ad
// Rc::new(tesseract::TesseractAdapter::new()),
];
adapters.extend(
builtin_spawning_adapters
BUILTIN_SPAWNING_ADAPTERS
.iter()
.map(|e| -> Arc<dyn FileAdapter> { Arc::new(e.to_adapter()) }),
);

View File

@ -6,22 +6,19 @@ use crate::{
matching::{FastFileMatcher, FileMatcher},
};
use anyhow::Result;
use async_stream::{stream, AsyncStream};
use bytes::{Buf, Bytes};
use async_stream::stream;
use bytes::Bytes;
use lazy_static::lazy_static;
use log::debug;
use log::*;
use regex::{Captures, Regex};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::path::Path;
use tokio::process::Command;
use tokio_util::io::StreamReader;
use std::future::Future;
use std::process::{ExitStatus, Stdio};
use std::process::Stdio;
use tokio::io::AsyncReadExt;
use tokio::process::Child;
use tokio::process::Command;
use tokio_util::io::StreamReader;
// mostly the same as AdapterMeta + SpawningFileAdapter
#[derive(Debug, Deserialize, Serialize, JsonSchema, Default, PartialEq, Clone)]
@ -59,7 +56,7 @@ fn strs(arr: &[&str]) -> Vec<String> {
}
lazy_static! {
pub static ref builtin_spawning_adapters: Vec<CustomAdapterConfig> = vec![
pub static ref BUILTIN_SPAWNING_ADAPTERS: Vec<CustomAdapterConfig> = vec![
// from https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/App/FormatHeuristics.hs
// excluding formats that could cause problems (.db ?= sqlite) or that are already text formats (e.g. xml-based)
//"db" -> Just "docbook"
@ -143,19 +140,6 @@ pub fn map_exe_error(err: std::io::Error, exe_name: &str, help: &str) -> Error {
}
}
/** waits for a process to finish, returns an io error if the process failed */
struct ProcWaitReader {
process: Option<Child>,
future: Option<Pin<Box<dyn Future<Output = std::io::Result<ExitStatus>>>>>,
}
impl ProcWaitReader {
fn new(cmd: Child) -> ProcWaitReader {
ProcWaitReader {
process: Some(cmd),
future: None,
}
}
}
fn proc_wait(mut child: Child) -> impl AsyncRead {
let s = stream! {
let res = child.wait().await?;
@ -310,12 +294,12 @@ mod test {
use crate::preproc::loop_adapt;
use crate::test_utils::*;
use anyhow::Result;
use pretty_assertions::{assert_eq, assert_ne};
use pretty_assertions::assert_eq;
use tokio::fs::File;
#[tokio::test]
async fn poppler() -> Result<()> {
let adapter = builtin_spawning_adapters
let adapter = BUILTIN_SPAWNING_ADAPTERS
.iter()
.find(|e| e.name == "poppler")
.expect("no poppler adapter");

View File

@ -2,12 +2,12 @@
//impl<T> FileAdapter for T where T: RunFnAdapter {}
use anyhow::Context;
use anyhow::Result;
use async_stream::stream;
use bytes::Bytes;
use encoding_rs_io::DecodeReaderBytesBuilder;
use std::cmp::min;
use std::ffi::OsStr;
use std::io::Cursor;
use std::path::PathBuf;
@ -77,7 +77,7 @@ impl Read for ReadErr {
* If the input stream does not contain valid text, returns the string `[rga: binary data]` instead
*/
pub fn postproc_encoding(
line_prefix: &str,
_line_prefix: &str,
inp: impl AsyncRead + Send + 'static,
) -> Result<Pin<Box<dyn AsyncRead + Send>>> {
Ok(Box::pin(inp))

View File

@ -9,7 +9,7 @@ use tokio::io::{AsyncRead, AsyncWriteExt};
use tokio_stream::StreamExt;
use tokio_util::io::{ReaderStream, StreamReader};
use crate::adapters::ReadBox;
/**
* wrap a AsyncRead so that it is passthrough,

View File

@ -1,4 +1,4 @@
use crate::adapted_iter::{AdaptedFilesIter, AdaptedFilesIterBox};
use crate::adapted_iter::{AdaptedFilesIterBox};
use crate::adapters::*;
use crate::caching_writer::async_read_and_write_to_cache;
use crate::config::RgaConfig;