Crate async_utf8_decoder[][src]

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());

Modules

decoder
error

Structs

Utf8Decoder

Enums

DecodeError

Type Definitions

Result