All rust tests pass
This commit is contained in:
parent
69662189fb
commit
cbf5a9d2ac
|
@ -209,8 +209,7 @@ fn parse_comparison(
|
|||
impl path::Selector {
|
||||
pub fn from_str(env: &Env, s: &str) -> Result<Self, CompilationError> {
|
||||
parse_selector(env, &(BytesBinarySource::new(s.as_bytes())
|
||||
.text_iovalues()
|
||||
.configured(false)
|
||||
.text().iovalues().read_annotations(false)
|
||||
.collect::<Result<Vec<_>, _>>()?))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,7 @@ pub struct CompilerConfig {
|
|||
pub fn load_schema_or_bundle(bundle: &mut Map<ModulePath, Schema>, i: &PathBuf) -> io::Result<()> {
|
||||
let mut f = File::open(&i)?;
|
||||
let mut src = IOBinarySource::new(&mut f);
|
||||
let mut reader = src.packed().iovalues();
|
||||
reader.set_read_annotations(false);
|
||||
let mut reader = src.packed().iovalues().read_annotations(false);
|
||||
let blob = reader.demand_next()?;
|
||||
let language = Language::default();
|
||||
|
||||
|
|
|
@ -42,8 +42,7 @@ mod tests {
|
|||
|
||||
let mut f = std::fs::File::open("../../../schema/schema.bin")?;
|
||||
let mut src = IOBinarySource::new(&mut f);
|
||||
let mut reader = src.packed().iovalues();
|
||||
reader.set_read_annotations(false);
|
||||
let mut reader = src.packed().iovalues().read_annotations(false);
|
||||
let schema = reader.demand_next()?;
|
||||
let language = crate::gen::Language::default();
|
||||
let parsed = Schema::parse(&language, &schema).expect("successful parse");
|
||||
|
|
|
@ -7,18 +7,16 @@ use clap::Clap;
|
|||
use clap::IntoApp;
|
||||
use clap_generate::{generate, generators};
|
||||
|
||||
use preserves::value::BinarySource;
|
||||
use preserves::value::IOBinarySource;
|
||||
use preserves::value::IOValue;
|
||||
use preserves::value::IOValueDomainCodec;
|
||||
use preserves::value::NestedValue;
|
||||
use preserves::value::PackedReader;
|
||||
use preserves::value::PackedWriter;
|
||||
use preserves::value::Reader;
|
||||
use preserves::value::Set;
|
||||
use preserves::value::TextReader;
|
||||
use preserves::value::TextWriter;
|
||||
use preserves::value::Value;
|
||||
use preserves::value::ViaCodec;
|
||||
use preserves::value::Writer;
|
||||
|
||||
use preserves::value::text::writer::CommaStyle;
|
||||
|
@ -138,8 +136,8 @@ struct Convert {
|
|||
#[clap(long, value_name = "filename")]
|
||||
bundle: Vec<std::path::PathBuf>,
|
||||
|
||||
#[clap(long)]
|
||||
schema: Option<String>,
|
||||
// #[clap(long)]
|
||||
// schema: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(ArgEnum, Clone, Debug)]
|
||||
|
@ -352,16 +350,14 @@ impl<R: io::Read> ValueStream<R> {
|
|||
InputFormat::Binary => return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData, "Expected binary input, saw text input")),
|
||||
}
|
||||
TextReader::new(&mut self.source, ViaCodec::new(IOValueDomainCodec))
|
||||
.next(self.read_annotations)?
|
||||
self.source.text().next(self.read_annotations, &mut IOValueDomainCodec)?
|
||||
} else {
|
||||
match self.input_format {
|
||||
InputFormat::AutoDetect | InputFormat::Binary => (),
|
||||
InputFormat::Text => return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData, "Expected text input, saw binary input")),
|
||||
}
|
||||
PackedReader::new(&mut self.source, IOValueDomainCodec)
|
||||
.next(self.read_annotations)?
|
||||
self.source.packed().next(self.read_annotations, &mut IOValueDomainCodec)?
|
||||
};
|
||||
|
||||
match maybe_value {
|
||||
|
|
|
@ -269,8 +269,7 @@ mod decoder_tests {
|
|||
#[test] fn skip_annotations_skip() {
|
||||
let buf = &b"\xbf\x82\xa3\x01\x82\xa3\x02"[..];
|
||||
let mut src = BytesBinarySource::new(&buf);
|
||||
let mut d = src.packed().iovalues();
|
||||
d.set_read_annotations(false);
|
||||
let mut d = src.packed().iovalues().read_annotations(false);
|
||||
let v = d.demand_next().unwrap();
|
||||
assert_eq!(v.annotations().slice().len(), 0);
|
||||
assert_eq!(v.value(), &Value::from(1));
|
||||
|
|
|
@ -242,8 +242,9 @@ impl<'de, N: NestedValue, Dec: DomainDecode<N::Embedded>, R: Reader<'de>>
|
|||
reader.configured(true, decode_embedded)
|
||||
}
|
||||
|
||||
pub fn set_read_annotations(&mut self, read_annotations: bool) {
|
||||
pub fn read_annotations(mut self, read_annotations: bool) -> Self {
|
||||
self.read_annotations = read_annotations;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn demand_next(&mut self) -> io::Result<N> {
|
||||
|
|
Loading…
Reference in New Issue