Function tycho::unmarshall_async[][src]

pub async fn unmarshall_async<R: AsyncRead + Unpin + Send>(
    reader: &mut R
) -> TychoResult<Element>

Unmarshall an element from a async readable object.

Example

use std::io::{BufReader, Cursor};
use tycho::unmarshall_async;

// Create a cursor with example bytes
let mut bytes = Cursor::new(vec![1, 4, 2, 1, 164]);

// Unmarshall cursor
let data = unmarshall_async(&mut bytes).await.unwrap();

assert_eq!(data, Value(Number(Unsigned16(420))));

File Example

use std::io::{BufReader, Cursor, Read};
use tycho::unmarshall_async;

// Create a cursor with example bytes
let mut bytes = tokio::fs::File::open("number.tycho").await.unwrap();

// Unmarshall cursor
let data = unmarshall_async(&mut bytes).await.unwrap();

assert_eq!(data, Value(Number(Unsigned16(420))));