Skip to main content

Object

Enum Object 

Source
pub enum Object {
    Null,
    Boolean(bool),
    Integer(i64),
    Real(f64),
    String(Vec<u8>),
    Name(Name),
    Array(Vec<Object>),
    Dict(Dict),
    Stream(Stream),
    Reference(ObjId),
}
Expand description

A COS object (§7.3.1’s eight basic types, plus the indirect reference, which is a value position in its own right per §7.3.10’s substitutability rule).

Exhaustive on purpose: §7.3.1 closes the set, and matches over it in other crates (the structure dump) rely on a new variant being a compile error rather than a wildcard.

Variants§

§

Null

null (§7.3.9). Also the resolution of any dangling reference (§7.3.10 — “shall not be considered an error”).

§

Boolean(bool)

true / false (§7.3.2).

§

Integer(i64)

Integer (§7.3.3). Kept distinct from Real — see module docs.

§

Real(f64)

Real (§7.3.3).

§

String(Vec<u8>)

String (§7.3.4), decoded to raw bytes (escapes/hex applied). Interpretation as text (§7.9.2) is a later layer’s concern.

§

Name(Name)

Name (§7.3.5), decoded.

§

Array(Vec<Object>)

Array (§7.3.6) — heterogeneous, possibly empty.

§

Dict(Dict)

Dictionary (§7.3.7).

§

Stream(Stream)

Stream (§7.3.8). Streams only occur as the body of an indirect object (§7.3.8.1 “all streams shall be indirect objects”); the parser enforces that.

§

Reference(ObjId)

An indirect reference N G R (§7.3.10) — a pointer, resolved on demand by the document layer (dangling → Null, generation mismatch → Null, cycle-guarded).

Implementations§

Source§

impl Object

Source

pub const fn as_int(&self) -> Option<i64>

This object as an integer, if it is one.

Source

pub const fn as_number(&self) -> Option<f64>

This object as a number, widening integer to f64 — the §7.3.3 NOTE 2 rule (“wherever a real number is expected, an integer may be used instead”). The converse direction is deliberately NOT offered.

Source

pub fn as_name(&self) -> Option<&Name>

This object as a name, if it is one.

Source

pub fn as_dict(&self) -> Option<&Dict>

This object as a dictionary, if it is one — a plain dict OR a stream’s dict (a stream is usable anywhere its dictionary content is what matters).

Source

pub fn as_array(&self) -> Option<&[Object]>

This object as an array, if it is one.

Source

pub const fn as_reference(&self) -> Option<ObjId>

This object as an indirect reference, if it is one.

Trait Implementations§

Source§

impl Clone for Object

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 Object

Source§

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

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

impl Display for Object

Source§

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

One unstyled line, sentence-sized: scalars exact, containers named rather than expanded (Pass 296.2).

variantrenders as
Nullnull
Booleantrue / false
Integer12
Real1.5
String(Hello), or <0102FF> when it is not printable text
Name/PageMode
Arrayan array of 3 items
Dicta dictionary of 14 entries
Streama stream of 14 entries
Reference12 0 R
§Why containers are NAMED and not expanded

The request this answers put it better than a restatement would: the pair being shown is kept versus discarded and the operator’s question is “did pdfcer pick the right one?”. A graph dumped into a status-bar sentence makes the readable case unreadable too — one enormous value destroys the line that the small value beside it was going to fit on.

So this is not a serialiser and must not become one. Debug remains the full graph and has not changed; crate::writer remains the way to produce bytes. This is the operator’s sentence, and a caller that wants a container’s contents should ask for them.

§Why the engine owns this at all

Three things were diverging across consumers, none of which fails a test: the slash on a name, whether a container expands, and — the one that bites silently — the #[non_exhaustive] wildcard. A shell’s catch-all arm renders “a value this build does not recognise”, so adding a variant here would quietly make every shell say that about it. Owning Display means the arm is added in the same commit as the variant, by the person who knows what it is.

The precedent was already set by ObjId, which is Display and renders 12 0 — the form found in the bytes. The absence of the same on Object read as an oversight because it was one.

§Not in scope

Localisation, wrapping, truncation, width awareness. Those belong to whoever is drawing the line.

Source§

impl PartialEq for Object

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 Object

Auto Trait Implementations§

§

impl Forget for Object

§

impl Freeze for Object

§

impl Move for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object
where RawVecInner: Send,

§

impl Sync for Object
where RawVecInner: Sync,

§

impl Unpin for Object
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Object

§

impl UnwindSafe for Object
where RawVecInner: UnwindSafe,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.