Skip to main content

ContentChunks

Struct ContentChunks 

Source
pub struct ContentChunks<'a> { /* private fields */ }
Expand description

A content stream read a window at a time (module docs).

§Examples

use pdfcer_model::content::ContentChunks;
use pdfcer_model::object::Dict;

let dict = Dict::new();
let mut chunks = ContentChunks::from_stream(&dict, b"0 0 m 10 10 l S");
let mut ops = 0;
while let Some(window) = chunks.next_chunk()? {
    ops += window.operations().count();
}
assert_eq!(ops, 3);

Implementations§

Source§

impl<'a> ContentChunks<'a>

Source

pub fn from_page( view: &DocumentView<'a>, page: &Page, ) -> Result<Self, ContentError>

A page’s /Contents, concatenated exactly as ContentStream::from_page concatenates them.

§Errors

ContentError::NotAStream when a /Contents entry does not resolve to a stream. Decoding has not started yet.

Source

pub fn from_form( view: &DocumentView<'a>, id: ObjId, ) -> Result<Self, ContentError>

A form XObject’s own content, as ContentStream::from_form reads it.

§Errors

ContentError::NotAStream when id is absent or not a stream.

Source

pub fn from_stream(dict: &'a Dict, raw: &'a [u8]) -> Self

One stream given by its dictionary and encoded bytes.

Source

pub fn prime(&mut self) -> Result<(), ContentError>

Read the first window now, so a caller can report an error in it before committing to the content; Self::next_chunk then returns that window first.

§Errors

As Self::next_chunk for its first window.

Source

pub fn truncation(&self) -> Option<ChunkTruncation>

Why reading stopped early, once it has.

Source

pub fn next_chunk(&mut self) -> Result<Option<ContentStream>, ContentError>

The next window, or None after the last.

§Errors

A decode or syntax error. In the first window every error is returned, as ContentStream::from_page would return it. After that, a decode error ends the content: the windows decoded before it are returned first, then the error once.

Trait Implementations§

Source§

impl<'a> Debug for ContentChunks<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ContentChunks<'a>

§

impl<'a> !Send for ContentChunks<'a>

§

impl<'a> !Sync for ContentChunks<'a>

§

impl<'a> !UnwindSafe for ContentChunks<'a>

§

impl<'a> Forget for ContentChunks<'a>

§

impl<'a> Freeze for ContentChunks<'a>

§

impl<'a> Move for ContentChunks<'a>

§

impl<'a> Unpin for ContentChunks<'a>

§

impl<'a> UnsafeUnpin for ContentChunks<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.