Skip to main content

Object

Enum Object 

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

A PDF object: any value that can appear inside a document.

Real holds an f64, so the enum is PartialEq but not Eq.

Variants§

§

Null

null.

§

Boolean(bool)

true or false.

§

Integer(i64)

An integer, written without a decimal point.

§

Real(f64)

A real number, always written with a decimal point.

§

String(PdfString)

A string, literal or hex.

§

Name(Vec<u8>)

A name, stored decoded: no leading /, #xx escapes resolved.

§

Array(Vec<Object>)

An array.

§

Dictionary(Dictionary)

A dictionary.

§

Stream(Stream)

A stream, only valid as the value of an indirect object.

§

Reference(ObjectId)

An indirect reference, n g R.

Implementations§

Source§

impl Object

Source

pub fn name(name: impl Into<Vec<u8>>) -> Self

A name object from decoded bytes.

Source

pub fn string(bytes: impl Into<Vec<u8>>) -> Self

A literal string object.

Source

pub fn hex_string(bytes: impl Into<Vec<u8>>) -> Self

A hex string object.

Source

pub fn array(items: impl IntoIterator<Item = Object>) -> Self

An array object.

Source

pub const fn reference(id: ObjectId) -> Self

A reference object.

Source

pub fn is_null(&self) -> bool

Whether this is null.

Source

pub fn as_integer(&self) -> Option<i64>

The integer value, if this is an integer.

Source

pub fn as_real(&self) -> Option<f64>

The numeric value as a real, accepting an integer too.

Source

pub fn as_name(&self) -> Option<&[u8]>

The name bytes, if this is a name.

Source

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

The array items, if this is an array.

Source

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

The dictionary, if this is one.

Source

pub fn as_stream(&self) -> Option<&Stream>

The stream, if this is one.

Source

pub fn as_string(&self) -> Option<&PdfString>

The string, if this is one.

Source

pub fn as_reference(&self) -> Option<ObjectId>

The reference target, if this is a reference.

Source

pub fn write_to(&self, out: &mut Vec<u8>)

Append the serialized form of this object to out.

The output is the canonical text form used by this crate: names keep only regular characters, strings keep the format they were parsed with, reals always carry a decimal point, and containers separate their elements with single spaces.

Source

pub fn to_bytes(&self) -> Vec<u8> ⓘ

Serialize this object into a fresh buffer.

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

Formats the value using the given formatter. Read more
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

§

impl Sync for Object

§

impl Unpin for Object

§

impl UnsafeUnpin for Object

§

impl UnwindSafe for Object

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.