Skip to main content

Object

Enum Object 

Source
pub enum Object {
    Null,
    Bool(bool),
    Integer(i64),
    Real(f64),
    String(PdfString),
    Name(Name),
    Array(Vec<Object>),
    Dict(Dict),
    Stream(Stream),
    Ref(ObjRef),
}
Expand description

A PDF object.

Added in 0.2.0.

Variants§

§

Null

null.

§

Bool(bool)

true / false.

§

Integer(i64)

An integer.

§

Real(f64)

A real number.

§

String(PdfString)

A literal or hex string.

§

Name(Name)

A name.

§

Array(Vec<Object>)

An array.

§

Dict(Dict)

A dictionary.

§

Stream(Stream)

A stream (only valid as the direct value of an indirect object).

§

Ref(ObjRef)

An indirect reference.

Implementations§

Source§

impl Object

Source

pub fn number(v: f64) -> Self

v as a number: an integer when it is integral and below 10¹⁵ in magnitude (612, not 612.0), else a real. PDF has no NaN or infinity, so a non-finite v is 0.

Added in 0.2.0.

Source

pub fn rounded(v: f64, decimals: u8) -> Self

v rounded to decimals decimal places (at most 15; more count as 15), then written as Object::number writes it: rounded(v, 0) is the nearest integer.

Added in 0.2.0.

Source

pub fn name(s: &str) -> Self

A name object.

Added in 0.2.0.

Source

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

The integer value, if this is an integer.

Added in 0.2.0.

Source

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

The numeric value of an integer or real.

Added in 0.2.0.

Source

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

The dictionary, if this is a dictionary (or a stream’s dictionary).

Added in 0.2.0.

Source

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

The array, if this is an array.

Added in 0.2.0.

Source

pub fn as_ref(&self) -> Option<ObjRef>

The reference, if this is a reference.

Added in 0.2.0.

Source

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

Serializes this object to a fresh buffer using the crate’s exact formatting rules.

Added in 0.2.0.

Source

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

Appends the serialization of this object to out.

Streams are written as <<dict>>\nstream\n…\nendstream with /Length set to the data length (kept in place if present, appended last otherwise).

Added in 0.2.0.

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 Default for Object

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Dict> for Object

Source§

fn from(v: Dict) -> Self

Converts to this type from the input type.
Source§

impl From<Name> for Object

Source§

fn from(v: Name) -> Self

Converts to this type from the input type.
Source§

impl From<ObjRef> for Object

Source§

fn from(v: ObjRef) -> Self

Converts to this type from the input type.
Source§

impl From<PdfString> for Object

Source§

fn from(v: PdfString) -> Self

Converts to this type from the input type.
Source§

impl From<Stream> for Object

Source§

fn from(v: Stream) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Object>> for Object

Source§

fn from(v: Vec<Object>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Object

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Object

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Object

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Object

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Object

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
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, 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.