#utf-8 #stream #async #decoder #io #future #string

async-utf8-decoder

Convert AsyncRead to incremental UTF8 string stream

11 releases (1 stable)

1.0.0 Nov 8, 2024
0.3.3 Jun 2, 2023
0.3.2 Feb 14, 2022
0.3.1 Sep 16, 2021
0.2.0 Mar 12, 2021

#485 in Asynchronous

Download history 22/week @ 2024-08-19 25/week @ 2024-08-26 13/week @ 2024-09-02 29/week @ 2024-09-09 31/week @ 2024-09-16 36/week @ 2024-09-23 16/week @ 2024-09-30 1/week @ 2024-10-07 24/week @ 2024-10-14 10/week @ 2024-10-21 5/week @ 2024-10-28 132/week @ 2024-11-04 17/week @ 2024-11-11 36/week @ 2024-11-18 25/week @ 2024-11-25 12/week @ 2024-12-02

101 downloads per month
Used in 5 crates (2 directly)

MIT license

21KB
298 lines

crates.io dependency status docs.rs MIT License Build Test Audit codecov

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

use futures::io;
use futures::channel::mpsc;
use async_utf8_decoder::Utf8Decoder;

let (mut tx, rx) = mpsc::unbounded::<io::Result<Vec<u8>>>();
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. Contributors need to agree that any modifications sent in this repository follow the license.

Dependencies

~320–800KB
~18K SLoC