rs-async-utf8-decoder

Audit Build Test

Incremental UTF8 decoder which convert [AsyncRead][] into [Stream][] of futures-rs.

Example

```rust use asyncstd::io::Cursor; use asyncutf8_decoder::Utf8Decoder;

let cur = Cursor::new(Vec::new()); let mut decoder = Utf8Decoder::new(cur);

async fn append(cursor: &mut Cursor>, data: &[u8]) -> Result<()> { let p = cursor.position(); cursor.setposition(cursor.getref().len() as u64); cursor.write(data).await?; cursor.set_position(p); Ok(()) }

// Decode full append(decoder.getmut(), &vec![240, 159, 146, 150]).await?; let decoded = decoder.next().await.unwrap()?; asserteq!("💖", decoded);

// Decode half append(decoder.getmut(), &vec![240, 159]).await?; let decoded = decoder.next().await.unwrap()?; asserteq!("", decoded); append(decoder.getmut(), &vec![146, 150]).await?; let decoded = decoder.next().await.unwrap()?; asserteq!("💖", decoded);

// Decode char append(decoder.getmut(), &vec![240]).await?; let decoded = decoder.next().await.unwrap()?; asserteq!("", decoded); append(decoder.getmut(), &vec![159]).await?; let decoded = decoder.next().await.unwrap()?; asserteq!("", decoded); append(decoder.getmut(), &vec![146]).await?; let decoded = decoder.next().await.unwrap()?; asserteq!("", decoded); append(decoder.getmut(), &vec![150]).await?; let decoded = decoder.next().await.unwrap()?; asserteq!("💖", decoded); ```

License

The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.