Giter VIP home page Giter VIP logo

lordofpipes / lz4-java-wrc Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 41 KB

A fork of `lz4jb` to ensure it gives back access to the underlying writer (wrc = "write continue"). `lz4jb` is a Rust implementation of the LZ4BlockOutputStream format from https://github.com/lz4/lz4-java. This is not compatible with the standard LZ4 Block format, but it is useful for reading Minecraft 1.20.5+ region files.

License: MIT License

Rust 100.00%

lz4-java-wrc's Introduction

lz4-java-wrc

Crate API

This is a fork of lz4jb that accepts the writer as a pointer instead of consuming it.

A streaming compression/decompression library which implements the LZ4BlockOutputStream format from lz4-java.

Beware: this format is not compatible with the standard LZ4 Block format. The Minecraft 1.20.5 lz4 chunk compression format is an example of a place this is used.

This repository contains:

  • lz4_java_wrc: a library which implements the Read and Write traits,

Usage

Add this to your Cargo.toml:

[dependencies]
lz4-java-wrc = "0.2.0"

Compression

Lz4BlockOutput is a wrapper around a type which implements the Write trait.

use lz4_java_wrc::Lz4BlockOutput;
use std::io::Write;

fn main() -> std::io::Result<()> {
    let mut output = Vec::new(); // Vec<u8> implements the Write trait
    Lz4BlockOutput::new(&mut output, 64)?
        .write_all("...".as_bytes())?;
    println!("{:?}", output);
    Ok(())
}

Decompression

Lz4BlockInput is a wrapper around a type which implements the Read trait.

use lz4_java_wrc::Lz4BlockInput;
use std::io::Read;

const D: [u8; 24] = [
    76, 90, 52, 66, 108, 111, 99, 107, 16, 3, 0, 0, 0, 3, 0, 0, 0, 82, 228, 119, 6, 46, 46, 46,
];

fn main() -> std::io::Result<()> {
    let mut output = String::new();
    Lz4BlockInput::new(&D[..]) // &[u8] implements the Read trait
        .read_to_string(&mut output)?;
    println!("{}", output);
    Ok(())
}

License

See the LICENCE file.

lz4-java-wrc's People

Contributors

trazfr avatar dependabot[bot] avatar lordofpipes avatar

Stargazers

Ville avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.