Metadata-Version: 2.4
Name: lz4inv
Version: 0.2.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Dist: pytest ; extra == 'tests'
Provides-Extra: tests
License-File: LICENSE
Summary: A Rust-backed Python module for decompressing data compressed with the modified LZ4 algorithm for an anime game.
Keywords: lz4,lz4inv,compression,decompression
Author-email: daflyinbed <1677759063@qq.com>
Maintainer-email: StarHeartHunt <starheart233@gmail.com>
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/MooncellWiki/lz4inv
Project-URL: Repository, https://github.com/MooncellWiki/lz4inv

# Lz4Inv

Lz4Inv is a Rust-backed Python module for decompressing data compressed with the modified LZ4 algorithm for an anime game. It leverages [PyO3](https://pyo3.rs/) to provide a high-performance decompression function directly from Python.

## Installation

### Prerequisites

- Rust (edition 2021)
- Python (version 3.9 or higher)
- [maturin](https://github.com/PyO3/maturin) for building the extension module

### Build and Install

1. Clone the repository:

   ```powershell
   git clone https://github.com/MooncellWiki/lz4inv.git
   cd lz4inv
   ```

2. Build the module using maturin:

   ```powershell
   maturin develop --release
   ```

3. Install the package (if not using `maturin develop`):

   ```powershell
   pip install .
   ```

## Usage

Import the module in your Python code to decompress LZ4 compressed data.  
The function accepts any object implementing Buffer protocol (for example `bytes`, `bytearray`, `memoryview`) as input for the compressed data.

```python
import lz4inv

with open("compressed_data.bin", "rb") as f:
    compressed_data = f.read()

decompressed_size = 131072
decompressed_data = lz4inv.decompress_buffer(compressed_data, decompressed_size)
```

For Python versions before 3.11, use `decompress()` as the Buffer protocol doesn't have a stable ABI in those versions.  
Note that `decompress()` specifically requires a `bytes` object as input.

```python
import lz4inv

with open("compressed_data.bin", "rb") as f:
    compressed_data = f.read()

decompressed_size = 131072
decompressed_data = lz4inv.decompress(compressed_data, decompressed_size)
```

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Acknowledgments

- [PyO3](https://github.com/PyO3/pyo3) for making Python/Rust interop simple.
- The LZ4 compression library for inspiration.

