pub struct StreamDeserializer { /* private fields */ }Expand description
Reads a stream of YAML documents (see deser::stream).
A document ends where the next one starts (at a --- line) or at a
document end marker (...). When reading a stream that stays open
(for instance a socket), the writer should end every document with ...
(see SerializerConfig::set_end_documents), otherwise a document is only
complete once the next one starts. Comments and directives before a
document belong to it.
use deser_yaml::DeserializerConfig;
let mut reader =
DeserializerConfig::new().reader(&b"--- a\n--- b\n"[..]);
assert_eq!(reader.read::<String>().unwrap().as_deref(), Some("a"));
assert_eq!(reader.read::<String>().unwrap().as_deref(), Some("b"));
assert_eq!(reader.read::<String>().unwrap(), None);Documents are parsed like with a Deserializer, so they can borrow
from the stream’s buffer (see
InputBuffer::deserialize).
Errors (including syntax errors) only discard their document, reading
continues with the next one.
Implementations§
Source§impl StreamDeserializer
impl StreamDeserializer
Sourcepub fn new() -> StreamDeserializer
pub fn new() -> StreamDeserializer
Creates a stream deserializer.
Sourcepub fn with_config(config: DeserializerConfig) -> StreamDeserializer
pub fn with_config(config: DeserializerConfig) -> StreamDeserializer
Creates a stream deserializer with the given configuration.
Sourcepub fn config(&self) -> &DeserializerConfig
pub fn config(&self) -> &DeserializerConfig
Returns the configuration.