Skip to main content

Object

Enum Object 

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

A PDF object.

Variants§

§

Null

null, and what a reference to a missing object resolves to.

§

Boolean(bool)

true or false.

§

Integer(i64)

An integer.

§

Real(f64)

A real number.

§

Name(Vec<u8>)

A name, without the leading /, with #xx escapes decoded.

§

String(Vec<u8>, StringFormat)

A string’s bytes, after unescaping (and after decryption).

§

Array(Vec<Object>)

An array.

§

Dictionary(Dictionary)

A dictionary.

§

Stream(Stream)

A stream: a dictionary and bytes.

§

Reference(ObjectId)

A reference to an indirect object.

Implementations§

Source§

impl Object

Source

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

A literal string object.

Source

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

A name object.

Source

pub const fn type_name(&self) -> &'static str

The type’s name, for error messages.

Source

pub const fn is_null(&self) -> bool

Whether this is null.

Source

pub fn as_bool(&self) -> Result<bool>

The boolean value.

Source

pub fn as_i64(&self) -> Result<i64>

The integer value. A real with no fractional part counts, because writers do emit 612.0 where an integer belongs.

Source

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

The numeric value of an integer or a real.

Source

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

The name’s bytes.

Source

pub fn as_str(&self) -> Result<&[u8]>

The string’s bytes.

Source

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

The array’s items.

Source

pub fn as_array_mut(&mut self) -> Result<&mut Vec<Object>>

The array, mutably.

Source

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

The dictionary. A stream answers with its dictionary.

Source

pub fn as_dict_mut(&mut self) -> Result<&mut Dictionary>

The dictionary, mutably. A stream answers with its dictionary.

Source

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

The stream.

Source

pub fn as_stream_mut(&mut self) -> Result<&mut Stream>

The stream, mutably.

Source

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

The reference’s target.

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 From<&str> for Object

A &str becomes a name, which is what dictionary values written by hand almost always are ("Type" => "Page"). Use Object::string for a string.

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<(u32, u16)> for Object

Source§

fn from(v: ObjectId) -> Self

Converts to this type from the input type.
Source§

impl From<Dictionary> for Object

Source§

fn from(v: Dictionary) -> 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<f32> for Object

Source§

fn from(v: f32) -> 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 From<usize> for Object

Source§

fn from(v: usize) -> 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
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<Object>: Freeze, *const LeafNode<Vec<u8>, Object> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(Vec<u8>, Object)>>: Freeze, *const ArcInner<[u8]> is !null: Freeze, PhantomData<ArcInner<[u8]>>: Freeze,

§

impl Move for Object

§

impl RefUnwindSafe for Object

§

impl Send for Object
where RawVecInner: Send, NodeRef<Owned, Vec<u8>, Object, LeafOrInternal>: Send, BoxRaw<(Vec<u8>, Object)>: Send, Arc<[u8]>: Send,

§

impl Sync for Object
where RawVecInner: Sync, NodeRef<Owned, Vec<u8>, Object, LeafOrInternal>: Sync, BoxRaw<(Vec<u8>, Object)>: Sync, Arc<[u8]>: Sync,

§

impl Unpin for Object
where *const u8 is !null: Unpin, *const LeafNode<Vec<u8>, Object> is !null: Unpin, Box<(Vec<u8>, Object)>: Unpin, Arc<[u8]>: Unpin,

§

impl UnsafeUnpin for Object
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<Object>: UnsafeUnpin, *const LeafNode<Vec<u8>, Object> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(Vec<u8>, Object)>>: UnsafeUnpin, *const ArcInner<[u8]> is !null: UnsafeUnpin, PhantomData<ArcInner<[u8]>>: UnsafeUnpin,

§

impl UnwindSafe for Object
where RawVecInner: UnwindSafe, BTreeMap<Vec<u8>, Object>: UnwindSafe, Arc<[u8]>: 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.