Expected behavior
I wanted to put the conversion option progress report function in a field, but I couldn't.
use core::future::Future;
use core::marker::PhantomData;
#[derive(Default, Debug)]
pub struct AsyncClosure<I, F, Fut, T>
where
F: FnMut(I) -> Fut,
Fut: Future<Output = T> + Send + 'static,
T: Send + 'static,
{
async_fn: Option<F>,
_p: PhantomData<fn(I) -> Fut>,
}
impl<I, F, Fut, T> AsyncClosure<I, F, Fut, T>
where
F: FnMut(I) -> Fut,
Fut: Future<Output = T> + Send + 'static,
T: Send + 'static,
{
pub const fn new(async_fn: F) -> Self {
Self {
async_fn: Some(async_fn),
_p: std::marker::PhantomData,
}
}
pub fn apply(&mut self, x: I) -> Fut {
match self.async_fn.as_mut() {
Some(f) => f(x),
None => async {},
}
}
}
use std::future::Future;
use std::path::{Path, PathBuf};
use tokio::fs;
use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use tokio_stream::StreamExt;
use tracing::trace;
pub use mapping_table::read_mapping_table;
pub use sequential::convert_dar_to_oar;
#[derive(Debug, Default)]
pub struct ConvertOptions<'a, P: AsRef<Path>, I, F, Fut, T>
where
F: FnMut(I) -> Fut,
Fut: Future<Output = T> + Send + 'static,
T: Send + 'static,
{
/// DAR source dir path
pub dar_dir: P,
/// OAR destination dir path(If not, it is inferred from src)
pub oar_dir: Option<PathBuf>,
/// mod name in config.json & directory name(If not, it is inferred from src)
pub mod_name: Option<&'a str>,
/// mod author in config.json
pub author: Option<&'a str>,
/// path to section name table
pub section_table: Option<HashMap<String, String>>,
/// path to section name table(For _1st_person)
pub section_1person_table: Option<HashMap<String, String>>,
/// After converting to OAR, add mohidden to the DAR directory before conversion to treat it as a hidden directory. (for MO2 users)
pub hide_dar: bool,
pub async_fn: AsyncClosure< I, F, Fut, T>,
}
other
No response