Expand description
Native async YAML parsing for tokio runtimes —
from_async_reader plus a tokio_util::codec::Decoder.
Gated by the tokio feature.
Native async YAML parsing for tokio
runtimes.
Bridges noyalib’s strict-parser entry points
(crate::from_str, crate::from_slice) onto
tokio::io::AsyncRead sources without forcing the caller
through tokio::task::spawn_blocking. Two surface shapes
are provided so callers can pick the right ergonomics for
their workload:
from_async_reader— drain a single document out of anytokio::io::AsyncReadinto the caller’sT.from_async_reader_multi— drain every----separated document and returnVec<T>.AsyncYamlStream: a backpressuredStreamof parsed documents, constructed withasync_yaml_streamorasync_yaml_stream_with_config.YamlDecoder: the lower-leveltokio_util::codec::Decoderused by the stream surface and available for custom framed pipelines.
§Backpressure
The from_async_reader entry points buffer the full payload
into a Vec<u8> before parsing because the underlying parser
is synchronous. The codec surface is the streaming choice:
it emits one document per decode call as soon as a complete
--- boundary is in the buffer.
Gated behind the tokio Cargo feature (which transitively
enables tokio-util and bytes for the codec API).
§Example
use tokio::io::BufReader;
let bytes: &[u8] = b"name: noyalib\nversion: 0.0.6\n";
let mut reader = BufReader::new(bytes);
#[derive(serde::Deserialize)]
struct Pkg { name: String, version: String }
let pkg: Pkg = noyalib::tokio_async::from_async_reader(&mut reader).await?;
assert_eq!(pkg.name, "noyalib");Structs§
- Yaml
Decoder - [
tokio_util::codec::Decoder] that emits one parsedTper----delimited YAML document in the byte stream.
Functions§
- async_
yaml_ stream - Wrap an asynchronous reader as a backpressured YAML document stream.
- async_
yaml_ stream_ with_ config - Wrap an asynchronous reader as a backpressured YAML document stream with caller-supplied parser limits and policies.
- from_
async_ reader - Drain the supplied reader to end-of-stream, then parse the
buffered bytes as a single YAML document into
T. - from_
async_ reader_ multi - Drain the reader and parse every
----separated document intoVec<T>using the defaultParserConfig. - from_
async_ reader_ multi_ with_ config from_async_reader_multiwith a caller-suppliedParserConfig. The reader is bounded byParserConfig::max_stream_bytes. Every split document is then bounded independently byParserConfig::max_document_length.- from_
async_ reader_ with_ config from_async_readerwith a caller-suppliedParserConfig.
Type Aliases§
- Async
Yaml Stream - A backpressured asynchronous stream of YAML documents.