//! Implements the Preserves [human-oriented text //! syntax](https://preserves.dev/preserves-text.html). //! //! # Summary of Text Syntax #![doc = include_str!("../../../doc/cheatsheet-text-plaintext.md")] pub mod reader; pub mod writer; pub use reader::TextReader; pub use writer::TextWriter; use crate::value::reader::BytesBinarySource; use std::io; use super::{DomainParse, IOValue, IOValueDomainCodec, NestedValue, Reader, ViaCodec}; /// Reads a value from the given string using the text syntax, discarding annotations. pub fn from_str>( s: &str, decode_embedded: Dec, ) -> io::Result { TextReader::new(&mut BytesBinarySource::new(s.as_bytes()), decode_embedded).demand_next(false) } /// Reads an [IOValue] from the given string using the text syntax, discarding annotations. pub fn iovalue_from_str(s: &str) -> io::Result { from_str(s, ViaCodec::new(IOValueDomainCodec)) } /// As [from_str], but includes annotations. pub fn annotated_from_str>( s: &str, decode_embedded: Dec, ) -> io::Result { TextReader::new(&mut BytesBinarySource::new(s.as_bytes()), decode_embedded).demand_next(true) } /// As [iovalue_from_str], but includes annotations. pub fn annotated_iovalue_from_str(s: &str) -> io::Result { annotated_from_str(s, ViaCodec::new(IOValueDomainCodec)) }