Skip to content

Commit

Permalink
Add basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
gyscos committed Jul 19, 2023
1 parent e9f4d6f commit 9f5d865
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
fn main() {
let some_content = "Something";
let compression_level = 3;

// Compress some text
let compressed =
zstd::encode_all(some_content.as_bytes(), compression_level).unwrap();

// Now uncompress it
let decoded: Vec<u8> = zstd::decode_all(compressed.as_slice()).unwrap();

// Convert it to text
let decoded_text = std::str::from_utf8(&decoded).unwrap();

assert_eq!(some_content, decoded_text);
}

0 comments on commit 9f5d865

Please sign in to comment.