Passsing references?
Heya, I was working on something using this library, and I'm noticing a distinct lack of being able to pass a reference to existing instances of objects, such as the initial Ironworks instance created.
This is what I've been doing to get myself going, but it feels kinda bad not being able to pass a reference into the new Excel instance being created.
let ironworks = Ironworks::new().with_resource(SqPack::new(Install::at(Path::new(
&env::var("FFXIV_PATH").expect("FFXIV_PATH not set"),
))));
let excel = Excel::new(ironworks).with_default_language(Language::English);
Ah, sorry, the public interface of iw has suffered a little from being heavily consumed in bm - the async stuff has lead to a fair amount of 'static for the sake of simplicity.
If you're just looking for the ability to use an Ironworks instance alongside Excel, Excel::new accepts impl Into<Arc<Ironworks>>, so the below should work fine:
let ironworks = Arc::new(Ironworks::new().with_resource(...));
let excel = Excel::new(Arc::clone(&ironworks));
// use as you'd expect
let list = ironworks.file::<exl::ExcelList>("exd/root.exl")?;
let field = excel.sheet("Item")?.row(37362)?.field(0)?;
bm does effectively this to manage its iw instances (permalink):
fn new(view: zipatch::View) -> Self {
let ironworks = Arc::new(Ironworks::new().with_resource(SqPack::new(view)));
let excel = Arc::new(Excel::new(ironworks.clone()));
Self { ironworks, excel }
}
looks like this repo's readme is outdated, whoops 😓