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

Add crate for API use #215

Open
Skyslycer opened this issue May 4, 2023 · 4 comments
Open

Add crate for API use #215

Skyslycer opened this issue May 4, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@Skyslycer
Copy link

Related problem or need

As far as I know, there is no crate to interact with packsquash in Rust or any other language, so the only solution would be either to just copy the code or run CLI commands, which is unpractical too.

Proposed solution

Publish a crate to the Rust Crate Repository for easy use of the program.

Alternative solutions

Maybe host an online Rest API, which can be used from any language.

Additional context

None :D

@Skyslycer Skyslycer added the enhancement New feature or request label May 4, 2023
@AlexTMjugador
Copy link
Member

AlexTMjugador commented May 4, 2023

Hi, thanks for your suggestion!

I've put work on an API on hold indefinitely because I'm not sure how it should be designed or implemented. Like Minecraft, PackSquash relies on packs residing on some kind of directory abstraction, so any API would require inputs that are not written to disk to implement a filesystem-like interface, which limits its scalability and flexibility more than I'd like.

A REST API sounds cool, but it would have to build a filesystem and run PackSquash with the specified options afterwards, which I also find somewhat lame: the server needs to store the entire pack somewhere anyway.

The way I see it, the main benefit from an API would be dropping the need for other applications to run external binaries or set up filesystem directories to optimize packs. This is indeed easier and more portable, but it does not enable fundamentally new usage modes for PackSquash. Internally, the CLI project already uses a private library crate that exposes an API, but this API is not stable at all, so using the API won't make upgrades for app developers easier, and stabilizing it would have a significant cost.

However, I'm open to reconsider this at some point! Any feedback and ideas on how to design this API are welcome. Code contributions are also welcome, but I'd recommend getting in touch first over Discord to coordinate efforts.

What would you expect from a PackSquash API? 😄

@Skyslycer
Copy link
Author

I was just thinking to automate packsquashing. I tried the GitHub Actions thingy, but it didn't work as well as I had hoped. So I thought I could write my own Rust program that interfaces with PackSquash and offers a Rest HTTP endpoint, so I could implement PackSquash into Oraxen (as an optional feature).

I haven't looked at the internals yet, but there should be somehow a way to pass a file and some options and get the squashed pack back.

I'd be happy to contribute if I know what I should do, although my Rust knowledge is not very advanced.

@AlexTMjugador
Copy link
Member

I see! Sorry for taking a while to reply, I was busy with other stuff ❤️

The new GUI frontend I'm working on for v0.4.0 also depends on the library crate I mentioned, as does the classic CLI frontend. The already existing library crate does indeed receive some options, among which is pack_directory.

If the end goal is to integrate PackSquash with Oraxen via a new frontend, I could incorporate it into this repository. A more generic REST API frontend may also be appropriate. Or we could even try to expose the library crate directly, after somehow removing its coupling with filesystem paths, without altering the functionality of the existing frontends.

Your goals and help could be very valuable in shaping a proper API. If you have the time, you can start by reading the internal library crate API docs by running cargo doc --open on the packages/packsquash directory of the master branch. After that, you can watch how it is used by packsquash_cli, and code an example separate crate inside packages that depends on the packsquash crate of the workspace. Feel free to join our Discord server if you have any questions!

@Skyslycer
Copy link
Author

No worries! Take your time.
I'll try to use the internal thingy.
Thanks for the help btw!

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

No branches or pull requests

2 participants