Skip to main content

ObjectStream

Struct ObjectStream 

Source
pub struct ObjectStream { /* private fields */ }
Expand description

A decoded object stream, ready for positional object lookup.

Constructed once per container by ObjectStream::parse and cached by the document loader — decoding is the expensive part and a container typically holds dozens to hundreds of objects, each of which would otherwise re-inflate the whole thing.

Implementations§

Source§

impl ObjectStream

Source

pub fn parse(dict: &Dict, raw: &[u8]) -> Result<Self, ObjStmError>

Decode raw through dict’s filter chain and read its Table 16 header and pair table.

dict is the container’s stream dictionary and raw its still-encoded data_span bytes.

§Errors

ObjStmError — see the variants; each names the §7.5.7 rule that was violated.

Source

pub fn len(&self) -> usize

How many objects the pair table describes (/N, as actually read).

Source

pub fn member_numbers(&self) -> impl Iterator<Item = u32> + '_

The object numbers this container holds, in stored (index) order.

Cheap: it reads the already-parsed pair table without decoding any object value (unlike ObjectStream::object_at). It exists for the cross-reference recovery path (crate::recover), which rebuilds the type-2 (InStream) entries a lost xref would otherwise have named — recovery needs only which numbers live in which container at what index, exactly the type-2 entry’s fields (§7.5.8.3 Table 18), and the pair table is the authority for that (module docs). The index of each yielded number is its position in the iterator, i.e. the type-2 entry’s field 3.

Source

pub fn member_lengths(&self) -> Vec<usize>

Decoded byte length of each member, in stored (index) order.

A member runs from its pair-table offset to the next larger offset, the last to the end of the decoded data. The pair table and its separators, which sit before /First, are not attributed to any member. Offsets out of order or out of range yield 0 for that member rather than an error: this answers “how much space”, a measurement, not a parse.

Source

pub fn is_empty(&self) -> bool

Whether the container holds no objects.

Source

pub fn object_at(&self, index: usize) -> Result<(u32, Object), ObjStmError>

Parse the object stored at 0-based index, returning its declared object number (from the pair table) and its value.

The object number is returned rather than assumed so the caller can cross-check it against the object number the type-2 cross-reference entry promised — a mismatch means the xref and the container disagree, which the strict loader refuses instead of silently trusting one of them.

§Errors

ObjStmError::IndexOutOfRange, ObjStmError::OffsetOutOfRange, ObjStmError::Parse, or ObjStmError::SoleReference.

Trait Implementations§

Source§

impl Clone for ObjectStream

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectStream

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for ObjectStream

Source§

impl PartialEq for ObjectStream

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ObjectStream

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.