Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bytealex/zlib-stream-rs
A websocket zlib-stream implementation in rust
https://github.com/bytealex/zlib-stream-rs
cloudflare flate2 hacktoberfest rust
Last synced: about 2 months ago
JSON representation
A websocket zlib-stream implementation in rust
- Host: GitHub
- URL: https://github.com/bytealex/zlib-stream-rs
- Owner: ByteAlex
- Created: 2021-09-17T13:34:45.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-12-05T16:33:19.000Z (about 3 years ago)
- Last Synced: 2024-12-23T06:07:25.845Z (about 2 months ago)
- Topics: cloudflare, flate2, hacktoberfest, rust
- Language: Rust
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# zlib-stream-rs
A simple utility crate to make decompressing from zlib-stream easier.
This crate is based of [flate2](https://github.com/rust-lang/flate2-rs) and their
[clouflare zlib backend](https://github.com/cloudflare/zlib).## Usage
1. StreamExt using `stream` feature
```rust
use zlib_stream::stream::ZlibStream;async fn setup + Sized, T: Stream + Unpin>(stream: T) {
let mut stream = ZlibStream::new(stream);
loop {
let data: Option, flate2::DecompressError>> = stream.next().await;
do_something(data);
}
}
```
2. Barebone Implementation
```rust
use zlib_stream::{ZlibStreamDecompressor, ZlibDecompressionError};fn worker_loop() {
let mut decompress: ZlibStreamDecompressor = ZlibStreamDecompressor::new();
loop {
let mut frame: Vec = get_compressed_frame();
match decompress.decompress(frame) {
Ok(vec) => process_data(vec),
Err(ZlibDecompressionError::NeedMoreData) => continue,
Err(_err) => panic!("Broken frame!"),
}
}
}
```