diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..8e53774 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,95 @@ +# Contributing to `rzfile` + +Thanks for your interest in contributing to `rzfile`! +Below you'll find the basic guidelines to help you get started. + +--- + +## Requirements + +* **Rust stable** (check with `rustc --version`) +* Use `cargo fmt`, `cargo clippy`, and `cargo test` before submitting any PRs +* Optional: `cargo nextest` and code coverage tools like `cargo tarpaulin` + +--- + +## Running Tests + +```bash +cargo test +``` + +To get code coverage: + +```bash +cargo install cargo-tarpaulin +cargo tarpaulin --out Html +``` + +--- + +## Project Structure + +* `src/lib.rs`: Crate root +* `src/file.rs`: File parsing and index handling +* `src/name.rs`: Encoding/decoding logic for filenames +* `src/error.rs`: Error types and descriptions +* `tests/`: Additional integration tests + +--- + +## Code Style + +Use: + +```bash +cargo fmt +cargo clippy --all-targets --all-features -- -D warnings +``` + +No warnings or `unwrap()`s in final PRs unless justified. + +--- + +## Pull Request Checklist + +Before opening a PR: + +* All tests pass (`cargo test`) +* Code is formatted (`cargo fmt`) +* No Clippy warnings (`cargo clippy`) +* No unnecessary `unwrap()`, `expect()`, or panics +* Added or updated tests if functionality changed +* Relevant documentation updated (including `README.md` or inline rustdoc) + +--- + +## Commit Guidelines + +Follow conventional commits: + +* `feat: Add ...` +* `fix: Correct ...` +* `test: Add test for ...` +* `chore: Maintenance ...` +* `docs: Update README / comments` + +--- + +## Feedback & Issues + +Found a bug or have a feature idea? + +* Use [GitHub Issues](https://github.com/NGemity/rzfile/issues) +* Try to reproduce bugs with a minimal test case + +--- + +## License + +By contributing, you agree that your code will be licensed under the same license as the rest of the project: MIT. + +--- + +Thanks again, +The `rzfile` Maintainers diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..9a8f69e --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,28 @@ +# Pull Request + +## Description + +Please explain what this PR does and why it's needed. +Link any related issues (e.g., `Closes #42`). + +## Changes + +- [ ] Feature added +- [ ] Bug fix +- [ ] Refactoring +- [ ] Docs update +- [ ] Other (explain below) + +## Checklist + +- [ ] Code is formatted with `cargo fmt` +- [ ] No Clippy warnings (`cargo clippy`) +- [ ] Tests pass (`cargo test`) +- [ ] Added or updated relevant tests +- [ ] Documentation updated (if applicable) +- [ ] Ready for review + +--- + +> If you're contributing for the first time: welcome! +> Check the `CONTRIBUTING.md` for development guidelines. \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34e1e00..a50e440 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,10 +14,16 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust - uses: actions/setup-rust@v1 + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly + + - name: Cache cargo registry + uses: actions/cache@v4 with: - rust-version: stable + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - name: Install tarpaulin run: cargo install cargo-tarpaulin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0d25636 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release Crate + +on: + push: + tags: + - 'v*.*.*' + +jobs: + publish: + name: Publish to crates.io + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + + - name: Check build + run: cargo build --release + + - name: Publish to crates.io + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} + run: cargo publish --locked \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9291952..3894d0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ dependencies = [ [[package]] name = "rzfile" -version = "0.1.0" +version = "0.2.0" dependencies = [ "thiserror", ] diff --git a/Cargo.toml b/Cargo.toml index 7c5ab2b..e7c3fca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rzfile" -version = "0.1.0" +version = "0.2.0" edition = "2024" authors = ["Marcel Exner "] description = "Library to handle RZ game data parsing and name decoding" diff --git a/README.md b/README.md index 2173510..bcc3f4f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,59 @@

rzfile
Rust Library for client file handling

+ + +# rzfile -### Intro -This library is part of the ROSE framework. -Mainly this is used for working with the client resources, e.g. `data.000` \ No newline at end of file +[![CI](https://github.com/NGemity/rzfile/actions/workflows/ci.yml/badge.svg)](https://github.com/NGemity/rzfile/actions/workflows/ci.yml) +[![codecov](https://codecov.io/github/NGemity/rzfile/graph/badge.svg?token=FPK427O7U9)](https://codecov.io/github/NGemity/rzfile) +[![crates.io](https://img.shields.io/crates/v/rzfile.svg)](https://crates.io/crates/rzfile) +[![docs.rs](https://docs.rs/rzfile/badge.svg)](https://docs.rs/rzfile) + +`rzfile` is a lightweight Rust library designed for parsing and handling binary file structures used in proprietary MMO game clients. It's part of the [`NGemity`](https://github.com/NGemity) project and supports tools such as the [RZEmulator](https://github.com/NGemity/RZEmulator). + +## Features + +* Parser for `data.00x` index files +* File name encryption and decryption based on game-specific logic +* Customizable encryption and reference tables +* Precise error handling via `RZError` (compatible with `thiserror`) +* Fully tested with high code coverage +* Minimal dependencies (only `thiserror` optionally) + +## Example + +```rust +use rzfile::file::parse_index; +use rzfile::name::{encode_file_name, decode_file_name}; + +let mut buffer = std::fs::read("data.000").unwrap(); +let entries = parse_index(&mut buffer, None).unwrap(); + +let encoded = encode_file_name("test.dds", None, None).unwrap(); +let decoded = decode_file_name(&encoded, None, None, true).unwrap(); + +assert_eq!(decoded, "test.dds"); +``` + +## Installation + +```bash +cargo add rzfile +``` + +Or manually via `Cargo.toml`: + +```toml +[dependencies] +rzfile = "0.1" +``` + +## Documentation + +* [docs.rs/rzfile](https://docs.rs/rzfile) +* [crates.io/crates/rzfile](https://crates.io/crates/rzfile) + +## License + +MIT © [NGemity](https://github.com/NGemity)