Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passsing references? #29

Open
raineaeternal opened this issue Jan 19, 2025 · 1 comment
Open

Passsing references? #29

raineaeternal opened this issue Jan 19, 2025 · 1 comment

Comments

@raineaeternal
Copy link

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);
@ackwell
Copy link
Owner

ackwell commented Jan 20, 2025

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 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants