Skip to content

Add package installer generics, BepInEx implementation #25

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

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

ethangreen-dev
Copy link
Member

No description provided.

This is done so to better handle the mapping of modloader variants to
specific package installers. We do so via enum as any modification of
these variants will incur a compilation error that must be handled.
This commit contains two major features: Traits that define the behavior
of filesystem operations and installer functionality, and an early
implementation of the bepinex package installer which uses this
functionality.

New traits:
- TrackedFs, which defines the API by which the installer will interact
  with the filesystem.
- PackageInstaller, which defines the functionality and types that an
  installer implementee must define / consume to function.
BpxInstaller::new(ConcreteFs::new(StateEntry::default()));

let fs = ConcreteFs::new(StateEntry::default());
let test = get_installer(&R2MLLoader::BepInEx, fs);

Check warning

Code scanning / clippy

unused variable: test Warning

unused variable: test
Ok(())
}

async fn file_delete(&mut self, target: &Path, tracked: bool) {

Check warning

Code scanning / clippy

unused variable: target Warning

unused variable: target
Ok(())
}

async fn dir_delete(&mut self, target: &Path, tracked: bool) {

Check warning

Code scanning / clippy

unused variable: tracked Warning

unused variable: tracked
impl StateEntry {
/// Add a new staged file. If overwrite is set then already existing
/// entries with the same path will be replaced.
pub fn add_staged(&mut self, file: StagedFile, overwrite: bool) {

Check warning

Code scanning / clippy

unused variable: file Warning

unused variable: file
impl StateEntry {
/// Add a new staged file. If overwrite is set then already existing
/// entries with the same path will be replaced.
pub fn add_staged(&mut self, file: StagedFile, overwrite: bool) {

Check warning

Code scanning / clippy

unused variable: overwrite Warning

unused variable: overwrite

/// Add a new linked file. If overwrite is set then already existing
/// entries with the same path will be replaced.
pub fn add_linked(&mut self, file: TrackedFile, overwrite: bool) {

Check warning

Code scanning / clippy

unused variable: file Warning

unused variable: file

/// Add a new linked file. If overwrite is set then already existing
/// entries with the same path will be replaced.
pub fn add_linked(&mut self, file: TrackedFile, overwrite: bool) {

Check warning

Code scanning / clippy

unused variable: overwrite Warning

unused variable: overwrite
... And a small edit to the PackageInstaller trait install_package and
uninstall_package functions to accept mutable self references, not
immutable.

In theory this is fine but it opens up problems if we plan on
multithreading file ops due to rust's mutable borrow rules. If this
becomes a problem (and we NEED mutability) we can rely on something like
a RefCell<T: TrackedFile> at the cost of some runtime peformance.
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

Successfully merging this pull request may close these issues.

1 participant