pub struct StreamDecoder<'a> { /* private fields */ }Expand description
Decodes one stream a chunk at a time under a ratio budget.
§Examples
use pdfcer_model::filters::{ReadStatus, StreamDecoder};
use pdfcer_model::object::Dict;
let dict = Dict::new(); // no /Filter: the raw bytes are the data
let mut dec = StreamDecoder::new(&dict, b"0 0 m 1 1 l S")?;
let mut out = Vec::new();
while dec.read(&mut out)? == ReadStatus::More {}
assert_eq!(out, b"0 0 m 1 1 l S");Implementations§
Source§impl<'a> StreamDecoder<'a>
impl<'a> StreamDecoder<'a>
Sourcepub fn new(dict: &Dict, raw: &'a [u8]) -> Result<Self, FilterError>
pub fn new(dict: &Dict, raw: &'a [u8]) -> Result<Self, FilterError>
Prepare to decode raw (the stream’s encoded bytes) per dict’s
/Filter and /DecodeParms.
§Errors
FilterError from parsing the filter chain, or from a stage this
decodes whole (module docs) — the same errors
super::decode_stream would report for it.
Sourcepub fn read(&mut self, out: &mut Vec<u8>) -> Result<ReadStatus, FilterError>
pub fn read(&mut self, out: &mut Vec<u8>) -> Result<ReadStatus, FilterError>
Append the next chunk (about 64 KiB) of decoded bytes to out.
§Errors
FilterError::Corrupt or FilterError::Truncated when the
stream is damaged part-way. Bytes decoded before the damage were
returned by earlier calls; the decoder is finished after an error.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for StreamDecoder<'a>
impl<'a> !Send for StreamDecoder<'a>
impl<'a> !Sync for StreamDecoder<'a>
impl<'a> !UnwindSafe for StreamDecoder<'a>
impl<'a> Forget for StreamDecoder<'a>
impl<'a> Freeze for StreamDecoder<'a>
impl<'a> Move for StreamDecoder<'a>
impl<'a> Unpin for StreamDecoder<'a>
impl<'a> UnsafeUnpin for StreamDecoder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more