Skip to main content

PsObject

Struct PsObject 

Source
pub struct PsObject {
    pub value: PsValue,
    pub flags: ObjFlags,
}
Expand description

A PostScript object: a tagged value with metadata flags.

PsObject is Clone + Copy — it’s a value type containing indices into arena stores, not heap references.

Fields§

§value: PsValue§flags: ObjFlags

Implementations§

Source§

impl PsObject

Source

pub fn int(v: impl Into<i64>) -> Self

Build an integer object.

Generic over anything that widens losslessly to i64 so the many i32/u8/u16 call sites need no cast.

Source

pub fn real(v: f64) -> Self

Source

pub fn bool(v: bool) -> Self

Source

pub fn null() -> Self

Source

pub fn mark() -> Self

Source

pub fn dict_mark() -> Self

Dict mark from << — distinct from [/mark marks.

Source

pub fn name_lit(id: NameId) -> Self

Literal name: /foo

Source

pub fn name_exec(id: NameId) -> Self

Executable name: foo

Source

pub fn operator(op: OpCode) -> Self

Source

pub fn string(entity: EntityId, len: u32) -> Self

Literal string.

Source

pub fn array(entity: EntityId, len: u32) -> Self

Literal array.

Source

pub fn procedure(entity: EntityId, len: u32) -> Self

Executable array (procedure body).

Source

pub fn dict(entity: EntityId) -> Self

Dict object.

Source

pub fn stopped_mark() -> Self

Stopped marker (internal).

Source

pub fn loop_mark(entity: EntityId) -> Self

Loop marker (internal).

Source

pub fn hard_return() -> Self

HardReturn marker (internal).

Source

pub fn dict_end(entity: EntityId) -> Self

DictEnd marker (internal) — conditionally pops the dict stack when reached.

Source

pub fn is_numeric(&self) -> bool

Source

pub fn is_int(&self) -> bool

Source

pub fn is_real(&self) -> bool

Source

pub fn is_bool(&self) -> bool

Source

pub fn is_array_type(&self) -> bool

Source

pub fn is_composite(&self) -> bool

Source

pub fn is_global_vm(&self) -> bool

Check if this object is in global VM using authoritative entity tag bits for composite types, falling back to ObjFlags for simple types.

Source

pub fn type_name(&self) -> &'static [u8]

PostScript type name as bytes (e.g. b"integertype").

Source

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

Extract as f64 (works for both Int and Real).

Source

pub fn as_i32(&self) -> Option<i32>

Extract as i32 (Int only), rejecting values outside i32 range.

PostScript integers are i64 (see PsValue::Int), but many callers need an i32 — array and string indices, character codes, operand counts. Those are all genuinely bounded, and a value too large to be one of them should fail the caller’s range check rather than wrap silently, so this returns None instead of truncating.

Source

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

Extract as i64 (Int only) — the full PostScript integer range.

Trait Implementations§

Source§

impl Clone for PsObject

Source§

fn clone(&self) -> PsObject

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 Copy for PsObject

Source§

impl Debug for PsObject

Source§

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

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

impl PartialEq for PsObject

Source§

fn eq(&self, other: &PsObject) -> 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 PsObject

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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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, <T as TryFrom<U>>::Error>

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.