10 releases

0.3.3 Jun 2, 2023
0.3.2 Feb 14, 2022
0.3.1 Sep 16, 2021
0.3.0 Jul 1, 2021
0.1.1 Mar 9, 2021

#303 in Asynchronous

Download history 109/week @ 2023-12-18 7/week @ 2023-12-25 174/week @ 2024-01-01 264/week @ 2024-01-08 178/week @ 2024-01-15 71/week @ 2024-01-22 82/week @ 2024-01-29 315/week @ 2024-02-05 137/week @ 2024-02-12 222/week @ 2024-02-19 187/week @ 2024-02-26 62/week @ 2024-03-04 164/week @ 2024-03-11 127/week @ 2024-03-18 196/week @ 2024-03-25 145/week @ 2024-04-01

639 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

~0.4–0.9MB
~20K SLoC