https://github.com/lambdalisue/rs-async-utf8-decoder
🦀 Utf8 decoder for AsyncRead in futures-rs
https://github.com/lambdalisue/rs-async-utf8-decoder
async rust utf8
Last synced: 5 months ago
JSON representation
🦀 Utf8 decoder for AsyncRead in futures-rs
- Host: GitHub
- URL: https://github.com/lambdalisue/rs-async-utf8-decoder
- Owner: lambdalisue
- License: mit
- Created: 2021-03-08T16:47:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-11-08T03:00:22.000Z (11 months ago)
- Last Synced: 2025-05-08T22:17:39.508Z (5 months ago)
- Topics: async, rust, utf8
- Language: Rust
- Homepage: https://crates.io/crates/async-utf8-decoder
- Size: 69.3 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://crates.io/crates/async-utf8-decoder)
[](https://deps.rs/repo/github/lambdalisue/rs-async-utf8-decoder)
[](https://docs.rs/async-utf8-decoder)
[](./LICENSE)
[](https://github.com/lambdalisue/rs-async-utf8-decoder/actions/workflows/build.yml)
[](https://github.com/lambdalisue/rs-async-utf8-decoder/actions/workflows/test.yml)
[](https://github.com/lambdalisue/rs-async-utf8-decoder/actions/workflows/audit.yml)
[](https://codecov.io/gh/lambdalisue/rs-async-utf8-decoder)# async-utf8-decoder
## Asynchronous and incremental UTF-8 decoder
`async-utf8-decoder` crate provides `Utf8Decoder` which allows to convert any object which
implements `AsyncRead` trait into a string stream which implements `Stream` trait.### Example
```rust
use futures::io;
use futures::channel::mpsc;
use async_utf8_decoder::Utf8Decoder;let (mut tx, rx) = mpsc::unbounded::>>();
let mut decoder = Utf8Decoder::new(rx.into_async_read());tx.send(Ok(vec![240])).await?;
assert!(timeout(decoder.next()).await.is_err());
tx.send(Ok(vec![159])).await?;
assert!(timeout(decoder.next()).await.is_err());
tx.send(Ok(vec![146])).await?;
assert!(timeout(decoder.next()).await.is_err());
tx.send(Ok(vec![150])).await?;
assert_eq!("💖", timeout(decoder.next()).await?.unwrap()?);
assert!(timeout(decoder.next()).await.is_err());
```# License
The code follows MIT license written in [LICENSE](./LICENSE). Contributors need
to agree that any modifications sent in this repository follow the license.