Debian Codegraph @

/

debian rust-lz-str 0.2.1-1debian librust-lz-str-dev debian librust-lz-str+default-dev debian librust-lz-str+nightly-dev debian librust-lz-str+rustc-hash-dev debian librust-lz-str-0-dev debian librust-lz-str-0+default-dev debian librust-lz-str-0+nightly-dev debian librust-lz-str-0+rustc-hash-dev debian librust-lz-str-0.2-dev debian librust-lz-str-0.2+default-dev debian librust-lz-str-0.2+nightly-dev debian librust-lz-str-0.2+rustc-hash-dev debian librust-lz-str-0.2.1-dev debian librust-lz-str-0.2.1+default-dev debian librust-lz-str-0.2.1+nightly-dev debian librust-lz-str-0.2.1+rustc-hash-dev cargo lz-str 0.2.1 debianjsonmakefilemarkdownrustrust-c-abishelltoml 28 files · 262 symbols
View dependency graph

Depends on

  • dh-cargo (dh-sequence-cargo)
  • cargo, debhelper-compat, librust-rustc-hash-1+default-dev, libstd-rust-dev, rustc
README (full)

lz-str-rs

crates.io Documentation MIT/Apache-2 licensed Rust

A port of lz-string to Rust.

Installing

Add the following to your Cargo.toml file:

[dependencies]
lz-str = "0.1.0"

Getting Started

// The demonstrated functions correspond with `LZString.compress` and `LZString.decompress` from the JS version.
fn main() {
    let data = "The quick brown fox jumps over the lazy dog";

    // Compress the data. This cannot fail.
    let compressed_data = lz_str::compress(data);

    // Decompress the data.
    // This may return `Option::None` if it fails.
    // Make sure to do error-checking in a real application to prevent crashes!
    let decompressed_data =
        lz_str::decompress(compressed_data).expect("`compressed_data` is invalid");

    // The decompressed_data should be the same as data, except encoded as UTF16.
    // We undo that here.
    // In a real application,
    // you will want to do error checking to prevent users from causing crashes with invalid data.
    let decompressed_data =
        String::from_utf16(&decompressed_data).expect("`decompressed_data` is not valid UTF16");

    assert!(data == decompressed_data);
}

See the examples directory for more examples.

Features

rustc-hash: This feature will replace some internal maps' hashers with rustc-hash, boosting performance at the cost of not using a DOS-resistant hasher.

Testing

cargo test

Benching

cargo bench

Bindings

WebAssembly

Authors

adumbidiot (Nathaniel Daniel)

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

dir benches/
dir debian/
dir examples/
dir src/
dir tests/
file .cargo_vcs_info.json
file .gitignore
file CHANGELOG.md
file Cargo.lock
file Cargo.toml
file Cargo.toml.orig
file LICENSE-APACHE.md
file LICENSE-MIT.md
file README.md