diff --git a/implementations/rust/preserves-tools/src/bin/preserves-tool.rs b/implementations/rust/preserves-tools/src/bin/preserves-tool.rs index 4046d4c..1c17d84 100644 --- a/implementations/rust/preserves-tools/src/bin/preserves-tool.rs +++ b/implementations/rust/preserves-tools/src/bin/preserves-tool.rs @@ -215,6 +215,7 @@ impl io::Read for RollingBuffer { fn convert(c: Convert) -> io::Result<()> { let mut r = RollingBuffer::new(io::stdin()); + let mut source = IOBinarySource::new(&mut r); let mut count = 0; let mut w: Box io::Result<()>> = match c.output_format { OutputFormat::Text => { @@ -235,7 +236,7 @@ fn convert(c: Convert) -> io::Result<()> { }; loop { let is_text = { - let peek_buf = r.peek_buf()?; + let peek_buf = source.read.peek_buf()?; if peek_buf.is_empty() { return Ok(()); } @@ -248,7 +249,7 @@ fn convert(c: Convert) -> io::Result<()> { InputFormat::Binary => return Err(io::Error::new( io::ErrorKind::InvalidData, "Expected binary input, saw text input")), } - TextReader::new(&mut IOBinarySource::new(&mut r), ViaCodec::new(IOValueDomainCodec)) + TextReader::new(&mut source, ViaCodec::new(IOValueDomainCodec)) .next(c.annotations.into())? } else { match c.input_format { @@ -256,7 +257,7 @@ fn convert(c: Convert) -> io::Result<()> { InputFormat::Text => return Err(io::Error::new( io::ErrorKind::InvalidData, "Expected text input, saw binary input")), } - PackedReader::new(&mut IOBinarySource::new(&mut r), IOValueDomainCodec) + PackedReader::new(&mut source, IOValueDomainCodec) .next(c.annotations.into())? }; @@ -264,7 +265,7 @@ fn convert(c: Convert) -> io::Result<()> { None => return Ok(()), Some(value) => { w(&value)?; - r.discard_to_pos(); + source.read.discard_to_pos(); count += 1; if let Some(limit) = c.limit { if count >= limit {